Skip to content

Commit 9fb8881

Browse files
committed
MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16...
When the system variables @@debug_dbug was assigned to some expression, Sys_debug_dbug::do_check() did not properly convert the value from the expression character set to utf8. So the value was erroneously re-interpretted as utf8 without conversion. In case of a tricky expression character set (e.g. utf16le), this led to unexpected results. Fix: Re-using Sys_var_charptr::do_string_check() in Sys_debug_dbug::do_check().
1 parent 952ab9a commit 9fb8881

File tree

3 files changed

+63
-14
lines changed

3 files changed

+63
-14
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Start of 10.5 tests
3+
#
4+
#
5+
# MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16...
6+
#
7+
SET NAMES utf8;
8+
SET collation_connection=utf16le_general_ci;
9+
SET debug_dbug='d,any_random_string';
10+
SELECT @@debug_dbug;
11+
@@debug_dbug
12+
d,any_random_string
13+
SET debug_dbug=CONCAT('d,', _latin1 0xDF);
14+
SELECT @@debug_dbug;
15+
@@debug_dbug
16+
d,ß
17+
SELECT HEX(@@debug_dbug);
18+
HEX(@@debug_dbug)
19+
642CC39F
20+
SET @@debug_dbug=NULL;
21+
SELECT @@debug_dbug;
22+
@@debug_dbug
23+
24+
SET @@debug_dbug=DEFAULT;
25+
SELECT @@debug_dbug;
26+
@@debug_dbug
27+
28+
SET NAMES latin1;
29+
#
30+
# End of 10.5 tests
31+
#
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--source include/have_debug.inc
2+
--source include/have_utf16.inc
3+
4+
--echo #
5+
--echo # Start of 10.5 tests
6+
--echo #
7+
8+
--echo #
9+
--echo # MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16...
10+
--echo #
11+
12+
SET NAMES utf8;
13+
SET collation_connection=utf16le_general_ci;
14+
SET debug_dbug='d,any_random_string';
15+
SELECT @@debug_dbug;
16+
SET debug_dbug=CONCAT('d,', _latin1 0xDF);
17+
SELECT @@debug_dbug;
18+
SELECT HEX(@@debug_dbug);
19+
20+
SET @@debug_dbug=NULL;
21+
SELECT @@debug_dbug;
22+
23+
SET @@debug_dbug=DEFAULT;
24+
SELECT @@debug_dbug;
25+
SET NAMES latin1;
26+
27+
--echo #
28+
--echo # End of 10.5 tests
29+
--echo #

sql/sys_vars.inl

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -947,21 +947,10 @@ public:
947947
{ option.var_type|= GET_STR; }
948948
bool do_check(THD *thd, set_var *var)
949949
{
950-
char buff[STRING_BUFFER_USUAL_SIZE];
951-
String str(buff, sizeof(buff), system_charset_info), *res;
952-
953-
if (!(res=var->value->val_str(&str)))
954-
{
950+
bool rc= Sys_var_charptr::do_string_check(thd, var, charset(thd));
951+
if (var->save_result.string_value.str == nullptr)
955952
var->save_result.string_value.str= const_cast<char*>("");
956-
var->save_result.string_value.length= 0;
957-
}
958-
else
959-
{
960-
size_t len= res->length();
961-
var->save_result.string_value.str= thd->strmake(res->ptr(), len);
962-
var->save_result.string_value.length= len;
963-
}
964-
return false;
953+
return rc;
965954
}
966955
bool session_update(THD *thd, set_var *var)
967956
{

0 commit comments

Comments
 (0)