MDEV-23138 Odd behavior of character_set variables set to utf16 (when allowed)

Sys_var_typelib did not work when assigned to an expression
with character sets with mbminlen>1.
Using val_str_ascii() instead of val_str() to fix this.
This commit is contained in:
Alexander Barkov 2024-11-18 11:34:13 +04:00
parent ed72eadfb8
commit b65504b8db
3 changed files with 24 additions and 1 deletions

View File

@ -2910,5 +2910,15 @@ CAST(_utf16 0x0061D83DDE0E0062 AS INT)
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'a?b'
#
# MDEV-23138 Odd behavior of character_set variables set to utf16 (when allowed)
#
SET character_set_connection=utf16;
SET tx_isolation= 'READ-COMMITTED';
SELECT @@tx_isolation;
@@tx_isolation
READ-COMMITTED
SET tx_isolation=DEFAULT;
SET NAMES utf8mb3;
#
# End of 10.5 tests
#

View File

@ -1029,6 +1029,15 @@ SET NAMES utf8;
# surrogate pairs is replaced to a single question mark.
SELECT CAST(_utf16 0x0061D83DDE0E0062 AS INT);
--echo #
--echo # MDEV-23138 Odd behavior of character_set variables set to utf16 (when allowed)
--echo #
SET character_set_connection=utf16;
SET tx_isolation= 'READ-COMMITTED';
SELECT @@tx_isolation;
SET tx_isolation=DEFAULT;
SET NAMES utf8mb3;
--echo #
--echo # End of 10.5 tests

View File

@ -334,7 +334,11 @@ public:
if (var->value->result_type() == STRING_RESULT)
{
if (!(res=var->value->val_str(&str)))
/*
Convert from the expression character set to ascii.
This is OK, as typelib values cannot have non-ascii characters.
*/
if (!(res= var->value->val_str_ascii(&str)))
return true;
else
if (!(var->save_result.ulonglong_value=