diff --git a/.github/configuration/upgrade-test-configuration.yml b/.github/configuration/upgrade-test-configuration.yml index 47912704d0..e062259241 100644 --- a/.github/configuration/upgrade-test-configuration.yml +++ b/.github/configuration/upgrade-test-configuration.yml @@ -268,5 +268,17 @@ upgrade-version: [{ } ], babelfishpg_tsql_server_collation_name: chinese_prc_ci_as +}, +{ + upgrade-path: [ + { + version: 16.7, + upgrade-type: null + }, + { + version: target.latest, + upgrade-type: major + } + ] } ] \ No newline at end of file diff --git a/contrib/babelfishpg_common/sql/binary.sql b/contrib/babelfishpg_common/sql/binary.sql index 3ad552287a..4ad6be24a7 100644 --- a/contrib/babelfishpg_common/sql/binary.sql +++ b/contrib/babelfishpg_common/sql/binary.sql @@ -66,6 +66,11 @@ LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; CREATE CAST (sys.VARCHAR AS sys.BBF_BINARY) WITH FUNCTION sys.varcharbinary (sys.VARCHAR, integer, boolean) AS ASSIGNMENT; +CREATE OR REPLACE FUNCTION sys.nvarcharbinary(sys.NVARCHAR, integer, boolean) +RETURNS sys.BBF_BINARY +AS 'babelfishpg_common', 'nvarcharbinary' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + CREATE OR REPLACE FUNCTION sys.varcharbinary(pg_catalog.VARCHAR, integer, boolean) RETURNS sys.BBF_BINARY AS 'babelfishpg_common', 'varcharbinary' @@ -99,6 +104,11 @@ LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; CREATE CAST (sys.BBF_BINARY AS sys.VARCHAR) WITH FUNCTION sys.binarysysvarchar (sys.BBF_BINARY, integer, boolean) AS IMPLICIT; +CREATE OR REPLACE FUNCTION sys.binarysysnvarchar(sys.BBF_BINARY, integer, boolean) +RETURNS sys.NVARCHAR +AS 'babelfishpg_common', 'varbinarynvarchar' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + CREATE OR REPLACE FUNCTION sys.binaryvarchar(sys.BBF_BINARY, integer, boolean) RETURNS pg_catalog.VARCHAR AS 'babelfishpg_common', 'varbinaryvarchar' diff --git a/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--5.0.0--5.1.0.sql b/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--5.0.0--5.1.0.sql index 9afd88b3aa..02828160b8 100644 --- a/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--5.0.0--5.1.0.sql +++ b/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--5.0.0--5.1.0.sql @@ -7,6 +7,27 @@ SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false); +CREATE OR REPLACE FUNCTION sys.nvarcharvarbinary(sys.NVARCHAR, integer, boolean) +RETURNS sys.BBF_VARBINARY +AS 'babelfishpg_common', 'nvarcharvarbinary' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.varbinarysysnvarchar(sys.BBF_VARBINARY, integer, boolean) +RETURNS sys.NVARCHAR +AS 'babelfishpg_common', 'varbinarynvarchar' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.binarysysnvarchar(sys.BBF_BINARY, integer, boolean) +RETURNS sys.NVARCHAR +AS 'babelfishpg_common', 'varbinarynvarchar' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.nvarcharbinary(sys.NVARCHAR, integer, boolean) +RETURNS sys.BBF_BINARY +AS 'babelfishpg_common', 'nvarcharbinary' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + + -- Please add your SQLs here /* * Note: These SQL statements may get executed multiple times specially when some features get backpatched. diff --git a/contrib/babelfishpg_common/sql/varbinary.sql b/contrib/babelfishpg_common/sql/varbinary.sql index 54f6b2d63a..80738194c7 100644 --- a/contrib/babelfishpg_common/sql/varbinary.sql +++ b/contrib/babelfishpg_common/sql/varbinary.sql @@ -71,6 +71,11 @@ LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; CREATE CAST (sys.BBF_VARBINARY AS pg_catalog.BYTEA) WITH FUNCTION sys.varbinarybytea(sys.BBF_VARBINARY, integer, boolean) AS ASSIGNMENT; +CREATE OR REPLACE FUNCTION sys.nvarcharvarbinary(sys.NVARCHAR, integer, boolean) +RETURNS sys.BBF_VARBINARY +AS 'babelfishpg_common', 'nvarcharvarbinary' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + CREATE OR REPLACE FUNCTION sys.varcharvarbinary(sys.VARCHAR, integer, boolean) RETURNS sys.BBF_VARBINARY AS 'babelfishpg_common', 'varcharvarbinary' @@ -111,6 +116,11 @@ LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; CREATE CAST (sys.BBF_VARBINARY AS sys.VARCHAR) WITH FUNCTION sys.varbinarysysvarchar (sys.BBF_VARBINARY, integer, boolean) AS IMPLICIT; +CREATE OR REPLACE FUNCTION sys.varbinarysysnvarchar(sys.BBF_VARBINARY, integer, boolean) +RETURNS sys.NVARCHAR +AS 'babelfishpg_common', 'varbinarynvarchar' +LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; + CREATE OR REPLACE FUNCTION sys.varbinaryvarchar(sys.BBF_VARBINARY, integer, boolean) RETURNS pg_catalog.VARCHAR AS 'babelfishpg_common', 'varbinaryvarchar' diff --git a/contrib/babelfishpg_common/src/varbinary.c b/contrib/babelfishpg_common/src/varbinary.c index 3ab6f070e9..623202dac9 100644 --- a/contrib/babelfishpg_common/src/varbinary.c +++ b/contrib/babelfishpg_common/src/varbinary.c @@ -38,9 +38,13 @@ #include "utils/pg_locale.h" #include "utils/sortsupport.h" #include "utils/varlena.h" +#include "lib/stringinfo.h" #include "instr.h" #include "logical.h" +#include "varchar.h" +#include "babelfishpg_common.h" +#include "typecode.h" PG_FUNCTION_INFO_V1(varbinaryin); PG_FUNCTION_INFO_V1(varbinaryout); @@ -56,8 +60,11 @@ PG_FUNCTION_INFO_V1(varbinaryrowversion); PG_FUNCTION_INFO_V1(rowversionbinary); PG_FUNCTION_INFO_V1(rowversionvarbinary); PG_FUNCTION_INFO_V1(varcharvarbinary); +PG_FUNCTION_INFO_V1(nvarcharvarbinary); PG_FUNCTION_INFO_V1(bpcharvarbinary); +PG_FUNCTION_INFO_V1(nvarcharbinary); PG_FUNCTION_INFO_V1(varbinaryvarchar); +PG_FUNCTION_INFO_V1(varbinarynvarchar); PG_FUNCTION_INFO_V1(varcharbinary); PG_FUNCTION_INFO_V1(bpcharbinary); PG_FUNCTION_INFO_V1(varcharrowversion); @@ -721,6 +728,84 @@ varcharvarbinary(PG_FUNCTION_ARGS) PG_RETURN_BYTEA_P(result); } +/* + * For nvarchar we need to convert the input string to UTF-16 encoding irrespective of input encoding + * So the source string is in UTF-8 encoding, we will convert it to UTF-16 encoding + */ +Datum +nvarcharvarbinary(PG_FUNCTION_ARGS) +{ + VarChar *source = PG_GETARG_VARCHAR_PP(0); + char *data = VARDATA_ANY(source); /* Source string is UTF-8 */ + char *encoded_data; + char *rp; + size_t len = VARSIZE_ANY_EXHDR(source); + int32 typmod = PG_GETARG_INT32(1); + bool isExplicit = PG_GETARG_BOOL(2); + int32 maxlen; + bytea *result; + int encodedByteLen; + StringInfoData buf; + MemoryContext ccxt = CurrentMemoryContext; + + if (!isExplicit) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("Implicit conversion from data type nvarchar to " + "varbinary is not allowed. Use the CONVERT function " + "to run this query."))); + + initStringInfo(&buf); + PG_TRY(); + { + /* + * For nvarchar convert the string to UTF16 from UTF8 irrespective of input encoding via TsqlUTF8toUTF16StringInfo() + * For this we need to prepare a StringInfoData() and assign the encoded_data, + * encodedByteLen from the string info data we prepared + */ + TsqlUTF8toUTF16StringInfo(&buf, data, len); + encoded_data = buf.data; + encodedByteLen= buf.len; + } + PG_CATCH(); + { + MemoryContext ectx; + ErrorData *errorData; + + ectx = MemoryContextSwitchTo(ccxt); + errorData = CopyErrorData(); + FlushErrorState(); + MemoryContextSwitchTo(ectx); + + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to convert from data type nvarchar to varbinary, %s", + errorData->message))); + } + PG_END_TRY(); + + /* + * If typmod is -1 (or invalid), use the actual length + * Length should be checked after encoding into server encoding + */ + if (typmod < (int32) VARHDRSZ) + maxlen = encodedByteLen; + else + maxlen = typmod - VARHDRSZ; + + if (encodedByteLen > maxlen) + encodedByteLen = maxlen; + + result = (bytea *) palloc0(encodedByteLen + VARHDRSZ); + SET_VARSIZE(result, encodedByteLen + VARHDRSZ); + + rp = VARDATA(result); + memcpy(rp, encoded_data, encodedByteLen); + pfree(buf.data); + + PG_RETURN_BYTEA_P(result); +} + Datum bpcharvarbinary(PG_FUNCTION_ARGS) { @@ -835,6 +920,79 @@ varbinaryvarchar(PG_FUNCTION_ARGS) PG_RETURN_VARCHAR_P(result); } +Datum +varbinarynvarchar(PG_FUNCTION_ARGS) +{ + bytea *source = PG_GETARG_BYTEA_PP(0); + char *data = VARDATA_ANY(source); + VarChar *result; + char *encoded_result; + size_t len = VARSIZE_ANY_EXHDR(source); + int32 typmod = -1; + int maxlen = -1; + int encodedByteLen; + StringInfoData buf; + char *paddedData = (char*)palloc0(len+1); + MemoryContext ccxt = CurrentMemoryContext; + + typmod = PG_GETARG_INT32(1); + maxlen = typmod - VARHDRSZ; + + /* + * Converts UTF-16 to UTF-8, handling odd-length inputs by padding. + * Respects maxlen if specified, otherwise processes full input. + * Uses TsqlUTF16toUTF8StringInfo for conversion, with error handling via PG_TRY. + */ + + /* truncating NULL bytes from end */ + while(len>0 && data[len-1] == '\0') + len -= 1; + + /* Do the Padding if lenngth is odd */ + memcpy(paddedData, data, len); + if(len % 2 != 0) + len = len + 1; + + if(!(maxlen < 0 || (len >> 1) <= maxlen)) + { + len = maxlen << 1; + } + + PG_TRY(); + { + /* Converts UTF-16 to UTF-8 using TsqlUTF16toUTF8StringInfo */ + initStringInfo(&buf); + TsqlUTF16toUTF8StringInfo(&buf, paddedData, len); + encoded_result = buf.data; + encodedByteLen= buf.len; + } + + + PG_CATCH(); + { + MemoryContext ectx; + ErrorData *errorData; + + ectx = MemoryContextSwitchTo(ccxt); + errorData = CopyErrorData(); + FlushErrorState(); + MemoryContextSwitchTo(ectx); + + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to convert from data type varbinary to nvarchar, %s", + errorData->message))); + } + PG_END_TRY(); + + result = (VarChar *) cstring_to_text_with_len(encoded_result, encodedByteLen); + pfree(buf.data); + pfree(paddedData); + + PG_RETURN_VARCHAR_P(result); +} + + Datum varcharbinary(PG_FUNCTION_ARGS) { @@ -874,6 +1032,49 @@ varcharbinary(PG_FUNCTION_ARGS) PG_RETURN_BYTEA_P(result); } +Datum +nvarcharbinary(PG_FUNCTION_ARGS) +{ + VarChar *source = PG_GETARG_VARCHAR_PP(0); + char *data = VARDATA_ANY(source); + char *rp; + size_t len = VARSIZE_ANY_EXHDR(source); + int32 typmod = PG_GETARG_INT32(1); + bool isExplicit = PG_GETARG_BOOL(2); + int32 maxlen; + bytea *result; + StringInfoData buf; + + if (!isExplicit) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("Implicit conversion from data type nvarchar to " + "binary is not allowed. Use the CONVERT function " + "to run this query."))); + + initStringInfo(&buf); + TsqlUTF8toUTF16StringInfo(&buf, data, len); + data = buf.data; + len= buf.len; + + /* If typmod is -1 (or invalid), use the actual length */ + if (typmod < (int32) VARHDRSZ) + maxlen = len; + else + maxlen = typmod - VARHDRSZ; + + if (len > maxlen) + len = maxlen; + + result = (bytea *) palloc0(maxlen + VARHDRSZ); + SET_VARSIZE(result, maxlen + VARHDRSZ); + + rp = VARDATA(result); + memcpy(rp, data, len); + pfree(buf.data); + PG_RETURN_BYTEA_P(result); +} + Datum bpcharbinary(PG_FUNCTION_ARGS) { diff --git a/contrib/babelfishpg_common/src/varchar.c b/contrib/babelfishpg_common/src/varchar.c index 1e4d30ec20..c3a4120b34 100644 --- a/contrib/babelfishpg_common/src/varchar.c +++ b/contrib/babelfishpg_common/src/varchar.c @@ -322,6 +322,178 @@ GetUTF8CodePoint(const unsigned char *in, int len, int *consumed_p) return code; } +static inline void +AddUTF16ToStringInfo(int32_t code, StringInfo buf) +{ + union + { + uint16_t value; + uint8_t half[2]; + } temp16; + + /* Check that this is a valid code point */ + if ((code > 0xD800 && code < 0xE000) || code < 0x0001 || code > 0x10FFFF) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid Unicode code point 0x%x", code))); + + /* Handle single 16-bit code point */ + if (code <= 0xFFFF) + { + appendStringInfoChar(buf, code & 0xFF); + appendStringInfoChar(buf, (code >> 8) & 0xFF); + return; + } + + temp16.value = 0xD800 + (((code - 0x010000) >> 10) & 0x03FF); + appendStringInfoChar(buf, temp16.half[0]); + appendStringInfoChar(buf, temp16.half[1]); + temp16.value = 0xDC00 + ((code - 0x010000) & 0x03FF); + appendStringInfoChar(buf, temp16.half[0]); + appendStringInfoChar(buf, temp16.half[1]); +} + +/* + * AddUTF8ToStringInfo - Add Unicode code point to a StringInfo in UTF-8 + */ +static inline void +AddUTF8ToStringInfo(int32_t code, StringInfo buf) +{ + /* Check that this is a valid code point */ + if ((code > 0xD800 && code < 0xE000) || code < 0x0001 || code > 0x10FFFF) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid Unicode code point 0x%x", code))); + + /* Range U+0000 .. U+007F (7 bit) */ + if (code <= 0x7F) + { + appendStringInfoChar(buf, code); + return; + } + + /* Range U+0080 .. U+07FF (11 bit) */ + if (code <= 0x7ff) + { + appendStringInfoChar(buf, 0xC0 | (code >> 6)); + appendStringInfoChar(buf, 0x80 | (code & 0x3F)); + return; + } + + /* Range U+0800 .. U+FFFF (16 bit) */ + if (code <= 0xFFFF) + { + appendStringInfoChar(buf, 0xE0 | (code >> 12)); + appendStringInfoChar(buf, 0x80 | ((code >> 6) & 0x3F)); + appendStringInfoChar(buf, 0x80 | (code & 0x3F)); + return; + } + + /* Range U+10000 .. U+10FFFF (21 bit) */ + appendStringInfoChar(buf, 0xF0 | (code >> 18)); + appendStringInfoChar(buf, 0x80 | ((code >> 12) & 0x3F)); + appendStringInfoChar(buf, 0x80 | ((code >> 6) & 0x3F)); + appendStringInfoChar(buf, 0x80 | (code & 0x3F)); +} + +static inline int32_t +GetUTF16CodePoint(const unsigned char *in, int len, int *consumed) +{ + uint16_t code1; + uint16_t code2; + int32_t result; + + /* Get the first 16 bits */ + code1 = in[1] << 8 | in[0]; + if (code1 < 0xD800 || code1 >= 0xE000) + { + /* + * This is a single 16 bit code point, which is equal to code1. + * PostgreSQL does not support NUL bytes in character data as it + * internally needs the ability to convert any datum to a NUL + * terminated C-string without explicit length information. + */ + if (code1 == 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid UTF16 byte sequence - " + "code point 0 not supported"))); + if (consumed) + *consumed = 2; + return (int32_t) code1; + } + + /* This is a surrogate pair - check that it is the high part */ + if (code1 >= 0xDC00) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid UTF16 byte sequence - " + "high part is (0x%02x, 0x%02x)", in[0], in[1]))); + + /* Check that there is a second surrogate half */ + if (len < 4) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid UTF16 byte sequence - " + "only 2 bytes (0x%02x, 0x%02x)", in[0], in[1]))); + + /* Get the second 16 bits (low part) */ + code2 = in[3] << 8 | in[2]; + if (code2 < 0xDC00 || code2 > 0xE000) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid UTF16 byte sequence - " + "low part is (0x%02x, 0x%02x)", in[2], in[3]))); + + /* Valid surrogate pair, convert to code point */ + result = ((code1 & 0x03FF) << 10 | (code2 & 0x03FF)) + 0x10000; + + /* Valid 32 bit surrogate code point */ + if (consumed) + *consumed = 4; + return result; +} + +void +TsqlUTF8toUTF16StringInfo(StringInfo out, const void *vin, size_t len) +{ + const unsigned char *in = vin; + size_t i; + int consumed; + int32_t code; + + for (i = 0; i < len;) + { + code = GetUTF8CodePoint(&in[i], len - i, &consumed); + AddUTF16ToStringInfo(code, out); + i += consumed; + } +} + +void +TsqlUTF16toUTF8StringInfo(StringInfo out, void *vin, int len) +{ + unsigned char *in = vin; + int i; + int consumed; + int32_t code; + + /* UTF16 data allways comes in 16-bit units */ + if ((len & 0x0001) != 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_EXCEPTION), + errmsg("invalid UTF16 byte sequence - " + "input data has odd number of bytes"))); + + for (i = 0; i < len;) + { + code = GetUTF16CodePoint(&in[i], len - i, &consumed); + AddUTF8ToStringInfo(code, out); + i += consumed; + } +} + + /* * TsqlUTF8LengthInUTF16 - compute the length of a UTF8 string in number of * 16-bit units if we were to convert it into diff --git a/contrib/babelfishpg_common/src/varchar.h b/contrib/babelfishpg_common/src/varchar.h index eb3c07d484..77846ff284 100644 --- a/contrib/babelfishpg_common/src/varchar.h +++ b/contrib/babelfishpg_common/src/varchar.h @@ -7,5 +7,7 @@ extern int32_t GetUTF8CodePoint(const unsigned char *in, int len, int *consumed_ extern void *tsql_varchar_input(const char *s, size_t len, int32 atttypmod); extern void *tsql_bpchar_input(const char *s, size_t len, int32 atttypmod); extern int TsqlUTF8LengthInUTF16(const void *vin, int len); +extern void TsqlUTF8toUTF16StringInfo(StringInfo out, const void *vin, size_t len); +extern void TsqlUTF16toUTF8StringInfo(StringInfo out, void *vin, int len); #endif diff --git a/contrib/babelfishpg_tsql/sql/ownership.sql b/contrib/babelfishpg_tsql/sql/ownership.sql index c8e3dad8eb..bc2ba789a0 100644 --- a/contrib/babelfishpg_tsql/sql/ownership.sql +++ b/contrib/babelfishpg_tsql/sql/ownership.sql @@ -448,7 +448,18 @@ AS 'babelfishpg_tsql', 'bbf_is_role_member' LANGUAGE C; CREATE OR REPLACE VIEW sys.database_principals AS SELECT CAST(Ext.orig_username AS SYS.SYSNAME) AS name, -CAST(Base.oid AS INT) AS principal_id, +-- PG reserves these oid > 16383 AND oid < 16400 for PG specific internal roles. +-- Any change here in the oid should be reflected in sys.database_role_members view as well. +CAST( + CASE Ext.orig_username + WHEN 'db_owner' THEN 16384 + WHEN 'db_accessadmin' THEN 16385 + WHEN 'db_securityadmin' THEN 16386 + WHEN 'db_ddladmin' THEN 16387 + WHEN 'db_datareader' THEN 16390 + WHEN 'db_datawriter' THEN 16391 + ELSE Base.oid + END AS INT) AS principal_id, CAST(Ext.type AS CHAR(1)) as type, CAST( CASE @@ -479,7 +490,12 @@ WHERE Ext.database_name = DB_NAME() UNION ALL SELECT CAST(name AS SYS.SYSNAME) AS name, -CAST(-1 AS INT) AS principal_id, +CAST( + CASE name + WHEN 'public' THEN 0 + WHEN 'INFORMATION_SCHEMA' THEN 3 + WHEN 'sys' THEN 4 + END AS INT) AS principal_id, CAST(type AS CHAR(1)) as type, CAST( CASE @@ -607,8 +623,26 @@ GRANT SELECT ON sys.sysusers TO PUBLIC; -- DATABASE_ROLE_MEMBERS CREATE OR REPLACE VIEW sys.database_role_members AS SELECT -CAST(Auth1.oid AS INT) AS role_principal_id, -CAST(Auth2.oid AS INT) AS member_principal_id +CAST( + CASE Ext1.orig_username + WHEN 'db_owner' THEN 16384 + WHEN 'db_accessadmin' THEN 16385 + WHEN 'db_securityadmin' THEN 16386 + WHEN 'db_ddladmin' THEN 16387 + WHEN 'db_datareader' THEN 16390 + WHEN 'db_datawriter' THEN 16391 + ELSE Auth1.oid + END AS INT) AS role_principal_id, +CAST( + CASE Ext2.orig_username + WHEN 'db_owner' THEN 16384 + WHEN 'db_accessadmin' THEN 16385 + WHEN 'db_securityadmin' THEN 16386 + WHEN 'db_ddladmin' THEN 16387 + WHEN 'db_datareader' THEN 16390 + WHEN 'db_datawriter' THEN 16391 + ELSE Auth2.oid + END AS INT) AS member_principal_id FROM pg_catalog.pg_auth_members AS Authmbr INNER JOIN pg_catalog.pg_roles AS Auth1 ON Auth1.oid = Authmbr.roleid INNER JOIN pg_catalog.pg_roles AS Auth2 ON Auth2.oid = Authmbr.member diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--5.0.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--5.0.0.sql index 54519d926f..e3bfe1cc01 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--5.0.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.4.0--5.0.0.sql @@ -543,7 +543,18 @@ AS 'babelfishpg_tsql', 'bbf_is_role_member' LANGUAGE C; CREATE OR REPLACE VIEW sys.database_principals AS SELECT CAST(Ext.orig_username AS SYS.SYSNAME) AS name, -CAST(Base.oid AS INT) AS principal_id, +-- PG reserves these oid > 16383 AND oid < 16400 for PG specific internal roles. +-- Any change here in the oid should be reflected in sys.database_role_members view as well. +CAST( + CASE Ext.orig_username + WHEN 'db_owner' THEN 16384 + WHEN 'db_accessadmin' THEN 16385 + WHEN 'db_securityadmin' THEN 16386 + WHEN 'db_ddladmin' THEN 16387 + WHEN 'db_datareader' THEN 16390 + WHEN 'db_datawriter' THEN 16391 + ELSE Base.oid + END AS INT) AS principal_id, CAST(Ext.type AS CHAR(1)) as type, CAST( CASE @@ -574,7 +585,12 @@ WHERE Ext.database_name = DB_NAME() UNION ALL SELECT CAST(name AS SYS.SYSNAME) AS name, -CAST(-1 AS INT) AS principal_id, +CAST( + CASE name + WHEN 'public' THEN 0 + WHEN 'INFORMATION_SCHEMA' THEN 3 + WHEN 'sys' THEN 4 + END AS INT) AS principal_id, CAST(type AS CHAR(1)) as type, CAST( CASE @@ -599,6 +615,41 @@ FROM (VALUES ('public', 'R'), ('sys', 'S'), ('INFORMATION_SCHEMA', 'S')) as dumm GRANT SELECT ON sys.database_principals TO PUBLIC; +-- DATABASE_ROLE_MEMBERS +CREATE OR REPLACE VIEW sys.database_role_members AS +SELECT +CAST( + CASE Ext1.orig_username + WHEN 'db_owner' THEN 16384 + WHEN 'db_accessadmin' THEN 16385 + WHEN 'db_securityadmin' THEN 16386 + WHEN 'db_ddladmin' THEN 16387 + WHEN 'db_datareader' THEN 16390 + WHEN 'db_datawriter' THEN 16391 + ELSE Auth1.oid + END AS INT) AS role_principal_id, +CAST( + CASE Ext2.orig_username + WHEN 'db_owner' THEN 16384 + WHEN 'db_accessadmin' THEN 16385 + WHEN 'db_securityadmin' THEN 16386 + WHEN 'db_ddladmin' THEN 16387 + WHEN 'db_datareader' THEN 16390 + WHEN 'db_datawriter' THEN 16391 + ELSE Auth2.oid + END AS INT) AS member_principal_id +FROM pg_catalog.pg_auth_members AS Authmbr +INNER JOIN pg_catalog.pg_roles AS Auth1 ON Auth1.oid = Authmbr.roleid +INNER JOIN pg_catalog.pg_roles AS Auth2 ON Auth2.oid = Authmbr.member +INNER JOIN sys.babelfish_authid_user_ext AS Ext1 ON Auth1.rolname = Ext1.rolname +INNER JOIN sys.babelfish_authid_user_ext AS Ext2 ON Auth2.rolname = Ext2.rolname +WHERE Ext1.database_name = DB_NAME() +AND Ext2.database_name = DB_NAME() +AND Ext1.type = 'R' +AND Ext2.orig_username != 'db_owner'; + +GRANT SELECT ON sys.database_role_members TO PUBLIC; + CREATE OR REPLACE PROCEDURE sys.sp_helpdbfixedrole("@rolename" sys.SYSNAME = NULL) AS $$ BEGIN diff --git a/contrib/babelfishpg_tsql/src/pl_handler.c b/contrib/babelfishpg_tsql/src/pl_handler.c index db44e78120..0aa7710819 100644 --- a/contrib/babelfishpg_tsql/src/pl_handler.c +++ b/contrib/babelfishpg_tsql/src/pl_handler.c @@ -3092,8 +3092,11 @@ bbf_ProcessUtility(PlannedStmt *pstmt, /* * check whether sql user name and role name contains * '\' or not + * + * check can be skipped if query is creating internal role + * for ALTER ROLE db_owner ADD MEMBER ... */ - if (isrole || !from_windows) + if ((isrole || !from_windows) && strcmp(queryString, INTERNAL_ALTER_ROLE) != 0) validateUserAndRole(stmt->role); /* Save the previous user to be restored after creating the login. */ diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index 2c7e3533e3..cd670e1b1c 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -71,6 +71,7 @@ PG_FUNCTION_INFO_V1(get_immediate_base_type_of_UDT); static Oid select_common_type_setop(ParseState *pstate, List *exprs, Node **which_expr, const char *context); static Oid select_common_type_for_isnull(ParseState *pstate, List *exprs); static Oid select_common_type_for_coalesce_function(ParseState *pstate, List *exprs); +static Oid get_immediate_base_type_of_UDT_internal(Oid typeid); /* Memory Context */ static MemoryContext pltsql_coercion_context = NULL; @@ -131,11 +132,13 @@ tsql_cast_raw_info_t tsql_cast_raw_infos[] = {PG_CAST_ENTRY, "sys", "bbf_varbinary", "pg_catalog", "int2", NULL, 'i', 'f'}, {TSQL_CAST_ENTRY, "sys", "bbf_varbinary", "sys", "rowversion", "varbinaryrowversion", 'i', 'f'}, {TSQL_CAST_ENTRY, "sys", "bbf_varbinary", "sys", "bbf_binary", "varbinarybinary", 'i', 'f'}, + {TSQL_CAST_ENTRY, "sys", "bbf_varbinary", "sys", "nvarchar", "varbinarysysnvarchar", 'i', 'f'}, /* binary {only allow to cast to integral data type) */ {PG_CAST_ENTRY, "sys", "bbf_binary", "pg_catalog", "int8", NULL, 'i', 'f'}, {PG_CAST_ENTRY, "sys", "bbf_binary", "pg_catalog", "int4", NULL, 'i', 'f'}, {PG_CAST_ENTRY, "sys", "bbf_binary", "pg_catalog", "int2", NULL, 'i', 'f'}, {TSQL_CAST_ENTRY, "sys", "bbf_binary", "sys", "rowversion", "binaryrowversion", 'i', 'f'}, + {TSQL_CAST_ENTRY, "sys", "bbf_binary", "sys", "nvarchar", "binarysysnvarchar", 'i', 'f'}, {TSQL_CAST_WITHOUT_FUNC_ENTRY, "sys", "bbf_binary", "sys", "bbf_varbinary", NULL, 'i', 'b'}, /* rowversion */ {PG_CAST_ENTRY, "sys", "rowversion", "pg_catalog", "int8", NULL, 'i', 'f'}, @@ -231,6 +234,8 @@ tsql_cast_raw_info_t tsql_cast_raw_infos[] = {TSQL_CAST_ENTRY, "sys", "bpchar", "pg_catalog", "name", "bpchar_to_name", 'i', 'f'}, {TSQL_CAST_ENTRY, "pg_catalog", "varchar", "pg_catalog", "name", "varchar_to_name", 'i', 'f'}, {TSQL_CAST_ENTRY, "sys", "varchar", "pg_catalog", "name", "varchar_to_name", 'i', 'f'}, + {TSQL_CAST_ENTRY, "sys", "nvarchar", "sys", "bbf_varbinary", "nvarcharvarbinary", 'a', 'f'}, + {TSQL_CAST_ENTRY, "sys", "nvarchar", "sys", "bbf_binary", "nvarcharbinary", 'a', 'f'}, /* fixeddecimal */ {PG_CAST_ENTRY, "sys", "fixeddecimal", "pg_catalog", "bpchar", NULL, 'i', 'f'}, {PG_CAST_ENTRY, "sys", "fixeddecimal", "sys", "bpchar", NULL, 'i', 'f'}, @@ -449,6 +454,18 @@ static tsql_cast_info_entry_t *tsql_cast_info_entries = NULL; static HTAB *ht_tsql_cast_info = NULL; bool inited_ht_tsql_cast_info = false; +/* Returns true if the oid belongs to binary, bbf_binary, varbinary, bbf_varbinary datatype */ +static bool +is_tsql_binary_family_datatype(Oid oid) +{ + if((*common_utility_plugin_ptr->is_tsql_binary_datatype)(oid) || (*common_utility_plugin_ptr->is_tsql_sys_varbinary_datatype)(oid) + || (*common_utility_plugin_ptr->is_tsql_sys_binary_datatype)(oid) || (*common_utility_plugin_ptr->is_tsql_varbinary_datatype)(oid)) + { + return true; + } + return false; +} + static CoercionPathType tsql_find_coercion_pathway(Oid sourceTypeId, Oid targetTypeId, CoercionContext ccontext, Oid *funcid) { @@ -462,8 +479,12 @@ tsql_find_coercion_pathway(Oid sourceTypeId, Oid targetTypeId, CoercionContext c bool isSqlVariantCast = false; bool isInt8Type = false; bool isInt8ToMoney = false; + bool isVarbinaryToNvarchar = false; + bool isNvarchartoVarbinary = false; Oid typeIds[2] = {sourceTypeId, targetTypeId}; + Oid UDT_sourceBaseType = InvalidOid; + Oid UDT_targetBaseType = InvalidOid; for (int i = 0; i < 2; i++) { @@ -494,22 +515,61 @@ tsql_find_coercion_pathway(Oid sourceTypeId, Oid targetTypeId, CoercionContext c ReleaseSysCache(tuple); break; } + if( i == 0 && strcmp(type_nsname, "sys") != 0 && strcmp(type_nsname, "pg_catalog") != 0) + { + UDT_sourceBaseType = get_immediate_base_type_of_UDT_internal(sourceTypeId); + } + + if(i == 1 && strcmp(type_nsname, "sys") != 0 && strcmp(type_nsname, "pg_catalog") != 0) + { + UDT_targetBaseType = get_immediate_base_type_of_UDT_internal(targetTypeId); + } + + ReleaseSysCache(tuple); } } + /* Check if the UDT's base type is nvarchar or varbinary. + * If so, use the immediate base type for further processing. + */ + if(UDT_sourceBaseType != InvalidOid && ((*common_utility_plugin_ptr->is_tsql_nvarchar_datatype)(UDT_sourceBaseType) || is_tsql_binary_family_datatype(UDT_sourceBaseType))) + { + typeIds[0] = UDT_sourceBaseType; + sourceTypeId = UDT_sourceBaseType; + } + + if(UDT_targetBaseType != InvalidOid && ((*common_utility_plugin_ptr->is_tsql_nvarchar_datatype)(UDT_targetBaseType) || is_tsql_binary_family_datatype(UDT_targetBaseType))) + { + typeIds[1] = UDT_targetBaseType; + targetTypeId = UDT_targetBaseType; + } + + /* We've found VARBINARY To NVARCHAR casting */ + if (is_tsql_binary_family_datatype(typeIds[0]) && (*common_utility_plugin_ptr->is_tsql_nvarchar_datatype)(typeIds[1])) + isVarbinaryToNvarchar = true; + + /* We've found NVARCHAR TO (bbf)(VAR)BINARY casting */ + if ((*common_utility_plugin_ptr->is_tsql_nvarchar_datatype)(typeIds[0]) && is_tsql_binary_family_datatype(typeIds[1])) + isNvarchartoVarbinary = true; + /* Perhaps the types are domains; if so, look at their base types */ if (!isSqlVariantCast) { - if (OidIsValid(sourceTypeId)) + /* + * if we are casting from NVARCHAR TO VARBINARY, don't look for base type of + * source so that it can call the cast function which matches with the + * exact types + */ + if (OidIsValid(sourceTypeId) && !isNvarchartoVarbinary) sourceTypeId = getBaseType(sourceTypeId); /* - * if we are casting from INT8 to MONEY, don't look for base type of + * if we are casting from INT8 to MONEY or VARBINARY To NVARCHAR, don't look for base type of * target so that it can call the cast function which matches with the * exact types */ - if (OidIsValid(targetTypeId) && !isInt8ToMoney) + if (OidIsValid(targetTypeId) && !isInt8ToMoney && !isVarbinaryToNvarchar) targetTypeId = getBaseType(targetTypeId); } diff --git a/test/JDBC/expected/babel_datatype.out b/test/JDBC/expected/babel_datatype.out index 821cc2f496..3ba0c04eed 100644 --- a/test/JDBC/expected/babel_datatype.out +++ b/test/JDBC/expected/babel_datatype.out @@ -2044,7 +2044,7 @@ select cast(cast('a' AS nvarchar(10)) as varbinary(2)); GO ~~START~~ varbinary -61 +6100 ~~END~~ select cast(cast(cast('a' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); @@ -2058,28 +2058,28 @@ select cast(cast('ab' AS nvarchar(10)) as varbinary(2)); GO ~~START~~ varbinary -6162 +6100 ~~END~~ select cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ select cast(cast('abc' AS nvarchar(10)) as varbinary(2)); GO ~~START~~ varbinary -6162 +6100 ~~END~~ select cast(cast(cast('abc' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ @@ -2211,28 +2211,28 @@ select cast(cast('ab' AS nvarchar(10)) as binary(2)); GO ~~START~~ binary -6162 +6100 ~~END~~ select cast(cast(cast('ab' AS nvarchar(10)) as binary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ select cast(cast('abc' AS nvarchar(10)) as binary(2)); GO ~~START~~ binary -6162 +6100 ~~END~~ select cast(cast(cast('abc' AS nvarchar(10)) as binary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ diff --git a/test/JDBC/expected/cast_nvarchar_test-vu-cleanup.out b/test/JDBC/expected/cast_nvarchar_test-vu-cleanup.out new file mode 100644 index 0000000000..93d03855a1 --- /dev/null +++ b/test/JDBC/expected/cast_nvarchar_test-vu-cleanup.out @@ -0,0 +1,20 @@ +-- to do in hashbytes PR +-- DROP TABLE IF EXISTS TestHash; +-- GO +DROP type user_defined_varbinary; +GO +DROP type user_defined_nvarchar; +GO +DROP VIEW IF EXISTS dbo.CastDemoView; +GO +DROP VIEW IF EXISTS dbo.CastDemoView1; +GO +DROP FUNCTION IF EXISTS dbo.CastNVarcharToVarbinary; +GO +DROP FUNCTION IF EXISTS dbo.CastVarbinaryToNVarchar; +GO +DROP FUNCTION IF EXISTS dbo.CastbinaryToNVarchar; +GO +DROP TABLE IF EXISTS casttable; +GO + diff --git a/test/JDBC/expected/cast_nvarchar_test-vu-prepare.out b/test/JDBC/expected/cast_nvarchar_test-vu-prepare.out new file mode 100644 index 0000000000..bc788efc1e --- /dev/null +++ b/test/JDBC/expected/cast_nvarchar_test-vu-prepare.out @@ -0,0 +1,76 @@ + +-- to do in hashbytes PR +-- CREATE TABLE TestHash( +-- nvarchar_data nvarchar(32) NOT NULL, +-- varchar_data varchar(32) NOT NULL, +-- cast_hashbytes_nvarchar_data AS (cast ( hashbytes('sha1', nvarchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +-- convert_hashbytes_nvarchar_data AS (convert( varbinary(20), hashbytes('sha1',nvarchar_data))) PERSISTED NOT NULL, +-- cast_hashbytes_varchar_data AS (cast ( hashbytes('sha1', varchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +-- convert_hashbytes_varchar_data AS (convert( varbinary(20), hashbytes('sha1',varchar_data))) PERSISTED NOT NULL +-- ); +-- GO +-- Function to cast NVARCHAR to VARBINARY +CREATE FUNCTION dbo.CastNVarcharToVarbinary +( + @Input NVARCHAR(MAX) +) +RETURNS VARBINARY(MAX) +AS +BEGIN + RETURN CAST(@Input AS VARBINARY(MAX)); +END +GO + +-- Function to cast VARBINARY to NVARCHAR +CREATE FUNCTION dbo.CastVarbinaryToNVarchar +( + @Input VARBINARY(MAX) +) +RETURNS NVARCHAR(MAX) +AS +BEGIN + RETURN CAST(@Input AS NVARCHAR(MAX)); +END +GO + +-- Function to cast BINARY to NVARCHAR +CREATE FUNCTION dbo.CastbinaryToNVarchar +( + @Input BINARY +) +RETURNS NVARCHAR(MAX) +AS +BEGIN + RETURN CAST(@Input AS NVARCHAR(MAX)); +END +GO + +-- View that demonstrates both casts +CREATE VIEW dbo.CastDemoView +AS +SELECT + dbo.CastNVarcharToVarbinary(N'Hello, World!') AS NVarcharToVarbinary, + dbo.CastVarbinaryToNVarchar(0x48656C6C6F2C20576F726C6421) AS VarbinaryToNVarchar, + dbo.CastbinaryToNVarchar(0x48656C6C6F2C20576F726C6421) AS binaryToNVarchar +GO + +create table casttable(nvarchar_data nvarchar(max), varbinary_data varbinary(max), binary_data binary(15), nvarchar_binary_data nvarchar(max)); +GO +insert into casttable(nvarchar_data, varbinary_data, binary_data, nvarchar_binary_data) values (N'test string', 0x48656C6C6F2C20576F726C6421, 0x48656C6C6F2C20576F726C6421, N'test string') +GO +~~ROW COUNT: 1~~ + + +CREATE VIEW dbo.CastDemoView1 +AS +SELECT + CAST(nvarchar_data AS VARBINARY(MAX)), + CAST(varbinary_data AS NVARCHAR(MAX)), + CAST(binary_data AS NVARCHAR(MAX)), + CAST(nvarchar_binary_data AS BINARY(15)) +FROM casttable +GO + + + + diff --git a/test/JDBC/expected/cast_nvarchar_test-vu-verify.out b/test/JDBC/expected/cast_nvarchar_test-vu-verify.out new file mode 100644 index 0000000000..d63936ec67 --- /dev/null +++ b/test/JDBC/expected/cast_nvarchar_test-vu-verify.out @@ -0,0 +1,357 @@ + + + + + + + + + + +-- to do in hashbytes pr +-- -- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +-- insert into TestHash values('value1', 'value1'); +-- GO +-- SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength +-- , LEN( nvarchar_data) AS nvarchar_data_len +-- , DATALENGTH( varchar_data) as varchar_data_btyes_datalength +-- , LEN( varchar_data) AS varchar_data_len +-- , * +-- from TestHash; +-- GO +-- -- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +-- SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'sha1', 'test string') +-- GO +-- --TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +-- SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +-- GO +--TEST CASE 4: Casting function for nvarchar to varbinary +SELECT cast(N'test string' as varbinary); +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO +~~START~~ +nvarchar +a +~~END~~ + + + + + + +-- to do in hashbytes PR +-- -- Test Case 5: Empty strings and NULL values +-- SELECT HASHBYTES('SHA1', '') AS empty_varchar, +-- HASHBYTES('SHA1', N'') AS empty_nvarchar, +-- HASHBYTES('SHA1', NULL) AS null_input; +-- GO +-- -- Test Case 6: Unicode characters +-- SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, +-- HASHBYTES('SHA1', N'Здравствуйте') AS russian, +-- HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +-- GO +-- -- Test Case 8: Different collations +-- SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, +-- HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +-- GO +-- -- Test Case 9: Combining varchar and nvarchar +-- SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +-- GO +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO +~~START~~ +nvarchar#!#varchar +test#!#test +~~END~~ + + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +680065006C006C006F00#!#68656C6C6F#!#68656C6C6F#!#68656C6C6F +~~END~~ + + + +-- to do in hashbytes PR +-- -- Test Case 12: Testing with special characters +-- SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, +-- HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, +-- HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, +-- HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +-- GO +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "WIN1252": 0x00)~~ + + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO +~~START~~ +varchar +Test String +~~END~~ + + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.)~~ + + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +~~START~~ +binary +7400650073007400200073007400720069006E0067000000000000000000 +~~END~~ + +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + + + +-- to do in hashbytes PR +-- -- Test Case 19: User defined hashbytes function +-- create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +-- GO +-- SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +-- GO +-- select hashbytes('abc') +-- GO +-- drop function dbo.hashbytes +-- GO +-- Test 20: Calling the function, procedure, views from prepare scripts +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO +~~START~~ +nvarchar +Test String +~~END~~ + + + +-- Test CastVarbinaryToNVarchar function +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +敔瑳瑓楲杮 +~~END~~ + + + +-- Test CastbinaryToNVarchar function +DECLARE @TestBinary BINARY = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +T +~~END~~ + + + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX), + binaryToNVarchar NVARCHAR(MAX) +); +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go +~~ROW COUNT: 1~~ + + +SELECT * FROM dbo.CastDemoView1; +GO +~~START~~ +varbinary#!#nvarchar#!#nvarchar#!#binary +7400650073007400200073007400720069006E006700#!#效汬Ɐ圠牯摬!#!#效汬Ɐ圠牯摬!#!#740065007300740020007300740072 +~~END~~ + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO +~~START~~ +nvarchar +Hello, World! +~~END~~ + + + + + +--TEST CASE 22: Calling hashbytes via function, procedure, views +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII +-- to do in hashbytes PR +-- SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +-- GO +-- -- Test the HashDemoView +-- SELECT * FROM dbo.HashDemoView; +-- GO +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + +--TEST CASE 24: NVARCHAR TO BINARY with maxlen < length of actual string +select cast(0x610061006100610061006100610061006100 as nvarchar(5)) +GO +~~START~~ +nvarchar +aaaaa +~~END~~ + +select cast(0x8765 as nvarchar(1)) +GO +~~START~~ +nvarchar +文 +~~END~~ + + + +--TEST CASE 25: Default typmod case with string getting truncated +select cast(N'Lorem ipsum dolor sit amet' as varbinary) +GO +~~START~~ +varbinary +4C006F00720065006D00200069007000730075006D00200064006F006C00 +~~END~~ + +select cast(0x4C006F00720065006D00200069007000730075006D00200064006F006C00 as nvarchar) +GO +~~START~~ +nvarchar +Lorem ipsum dol +~~END~~ + +--TEST CASE 26: String getting truncted with defined typmod i.e len > maxlen +select cast(N'tesst string' as varbinary(4)) +GO +~~START~~ +varbinary +74006500 +~~END~~ + +select cast(0x74006500 as nvarchar) +GO +~~START~~ +nvarchar +te +~~END~~ + + +select cast(N'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea' as varbinary(MAX)) +GO +~~START~~ +varbinary +4C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100 +~~END~~ + + +select cast(0x0006161 as nvarchar) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to nvarchar, invalid UTF16 byte sequence - code point 0 not supported)~~ + diff --git a/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-cleanup.out b/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-cleanup.out new file mode 100644 index 0000000000..b84f229da8 --- /dev/null +++ b/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-cleanup.out @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS TestHash; +GO +DROP type user_defined_varbinary; +GO +DROP type user_defined_nvarchar; +GO +DROP VIEW IF EXISTS dbo.CastDemoView; +GO +DROP FUNCTION IF EXISTS dbo.CastNVarcharToVarbinary; +GO +DROP FUNCTION IF EXISTS dbo.CastVarbinaryToNVarchar; +GO +DROP FUNCTION IF EXISTS dbo.HashMultipleTypes; +GO +DROP PROCEDURE IF EXISTS dbo.PrintHashResults; +GO +DROP VIEW IF EXISTS dbo.HashDemoView; +GO + diff --git a/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-prepare.out b/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-prepare.out new file mode 100644 index 0000000000..0c2e397cf2 --- /dev/null +++ b/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-prepare.out @@ -0,0 +1,71 @@ +CREATE TABLE TestHash( +nvarchar_data nvarchar(32) NOT NULL, +varchar_data varchar(32) NOT NULL, +cast_hashbytes_nvarchar_data AS (cast ( hashbytes('sha1', nvarchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +convert_hashbytes_nvarchar_data AS (convert( varbinary(20), hashbytes('sha1',nvarchar_data))) PERSISTED NOT NULL, +cast_hashbytes_varchar_data AS (cast ( hashbytes('sha1', varchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +convert_hashbytes_varchar_data AS (convert( varbinary(20), hashbytes('sha1',varchar_data))) PERSISTED NOT NULL +); +GO + +-- Function to cast NVARCHAR to VARBINARY +CREATE FUNCTION dbo.CastNVarcharToVarbinary +( + @Input NVARCHAR(MAX) +) +RETURNS VARBINARY(MAX) +AS +BEGIN + RETURN CAST(@Input AS VARBINARY(MAX)); +END +GO + +-- Function to cast VARBINARY to NVARCHAR +CREATE FUNCTION dbo.CastVarbinaryToNVarchar +( + @Input VARBINARY(MAX) +) +RETURNS NVARCHAR(MAX) +AS +BEGIN + RETURN CAST(@Input AS NVARCHAR(MAX)); +END +GO + +-- View that demonstrates both casts +CREATE VIEW dbo.CastDemoView +AS +SELECT + dbo.CastNVarcharToVarbinary(N'Hello, World!') AS NVarcharToVarbinary, + dbo.CastVarbinaryToNVarchar(0x48656C6C6F2C20576F726C6421) AS VarbinaryToNVarchar +GO + + +-- Function to hash different input types +CREATE FUNCTION dbo.HashMultipleTypes +( + @VarcharInput VARCHAR(MAX), + @NVarcharInput NVARCHAR(MAX), + @VarbinaryInput VARBINARY(MAX) +) +RETURNS TABLE +AS +RETURN +( + SELECT + HASHBYTES('SHA2_256', @VarcharInput) AS VarcharHash, + HASHBYTES('SHA2_256', @NVarcharInput) AS NVarcharHash, + HASHBYTES('SHA2_256', @VarbinaryInput) AS VarbinaryHash +) +GO + + +-- View to demonstrate hashing +CREATE VIEW dbo.HashDemoView +AS +SELECT + HASHBYTES('SHA2_256', CAST('Hello' AS VARCHAR(MAX))) AS VarcharHash, + HASHBYTES('SHA2_256', CAST(N'Hello' AS NVARCHAR(MAX))) AS NVarcharHash, + HASHBYTES('SHA2_256', CAST(0x48656C6C6F AS VARBINARY(MAX))) AS VarbinaryHash +GO + diff --git a/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-verify.out b/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-verify.out new file mode 100644 index 0000000000..16e32de7ec --- /dev/null +++ b/test/JDBC/expected/cast_nvarchar_test_before_16_5-vu-verify.out @@ -0,0 +1,368 @@ +-- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +insert into TestHash values('value1', 'value1'); +GO +~~ROW COUNT: 1~~ + + +SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength + , LEN( nvarchar_data) AS nvarchar_data_len + , DATALENGTH( varchar_data) as varchar_data_btyes_datalength + , LEN( varchar_data) AS varchar_data_len + , * +from TestHash; +GO +~~START~~ +int#!#int#!#int#!#int#!#nvarchar#!#varchar#!#varbinary#!#varbinary#!#varbinary#!#varbinary +6#!#6#!#6#!#6#!#value1#!#value1#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB +~~END~~ + +-- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + +SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +6F8DB599DE986FAB7A21625B7916589C#!#6F8DB599DE986FAB7A21625B7916589C +~~END~~ + + +SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B#!#D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B +~~END~~ + + +SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC#!#10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC +~~END~~ + + +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + +SELECT hashbytes( 'sha1', 'test string') +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +--TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + + +--TEST CASE 4: Casting function for nvarchar to varbinary +SELECT cast(N'test string' as varbinary); +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO +~~START~~ +nvarchar +a +~~END~~ + + +-- Test Case 5: Empty strings and NULL values +SELECT HASHBYTES('SHA1', '') AS empty_varchar, + HASHBYTES('SHA1', N'') AS empty_nvarchar, + HASHBYTES('SHA1', NULL) AS null_input; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!#DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!# +~~END~~ + + +-- Test Case 6: Unicode characters +SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, + HASHBYTES('SHA1', N'Здравствуйте') AS russian, + HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +20427A708C3F6F07CF12AB23557982D9E6D23B61#!#E2D105A2541F2DC6C8B93DF73D07DF30B33FD80A#!#3B114970B215D62CB987A4D5644FEE7001C78234 +~~END~~ + + +-- Test Case 8: Different collations +SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, + HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +GO +~~START~~ +varbinary#!#varbinary +AAF4C61DDCC5E8A2DABEDE0F3B482CD9AEA9434D#!#AAF4C61DDCC5E8A2DABEDE0F3B482CD9AEA9434D +~~END~~ + + +-- Test Case 9: Combining varchar and nvarchar +SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +GO +~~START~~ +varbinary +6ADFB183A4A2C94A2F92DAB5ADE762A47889A5A1 +~~END~~ + + +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO +~~START~~ +nvarchar#!#varchar +test#!#test +~~END~~ + + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +680065006C006C006F00#!#68656C6C6F#!#68656C6C6F#!#68656C6C6F +~~END~~ + + +-- Test Case 12: Testing with special characters +SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, + HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, + HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, + HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F +~~END~~ + + +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "WIN1252": 0x00)~~ + + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO +~~START~~ +varchar +Test String +~~END~~ + + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.)~~ + + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +~~START~~ +binary +7400650073007400200073007400720069006E0067000000000000000000 +~~END~~ + +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 19: User defined hashbytes function +create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +GO +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +select hashbytes('abc') +GO +~~START~~ +varchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "dummy hashbytes" does not exist)~~ + +drop function dbo.hashbytes +GO + + +-- Test 20: Calling the function, procedure, views from prepare scripts +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO +~~START~~ +nvarchar +Test String +~~END~~ + + + +-- Test CastVarbinaryToNVarchar function +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +敔瑳瑓楲杮 +~~END~~ + + + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX) +); +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go +~~ROW COUNT: 1~~ + + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO +~~START~~ +nvarchar +Hello, World! +~~END~~ + + + + +--TEST CASE 22: Calling hashbytes via function, procedure, views +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII +SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25 +~~END~~ + +-- Test the HashDemoView +SELECT * FROM dbo.HashDemoView; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969 +~~END~~ + + +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + + diff --git a/test/JDBC/expected/concat-before-15_9-or-16_5-vu-verify.out b/test/JDBC/expected/concat-before-15_9-or-16_5-vu-verify.out index ad8c38422d..b2af2077fc 100644 --- a/test/JDBC/expected/concat-before-15_9-or-16_5-vu-verify.out +++ b/test/JDBC/expected/concat-before-15_9-or-16_5-vu-verify.out @@ -432,7 +432,7 @@ SELECT CONCAT( 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' AS cha GO ~~START~~ nvarchar -ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLMefOPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcdefg +ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLM晥OPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcde杦 ~~END~~ @@ -1197,16 +1197,16 @@ SELECT CONCAT(col_nvarchar, col_binary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1214,16 +1214,16 @@ SELECT CONCAT(col_nvarchar, col_varbinary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1535,16 +1535,16 @@ EXEC babel_3409_concat_dep_proc2 GO ~~START~~ nvarchar -abc12.002000-12-12 12:43:102000-12-12 12:43:10ab2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 -🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10cd2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 -🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10ef2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 -比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10gh2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 -莫斯16.002000-12-16 12:43:102000-12-16 12:43:10ip2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 +abc12.002000-12-12 12:43:102000-12-12 12:43:10扡2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 +🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10摣2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 +🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10晥2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 +比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10桧2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 +莫斯16.002000-12-16 12:43:102000-12-16 12:43:10灩2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 -Anikait17.002000-12-17 12:43:102000-12-17 12:43:10qr2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 +Anikait17.002000-12-17 12:43:102000-12-17 12:43:10牱2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 -Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10rs2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 +Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10獲2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -1552,7 +1552,7 @@ SELECT babel_3409_concat_dep_func2() GO ~~START~~ nvarchar -abcababcabc +abc扡abcabc ~~END~~ diff --git a/test/JDBC/expected/concat-vu-verify.out b/test/JDBC/expected/concat-vu-verify.out index 9d98187e47..6611c81c7a 100644 --- a/test/JDBC/expected/concat-vu-verify.out +++ b/test/JDBC/expected/concat-vu-verify.out @@ -432,7 +432,7 @@ SELECT CONCAT( 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' AS cha GO ~~START~~ nvarchar -ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLMefOPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcdefg +ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLM晥OPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcde杦 ~~END~~ @@ -1463,16 +1463,16 @@ SELECT CONCAT(col_nvarchar, col_binary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1480,16 +1480,16 @@ SELECT CONCAT(col_nvarchar, col_varbinary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1852,16 +1852,16 @@ EXEC babel_3409_concat_dep_proc2 GO ~~START~~ nvarchar -abc12.002000-12-12 12:43:102000-12-12 12:43:10ab2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 -🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10cd2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 -🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10ef2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 -比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10gh2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 -莫斯16.002000-12-16 12:43:102000-12-16 12:43:10ip2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 +abc12.002000-12-12 12:43:102000-12-12 12:43:10扡2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 +🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10摣2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 +🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10晥2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 +比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10桧2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 +莫斯16.002000-12-16 12:43:102000-12-16 12:43:10灩2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 -Anikait17.002000-12-17 12:43:102000-12-17 12:43:10qr2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 +Anikait17.002000-12-17 12:43:102000-12-17 12:43:10牱2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 -Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10rs2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 +Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10獲2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -1869,7 +1869,7 @@ SELECT babel_3409_concat_dep_func2() GO ~~START~~ nvarchar -abcababcabc +abc扡abcabc ~~END~~ diff --git a/test/JDBC/expected/concat_ws-before-15_5-or-14_10-vu-verify.out b/test/JDBC/expected/concat_ws-before-15_5-or-14_10-vu-verify.out index 4bcbb450a8..4627571670 100644 --- a/test/JDBC/expected/concat_ws-before-15_5-or-14_10-vu-verify.out +++ b/test/JDBC/expected/concat_ws-before-15_5-or-14_10-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1397,16 +1397,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1431,16 +1431,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2332,16 +2332,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2349,16 +2349,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2366,16 +2366,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2383,16 +2383,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3324,16 +3324,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3341,7 +3341,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/concat_ws-before-15_9-or-16_5-vu-verify.out b/test/JDBC/expected/concat_ws-before-15_9-or-16_5-vu-verify.out index 4c7a22a10b..bb033b6198 100644 --- a/test/JDBC/expected/concat_ws-before-15_9-or-16_5-vu-verify.out +++ b/test/JDBC/expected/concat_ws-before-15_9-or-16_5-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1397,16 +1397,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1431,16 +1431,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2332,16 +2332,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2349,16 +2349,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2366,16 +2366,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2383,16 +2383,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3324,16 +3324,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3341,7 +3341,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/concat_ws-vu-verify.out b/test/JDBC/expected/concat_ws-vu-verify.out index d50fe5c3c5..fd334241be 100644 --- a/test/JDBC/expected/concat_ws-vu-verify.out +++ b/test/JDBC/expected/concat_ws-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1544,16 +1544,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1578,16 +1578,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2683,16 +2683,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2700,16 +2700,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2717,16 +2717,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2734,16 +2734,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3808,16 +3808,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3825,7 +3825,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/db_owner-vu-verify.out b/test/JDBC/expected/db_owner-vu-verify.out index 89bfe9455a..2be2206841 100644 --- a/test/JDBC/expected/db_owner-vu-verify.out +++ b/test/JDBC/expected/db_owner-vu-verify.out @@ -2063,3 +2063,60 @@ use master go drop database dbowner_averyveryveryveryveryveryveryveryveryveryverylongdatabasename go + +-- Check for windows login +exec sys.babelfish_add_domain_mapping_entry 'dbownerdomain', 'dbownerdomain.babel'; +go +create login [dbownerdomain\abc] from windows +go +create user [dbownerdomain\abc] +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +~~START~~ +int +0 +~~END~~ + +alter role db_owner add member [dbownerdomain\abc] +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +~~START~~ +int +1 +~~END~~ + +alter role db_owner drop member [dbownerdomain\abc] +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +~~START~~ +int +0 +~~END~~ + +exec sp_addrolemember 'db_owner', 'dbownerdomain\abc' +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +~~START~~ +int +1 +~~END~~ + +exec sp_droprolemember 'db_owner', 'dbownerdomain\abc' +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +~~START~~ +int +0 +~~END~~ + +drop user [dbownerdomain\abc] +go +drop login [dbownerdomain\abc] +go +exec sys.babelfish_remove_domain_mapping_entry 'dbownerdomain' +go diff --git a/test/JDBC/expected/db_securityadmin-vu-prepare.out b/test/JDBC/expected/db_securityadmin-vu-prepare.out index 64bc1d71a5..36553d9a3e 100644 --- a/test/JDBC/expected/db_securityadmin-vu-prepare.out +++ b/test/JDBC/expected/db_securityadmin-vu-prepare.out @@ -41,17 +41,6 @@ GO CREATE SEQUENCE babel_5135_schema1.babel_5135_seq1 START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 999999 CYCLE; GO -CREATE VIEW babel_5135_show_role_mem AS -SELECT -roles.name AS RolePrincipalName -, members.name AS MemberPrincipalName -FROM sys.database_role_members AS db_role_mems -INNER JOIN sys.database_principals AS roles - ON db_role_mems.role_principal_id = roles.principal_id -INNER JOIN sys.database_principals AS members - ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; -GO - CREATE PROCEDURE babel_5135_roleop_proc1 AS BEGIN CREATE ROLE babel_5135_role2; ALTER ROLE babel_5135_role2 WITH NAME = babel_5135_role3; DROP ROLE babel_5135_role3; END GO CREATE PROCEDURE babel_5135_roleop_proc2 AS BEGIN ALTER ROLE babel_5135_r1 ADD MEMBER babel_5135_u1; END @@ -100,14 +89,3 @@ GO create user babel_5135_u1 for login babel_5135_l1; GO - -CREATE VIEW babel_5135_show_role_mem AS -SELECT -roles.name AS RolePrincipalName -, members.name AS MemberPrincipalName -FROM sys.database_role_members AS db_role_mems -INNER JOIN sys.database_principals AS roles - ON db_role_mems.role_principal_id = roles.principal_id -INNER JOIN sys.database_principals AS members - ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; -GO diff --git a/test/JDBC/expected/db_securityadmin-vu-verify.out b/test/JDBC/expected/db_securityadmin-vu-verify.out index c4aa540f35..2cb9a4dde3 100644 --- a/test/JDBC/expected/db_securityadmin-vu-verify.out +++ b/test/JDBC/expected/db_securityadmin-vu-verify.out @@ -20,6 +20,31 @@ GO ALTER ROLE db_securityadmin ADD MEMBER babel_5135_r1; GO +CREATE VIEW babel_5135_show_role_mem AS +SELECT +roles.name AS RolePrincipalName +, members.name AS MemberPrincipalName +FROM sys.database_role_members AS db_role_mems +INNER JOIN sys.database_principals AS roles + ON db_role_mems.role_principal_id = roles.principal_id +INNER JOIN sys.database_principals AS members + ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; +GO + +-- Should only show fixed database roles +SELECT name from sys.database_principals WHERE principal_id > 16383 AND principal_id < 16400 ORDER BY name; +GO +~~START~~ +varchar +db_accessadmin +db_datareader +db_datawriter +db_ddladmin +db_owner +db_securityadmin +~~END~~ + + EXEC sp_addrolemember 'db_securityadmin', 'babel_5135_u1'; GO @@ -58,6 +83,31 @@ varchar#!#varchar USE babel_5135_db1; GO +CREATE VIEW babel_5135_show_role_mem AS +SELECT +roles.name AS RolePrincipalName +, members.name AS MemberPrincipalName +FROM sys.database_role_members AS db_role_mems +INNER JOIN sys.database_principals AS roles + ON db_role_mems.role_principal_id = roles.principal_id +INNER JOIN sys.database_principals AS members + ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; +GO + +-- Should only show fixed database roles +SELECT name from sys.database_principals WHERE principal_id > 16383 AND principal_id < 16400 ORDER BY name; +GO +~~START~~ +varchar +db_accessadmin +db_datareader +db_datawriter +db_ddladmin +db_owner +db_securityadmin +~~END~~ + + ALTER ROLE db_securityadmin ADD MEMBER babel_5135_u1; GO diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-1206.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-1206.out index 3bbb0cb375..d5e3a243f0 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-1206.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-1206.out @@ -87,16 +87,14 @@ go insert into babel_1206_t3 values (0xaaa); go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "GBK": 0xaa)~~ +~~ROW COUNT: 1~~ --should throw an error because of duplicate index key insert into babel_1206_t3 values (0xaaa); go -~~ERROR (Code: 33557097)~~ +~~ERROR (Code: 2627)~~ -~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "GBK": 0xaa)~~ +~~ERROR (Message: duplicate key value violates unique constraint "babel_1206_t3_i3")~~ drop table babel_1265_t1; diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/babel_datatype.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/babel_datatype.out index feb5e8f4bf..a9770af423 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/babel_datatype.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/babel_datatype.out @@ -2044,7 +2044,7 @@ select cast(cast('a' AS nvarchar(10)) as varbinary(2)); GO ~~START~~ varbinary -61 +6100 ~~END~~ select cast(cast(cast('a' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); @@ -2058,28 +2058,28 @@ select cast(cast('ab' AS nvarchar(10)) as varbinary(2)); GO ~~START~~ varbinary -6162 +6100 ~~END~~ select cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ select cast(cast('abc' AS nvarchar(10)) as varbinary(2)); GO ~~START~~ varbinary -6162 +6100 ~~END~~ select cast(cast(cast('abc' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ @@ -2211,28 +2211,28 @@ select cast(cast('ab' AS nvarchar(10)) as binary(2)); GO ~~START~~ binary -6162 +6100 ~~END~~ select cast(cast(cast('ab' AS nvarchar(10)) as binary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ select cast(cast('abc' AS nvarchar(10)) as binary(2)); GO ~~START~~ binary -6162 +6100 ~~END~~ select cast(cast(cast('abc' AS nvarchar(10)) as binary(2)) as nvarchar(2)); GO ~~START~~ nvarchar -ab +a ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/cast_nvarchar_test-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/cast_nvarchar_test-vu-verify.out new file mode 100644 index 0000000000..a587eccd56 --- /dev/null +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/cast_nvarchar_test-vu-verify.out @@ -0,0 +1,357 @@ + + + + + + + + + + +-- to do in hashbytes pr +-- -- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +-- insert into TestHash values('value1', 'value1'); +-- GO +-- SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength +-- , LEN( nvarchar_data) AS nvarchar_data_len +-- , DATALENGTH( varchar_data) as varchar_data_btyes_datalength +-- , LEN( varchar_data) AS varchar_data_len +-- , * +-- from TestHash; +-- GO +-- -- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +-- SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +-- GO +-- SELECT hashbytes( 'sha1', 'test string') +-- GO +-- --TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +-- SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +-- GO +--TEST CASE 4: Casting function for nvarchar to varbinary +SELECT cast(N'test string' as varbinary); +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO +~~START~~ +nvarchar +a +~~END~~ + + + + + + +-- to do in hashbytes PR +-- -- Test Case 5: Empty strings and NULL values +-- SELECT HASHBYTES('SHA1', '') AS empty_varchar, +-- HASHBYTES('SHA1', N'') AS empty_nvarchar, +-- HASHBYTES('SHA1', NULL) AS null_input; +-- GO +-- -- Test Case 6: Unicode characters +-- SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, +-- HASHBYTES('SHA1', N'Здравствуйте') AS russian, +-- HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +-- GO +-- -- Test Case 8: Different collations +-- SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, +-- HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +-- GO +-- -- Test Case 9: Combining varchar and nvarchar +-- SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +-- GO +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO +~~START~~ +nvarchar#!#varchar +test#!#test +~~END~~ + + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +680065006C006C006F00#!#68656C6C6F#!#68656C6C6F#!#68656C6C6F +~~END~~ + + + +-- to do in hashbytes PR +-- -- Test Case 12: Testing with special characters +-- SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, +-- HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, +-- HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, +-- HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +-- GO +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "GBK": 0x00)~~ + + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO +~~START~~ +varchar +Test String +~~END~~ + + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.)~~ + + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +~~START~~ +binary +7400650073007400200073007400720069006E0067000000000000000000 +~~END~~ + +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + + + +-- to do in hashbytes PR +-- -- Test Case 19: User defined hashbytes function +-- create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +-- GO +-- SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +-- GO +-- select hashbytes('abc') +-- GO +-- drop function dbo.hashbytes +-- GO +-- Test 20: Calling the function, procedure, views from prepare scripts +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO +~~START~~ +nvarchar +Test String +~~END~~ + + + +-- Test CastVarbinaryToNVarchar function +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +敔瑳瑓楲杮 +~~END~~ + + + +-- Test CastbinaryToNVarchar function +DECLARE @TestBinary BINARY = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +T +~~END~~ + + + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX), + binaryToNVarchar NVARCHAR(MAX) +); +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go +~~ROW COUNT: 1~~ + + +SELECT * FROM dbo.CastDemoView1; +GO +~~START~~ +varbinary#!#nvarchar#!#nvarchar#!#binary +7400650073007400200073007400720069006E006700#!#效汬Ɐ圠牯摬!#!#效汬Ɐ圠牯摬!#!#740065007300740020007300740072 +~~END~~ + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO +~~START~~ +nvarchar +Hello, World! +~~END~~ + + + + + +--TEST CASE 22: Calling hashbytes via function, procedure, views +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII +-- to do in hashbytes PR +-- SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +-- GO +-- -- Test the HashDemoView +-- SELECT * FROM dbo.HashDemoView; +-- GO +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + +--TEST CASE 24: NVARCHAR TO BINARY with maxlen < length of actual string +select cast(0x610061006100610061006100610061006100 as nvarchar(5)) +GO +~~START~~ +nvarchar +aaaaa +~~END~~ + +select cast(0x8765 as nvarchar(1)) +GO +~~START~~ +nvarchar +文 +~~END~~ + + + +--TEST CASE 25: Default typmod case with string getting truncated +select cast(N'Lorem ipsum dolor sit amet' as varbinary) +GO +~~START~~ +varbinary +4C006F00720065006D00200069007000730075006D00200064006F006C00 +~~END~~ + +select cast(0x4C006F00720065006D00200069007000730075006D00200064006F006C00 as nvarchar) +GO +~~START~~ +nvarchar +Lorem ipsum dol +~~END~~ + +--TEST CASE 26: String getting truncted with defined typmod i.e len > maxlen +select cast(N'tesst string' as varbinary(4)) +GO +~~START~~ +varbinary +74006500 +~~END~~ + +select cast(0x74006500 as nvarchar) +GO +~~START~~ +nvarchar +te +~~END~~ + + +select cast(N'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea' as varbinary(MAX)) +GO +~~START~~ +varbinary +4C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100200063006F006D006D006F0064006F00200063006F006E007300650071007500610074002E002000440075006900730020006100750074006500200069007200750072006500200064006F006C006F007200200069006E00200072006500700072006500680065006E0064006500720069007400200069006E00200076006F006C007500700074006100740065002000760065006C0069007400200065007300730065002000630069006C006C0075006D00200064006F006C006F0072006500200065007500200066007500670069006100740020006E0075006C006C0061002000700061007200690061007400750072002E0020004500780063006500700074006500750072002000730069006E00740020006F006300630061006500630061007400200063007500700069006400610074006100740020006E006F006E002000700072006F006900640065006E0074002C002000730075006E007400200069006E002000630075006C0070006100200071007500690020006F0066006600690063006900610020006400650073006500720075006E00740020006D006F006C006C0069007400200061006E0069006D00200069006400200065007300740020006C00610062006F00720075006D002E0020004C006F00720065006D00200069007000730075006D00200064006F006C006F0072002000730069007400200061006D00650074002C00200063006F006E00730065006300740065007400750072002000610064006900700069007300630069006E006700200065006C00690074002E002000530065006400200064006F00200065006900750073006D006F0064002000740065006D0070006F007200200069006E006300690064006900640075006E00740020007500740020006C00610062006F0072006500200065007400200064006F006C006F007200650020006D00610067006E006100200061006C0069007100750061002E00200055007400200065006E0069006D0020006100640020006D0069006E0069006D002000760065006E00690061006D002C002000710075006900730020006E006F0073007400720075006400200065007800650072006300690074006100740069006F006E00200075006C006C0061006D0063006F0020006C00610062006F0072006900730020006E00690073006900200075007400200061006C0069007100750069007000200065007800200065006100 +~~END~~ + + +select cast(0x0006161 as nvarchar) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to nvarchar, invalid UTF16 byte sequence - code point 0 not supported)~~ + diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/cast_nvarchar_test_before_16_5-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/cast_nvarchar_test_before_16_5-vu-verify.out new file mode 100644 index 0000000000..92a8a1fb09 --- /dev/null +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/cast_nvarchar_test_before_16_5-vu-verify.out @@ -0,0 +1,368 @@ +-- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +insert into TestHash values('value1', 'value1'); +GO +~~ROW COUNT: 1~~ + + +SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength + , LEN( nvarchar_data) AS nvarchar_data_len + , DATALENGTH( varchar_data) as varchar_data_btyes_datalength + , LEN( varchar_data) AS varchar_data_len + , * +from TestHash; +GO +~~START~~ +int#!#int#!#int#!#int#!#nvarchar#!#varchar#!#varbinary#!#varbinary#!#varbinary#!#varbinary +6#!#6#!#6#!#6#!#value1#!#value1#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB +~~END~~ + +-- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + +SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +6F8DB599DE986FAB7A21625B7916589C#!#6F8DB599DE986FAB7A21625B7916589C +~~END~~ + + +SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B#!#D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B +~~END~~ + + +SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC#!#10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC +~~END~~ + + +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + +SELECT hashbytes( 'sha1', 'test string') +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +--TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + + +--TEST CASE 4: Casting function for nvarchar to varbinary +SELECT cast(N'test string' as varbinary); +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO +~~START~~ +nvarchar +a +~~END~~ + + +-- Test Case 5: Empty strings and NULL values +SELECT HASHBYTES('SHA1', '') AS empty_varchar, + HASHBYTES('SHA1', N'') AS empty_nvarchar, + HASHBYTES('SHA1', NULL) AS null_input; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!#DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!# +~~END~~ + + +-- Test Case 6: Unicode characters +SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, + HASHBYTES('SHA1', N'Здравствуйте') AS russian, + HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +20427A708C3F6F07CF12AB23557982D9E6D23B61#!#E2D105A2541F2DC6C8B93DF73D07DF30B33FD80A#!#3B114970B215D62CB987A4D5644FEE7001C78234 +~~END~~ + + +-- Test Case 8: Different collations +SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, + HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +GO +~~START~~ +varbinary#!#varbinary +AAF4C61DDCC5E8A2DABEDE0F3B482CD9AEA9434D#!#AAF4C61DDCC5E8A2DABEDE0F3B482CD9AEA9434D +~~END~~ + + +-- Test Case 9: Combining varchar and nvarchar +SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +GO +~~START~~ +varbinary +6ADFB183A4A2C94A2F92DAB5ADE762A47889A5A1 +~~END~~ + + +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO +~~START~~ +nvarchar#!#varchar +test#!#test +~~END~~ + + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +680065006C006C006F00#!#68656C6C6F#!#68656C6C6F#!#68656C6C6F +~~END~~ + + +-- Test Case 12: Testing with special characters +SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, + HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, + HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, + HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F +~~END~~ + + +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "GBK": 0x00)~~ + + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO +~~START~~ +varchar +Test String +~~END~~ + + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.)~~ + + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +~~START~~ +binary +7400650073007400200073007400720069006E0067000000000000000000 +~~END~~ + +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 19: User defined hashbytes function +create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +GO +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +select hashbytes('abc') +GO +~~START~~ +varchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "dummy hashbytes" does not exist)~~ + +drop function dbo.hashbytes +GO + + +-- Test 20: Calling the function, procedure, views from prepare scripts +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO +~~START~~ +nvarchar +Test String +~~END~~ + + + +-- Test CastVarbinaryToNVarchar function +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +敔瑳瑓楲杮 +~~END~~ + + + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX) +); +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go +~~ROW COUNT: 1~~ + + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO +~~START~~ +nvarchar +Hello, World! +~~END~~ + + + + +--TEST CASE 22: Calling hashbytes via function, procedure, views +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII +SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25 +~~END~~ + +-- Test the HashDemoView +SELECT * FROM dbo.HashDemoView; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969 +~~END~~ + + +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + + diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-before-15_9-or-16_5-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-before-15_9-or-16_5-vu-verify.out index 6d9ad21817..e839c615fb 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-before-15_9-or-16_5-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-before-15_9-or-16_5-vu-verify.out @@ -432,7 +432,7 @@ SELECT CONCAT( 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' AS cha GO ~~START~~ nvarchar -ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLMefOPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcdefg +ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLM晥OPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcde杦 ~~END~~ @@ -1197,16 +1197,16 @@ SELECT CONCAT(col_nvarchar, col_binary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1214,16 +1214,16 @@ SELECT CONCAT(col_nvarchar, col_varbinary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1535,16 +1535,16 @@ EXEC babel_3409_concat_dep_proc2 GO ~~START~~ nvarchar -abc12.002000-12-12 12:43:102000-12-12 12:43:10ab2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 -🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10cd2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 -🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10ef2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 -比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10gh2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 -莫斯16.002000-12-16 12:43:102000-12-16 12:43:10ip2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 +abc12.002000-12-12 12:43:102000-12-12 12:43:10扡2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 +🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10摣2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 +🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10晥2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 +比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10桧2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 +莫斯16.002000-12-16 12:43:102000-12-16 12:43:10灩2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 -Anikait17.002000-12-17 12:43:102000-12-17 12:43:10qr2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 +Anikait17.002000-12-17 12:43:102000-12-17 12:43:10牱2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 -Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10rs2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 +Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10獲2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -1552,7 +1552,7 @@ SELECT babel_3409_concat_dep_func2() GO ~~START~~ nvarchar -abcababcabc +abc扡abcabc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-vu-verify.out index eb8fed6616..5c4c0075e3 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat-vu-verify.out @@ -432,7 +432,7 @@ SELECT CONCAT( 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' AS cha GO ~~START~~ nvarchar -ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLMefOPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcdefg +ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLM晥OPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcde杦 ~~END~~ @@ -1463,16 +1463,16 @@ SELECT CONCAT(col_nvarchar, col_binary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1480,16 +1480,16 @@ SELECT CONCAT(col_nvarchar, col_varbinary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1852,16 +1852,16 @@ EXEC babel_3409_concat_dep_proc2 GO ~~START~~ nvarchar -abc12.002000-12-12 12:43:102000-12-12 12:43:10ab2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 -🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10cd2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 -🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10ef2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 -比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10gh2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 -莫斯16.002000-12-16 12:43:102000-12-16 12:43:10ip2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 +abc12.002000-12-12 12:43:102000-12-12 12:43:10扡2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 +🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10摣2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 +🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10晥2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 +比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10桧2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 +莫斯16.002000-12-16 12:43:102000-12-16 12:43:10灩2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 -Anikait17.002000-12-17 12:43:102000-12-17 12:43:10qr2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 +Anikait17.002000-12-17 12:43:102000-12-17 12:43:10牱2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 -Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10rs2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 +Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10獲2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -1869,7 +1869,7 @@ SELECT babel_3409_concat_dep_func2() GO ~~START~~ nvarchar -abcababcabc +abc扡abcabc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_5-or-14_10-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_5-or-14_10-vu-verify.out index cfbdbca591..8eb7adbadc 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_5-or-14_10-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_5-or-14_10-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1397,16 +1397,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1431,16 +1431,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2332,16 +2332,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2349,16 +2349,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2366,16 +2366,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2383,16 +2383,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3316,16 +3316,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3333,7 +3333,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_9-or-16_5-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_9-or-16_5-vu-verify.out index 630b17e5cd..64d3601d35 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_9-or-16_5-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-before-15_9-or-16_5-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1397,16 +1397,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1431,16 +1431,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2332,16 +2332,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2349,16 +2349,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2366,16 +2366,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2383,16 +2383,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3324,16 +3324,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3341,7 +3341,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-vu-verify.out index 65343b8eb5..77e4839f66 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/concat_ws-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1544,16 +1544,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1578,16 +1578,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2683,16 +2683,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2700,16 +2700,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2717,16 +2717,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2734,16 +2734,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3808,16 +3808,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3825,7 +3825,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-before-15_8-or-16_4-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-before-15_8-or-16_4-vu-verify.out index 5b3a56aec6..1e5633c018 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-before-15_8-or-16_4-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-before-15_8-or-16_4-vu-verify.out @@ -2139,7 +2139,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -尔·比 DEF +ABCDEF ~~END~~ @@ -2148,7 +2148,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -ABCD +䉁䑃 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-vu-verify.out index 033468b944..c72095b5aa 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/replace-vu-verify.out @@ -2160,7 +2160,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -尔·比 DEF +ABCDEF ~~END~~ @@ -2169,7 +2169,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -ABCD +䉁䑃 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-14_5-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-14_5-vu-verify.out index 5df21fe767..c3aadc60e6 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-14_5-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-14_5-vu-verify.out @@ -1134,10 +1134,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1146,10 +1146,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1158,10 +1158,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1170,10 +1170,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_5-or-14_10-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_5-or-14_10-vu-verify.out index 1b7dc79983..3233926163 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_5-or-14_10-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_5-or-14_10-vu-verify.out @@ -1134,10 +1134,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1146,10 +1146,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1158,10 +1158,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1170,10 +1170,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_9-or-16_5-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_9-or-16_5-vu-verify.out index 2ac523fa7e..cdccc09af5 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_9-or-16_5-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-before-15_9-or-16_5-vu-verify.out @@ -1135,10 +1135,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1147,10 +1147,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1159,10 +1159,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1171,10 +1171,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-vu-verify.out index 23eed0b1c4..a24c0a69cd 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/string_agg-vu-verify.out @@ -1234,10 +1234,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1246,10 +1246,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1258,10 +1258,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1270,10 +1270,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-before-15_8-or-16_4-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-before-15_8-or-16_4-vu-verify.out index 2fd71f6db8..4799695210 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-before-15_8-or-16_4-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-before-15_8-or-16_4-vu-verify.out @@ -978,7 +978,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -987,7 +987,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1072,7 +1072,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1081,7 +1081,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1166,7 +1166,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1175,7 +1175,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1272,7 +1272,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1281,7 +1281,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1366,7 +1366,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1375,7 +1375,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1460,7 +1460,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1469,7 +1469,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-vu-verify.out index f54d532fb3..db483ffc01 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/stuff-vu-verify.out @@ -978,7 +978,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -987,7 +987,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1072,7 +1072,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1081,7 +1081,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1166,7 +1166,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1175,7 +1175,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1272,7 +1272,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1281,7 +1281,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1366,7 +1366,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1375,7 +1375,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1460,7 +1460,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1469,7 +1469,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/cast_nvarchar_test-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/cast_nvarchar_test-vu-verify.out new file mode 100644 index 0000000000..d7d02060a5 --- /dev/null +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/cast_nvarchar_test-vu-verify.out @@ -0,0 +1,384 @@ +-- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +insert into TestHash values('value1', 'value1'); +GO +~~ROW COUNT: 1~~ + + +SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength + , LEN( nvarchar_data) AS nvarchar_data_len + , DATALENGTH( varchar_data) as varchar_data_btyes_datalength + , LEN( varchar_data) AS varchar_data_len + , * +from TestHash; +GO +~~START~~ +int#!#int#!#int#!#int#!#nvarchar#!#varchar#!#varbinary#!#varbinary#!#varbinary#!#varbinary +6#!#6#!#6#!#6#!#value1#!#value1#!#BFF418C872BAFEE476F578F93BAD732F499B4193#!#BFF418C872BAFEE476F578F93BAD732F499B4193#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB +~~END~~ + +-- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#B4AA115AEBADD046850F18E1DF71A8BF254CD688 +~~END~~ + + +SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +6F8DB599DE986FAB7A21625B7916589C#!#8EF34B0E4B64320AA590A0DDD043D0A8 +~~END~~ + + +SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B#!#BDB5A12B473383674D31C9068D13896278CA7979CF99CDD592C64B3994FCB5CE +~~END~~ + + +SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC#!#7740DCE2348B37BDBD313DC4577E5FA91687EB35EE3B39A4BDA39B70EA20C5FE7865289F1612946E7CD89458CE42C8AC5577FB716975FAD0F9C53F3A28B10885 +~~END~~ + + +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#B4AA115AEBADD046850F18E1DF71A8BF254CD688 +~~END~~ + + +SELECT hashbytes( 'sha1', 'test string') +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +--TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +GO +~~START~~ +varbinary +B4AA115AEBADD046850F18E1DF71A8BF254CD688 +~~END~~ + + + +--TEST CASE 4: Casting function for nvarchar to varbinary +SELECT cast(N'test string' as varbinary); +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO +~~START~~ +nvarchar +a +~~END~~ + + +-- Test Case 5: Empty strings and NULL values +SELECT HASHBYTES('SHA1', '') AS empty_varchar, + HASHBYTES('SHA1', N'') AS empty_nvarchar, + HASHBYTES('SHA1', NULL) AS null_input; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!#DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!# +~~END~~ + + +-- Test Case 6: Unicode characters +SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, + HASHBYTES('SHA1', N'Здравствуйте') AS russian, + HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +468B7C156768A579085BBBD1630D2ED215D3A86C#!#EBFDE11B499DEA0130EE3DFCDC632ADEA0AD71F2#!#4D4A69489A61649C1330FB5B600191E00B76B6A0 +~~END~~ + + +-- Test Case 8: Different collations +SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, + HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +GO +~~START~~ +varbinary#!#varbinary +B6D795FBD58CC7592D955A219374339A323801A9#!#B6D795FBD58CC7592D955A219374339A323801A9 +~~END~~ + + +-- Test Case 9: Combining varchar and nvarchar +SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +GO +~~START~~ +varbinary +D981D4B037201043FFDCBD310FCDE36F44D9AAC5 +~~END~~ + + +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO +~~START~~ +nvarchar#!#varchar +test#!#test +~~END~~ + + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +680065006C006C006F00#!#68656C6C6F#!#68656C6C6F#!#68656C6C6F +~~END~~ + + +-- Test Case 12: Testing with special characters +SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, + HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, + HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, + HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#1F725EE9D69965F6F755140E66089A041B5AACC2#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F#!#C97EDD9DE05497798CBA896371C594DF87043753 +~~END~~ + + +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "SJIS": 0x00)~~ + + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO +~~START~~ +varchar +Test String +~~END~~ + + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.)~~ + + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +~~START~~ +binary +7400650073007400200073007400720069006E0067000000000000000000 +~~END~~ + +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 19: User defined hashbytes function +create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +GO +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#B4AA115AEBADD046850F18E1DF71A8BF254CD688 +~~END~~ + +select hashbytes('abc') +GO +~~START~~ +varchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "dummy hashbytes" does not exist)~~ + +drop function dbo.hashbytes +GO + + +-- Test 20: Calling the function, procedure, views from prepare scripts +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO +~~START~~ +nvarchar +Test String +~~END~~ + + + +-- Test CastVarbinaryToNVarchar function +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +敔瑳瑓楲杮 +~~END~~ + + + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX) +); +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go +~~ROW COUNT: 1~~ + + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO +~~START~~ +nvarchar +Hello, World! +~~END~~ + + + + +--TEST CASE 22: Calling hashbytes via function, procedure, views +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII +SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#E6FA3CA87B1B641AB646D3B4933BBA8D0970763F030B6578A60ABDEAE7366247#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25 +~~END~~ + +-- Test the HashDemoView +SELECT * FROM dbo.HashDemoView; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#A07E4F7343246C82B26F32E56F85418D518D8B2F2DAE77F1D56FE7AF50DB97AF#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969 +~~END~~ + + +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + +--TEST CASE 24: NVARCHAR TO BINARY with maxlen < length of actual string +select cast(0x610061006100610061006100610061006100 as nvarchar(5)) +GO +~~START~~ +nvarchar +aaaaa +~~END~~ + +select cast(0x8765 as nvarchar(1)) +GO +~~START~~ +nvarchar +文 +~~END~~ + + + + diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/cast_nvarchar_test_before_16_5-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/cast_nvarchar_test_before_16_5-vu-verify.out new file mode 100644 index 0000000000..0290e11330 --- /dev/null +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/cast_nvarchar_test_before_16_5-vu-verify.out @@ -0,0 +1,368 @@ +-- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +insert into TestHash values('value1', 'value1'); +GO +~~ROW COUNT: 1~~ + + +SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength + , LEN( nvarchar_data) AS nvarchar_data_len + , DATALENGTH( varchar_data) as varchar_data_btyes_datalength + , LEN( varchar_data) AS varchar_data_len + , * +from TestHash; +GO +~~START~~ +int#!#int#!#int#!#int#!#nvarchar#!#varchar#!#varbinary#!#varbinary#!#varbinary#!#varbinary +6#!#6#!#6#!#6#!#value1#!#value1#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB#!#8107759ABABCBFA34BCB02BC4309CAF6354982AB +~~END~~ + +-- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + +SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +#!# +~~END~~ + + +SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +6F8DB599DE986FAB7A21625B7916589C#!#6F8DB599DE986FAB7A21625B7916589C +~~END~~ + + +SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B#!#D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B +~~END~~ + + +SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC#!#10E6D647AF44624442F388C2C14A787FF8B17E6165B83D767EC047768D8CBCB71A1A3226E7CC7816BC79C0427D94A9DA688C41A3992C7BF5E4D7CC3E0BE5DBAC +~~END~~ + + +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + +SELECT hashbytes( 'sha1', 'test string') +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +--TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +GO +~~START~~ +varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + + + +--TEST CASE 4: Casting function for nvarchar to varbinary +SELECT cast(N'test string' as varbinary); +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO +~~START~~ +nvarchar +a +~~END~~ + + +-- Test Case 5: Empty strings and NULL values +SELECT HASHBYTES('SHA1', '') AS empty_varchar, + HASHBYTES('SHA1', N'') AS empty_nvarchar, + HASHBYTES('SHA1', NULL) AS null_input; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!#DA39A3EE5E6B4B0D3255BFEF95601890AFD80709#!# +~~END~~ + + +-- Test Case 6: Unicode characters +SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, + HASHBYTES('SHA1', N'Здравствуйте') AS russian, + HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +20427A708C3F6F07CF12AB23557982D9E6D23B61#!#E2D105A2541F2DC6C8B93DF73D07DF30B33FD80A#!#3B114970B215D62CB987A4D5644FEE7001C78234 +~~END~~ + + +-- Test Case 8: Different collations +SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, + HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +GO +~~START~~ +varbinary#!#varbinary +AAF4C61DDCC5E8A2DABEDE0F3B482CD9AEA9434D#!#AAF4C61DDCC5E8A2DABEDE0F3B482CD9AEA9434D +~~END~~ + + +-- Test Case 9: Combining varchar and nvarchar +SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +GO +~~START~~ +varbinary +6ADFB183A4A2C94A2F92DAB5ADE762A47889A5A1 +~~END~~ + + +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO +~~START~~ +nvarchar#!#varchar +test#!#test +~~END~~ + + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +680065006C006C006F00#!#68656C6C6F#!#68656C6C6F#!#68656C6C6F +~~END~~ + + +-- Test Case 12: Testing with special characters +SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, + HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, + HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, + HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary#!#varbinary +0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#0A0A9F2A6772942557AB5355D76AF442F8F65E01#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F#!#62E451F6ED58D1FF234A05B8467C0CEB1D4B285F +~~END~~ + + +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Failed to convert from data type varbinary to varchar, invalid byte sequence for encoding "SJIS": 0x00)~~ + + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO +~~START~~ +varchar +Test String +~~END~~ + + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.)~~ + + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +~~START~~ +binary +7400650073007400200073007400720069006E0067000000000000000000 +~~END~~ + +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +~~START~~ +varbinary +7400650073007400200073007400720069006E006700 +~~END~~ + +-- Test Case 19: User defined hashbytes function +create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +GO +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +~~START~~ +varbinary#!#varbinary +661295C9CBF9D6B2F6428414504A8DEED3020641#!#661295C9CBF9D6B2F6428414504A8DEED3020641 +~~END~~ + +select hashbytes('abc') +GO +~~START~~ +varchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "dummy hashbytes" does not exist)~~ + +drop function dbo.hashbytes +GO + + +-- Test 20: Calling the function, procedure, views from prepare scripts +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO +~~START~~ +nvarchar +Test String +~~END~~ + + + +-- Test CastVarbinaryToNVarchar function +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO +~~START~~ +nvarchar +敔瑳瑓楲杮 +~~END~~ + + + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX) +); +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go +~~ROW COUNT: 1~~ + + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO +~~START~~ +nvarchar +Hello, World! +~~END~~ + + + + +--TEST CASE 22: Calling hashbytes via function, procedure, views +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII +SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25#!#532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25 +~~END~~ + +-- Test the HashDemoView +SELECT * FROM dbo.HashDemoView; +GO +~~START~~ +varbinary#!#varbinary#!#varbinary +185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969#!#185F8DB32271FE25F561A6FC938B2E264306EC304EDA518007D1764826381969 +~~END~~ + + +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +~~START~~ +nvarchar +test string +~~END~~ + + + diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat-vu-verify.out index 87ceca8ef8..860126ede7 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat-vu-verify.out @@ -432,7 +432,7 @@ SELECT CONCAT( 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' AS cha GO ~~START~~ nvarchar -ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLMefOPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcdefg +ab🙂🙂def比尔hijklmnopqrstuvwxyzABCDEFGHIJKLM晥OPQRST🙂🙂VWXYZ0123456789.,-_!@#$%^&*()[]{}<>/\\|:;"\?+=~`abcde杦 ~~END~~ @@ -1463,16 +1463,16 @@ SELECT CONCAT(col_nvarchar, col_binary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1480,16 +1480,16 @@ SELECT CONCAT(col_nvarchar, col_varbinary) from babel_3409_concat_t1 ORDER BY id GO ~~START~~ nvarchar -abcab -🙂defghicd -🙂🙂ef -比尔·拉gh -莫斯ip +abc扡 +🙂defghi摣 +🙂🙂晥 +比尔·拉桧 +莫斯灩 -Anikaitqr +Anikait牱 -Agrawalrs +Agrawal獲 ~~END~~ @@ -1852,16 +1852,16 @@ EXEC babel_3409_concat_dep_proc2 GO ~~START~~ nvarchar -abc12.002000-12-12 12:43:102000-12-12 12:43:10ab2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 -🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10cd2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 -🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10ef2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 -比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10gh2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 -莫斯16.002000-12-16 12:43:102000-12-16 12:43:10ip2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 +abc12.002000-12-12 12:43:102000-12-12 12:43:10扡2000-12-1212:43:102000-12-12 12:43:10.1234 +10:00 +🙂defghi13.002000-12-13 12:43:102000-12-13 12:43:10摣2000-12-1312:43:102000-12-13 12:43:10.1234 +10:00 +🙂🙂14.002000-12-14 12:43:102000-12-14 12:43:10晥2000-12-1412:43:102000-12-14 12:43:10.1234 +10:00 +比尔·拉15.002000-12-15 12:43:102000-12-15 12:43:10桧2000-12-1512:43:102000-12-15 12:43:10.1234 +10:00 +莫斯16.002000-12-16 12:43:102000-12-16 12:43:10灩2000-12-1612:43:102000-12-16 12:43:10.1234 +10:00 -Anikait17.002000-12-17 12:43:102000-12-17 12:43:10qr2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 +Anikait17.002000-12-17 12:43:102000-12-17 12:43:10牱2000-12-1712:43:102000-12-17 12:43:10.1234 +10:00 -Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10rs2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 +Agrawal18.002000-12-18 12:43:102000-12-18 12:43:10獲2000-12-1812:43:102000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -1869,7 +1869,7 @@ SELECT babel_3409_concat_dep_func2() GO ~~START~~ nvarchar -abcababcabc +abc扡abcabc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat_ws-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat_ws-vu-verify.out index 062f626766..05b84c3b0a 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat_ws-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/concat_ws-vu-verify.out @@ -804,7 +804,7 @@ SELECT CONCAT_WS('-', 'a', 'b', CAST('🙂🙂' AS nvarchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -812,7 +812,7 @@ SELECT CONCAT_WS(N'-', 'a', 'b', CAST('🙂🙂' AS varchar), 'd', 'e', CAST('f' GO ~~START~~ nvarchar -a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-ef-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-fg +a-b-🙂🙂-d-e-f-比尔-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-A-B-C-D-E-F-G-H-I-J-K-L-M-晥-O-P-Q-R-S-T-🙂🙂-V-W-X-Y-Z-0-1-2-3-4-5-6-7-8-9-.-,---_-!-@-#-$-%-^-&-*-(-)-[-]-{-}-<->-/-\\-|-:-;-"-\-?-+-=-~-`-a-b-c-d-杦 ~~END~~ @@ -1544,16 +1544,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -1578,16 +1578,16 @@ SELECT CONCAT_WS(col_nvarchar, col_varchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2683,16 +2683,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_binary) from babel_3409_concat_w GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2700,16 +2700,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_binary) from babel_3409_concat_ GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2717,16 +2717,16 @@ SELECT CONCAT_WS(col_varchar, col_nvarchar, col_varbinary) from babel_3409_conca GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -2734,16 +2734,16 @@ SELECT CONCAT_WS(col_nvarchar, col_nvarchar, col_varbinary) from babel_3409_conc GO ~~START~~ nvarchar -abcabcab -🙂defghi🙂defghicd -🙂🙂🙂🙂ef -比尔·拉比尔·拉gh -莫斯莫斯ip +abcabc扡 +🙂defghi🙂defghi摣 +🙂🙂🙂🙂晥 +比尔·拉比尔·拉桧 +莫斯莫斯灩 -AnikaitAnikaitqr +AnikaitAnikait牱 -AgrawalAgrawalrs +AgrawalAgrawal獲 ~~END~~ @@ -3808,16 +3808,16 @@ EXEC babel_3409_concat_ws_dep_proc2 GO ~~START~~ nvarchar -abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-ab-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 -🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-cd-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 -🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-ef-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 -比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-gh-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 -莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-ip-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 +abc-12.00-2000-12-12 12:43:10-2000-12-12 12:43:10-扡-2000-12-12-12:43:10-2000-12-12 12:43:10.1234 +10:00 +🙂defghi-13.00-2000-12-13 12:43:10-2000-12-13 12:43:10-摣-2000-12-13-12:43:10-2000-12-13 12:43:10.1234 +10:00 +🙂🙂-14.00-2000-12-14 12:43:10-2000-12-14 12:43:10-晥-2000-12-14-12:43:10-2000-12-14 12:43:10.1234 +10:00 +比尔·拉-15.00-2000-12-15 12:43:10-2000-12-15 12:43:10-桧-2000-12-15-12:43:10-2000-12-15 12:43:10.1234 +10:00 +莫斯-16.00-2000-12-16 12:43:10-2000-12-16 12:43:10-灩-2000-12-16-12:43:10-2000-12-16 12:43:10.1234 +10:00 -Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-qr-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 +Anikait-17.00-2000-12-17 12:43:10-2000-12-17 12:43:10-牱-2000-12-17-12:43:10-2000-12-17 12:43:10.1234 +10:00 -Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-rs-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 +Agrawal-18.00-2000-12-18 12:43:10-2000-12-18 12:43:10-獲-2000-12-18-12:43:10-2000-12-18 12:43:10.1234 +10:00 ~~END~~ @@ -3825,7 +3825,7 @@ SELECT babel_3409_concat_ws_dep_func2() GO ~~START~~ nvarchar -abc-ab-abc-abc +abc-扡-abc-abc ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/replace-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/replace-vu-verify.out index 928f210898..db34a40a7d 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/replace-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/replace-vu-verify.out @@ -2160,7 +2160,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -??比 DEF +ABCDEF ~~END~~ @@ -2169,7 +2169,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -ABCD +䉁䑃 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/string_agg-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/string_agg-vu-verify.out index 8b1cc848d1..ac039674a4 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/string_agg-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/string_agg-vu-verify.out @@ -1234,10 +1234,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1246,10 +1246,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1258,10 +1258,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1270,10 +1270,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/stuff-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/stuff-vu-verify.out index e7535ac31b..824f17a75f 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/stuff-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/stuff-vu-verify.out @@ -978,7 +978,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -987,7 +987,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1072,7 +1072,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比??ef斯 +比??晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1081,7 +1081,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比??ef斯 +比??晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1166,7 +1166,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比??ef斯 +比??晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1175,7 +1175,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比??ef斯 +比??晥斯 ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1272,7 +1272,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1281,7 +1281,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1366,7 +1366,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1375,7 +1375,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1460,7 +1460,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1469,7 +1469,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' diff --git a/test/JDBC/expected/replace-before-15_8-or-16_4-vu-verify.out b/test/JDBC/expected/replace-before-15_8-or-16_4-vu-verify.out index 105150590e..d8d64c6770 100644 --- a/test/JDBC/expected/replace-before-15_8-or-16_4-vu-verify.out +++ b/test/JDBC/expected/replace-before-15_8-or-16_4-vu-verify.out @@ -2139,7 +2139,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -?·? DEF +ABCDEF ~~END~~ @@ -2148,7 +2148,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -ABCD +䉁䑃 ~~END~~ diff --git a/test/JDBC/expected/replace-vu-verify.out b/test/JDBC/expected/replace-vu-verify.out index 5e6d58257f..72952d0ef7 100644 --- a/test/JDBC/expected/replace-vu-verify.out +++ b/test/JDBC/expected/replace-vu-verify.out @@ -2160,7 +2160,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -?·? DEF +ABCDEF ~~END~~ @@ -2169,7 +2169,7 @@ SELECT replace(@inputString, @pattern, @replacement) GO ~~START~~ nvarchar -ABCD +䉁䑃 ~~END~~ diff --git a/test/JDBC/expected/string_agg-before-14_5-vu-verify.out b/test/JDBC/expected/string_agg-before-14_5-vu-verify.out index 9adbaab5b5..041d01659a 100644 --- a/test/JDBC/expected/string_agg-before-14_5-vu-verify.out +++ b/test/JDBC/expected/string_agg-before-14_5-vu-verify.out @@ -1135,10 +1135,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1147,10 +1147,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1159,10 +1159,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1171,10 +1171,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/string_agg-before-15_5-or-14_10-vu-verify.out b/test/JDBC/expected/string_agg-before-15_5-or-14_10-vu-verify.out index f6a7c2b343..b2c262947f 100644 --- a/test/JDBC/expected/string_agg-before-15_5-or-14_10-vu-verify.out +++ b/test/JDBC/expected/string_agg-before-15_5-or-14_10-vu-verify.out @@ -1135,10 +1135,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1147,10 +1147,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1159,10 +1159,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1171,10 +1171,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/string_agg-before-15_9-or-16_5-vu-verify.out b/test/JDBC/expected/string_agg-before-15_9-or-16_5-vu-verify.out index 0be19ef72e..4ed448001b 100644 --- a/test/JDBC/expected/string_agg-before-15_9-or-16_5-vu-verify.out +++ b/test/JDBC/expected/string_agg-before-15_9-or-16_5-vu-verify.out @@ -1135,10 +1135,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1147,10 +1147,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1159,10 +1159,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1171,10 +1171,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/string_agg-vu-verify.out b/test/JDBC/expected/string_agg-vu-verify.out index 7f371f8cd3..7d5ab694cd 100644 --- a/test/JDBC/expected/string_agg-vu-verify.out +++ b/test/JDBC/expected/string_agg-vu-verify.out @@ -1234,10 +1234,10 @@ SELECT STRING_AGG(col_binary, '-') FROM babel_5156_string_agg_t1 GROUP BY group_ GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1246,10 +1246,10 @@ SELECT STRING_AGG(col_binary, @sep) FROM babel_5156_string_agg_t1 GROUP BY group GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1258,10 +1258,10 @@ SELECT STRING_AGG(col_varbinary, '-') FROM babel_5156_string_agg_t1 GROUP BY gro GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ @@ -1270,10 +1270,10 @@ SELECT STRING_AGG(col_varbinary, @sep) FROM babel_5156_string_agg_t1 GROUP BY gr GO ~~START~~ nvarchar -ab-cd-ef -gh-ip +扡-摣-晥 +桧-灩 -qr-rs +牱-獲 ~~END~~ diff --git a/test/JDBC/expected/stuff-before-15_8-or-16_4-vu-verify.out b/test/JDBC/expected/stuff-before-15_8-or-16_4-vu-verify.out index db5f383b45..a8da981fbb 100644 --- a/test/JDBC/expected/stuff-before-15_8-or-16_4-vu-verify.out +++ b/test/JDBC/expected/stuff-before-15_8-or-16_4-vu-verify.out @@ -978,7 +978,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -987,7 +987,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1072,7 +1072,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1081,7 +1081,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1166,7 +1166,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1175,7 +1175,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1272,7 +1272,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1281,7 +1281,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1366,7 +1366,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1375,7 +1375,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1460,7 +1460,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1469,7 +1469,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' diff --git a/test/JDBC/expected/stuff-vu-verify.out b/test/JDBC/expected/stuff-vu-verify.out index 28a83e56f4..19d3a3a772 100644 --- a/test/JDBC/expected/stuff-vu-verify.out +++ b/test/JDBC/expected/stuff-vu-verify.out @@ -978,7 +978,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -987,7 +987,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi?? +abc晥efghi?? ~~END~~ DECLARE @inputString NCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1072,7 +1072,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1081,7 +1081,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1166,7 +1166,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1175,7 +1175,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -??·ef? +??·晥? ~~END~~ DECLARE @inputString NCHAR(25) = N'比尔·拉莫斯' @@ -1272,7 +1272,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1281,7 +1281,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -abcefefghi🙂🙂 +abc晥efghi🙂🙂 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'abc🙂defghi🙂🙂' @@ -1366,7 +1366,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1375,7 +1375,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1460,7 +1460,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' @@ -1469,7 +1469,7 @@ SELECT stuff(@inputString, 4, 2, @replaceString) COLLATE CHINESE_PRC_CI_AS GO ~~START~~ nvarchar -比尔·ef斯 +比尔·晥斯 ~~END~~ DECLARE @inputString NVARCHAR(25) = N'比尔·拉莫斯' diff --git a/test/JDBC/input/cast_nvarchar_test-vu-cleanup.sql b/test/JDBC/input/cast_nvarchar_test-vu-cleanup.sql new file mode 100644 index 0000000000..dd1d5e875b --- /dev/null +++ b/test/JDBC/input/cast_nvarchar_test-vu-cleanup.sql @@ -0,0 +1,27 @@ +-- to do in hashbytes PR +-- DROP TABLE IF EXISTS TestHash; +-- GO +DROP type user_defined_varbinary; +GO +DROP type user_defined_nvarchar; +GO +DROP VIEW IF EXISTS dbo.CastDemoView; +GO +DROP VIEW IF EXISTS dbo.CastDemoView1; +GO +DROP FUNCTION IF EXISTS dbo.CastNVarcharToVarbinary; +GO +DROP FUNCTION IF EXISTS dbo.CastVarbinaryToNVarchar; +GO +DROP FUNCTION IF EXISTS dbo.CastbinaryToNVarchar; +GO +DROP TABLE IF EXISTS casttable; +GO +-- to do in hashbytes PR +-- DROP FUNCTION IF EXISTS dbo.HashMultipleTypes; +-- GO +-- DROP PROCEDURE IF EXISTS dbo.PrintHashResults; +-- GO +-- DROP VIEW IF EXISTS dbo.HashDemoView; +-- GO + diff --git a/test/JDBC/input/cast_nvarchar_test-vu-prepare.sql b/test/JDBC/input/cast_nvarchar_test-vu-prepare.sql new file mode 100644 index 0000000000..d031ff2a8e --- /dev/null +++ b/test/JDBC/input/cast_nvarchar_test-vu-prepare.sql @@ -0,0 +1,100 @@ +-- to do in hashbytes PR +-- CREATE TABLE TestHash( +-- nvarchar_data nvarchar(32) NOT NULL, +-- varchar_data varchar(32) NOT NULL, +-- cast_hashbytes_nvarchar_data AS (cast ( hashbytes('sha1', nvarchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +-- convert_hashbytes_nvarchar_data AS (convert( varbinary(20), hashbytes('sha1',nvarchar_data))) PERSISTED NOT NULL, +-- cast_hashbytes_varchar_data AS (cast ( hashbytes('sha1', varchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +-- convert_hashbytes_varchar_data AS (convert( varbinary(20), hashbytes('sha1',varchar_data))) PERSISTED NOT NULL +-- ); +-- GO + +-- Function to cast NVARCHAR to VARBINARY +CREATE FUNCTION dbo.CastNVarcharToVarbinary +( + @Input NVARCHAR(MAX) +) +RETURNS VARBINARY(MAX) +AS +BEGIN + RETURN CAST(@Input AS VARBINARY(MAX)); +END +GO + +-- Function to cast VARBINARY to NVARCHAR +CREATE FUNCTION dbo.CastVarbinaryToNVarchar +( + @Input VARBINARY(MAX) +) +RETURNS NVARCHAR(MAX) +AS +BEGIN + RETURN CAST(@Input AS NVARCHAR(MAX)); +END +GO + +-- Function to cast BINARY to NVARCHAR +CREATE FUNCTION dbo.CastbinaryToNVarchar +( + @Input BINARY +) +RETURNS NVARCHAR(MAX) +AS +BEGIN + RETURN CAST(@Input AS NVARCHAR(MAX)); +END +GO + +-- View that demonstrates both casts +CREATE VIEW dbo.CastDemoView +AS +SELECT + dbo.CastNVarcharToVarbinary(N'Hello, World!') AS NVarcharToVarbinary, + dbo.CastVarbinaryToNVarchar(0x48656C6C6F2C20576F726C6421) AS VarbinaryToNVarchar, + dbo.CastbinaryToNVarchar(0x48656C6C6F2C20576F726C6421) AS binaryToNVarchar +GO + +create table casttable(nvarchar_data nvarchar(max), varbinary_data varbinary(max), binary_data binary(15), nvarchar_binary_data nvarchar(max)); +GO +insert into casttable(nvarchar_data, varbinary_data, binary_data, nvarchar_binary_data) values (N'test string', 0x48656C6C6F2C20576F726C6421, 0x48656C6C6F2C20576F726C6421, N'test string') +GO + +CREATE VIEW dbo.CastDemoView1 +AS +SELECT + CAST(nvarchar_data AS VARBINARY(MAX)), + CAST(varbinary_data AS NVARCHAR(MAX)), + CAST(binary_data AS NVARCHAR(MAX)), + CAST(nvarchar_binary_data AS BINARY(15)) +FROM casttable +GO + +-- to do in hashbytes PR +-- -- Function hashbytes different input types +-- CREATE FUNCTION dbo.HashMultipleTypes +-- ( +-- @VarcharInput VARCHAR(MAX), +-- @NVarcharInput NVARCHAR(MAX), +-- @VarbinaryInput VARBINARY(MAX) +-- ) +-- RETURNS TABLE +-- AS +-- RETURN +-- ( +-- SELECT +-- HASHBYTES('SHA2_256', @VarcharInput) AS VarcharHash, +-- HASHBYTES('SHA2_256', @NVarcharInput) AS NVarcharHash, +-- HASHBYTES('SHA2_256', @VarbinaryInput) AS VarbinaryHash +-- ) +-- GO + + +-- -- View to demonstrate hashing +-- CREATE VIEW dbo.HashDemoView +-- AS +-- SELECT +-- HASHBYTES('SHA2_256', CAST('Hello' AS VARCHAR(MAX))) AS VarcharHash, +-- HASHBYTES('SHA2_256', CAST(N'Hello' AS NVARCHAR(MAX))) AS NVarcharHash, +-- HASHBYTES('SHA2_256', CAST(0x48656C6C6F AS VARBINARY(MAX))) AS VarbinaryHash +-- GO + diff --git a/test/JDBC/input/cast_nvarchar_test-vu-verify.sql b/test/JDBC/input/cast_nvarchar_test-vu-verify.sql new file mode 100644 index 0000000000..3157f20aa8 --- /dev/null +++ b/test/JDBC/input/cast_nvarchar_test-vu-verify.sql @@ -0,0 +1,228 @@ +-- to do in hashbytes pr +-- -- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +-- insert into TestHash values('value1', 'value1'); +-- GO + +-- SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength +-- , LEN( nvarchar_data) AS nvarchar_data_len +-- , DATALENGTH( varchar_data) as varchar_data_btyes_datalength +-- , LEN( varchar_data) AS varchar_data_len +-- , * +-- from TestHash; +-- GO +-- -- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +-- SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +-- GO + +-- SELECT hashbytes( 'sha1', 'test string') +-- GO +-- --TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +-- SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +-- GO + +--TEST CASE 4: Casting function for nvarchar to varbinary + +SELECT cast(N'test string' as varbinary); +GO + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO + +-- to do in hashbytes PR +-- -- Test Case 5: Empty strings and NULL values +-- SELECT HASHBYTES('SHA1', '') AS empty_varchar, +-- HASHBYTES('SHA1', N'') AS empty_nvarchar, +-- HASHBYTES('SHA1', NULL) AS null_input; +-- GO + +-- -- Test Case 6: Unicode characters +-- SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, +-- HASHBYTES('SHA1', N'Здравствуйте') AS russian, +-- HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +-- GO + +-- -- Test Case 8: Different collations +-- SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, +-- HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +-- GO + +-- -- Test Case 9: Combining varchar and nvarchar +-- SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +-- GO + +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO + +-- to do in hashbytes PR +-- -- Test Case 12: Testing with special characters +-- SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, +-- HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, +-- HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, +-- HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +-- GO + +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO + +-- to do in hashbytes PR +-- -- Test Case 19: User defined hashbytes function +-- create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +-- GO +-- SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +-- GO +-- select hashbytes('abc') +-- GO +-- drop function dbo.hashbytes +-- GO + +-- Test 20: Calling the function, procedure, views from prepare scripts + +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO + +-- Test CastVarbinaryToNVarchar function + +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO + +-- Test CastbinaryToNVarchar function + +DECLARE @TestBinary BINARY = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX), + binaryToNVarchar NVARCHAR(MAX) +); + +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go + +SELECT * FROM dbo.CastDemoView1; +GO +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO + +--TEST CASE 22: Calling hashbytes via function, procedure, views + +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII + +-- to do in hashbytes PR +-- SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +-- GO +-- -- Test the HashDemoView +-- SELECT * FROM dbo.HashDemoView; +-- GO + +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO +--TEST CASE 24: NVARCHAR TO BINARY with maxlen < length of actual string +select cast(0x610061006100610061006100610061006100 as nvarchar(5)) +GO +select cast(0x8765 as nvarchar(1)) +GO + +--TEST CASE 25: Default typmod case with string getting truncated + +select cast(N'Lorem ipsum dolor sit amet' as varbinary) +GO +select cast(0x4C006F00720065006D00200069007000730075006D00200064006F006C00 as nvarchar) +GO +--TEST CASE 26: String getting truncted with defined typmod i.e len > maxlen +select cast(N'tesst string' as varbinary(4)) +GO +select cast(0x74006500 as nvarchar) +GO + +select cast(N'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea' as varbinary(MAX)) +GO + +select cast(0x0006161 as nvarchar) +GO diff --git a/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-cleanup.sql b/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-cleanup.sql new file mode 100644 index 0000000000..b84f229da8 --- /dev/null +++ b/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-cleanup.sql @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS TestHash; +GO +DROP type user_defined_varbinary; +GO +DROP type user_defined_nvarchar; +GO +DROP VIEW IF EXISTS dbo.CastDemoView; +GO +DROP FUNCTION IF EXISTS dbo.CastNVarcharToVarbinary; +GO +DROP FUNCTION IF EXISTS dbo.CastVarbinaryToNVarchar; +GO +DROP FUNCTION IF EXISTS dbo.HashMultipleTypes; +GO +DROP PROCEDURE IF EXISTS dbo.PrintHashResults; +GO +DROP VIEW IF EXISTS dbo.HashDemoView; +GO + diff --git a/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-prepare.sql b/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-prepare.sql new file mode 100644 index 0000000000..0c2e397cf2 --- /dev/null +++ b/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-prepare.sql @@ -0,0 +1,71 @@ +CREATE TABLE TestHash( +nvarchar_data nvarchar(32) NOT NULL, +varchar_data varchar(32) NOT NULL, +cast_hashbytes_nvarchar_data AS (cast ( hashbytes('sha1', nvarchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +convert_hashbytes_nvarchar_data AS (convert( varbinary(20), hashbytes('sha1',nvarchar_data))) PERSISTED NOT NULL, +cast_hashbytes_varchar_data AS (cast ( hashbytes('sha1', varchar_data) AS varbinary(20) )) PERSISTED NOT NULL, +convert_hashbytes_varchar_data AS (convert( varbinary(20), hashbytes('sha1',varchar_data))) PERSISTED NOT NULL +); +GO + +-- Function to cast NVARCHAR to VARBINARY +CREATE FUNCTION dbo.CastNVarcharToVarbinary +( + @Input NVARCHAR(MAX) +) +RETURNS VARBINARY(MAX) +AS +BEGIN + RETURN CAST(@Input AS VARBINARY(MAX)); +END +GO + +-- Function to cast VARBINARY to NVARCHAR +CREATE FUNCTION dbo.CastVarbinaryToNVarchar +( + @Input VARBINARY(MAX) +) +RETURNS NVARCHAR(MAX) +AS +BEGIN + RETURN CAST(@Input AS NVARCHAR(MAX)); +END +GO + +-- View that demonstrates both casts +CREATE VIEW dbo.CastDemoView +AS +SELECT + dbo.CastNVarcharToVarbinary(N'Hello, World!') AS NVarcharToVarbinary, + dbo.CastVarbinaryToNVarchar(0x48656C6C6F2C20576F726C6421) AS VarbinaryToNVarchar +GO + + +-- Function to hash different input types +CREATE FUNCTION dbo.HashMultipleTypes +( + @VarcharInput VARCHAR(MAX), + @NVarcharInput NVARCHAR(MAX), + @VarbinaryInput VARBINARY(MAX) +) +RETURNS TABLE +AS +RETURN +( + SELECT + HASHBYTES('SHA2_256', @VarcharInput) AS VarcharHash, + HASHBYTES('SHA2_256', @NVarcharInput) AS NVarcharHash, + HASHBYTES('SHA2_256', @VarbinaryInput) AS VarbinaryHash +) +GO + + +-- View to demonstrate hashing +CREATE VIEW dbo.HashDemoView +AS +SELECT + HASHBYTES('SHA2_256', CAST('Hello' AS VARCHAR(MAX))) AS VarcharHash, + HASHBYTES('SHA2_256', CAST(N'Hello' AS NVARCHAR(MAX))) AS NVarcharHash, + HASHBYTES('SHA2_256', CAST(0x48656C6C6F AS VARBINARY(MAX))) AS VarbinaryHash +GO + diff --git a/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-verify.sql b/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-verify.sql new file mode 100644 index 0000000000..8090a06d1b --- /dev/null +++ b/test/JDBC/input/cast_nvarchar_test_before_16_5-vu-verify.sql @@ -0,0 +1,190 @@ +-- TEST CASE 1: creating a table and then calling hashbytes for nvarchar and varchar input +insert into TestHash values('value1', 'value1'); +GO + +SELECT DATALENGTH( nvarchar_data) as nvarchar_data_datalength + , LEN( nvarchar_data) AS nvarchar_data_len + , DATALENGTH( varchar_data) as varchar_data_btyes_datalength + , LEN( varchar_data) AS varchar_data_len + , * +from TestHash; +GO +-- TEST CASE 2: Casting nvarchar and varchar with different algorithms using Hashbytes +SELECT hashbytes( 'sha1', 'test string' ) as vary_string, hashbytes( 'sha1', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'MD2', 'test string' ) as vary_string, hashbytes( 'MD2', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'MD4', 'test string' ) as vary_string, hashbytes( 'MD4', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'MD5', 'test string' ) as vary_string, hashbytes( 'MD5', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'SHA2_256', 'test string' ) as vary_string, hashbytes( 'SHA2_256', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'SHA2_512', 'test string' ) as vary_string, hashbytes( 'SHA2_512', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO + +SELECT hashbytes( 'sha1', 'test string') +GO +--TEST CASE 3: testing hashbytes via casting a varchar to nvarchar +SELECT hashbytes('sha1',cast('test string' as sys.nvarchar)) +GO + +--TEST CASE 4: Casting function for nvarchar to varbinary + +SELECT cast(N'test string' as varbinary); +GO + +SELECT cast(cast(cast('ab' AS nvarchar(10)) as varbinary(2)) as nvarchar(2)); +GO + +-- Test Case 5: Empty strings and NULL values +SELECT HASHBYTES('SHA1', '') AS empty_varchar, + HASHBYTES('SHA1', N'') AS empty_nvarchar, + HASHBYTES('SHA1', NULL) AS null_input; +GO + +-- Test Case 6: Unicode characters +SELECT HASHBYTES('SHA1', N'こんにちは') AS japanese, + HASHBYTES('SHA1', N'Здравствуйте') AS russian, + HASHBYTES('SHA1', N'🙂😊😀') AS emojis; +GO + +-- Test Case 8: Different collations +SELECT HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CI_AS) AS ci_as, + HASHBYTES('SHA1', N'hello' COLLATE Latin1_General_CS_AS) AS cs_as; +GO + +-- Test Case 9: Combining varchar and nvarchar +SELECT HASHBYTES('SHA1', 'hello' + N'world') AS combined; +GO + +-- Test Case 10: Roundtrip conversions +SELECT CAST(CAST(N'test' AS VARBINARY(8)) AS NVARCHAR(4)) AS nvarchar_roundtrip, + CAST(CAST('test' AS VARBINARY(8)) AS VARCHAR(4)) AS varchar_roundtrip; +GO + +-- Test Case 11: CAST and CONVERT between varchar, nvarchar, and varbinary +SELECT CAST(N'hello' AS VARBINARY(10)) AS nvarchar_to_varbinary, + CAST('hello' AS VARBINARY(10)) AS varchar_to_varbinary, + CONVERT(VARBINARY(10), N'hello') AS nvarchar_to_varbinary_convert, + CONVERT(VARBINARY(10), 'hello') AS varchar_to_varbinary_convert; +GO + +-- Test Case 12: Testing with special characters +SELECT HASHBYTES('SHA1', 'Hello, World!') AS varchar_special, + HASHBYTES('SHA1', N'Hello, World!') AS nvarchar_special, + HASHBYTES('SHA1', 'Hello' + CHAR(13) + CHAR(10) + 'World') AS varchar_newline, + HASHBYTES('SHA1', N'Hello' + NCHAR(13) + NCHAR(10) + N'World') AS nvarchar_newline; +GO + +-- Test Case 13: NVARCHAR -> VARBINARY -> VARCHAR -> NVARCHAR -> VARBINARY +SELECT CAST( + CAST( + CAST( + CAST(N'Hello World' AS VARBINARY(100)) + AS VARCHAR(100)) + AS NVARCHAR(100)) +AS VARBINARY(100)) AS four_casts; +GO + +-- Test Case 14: VARCHAR -> NVARCHAR -> VARBINARY -> NVARCHAR -> VARCHAR +SELECT CAST( + CAST( + CAST( + CAST('Test String' AS NVARCHAR(50)) + AS VARBINARY(50)) + AS NVARCHAR(50)) +AS VARCHAR(50)) AS four_casts; +GO + +-- Test Case 15: Implicit conversion from data type nvarchar to varbinary is not allowed. +DECLARE @a varbinary(10); SET @a = CAST(N'21' AS nvarchar(10)); SELECT @a +GO + +-- Test Case 16: Casting with UDT on nvarchar -> varbinary, UDT on varbinary to nvarchar, UDT on nvarchar to UDT on varbinary +create type user_defined_nvarchar from nvarchar(50); +select cast(cast(N'test string' as user_defined_nvarchar) as varbinary) +GO + +create type user_defined_varbinary from varbinary(50); +select cast(cast(0x7400650073007400200073007400720069006E006700 as user_defined_varbinary) as nvarchar) +GO + +select cast(cast(N'test string' as user_defined_nvarchar) as user_defined_varbinary) +go +-- Test Case 17: NVARCHAR-> BINARY +select cast(N'test string' as binary) +GO +-- Test Case 18: NVARCHAR-> User Defined varbinary +select cast(N'test string' as user_defined_varbinary) +GO +-- Test Case 19: User defined hashbytes function +create function dbo.hashbytes(@data sys.varchar)returns sys.varchar AS BEGIN return "dummy hashbytes";END +GO +SELECT hashbytes( 'SHA', 'test string' ) as vary_string, hashbytes( 'SHA', N'test string' ) as unicode_string +GO +select hashbytes('abc') +GO +drop function dbo.hashbytes +GO + +-- Test 20: Calling the function, procedure, views from prepare scripts + +-- Test CastNVarcharToVarbinary function +DECLARE @TestString NVARCHAR(100) = N'Test String'; +DECLARE @BinaryResult VARBINARY(MAX); +SET @BinaryResult = dbo.CastNVarcharToVarbinary(@TestString); +select cast (@BinaryResult as nvarchar) +GO + +-- Test CastVarbinaryToNVarchar function + +DECLARE @TestBinary VARBINARY(100) = 0x54657374537472696E67; -- 'Test String' in ASCII +DECLARE @StringResult NVARCHAR(MAX); +SET @StringResult = dbo.CastVarbinaryToNVarchar(@TestBinary); +select cast (@StringResult as nvarchar) +GO + +-- Test CastDemoView +DECLARE @ViewResult TABLE ( + NVarcharToVarbinary VARBINARY(MAX), + VarbinaryToNVarchar NVARCHAR(MAX) +); + +INSERT INTO @ViewResult +SELECT * FROM dbo.CastDemoView; +go + +-- TEST CASE 21: Assigned Casting +DECLARE @NVarcharValue NVARCHAR(100) = N'Hello, World!'; +DECLARE @AssignedVarbinary VARBINARY(100); +SET @AssignedVarbinary = CAST(@NVarcharValue AS VARBINARY(100)); +select CAST(@AssignedVarbinary AS NVARCHAR(100)); +GO + +--TEST CASE 22: Calling hashbytes via function, procedure, views + +-- Test the HashMultipleTypes function +DECLARE @TestVarchar VARCHAR(10) = 'Test'; +DECLARE @TestNVarchar NVARCHAR(10) = N'Test'; +DECLARE @TestVarbinary VARBINARY(10) = 0x54657374; -- 'Test' in ASCII + +SELECT * FROM dbo.HashMultipleTypes(@TestVarchar, @TestNVarchar, @TestVarbinary); +GO +-- Test the HashDemoView +SELECT * FROM dbo.HashDemoView; +GO + +--TEST CASE 23: BINARY TO NVARCHAR +select cast(cast(N'test string' as binary) as nvarchar) +GO + + diff --git a/test/JDBC/input/db_owner-vu-verify.mix b/test/JDBC/input/db_owner-vu-verify.mix index 2177eaacde..4147484256 100644 --- a/test/JDBC/input/db_owner-vu-verify.mix +++ b/test/JDBC/input/db_owner-vu-verify.mix @@ -1125,3 +1125,35 @@ use master go drop database dbowner_averyveryveryveryveryveryveryveryveryveryverylongdatabasename go + +-- Check for windows login +exec sys.babelfish_add_domain_mapping_entry 'dbownerdomain', 'dbownerdomain.babel'; +go +create login [dbownerdomain\abc] from windows +go +create user [dbownerdomain\abc] +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +alter role db_owner add member [dbownerdomain\abc] +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +alter role db_owner drop member [dbownerdomain\abc] +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +exec sp_addrolemember 'db_owner', 'dbownerdomain\abc' +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +exec sp_droprolemember 'db_owner', 'dbownerdomain\abc' +go +select is_rolemember('db_owner', 'dbownerdomain\abc') +go +drop user [dbownerdomain\abc] +go +drop login [dbownerdomain\abc] +go +exec sys.babelfish_remove_domain_mapping_entry 'dbownerdomain' +go diff --git a/test/JDBC/input/ownership/db_securityadmin-vu-prepare.mix b/test/JDBC/input/ownership/db_securityadmin-vu-prepare.mix index e07aa1544e..36553d9a3e 100644 --- a/test/JDBC/input/ownership/db_securityadmin-vu-prepare.mix +++ b/test/JDBC/input/ownership/db_securityadmin-vu-prepare.mix @@ -41,17 +41,6 @@ GO CREATE SEQUENCE babel_5135_schema1.babel_5135_seq1 START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 999999 CYCLE; GO -CREATE VIEW babel_5135_show_role_mem AS -SELECT -roles.name AS RolePrincipalName -, members.name AS MemberPrincipalName -FROM sys.database_role_members AS db_role_mems -INNER JOIN sys.database_principals AS roles - ON db_role_mems.role_principal_id = roles.principal_id -INNER JOIN sys.database_principals AS members - ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; -GO - CREATE PROCEDURE babel_5135_roleop_proc1 AS BEGIN CREATE ROLE babel_5135_role2; ALTER ROLE babel_5135_role2 WITH NAME = babel_5135_role3; DROP ROLE babel_5135_role3; END GO CREATE PROCEDURE babel_5135_roleop_proc2 AS BEGIN ALTER ROLE babel_5135_r1 ADD MEMBER babel_5135_u1; END @@ -100,14 +89,3 @@ GO create user babel_5135_u1 for login babel_5135_l1; GO - -CREATE VIEW babel_5135_show_role_mem AS -SELECT -roles.name AS RolePrincipalName -, members.name AS MemberPrincipalName -FROM sys.database_role_members AS db_role_mems -INNER JOIN sys.database_principals AS roles - ON db_role_mems.role_principal_id = roles.principal_id -INNER JOIN sys.database_principals AS members - ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; -GO \ No newline at end of file diff --git a/test/JDBC/input/ownership/db_securityadmin-vu-verify.mix b/test/JDBC/input/ownership/db_securityadmin-vu-verify.mix index 9161ae14f9..27acd8afa1 100644 --- a/test/JDBC/input/ownership/db_securityadmin-vu-verify.mix +++ b/test/JDBC/input/ownership/db_securityadmin-vu-verify.mix @@ -20,6 +20,21 @@ GO ALTER ROLE db_securityadmin ADD MEMBER babel_5135_r1; GO +CREATE VIEW babel_5135_show_role_mem AS +SELECT +roles.name AS RolePrincipalName +, members.name AS MemberPrincipalName +FROM sys.database_role_members AS db_role_mems +INNER JOIN sys.database_principals AS roles + ON db_role_mems.role_principal_id = roles.principal_id +INNER JOIN sys.database_principals AS members + ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; +GO + +-- Should only show fixed database roles +SELECT name from sys.database_principals WHERE principal_id > 16383 AND principal_id < 16400 ORDER BY name; +GO + EXEC sp_addrolemember 'db_securityadmin', 'babel_5135_u1'; GO @@ -48,6 +63,21 @@ GO USE babel_5135_db1; GO +CREATE VIEW babel_5135_show_role_mem AS +SELECT +roles.name AS RolePrincipalName +, members.name AS MemberPrincipalName +FROM sys.database_role_members AS db_role_mems +INNER JOIN sys.database_principals AS roles + ON db_role_mems.role_principal_id = roles.principal_id +INNER JOIN sys.database_principals AS members + ON db_role_mems.member_principal_id = members.principal_id order by MemberPrincipalName; +GO + +-- Should only show fixed database roles +SELECT name from sys.database_principals WHERE principal_id > 16383 AND principal_id < 16400 ORDER BY name; +GO + ALTER ROLE db_securityadmin ADD MEMBER babel_5135_u1; GO diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index ce42d37ec0..db5885314a 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -514,6 +514,9 @@ ignore#!#BABEL-5119_before_16_5-vu-cleanup ignore#!#BABEL-5059_before_16_5-vu-prepare ignore#!#BABEL-5059_before_16_5-vu-verify ignore#!#BABEL-5059_before_16_5-vu-cleanup +ignore#!#cast_nvarchar_test_before_16_5-vu-prepare +ignore#!#cast_nvarchar_test_before_16_5-vu-verify +ignore#!#cast_nvarchar_test_before_16_5-vu-cleanup ignore#!#declare_atatglobalvars_upgrade-before-16_5-vu-cleanup ignore#!#declare_atatglobalvars_upgrade-before-16_5-vu-prepare ignore#!#declare_atatglobalvars_upgrade-before-16_5-vu-verify diff --git a/test/JDBC/upgrade/15_10/schedule b/test/JDBC/upgrade/15_10/schedule index dc494a9dcd..8e2555b601 100644 --- a/test/JDBC/upgrade/15_10/schedule +++ b/test/JDBC/upgrade/15_10/schedule @@ -558,6 +558,7 @@ db_ddladmin BABEL-5186 BABEL-2736 smalldatetime_date_cmp +cast_nvarchar_test_before_16_5 test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 test_conv_string_to_datetime2-before-17_3 diff --git a/test/JDBC/upgrade/15_11/schedule b/test/JDBC/upgrade/15_11/schedule index 46483e0175..b9be6664ed 100644 --- a/test/JDBC/upgrade/15_11/schedule +++ b/test/JDBC/upgrade/15_11/schedule @@ -558,6 +558,7 @@ db_ddladmin BABEL-5186 BABEL-2736 smalldatetime_date_cmp +cast_nvarchar_test_before_16_5 test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 test_conv_string_to_datetime2-before-17_3 diff --git a/test/JDBC/upgrade/15_3/schedule b/test/JDBC/upgrade/15_3/schedule index c792d83f49..49649b2568 100644 --- a/test/JDBC/upgrade/15_3/schedule +++ b/test/JDBC/upgrade/15_3/schedule @@ -496,6 +496,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 datareader_datawriter BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 smalldatetime_date_cmp-before-15_5-16_1 test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 diff --git a/test/JDBC/upgrade/15_4/schedule b/test/JDBC/upgrade/15_4/schedule index 826f8972f6..3724d78609 100644 --- a/test/JDBC/upgrade/15_4/schedule +++ b/test/JDBC/upgrade/15_4/schedule @@ -509,6 +509,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 datareader_datawriter BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 smalldatetime_date_cmp-before-15_5-16_1 test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 diff --git a/test/JDBC/upgrade/15_5/schedule b/test/JDBC/upgrade/15_5/schedule index 0aeeae2968..6a2627adb1 100644 --- a/test/JDBC/upgrade/15_5/schedule +++ b/test/JDBC/upgrade/15_5/schedule @@ -540,6 +540,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 dbcreator_role BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 securityadmin_role datareader_datawriter smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_6/schedule b/test/JDBC/upgrade/15_6/schedule index bda84bf8d6..013173ddae 100644 --- a/test/JDBC/upgrade/15_6/schedule +++ b/test/JDBC/upgrade/15_6/schedule @@ -556,6 +556,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 dbcreator_role BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 securityadmin_role datareader_datawriter smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_7/schedule b/test/JDBC/upgrade/15_7/schedule index bf146410ab..98a062b004 100644 --- a/test/JDBC/upgrade/15_7/schedule +++ b/test/JDBC/upgrade/15_7/schedule @@ -564,6 +564,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 dbcreator_role BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 securityadmin_role datareader_datawriter smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_8/schedule b/test/JDBC/upgrade/15_8/schedule index d99b05511d..55df68b3c5 100644 --- a/test/JDBC/upgrade/15_8/schedule +++ b/test/JDBC/upgrade/15_8/schedule @@ -555,6 +555,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 dbcreator_role BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 securityadmin_role datareader_datawriter smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/16_1/schedule b/test/JDBC/upgrade/16_1/schedule index 190caff12f..21da7fe11f 100644 --- a/test/JDBC/upgrade/16_1/schedule +++ b/test/JDBC/upgrade/16_1/schedule @@ -551,6 +551,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 datareader_datawriter BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 smalldatetime_date_cmp test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 diff --git a/test/JDBC/upgrade/16_2/schedule b/test/JDBC/upgrade/16_2/schedule index 463e792f61..0b9c59350e 100644 --- a/test/JDBC/upgrade/16_2/schedule +++ b/test/JDBC/upgrade/16_2/schedule @@ -565,6 +565,7 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 declare_atatglobalvars_upgrade-before-16_5 BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 securityadmin_role datareader_datawriter smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/16_3/schedule b/test/JDBC/upgrade/16_3/schedule index 651be1db06..c6fc370c4e 100644 --- a/test/JDBC/upgrade/16_3/schedule +++ b/test/JDBC/upgrade/16_3/schedule @@ -567,6 +567,7 @@ GRANT_SCHEMA-before-15_9-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 dbcreator_role securityadmin_role datareader_datawriter diff --git a/test/JDBC/upgrade/16_4/schedule b/test/JDBC/upgrade/16_4/schedule index 4b4a7c1b2b..3b3d577ff8 100644 --- a/test/JDBC/upgrade/16_4/schedule +++ b/test/JDBC/upgrade/16_4/schedule @@ -582,6 +582,7 @@ dbcreator_role declare_atatglobalvars_upgrade-before-16_5 BABEL-5186 BABEL-2736-before-16_5 +cast_nvarchar_test_before_16_5 securityadmin_role datareader_datawriter smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/16_6/schedule b/test/JDBC/upgrade/16_6/schedule index 9f380b3a60..b28ff42b7f 100644 --- a/test/JDBC/upgrade/16_6/schedule +++ b/test/JDBC/upgrade/16_6/schedule @@ -581,6 +581,7 @@ BABEL-CASE_EXPR charindex_replace_patindex BABEL-5186 BABEL-2736 +cast_nvarchar_test_before_16_5 securityadmin_role db_accessadmin datareader_datawriter diff --git a/test/JDBC/upgrade/16_7/schedule b/test/JDBC/upgrade/16_7/schedule index d47bcb4624..71603ef6a8 100644 --- a/test/JDBC/upgrade/16_7/schedule +++ b/test/JDBC/upgrade/16_7/schedule @@ -89,7 +89,7 @@ BABEL-3392 BABEL-3402 BABEL-3474 BABEL-3478 -BABEL-3486 +BABEL-3486-before-17_3 BABEL-3513 BABEL-3556 BABEL-3588 @@ -592,6 +592,7 @@ dbcreator_role db_securityadmin db_ddladmin smalldatetime_date_cmp +cast_nvarchar_test test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 test_conv_string_to_datetime2-before-17_3 diff --git a/test/JDBC/upgrade/17_2/schedule b/test/JDBC/upgrade/17_2/schedule index 490a4698cc..20df7eaffa 100644 --- a/test/JDBC/upgrade/17_2/schedule +++ b/test/JDBC/upgrade/17_2/schedule @@ -591,6 +591,7 @@ BABEL-2736 datareader_datawriter db_owner smalldatetime_date_cmp +cast_nvarchar_test_before_16_5 test_conv_string_to_date-before-17_3 test_conv_string_to_datetime-before-17_3 test_conv_string_to_datetime2-before-17_3 diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 3fde7b6171..646108c3ea 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -595,6 +595,7 @@ BABEL-CASE_EXPR charindex_replace_patindex BABEL-5186 BABEL-2736 +cast_nvarchar_test datareader_datawriter db_owner smalldatetime_date_cmp diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index d3a698b82d..7dc158c81c 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -979,6 +979,7 @@ View sys.change_tracking_tables View sys.database_files View sys.database_filestream_options View sys.database_recovery_status +View sys.database_role_members View sys.dm_hadr_cluster View sys.dm_hadr_database_replica_states View sys.dm_os_host_info