Skip to content

Commit b3a3da8

Browse files
Martin Hanssondahlerlend
authored andcommitted
Bug#31063981: ASSERTION "MYSQLLEX"
The parser doesn't support multi-byte character sets with minimum length greater than 1. Hence the functions that call the parser shouldn't either. Change-Id: I3afe847a4e7749513540ee88e77a51cc6ebaaac5
1 parent ba5bc90 commit b3a3da8

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

include/m_ctype.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -743,4 +743,8 @@ static inline uint my_ismbchar(const CHARSET_INFO *cs, const uchar *str,
743743
((s)->cset->strntoull((s), (a), (b), (c), (d), (e)))
744744
#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s), (a), (b), (c), (d)))
745745

746+
static inline bool is_supported_parser_charset(const CHARSET_INFO *cs) {
747+
return (cs->mbminlen == 1);
748+
}
749+
746750
#endif // M_CTYPE_INCLUDED

share/messages_to_clients.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9373,6 +9373,9 @@ ER_MDL_OUT_OF_RESOURCES
93739373
ER_IMPLICIT_COMPARISON_FOR_JSON
93749374
eng "Evaluating a JSON value in SQL boolean context does an implicit comparison against JSON integer 0; if this is not what you want, consider converting JSON to a SQL numeric type with JSON_VALUE RETURNING"
93759375

9376+
ER_FUNCTION_DOES_NOT_SUPPORT_CHARACTER_SET
9377+
eng "The function %s does not support the character set '%s'."
9378+
93769379
#
93779380
# End of 8.0 error messages (server-to-client).
93789381
# Do NOT add messages intended for the error log above!

sql/item_strfunc.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646

4747
#include "base64.h" // base64_encode_max_arg_length
4848
#include "decimal.h"
49+
#include "field_types.h" // MYSQL_TYPE_BIT
50+
#include "lex_string.h" // LEX_CSTRING
51+
#include "m_ctype.h" // is_supported_parser_charset
4952
#include "m_string.h"
5053
#include "my_aes.h" // MY_AES_IV_SIZE
5154
#include "my_byteorder.h"
@@ -926,7 +929,12 @@ String *Item_func_statement_digest::val_str_ascii(String *buf) {
926929
{
927930
THD *thd = current_thd;
928931
Thd_parse_modifier thd_mod(thd, m_token_buffer);
929-
932+
const CHARSET_INFO *cs = args[0]->charset_for_protocol();
933+
if (!is_supported_parser_charset(cs)) {
934+
my_error(ER_FUNCTION_DOES_NOT_SUPPORT_CHARACTER_SET, myf(0), func_name(),
935+
cs->name);
936+
return error_str();
937+
}
930938
if (parse(thd, args[0], statement_string)) return error_str();
931939
compute_digest_hash(&thd->m_digest->m_digest_storage, digest);
932940
}
@@ -956,7 +964,12 @@ String *Item_func_statement_digest_text::val_str(String *buf) {
956964

957965
THD *thd = current_thd;
958966
Thd_parse_modifier thd_mod(thd, m_token_buffer);
959-
967+
const CHARSET_INFO *cs = args[0]->charset_for_protocol();
968+
if (!is_supported_parser_charset(cs)) {
969+
my_error(ER_FUNCTION_DOES_NOT_SUPPORT_CHARACTER_SET, myf(0), func_name(),
970+
cs->name);
971+
return error_str();
972+
}
960973
if (parse(thd, args[0], statement_string)) return error_str();
961974

962975
compute_digest_text(&thd->m_digest->m_digest_storage, buf);

sql/sql_parse.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ bool show_precheck(THD *thd, LEX *lex, bool lock);
127127
extern uint sql_command_flags[];
128128
extern const LEX_CSTRING command_name[];
129129

130-
inline bool is_supported_parser_charset(const CHARSET_INFO *cs) {
131-
return (cs->mbminlen == 1);
132-
}
133-
134130
bool sqlcom_can_generate_row_events(enum enum_sql_command command);
135131

136132
bool all_tables_not_ok(THD *thd, TABLE_LIST *tables);

sql/sys_vars.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,10 @@ static Sys_var_struct<CHARSET_INFO, Get_csname> Sys_character_set_database(
17491749
static bool check_cs_client(sys_var *self, THD *thd, set_var *var) {
17501750
if (check_charset_not_null(self, thd, var)) return true;
17511751

1752-
// Currently, UCS-2 cannot be used as a client character set
1752+
// We don't currently support any variable-width character set with a minumum
1753+
// length greater than 1. If we ever do, we have to revisit
1754+
// is_supported_parser_charset(). See Item_func_statement_digest::val_str()
1755+
// and Item_func_statement_digest_text::val_str().
17531756
return (static_cast<const CHARSET_INFO *>(var->save_result.ptr))->mbminlen >
17541757
1;
17551758
}

0 commit comments

Comments
 (0)