diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 0068e91761..dc286721c9 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -54,6 +54,7 @@ /* Hooks for engine*/ extern find_coercion_pathway_hook_type find_coercion_pathway_hook; extern determine_datatype_precedence_hook_type determine_datatype_precedence_hook; +extern is_tsql_base_datatype_hook_type is_tsql_base_datatype_hook; extern func_select_candidate_hook_type func_select_candidate_hook; extern coerce_string_literal_hook_type coerce_string_literal_hook; extern select_common_type_hook_type select_common_type_hook; @@ -846,6 +847,15 @@ tsql_has_higher_precedence(Oid typeId1, Oid typeId2) return type1_precedence < type2_precedence; } +/* + * Returns if given data type is a base type in T-SQL. + */ +static bool +is_tsql_base_datatype(Oid typeId) +{ + return tsql_get_type_precedence(typeId) != -1; +} + static bool is_vectorized_binary_operator(FuncCandidateList candidate) { @@ -2135,6 +2145,7 @@ init_tsql_datatype_precedence_hash_tab(PG_FUNCTION_ARGS) /* Register Hooks */ determine_datatype_precedence_hook = tsql_has_higher_precedence; + is_tsql_base_datatype_hook = is_tsql_base_datatype; func_select_candidate_hook = tsql_func_select_candidate; coerce_string_literal_hook = tsql_coerce_string_literal_hook; select_common_type_hook = tsql_select_common_type_hook; diff --git a/test/JDBC/expected/BABEL-3392-vu-verify.out b/test/JDBC/expected/BABEL-3392-vu-verify.out index bcff76215e..30963fcb3a 100644 --- a/test/JDBC/expected/BABEL-3392-vu-verify.out +++ b/test/JDBC/expected/BABEL-3392-vu-verify.out @@ -1637,7 +1637,7 @@ SELECT name, max_length FROM sys.columns WHERE name = 'babel4157_c1' GO ~~START~~ varchar#!#smallint -babel4157_c1#!# +babel4157_c1#!#3 ~~END~~ @@ -1890,14 +1890,14 @@ select cast(17 as varbinary(1)) UNION select cast(10 as varbinary(2)) union sele GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type "nchar" to bbf_varbinary)~~ +~~ERROR (Message: UNION could not convert type "nchar" to varbinary)~~ SELECT CAST(N'ΘЖऌฒ' AS NCHAR(15)) UNION select cast(10 as varbinary(2)); GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type varbinary to bpchar)~~ +~~ERROR (Message: UNION could not convert type varbinary to "nchar")~~ SELECT CAST(1 as BIT) UNION SELECT cast(N'ab' as NCHAR(10)) UNION SELECT CAST('bar' as CHAR(10)); diff --git a/test/JDBC/expected/BABEL-5242-union-tsql-basetype.out b/test/JDBC/expected/BABEL-5242-union-tsql-basetype.out new file mode 100644 index 0000000000..a63e738884 --- /dev/null +++ b/test/JDBC/expected/BABEL-5242-union-tsql-basetype.out @@ -0,0 +1,543 @@ +-- +-- Tests on the result data type should retain as tsql base type after UNION +-- +CREATE TABLE t1 ( + a INT, + TransactionAmount money NULL +); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 't1' + AND a.[name] = 'TransactionAmount'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +CREATE VIEW TestView AS + select + traamo = a + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + SELECT CASE 2 + WHEN 1 THEN a + WHEN 2 THEN TransactionAmount + END AS traamo + FROM t1; +GO + + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = null + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(null AS money) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(11 AS NUMERIC) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- Result data type after UNION between numeric and money should be numeric +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +numeric#!#numeric +~~END~~ + + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE t1 ( + a smallmoney, + b money, + c text, + d numeric, + e int +); +GO + +INSERT INTO t1 VALUES (214748.3647, 922337203685477.5807, 'test', 1.2, 4), (-214748.3648, -922337203685477.5808, 'test', 2.3, 4); +GO +~~ROW COUNT: 2~~ + + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select traamo = CAST(214748.3657 AS MONEY); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +SELECT * FROM TestView ORDER BY traamo; +GO +~~START~~ +money +-922337203685477.5808 +-214748.3648 +214748.3647 +214748.3657 +922337203685477.5807 +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE view TestView as + select + traamo = b + from t1 +union all + select + traamo = a + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +-- Coercion error should be raised +SELECT a FROM t1 +UNION +SELECT b FROM t1 +UNION +SELECT c FROM t1; +GO +~~START~~ +money +~~ERROR (Code: 293)~~ + +~~ERROR (Message: invalid characters found: cannot cast value "test" to money)~~ + + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select + traamo = d + from t1 +union all + select + traamo = e + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +numeric#!#numeric +~~END~~ + + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE ti ( + a tinyint, + b smallint +); +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = null + from ti; +GO + +-- Should be tinyint instead of smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +tinyint#!#tinyint +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = b + from ti; +GO + +-- Should be smallint since UNION between tinyint and smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +smallint#!#smallint +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = b + from ti +union all + select + traamo = a + from ti; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +smallint#!#smallint +~~END~~ + + +INSERT INTO ti VALUES (255, 256), (0, -1); +GO +~~ROW COUNT: 2~~ + + +SELECT * FROM TestView ORDER BY traamo; +GO +~~START~~ +smallint +-1 +0 +255 +256 +~~END~~ + + + +DROP VIEW TestView; +DROP TABLE ti; +GO + +-- Involving user-defined type in T-SQL, result after UNION should be the base type +CREATE TYPE SSN FROM VARCHAR(11) NOT NULL; +GO + +CREATE TABLE tn (a VARCHAR(11) NOT NULL, b SSN); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'tn' + AND a.[name] = 'b'; +GO +~~START~~ +varchar#!#nvarchar +ssn#!#ssn +~~END~~ + + +CREATE VIEW TestView AS + select + traamo = 'hope' + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +varchar#!#varchar +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +varchar#!#varchar +~~END~~ + + +DROP VIEW TestView; +GO + +DROP TABLE tn; +GO + +DROP TYPE SSN; +GO + +CREATE TYPE BABEL_CASE_EXPR_TEST_UDT FROM NVARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'ةيسايق - ليجستلا ةقاطب' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ةيسايق - ليجستلا ةقاطب +~~END~~ + + +DROP TYPE BABEL_CASE_EXPR_TEST_UDT; +GO + +-- Coercion error should be raised +SELECT 'unknown' +UNION +SELECT $1.0 +UNION +SELECT N'xyz'; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type numeric: "unknown")~~ + diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index d162a5a3e5..7cbd7d9bfb 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index 76e7e954ca..3d2606ea2b 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out index f873655520..bd6041dd04 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out @@ -1637,7 +1637,7 @@ SELECT name, max_length FROM sys.columns WHERE name = 'babel4157_c1' GO ~~START~~ varchar#!#smallint -babel4157_c1#!# +babel4157_c1#!#3 ~~END~~ @@ -1890,14 +1890,14 @@ select cast(17 as varbinary(1)) UNION select cast(10 as varbinary(2)) union sele GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type "nchar" to bbf_varbinary)~~ +~~ERROR (Message: UNION could not convert type "nchar" to varbinary)~~ SELECT CAST(N'ΘЖऌฒ' AS NCHAR(15)) UNION select cast(10 as varbinary(2)); GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type varbinary to bpchar)~~ +~~ERROR (Message: UNION could not convert type varbinary to "nchar")~~ SELECT CAST(1 as BIT) UNION SELECT cast(N'ab' as NCHAR(10)) UNION SELECT CAST('bar' as CHAR(10)); diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index d311f1b907..48250a5087 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,7 +10436,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,7 +10968,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out index f0332904d4..8851f6b1a1 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,7 +10436,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,7 +10968,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out index e7e8261699..b4c6b93aa3 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out @@ -1637,7 +1637,7 @@ SELECT name, max_length FROM sys.columns WHERE name = 'babel4157_c1' GO ~~START~~ varchar#!#smallint -babel4157_c1#!# +babel4157_c1#!#3 ~~END~~ @@ -1890,14 +1890,14 @@ select cast(17 as varbinary(1)) UNION select cast(10 as varbinary(2)) union sele GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type "nchar" to bbf_varbinary)~~ +~~ERROR (Message: UNION could not convert type "nchar" to varbinary)~~ SELECT CAST(N'ΘЖऌฒ' AS NCHAR(15)) UNION select cast(10 as varbinary(2)); GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type varbinary to bpchar)~~ +~~ERROR (Message: UNION could not convert type varbinary to "nchar")~~ SELECT CAST(1 as BIT) UNION SELECT cast(N'ab' as NCHAR(10)) UNION SELECT CAST('bar' as CHAR(10)); diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index ad3b761a5b..3ac4829781 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -403,7 +403,7 @@ nvarchar SELECT * FROM BABEL_5103_V2 GO ~~START~~ -varchar +nvarchar 登録カード ~~END~~ @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out index 3e7235a458..3ac4829781 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/input/BABEL-5242-union-tsql-basetype.sql b/test/JDBC/input/BABEL-5242-union-tsql-basetype.sql new file mode 100644 index 0000000000..eb241f61da --- /dev/null +++ b/test/JDBC/input/BABEL-5242-union-tsql-basetype.sql @@ -0,0 +1,432 @@ +-- +-- Tests on the result data type should retain as tsql base type after UNION +-- +CREATE TABLE t1 ( + a INT, + TransactionAmount money NULL +); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 't1' + AND a.[name] = 'TransactionAmount'; +GO + +CREATE VIEW TestView AS + select + traamo = a + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + SELECT CASE 2 + WHEN 1 THEN a + WHEN 2 THEN TransactionAmount + END AS traamo + FROM t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; + +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = null + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(null AS money) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(11 AS NUMERIC) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- Result data type after UNION between numeric and money should be numeric +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE t1 ( + a smallmoney, + b money, + c text, + d numeric, + e int +); +GO + +INSERT INTO t1 VALUES (214748.3647, 922337203685477.5807, 'test', 1.2, 4), (-214748.3648, -922337203685477.5808, 'test', 2.3, 4); +GO + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select traamo = CAST(214748.3657 AS MONEY); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +SELECT * FROM TestView ORDER BY traamo; +GO + +DROP VIEW TestView; +GO + +CREATE view TestView as + select + traamo = b + from t1 +union all + select + traamo = a + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +-- Coercion error should be raised +SELECT a FROM t1 +UNION +SELECT b FROM t1 +UNION +SELECT c FROM t1; +GO + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select + traamo = d + from t1 +union all + select + traamo = e + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE ti ( + a tinyint, + b smallint +); +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = null + from ti; +GO + +-- Should be tinyint instead of smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = b + from ti; +GO + +-- Should be smallint since UNION between tinyint and smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = b + from ti +union all + select + traamo = a + from ti; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +INSERT INTO ti VALUES (255, 256), (0, -1); +GO + +SELECT * FROM TestView ORDER BY traamo; +GO + +DROP VIEW TestView; + +DROP TABLE ti; +GO + +-- Involving user-defined type in T-SQL, result after UNION should be the base type +CREATE TYPE SSN FROM VARCHAR(11) NOT NULL; +GO + +CREATE TABLE tn (a VARCHAR(11) NOT NULL, b SSN); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'tn' + AND a.[name] = 'b'; +GO + +CREATE VIEW TestView AS + select + traamo = 'hope' + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +DROP TABLE tn; +GO + +DROP TYPE SSN; +GO + +CREATE TYPE BABEL_CASE_EXPR_TEST_UDT FROM NVARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'ةيسايق - ليجستلا ةقاطب' AS NTEXT) +END AS RESULT +GO + +DROP TYPE BABEL_CASE_EXPR_TEST_UDT; +GO + +-- Coercion error should be raised +SELECT 'unknown' +UNION +SELECT $1.0 +UNION +SELECT N'xyz'; +GO