Skip to content

Commit

Permalink
[OSS-ONLY] Update database collation related tests (babelfish-for-pos…
Browse files Browse the repository at this point in the history
…tgresql#3065)

To obtain the collation related metadata information of a table returning function we were using sp_describe_first_result_set till now. This procedure also returns the system_type_id (oid) of the datatype, which can change (but not an actual issue). As we only aim to obtain the collation related info, updated the test in such a way to obtain expected columns.

###Issues Resolved
test_db_collation

Signed-off-by: Shameem Ahmed [email protected]
  • Loading branch information
ahmed-shameem authored Oct 30, 2024
1 parent f29e512 commit 5444c49
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ GO
DROP INDEX test_db_idx8 on test_db_collation_vu_prepare_db121_columns;
GO

DROP VIEW func_output1;
GO

DROP VIEW func_output2;
GO

DROP VIEW test_db_collation_vu_prepare_db121_v1;
GO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,21 +344,34 @@ RETURNS TABLE
AS
RETURN
(
SELECT t1.nv
SELECT t1.nv as col
FROM test_db_collation_vu_prepare_db121_t1 t1
INNER JOIN test_db_collation_vu_prepare_db121_t2 t2 ON t1.nv = t2.nv ORDER BY t1.nv
);
GO

EXEC sp_describe_first_result_set @tsql = N'SELECT * FROM test_db_collation_vu_prepare_db121_f1()';
-- Create view to hold the function's output
CREATE VIEW func_output1 AS
SELECT * FROM test_db_collation_vu_prepare_db121_f1();
GO

-- Query INFORMATION_SCHEMA to get column information
SELECT
c.COLUMN_NAME,
c.COLLATION_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN
INFORMATION_SCHEMA.VIEWS v ON c.TABLE_NAME = v.TABLE_NAME
WHERE
v.TABLE_NAME = 'func_output1';
GO
~~START~~
bit#!#int#!#varchar#!#bit#!#int#!#nvarchar#!#smallint#!#tinyint#!#tinyint#!#varchar#!#int#!#varchar#!#varchar#!#varchar#!#nvarchar#!#int#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#bit#!#bit#!#smallint#!#smallint#!#smallint#!#int#!#int#!#int#!#tinyint
0#!#1#!#nv#!#1#!#17084#!#nvarchar#!#-1#!#0#!#0#!#bbf_unicode_cp1_ci_ai#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#231#!#-1#!#15729673#!#54
nvarchar#!#nvarchar
col#!#bbf_unicode_cp1_ci_ai
~~END~~



CREATE FUNCTION test_db_collation_vu_prepare_db121_f2()
RETURNS @res_tab TABLE
(
Expand All @@ -375,15 +388,30 @@ BEGIN
END;
GO

EXEC sp_describe_first_result_set @tsql = N'SELECT * FROM test_db_collation_vu_prepare_db121_f2()';
-- Create view to hold the function's output
CREATE VIEW func_output2 AS
SELECT * FROM test_db_collation_vu_prepare_db121_f2();
GO

-- Query INFORMATION_SCHEMA to get column information
SELECT
c.COLUMN_NAME,
c.COLLATION_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN
INFORMATION_SCHEMA.VIEWS v ON c.TABLE_NAME = v.TABLE_NAME
WHERE
v.TABLE_NAME = 'func_output2';
GO
~~START~~
bit#!#int#!#varchar#!#bit#!#int#!#nvarchar#!#smallint#!#tinyint#!#tinyint#!#varchar#!#int#!#varchar#!#varchar#!#varchar#!#nvarchar#!#int#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#bit#!#bit#!#smallint#!#smallint#!#smallint#!#int#!#int#!#int#!#tinyint
0#!#1#!#col1#!#1#!#17028#!#varchar#!#50#!#0#!#0#!#bbf_unicode_cp1_ci_ai#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#167#!#50#!#15729673#!#54
0#!#2#!#col2#!#1#!#17084#!#nvarchar#!#100#!#0#!#0#!#bbf_unicode_cp1_ci_ai#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#231#!#100#!#15729673#!#54
nvarchar#!#nvarchar
col1#!#bbf_unicode_cp1_ci_ai
col2#!#bbf_unicode_cp1_ci_ai
~~END~~



CREATE VIEW test_db_collation_vu_prepare_db121_v1 AS SELECT nv FROM test_db_collation_vu_prepare_db121_t1 ORDER BY nv;
GO

Expand Down
6 changes: 6 additions & 0 deletions test/JDBC/expected/test_db_collation-vu-cleanup.out
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ GO
DROP INDEX test_db_idx8 on test_db_collation_vu_prepare_db121_columns;
GO

DROP VIEW func_output1;
GO

DROP VIEW func_output2;
GO

DROP VIEW test_db_collation_vu_prepare_db121_v1;
GO

Expand Down
46 changes: 37 additions & 9 deletions test/JDBC/expected/test_db_collation-vu-prepare.out
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,34 @@ RETURNS TABLE
AS
RETURN
(
SELECT t1.nv
SELECT t1.nv as col
FROM test_db_collation_vu_prepare_db121_t1 t1
INNER JOIN test_db_collation_vu_prepare_db121_t2 t2 ON t1.nv = t2.nv ORDER BY t1.nv
);
GO

EXEC sp_describe_first_result_set @tsql = N'SELECT * FROM test_db_collation_vu_prepare_db121_f1()';
-- Create view to hold the function's output
CREATE VIEW func_output1 AS
SELECT * FROM test_db_collation_vu_prepare_db121_f1();
GO

-- Query INFORMATION_SCHEMA to get column information
SELECT
c.COLUMN_NAME,
c.COLLATION_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN
INFORMATION_SCHEMA.VIEWS v ON c.TABLE_NAME = v.TABLE_NAME
WHERE
v.TABLE_NAME = 'func_output1';
GO
~~START~~
bit#!#int#!#varchar#!#bit#!#int#!#nvarchar#!#smallint#!#tinyint#!#tinyint#!#varchar#!#int#!#varchar#!#varchar#!#varchar#!#nvarchar#!#int#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#bit#!#bit#!#smallint#!#smallint#!#smallint#!#int#!#int#!#int#!#tinyint
0#!#1#!#nv#!#1#!#17084#!#nvarchar#!#-1#!#0#!#0#!#bbf_unicode_cp1_ci_ai#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#231#!#-1#!#15729673#!#54
nvarchar#!#nvarchar
col#!#bbf_unicode_cp1_ci_ai
~~END~~



CREATE FUNCTION test_db_collation_vu_prepare_db121_f2()
RETURNS @res_tab TABLE
(
Expand All @@ -379,15 +392,30 @@ BEGIN
END;
GO

EXEC sp_describe_first_result_set @tsql = N'SELECT * FROM test_db_collation_vu_prepare_db121_f2()';
-- Create view to hold the function's output
CREATE VIEW func_output2 AS
SELECT * FROM test_db_collation_vu_prepare_db121_f2();
GO

-- Query INFORMATION_SCHEMA to get column information
SELECT
c.COLUMN_NAME,
c.COLLATION_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN
INFORMATION_SCHEMA.VIEWS v ON c.TABLE_NAME = v.TABLE_NAME
WHERE
v.TABLE_NAME = 'func_output2';
GO
~~START~~
bit#!#int#!#varchar#!#bit#!#int#!#nvarchar#!#smallint#!#tinyint#!#tinyint#!#varchar#!#int#!#varchar#!#varchar#!#varchar#!#nvarchar#!#int#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#bit#!#bit#!#bit#!#bit#!#bit#!#smallint#!#smallint#!#smallint#!#int#!#int#!#int#!#tinyint
0#!#1#!#col1#!#1#!#17028#!#varchar#!#50#!#0#!#0#!#bbf_unicode_cp1_ci_ai#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#167#!#50#!#15729673#!#54
0#!#2#!#col2#!#1#!#17084#!#nvarchar#!#100#!#0#!#0#!#bbf_unicode_cp1_ci_ai#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#0#!#<NULL>#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#231#!#100#!#15729673#!#54
nvarchar#!#nvarchar
col1#!#bbf_unicode_cp1_ci_ai
col2#!#bbf_unicode_cp1_ci_ai
~~END~~



CREATE VIEW test_db_collation_vu_prepare_db121_v1 AS SELECT nv FROM test_db_collation_vu_prepare_db121_t1 ORDER BY nv;
GO

Expand Down
6 changes: 6 additions & 0 deletions test/JDBC/input/test_db_collation-vu-cleanup.mix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ GO
DROP INDEX test_db_idx8 on test_db_collation_vu_prepare_db121_columns;
GO

DROP VIEW func_output1;
GO

DROP VIEW func_output2;
GO

DROP VIEW test_db_collation_vu_prepare_db121_v1;
GO

Expand Down
34 changes: 31 additions & 3 deletions test/JDBC/input/test_db_collation-vu-prepare.mix
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,28 @@ RETURNS TABLE
AS
RETURN
(
SELECT t1.nv
SELECT t1.nv as col
FROM test_db_collation_vu_prepare_db121_t1 t1
INNER JOIN test_db_collation_vu_prepare_db121_t2 t2 ON t1.nv = t2.nv ORDER BY t1.nv
);
GO

EXEC sp_describe_first_result_set @tsql = N'SELECT * FROM test_db_collation_vu_prepare_db121_f1()';
-- Create view to hold the function's output
CREATE VIEW func_output1 AS
SELECT * FROM test_db_collation_vu_prepare_db121_f1();
GO

-- Query INFORMATION_SCHEMA to get column information
SELECT
c.COLUMN_NAME,
c.COLLATION_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN
INFORMATION_SCHEMA.VIEWS v ON c.TABLE_NAME = v.TABLE_NAME
WHERE
v.TABLE_NAME = 'func_output1';
GO

CREATE FUNCTION test_db_collation_vu_prepare_db121_f2()
RETURNS @res_tab TABLE
Expand All @@ -274,9 +287,24 @@ BEGIN
END;
GO

EXEC sp_describe_first_result_set @tsql = N'SELECT * FROM test_db_collation_vu_prepare_db121_f2()';
-- Create view to hold the function's output
CREATE VIEW func_output2 AS
SELECT * FROM test_db_collation_vu_prepare_db121_f2();
GO

-- Query INFORMATION_SCHEMA to get column information
SELECT
c.COLUMN_NAME,
c.COLLATION_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
JOIN
INFORMATION_SCHEMA.VIEWS v ON c.TABLE_NAME = v.TABLE_NAME
WHERE
v.TABLE_NAME = 'func_output2';
GO


CREATE VIEW test_db_collation_vu_prepare_db121_v1 AS SELECT nv FROM test_db_collation_vu_prepare_db121_t1 ORDER BY nv;
GO

Expand Down

0 comments on commit 5444c49

Please sign in to comment.