-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed definition of parsename, session_context and sp_set_session_con…
…text (#2152) Following is the current definition of PARSENAME, session_context and sp_set_session_context -- parsename CREATE OR REPLACE FUNCTION sys.parsename(object_name sys.VARCHAR, object_piece int) RETURNS sys.SYSNAME AS 'babelfishpg_tsql', 'parsename' LANGUAGE C IMMUTABLE STRICT; -- session_context CREATE OR REPLACE FUNCTION sys.session_context ("@key" sys.sysname) RETURNS sys.SQL_VARIANT AS 'babelfishpg_tsql', 'session_context' LANGUAGE C; GRANT EXECUTE ON FUNCTION sys.session_context TO PUBLIC; -- sp_set_session_context CREATE OR REPLACE PROCEDURE sys.sp_set_session_context ("@key" sys.sysname, "@value" sys.SQL_VARIANT, "@read_only" sys.bit = 0) AS 'babelfishpg_tsql', 'sp_set_session_context' LANGUAGE C; GRANT EXECUTE ON PROCEDURE sys.sp_set_session_context TO PUBLIC; But the correct definitions should be as follows, in these definitions sys.NVARCHAR should be used instead of sys.VARCHAR and sys.NVARCHAR(128) instead of sys.SYSNAME. This commit fixes such issues. --parsename CREATE OR REPLACE FUNCTION sys.parsename(object_name sys.NVARCHAR(128), object_piece int) RETURNS sys.NVARCHAR(128) AS 'babelfishpg_tsql', 'parsename' LANGUAGE C IMMUTABLE STRICT; -- session_context CREATE OR REPLACE FUNCTION sys.session_context ("@key" sys.NVARCHAR(128)) RETURNS sys.SQL_VARIANT AS 'babelfishpg_tsql', 'session_context' LANGUAGE C; GRANT EXECUTE ON FUNCTION sys.session_context TO PUBLIC; -- sp_set_session_context CREATE OR REPLACE PROCEDURE sys.sp_set_session_context ("@key" sys.NVARCHAR(128), "@value" sys.SQL_VARIANT, "@read_only" sys.bit = 0) AS 'babelfishpg_tsql', 'sp_set_session_context' LANGUAGE C; GRANT EXECUTE ON PROCEDURE sys.sp_set_session_context TO PUBLIC; Task: BABEL-4583 Signed-off-by: Rohit Bhagat <[email protected]>
- Loading branch information
1 parent
dff6a8f
commit 37c2532
Showing
36 changed files
with
1,191 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/JDBC/expected/sys-parsename-before-15_6-or-16_1-vu-cleanup.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
DROP VIEW IF EXISTS parsename_EmployeeDatabaseView1_before_14_11_or_15_6; | ||
GO | ||
|
||
DROP PROCEDURE IF EXISTS parsename_GetEmployeeDatabaseName1_before_14_11_or_15_6; | ||
GO | ||
|
||
DROP VIEW IF EXISTS parsename_EmployeeDatabaseView2_before_14_11_or_15_6; | ||
GO | ||
|
||
DROP PROCEDURE IF EXISTS parsename_GetEmployeeDatabaseName2_before_14_11_or_15_6; | ||
GO | ||
|
||
DROP VIEW IF EXISTS parsename_EmployeeDatabaseView3_before_14_11_or_15_6; | ||
GO | ||
|
||
DROP PROCEDURE IF EXISTS parsename_GetEmployeeDatabaseName3_before_14_11_or_15_6; | ||
GO | ||
|
||
DROP TABLE IF EXISTS parsename_Employee_before_14_11_or_15_6; | ||
GO |
54 changes: 54 additions & 0 deletions
54
test/JDBC/expected/sys-parsename-before-15_6-or-16_1-vu-prepare.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
CREATE TABLE parsename_Employee_before_14_11_or_15_6 ( | ||
EmployeeID INT PRIMARY KEY, | ||
FirstName NVARCHAR(50), | ||
LastName NVARCHAR(50), | ||
HireDate DATETIME, | ||
Salary MONEY | ||
); | ||
GO | ||
|
||
|
||
-- Insert some sample data | ||
INSERT INTO parsename_Employee_before_14_11_or_15_6(EmployeeID, FirstName, LastName, HireDate, Salary) | ||
VALUES (1, 'John', 'Doe', '2020-01-01', 50000), | ||
(2, 'Jane', 'Smith', '2020-02-01', 60000), | ||
(3, 'Bob', 'Johnson', '2020-03-01', 70000); | ||
GO | ||
~~ROW COUNT: 3~~ | ||
|
||
|
||
CREATE VIEW parsename_EmployeeDatabaseView1_before_14_11_or_15_6 | ||
AS | ||
SELECT PARSENAME('tempdb.dbo.Employee', 3) AS [Database Name] | ||
GO | ||
|
||
CREATE PROCEDURE parsename_GetEmployeeDatabaseName1_before_14_11_or_15_6 | ||
AS | ||
BEGIN | ||
SELECT PARSENAME('tempdb.dbo.Employee', 3) AS [Database Name] | ||
END | ||
GO | ||
|
||
CREATE VIEW parsename_EmployeeDatabaseView2_before_14_11_or_15_6 | ||
AS | ||
SELECT PARSENAME('tempdb.dbo.Employee', 2) AS [Schema Name] | ||
GO | ||
|
||
CREATE PROCEDURE parsename_GetEmployeeDatabaseName2_before_14_11_or_15_6 | ||
AS | ||
BEGIN | ||
SELECT PARSENAME('tempdb.dbo.Employee', 2) AS [Schema Name] | ||
END | ||
GO | ||
|
||
CREATE VIEW parsename_EmployeeDatabaseView3_before_14_11_or_15_6 | ||
AS | ||
SELECT PARSENAME('tempdb.dbo.Employee', 1) AS [Table Name] | ||
GO | ||
|
||
CREATE PROCEDURE parsename_GetEmployeeDatabaseName3_before_14_11_or_15_6 | ||
AS | ||
BEGIN | ||
SELECT PARSENAME('tempdb.dbo.Employee_parsename', 1) AS [Table Name] | ||
END | ||
GO |
Oops, something went wrong.