Bug #115291 | 8024 upgrade 8030 character set exception | ||
---|---|---|---|
Submitted: | 12 Jun 2024 7:43 | Modified: | 13 Jun 2024 11:17 |
Reporter: | lei yue | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Installing | Severity: | S4 (Feature request) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[12 Jun 2024 7:43]
lei yue
[12 Jun 2024 7:44]
lei yue
args[0] ``` (gdb) p *args[0] $28 = { <Parse_tree_node_tmpl<Parse_context>> = { _vptr.Parse_tree_node_tmpl = 0x48cc430 <vtable for Item_func_conv_charset+16> }, members of Item: next_free = 0x7fe68e74ad70, str_value = { m_ptr = 0x0, m_length = 0, m_charset = 0x4a6ffc0 <my_charset_bin>, m_alloced_length = 0, m_is_alloced = false }, collation = { collation = 0x4a7d400 <my_charset_utf8mb4_0900_ai_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3 }, item_name = { <Name_string> = { <Simple_cstring> = { m_str = 0x0, m_length = 0 }, <No data fields>}, members of Item_name_string: m_is_autogenerated = true }, orig_name = { <Name_string> = { <Simple_cstring> = { m_str = 0x0, m_length = 0 }, <No data fields>}, members of Item_name_string: m_is_autogenerated = true }, max_length = 1020, marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 15 '\017', fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false, m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002', static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ', static PROP_SAVED_AGGREGATION = 64 '@', m_accum_properties = 0 '\000' } ``` args[1] ``` (gdb) p *args[1] $29 = { <Parse_tree_node_tmpl<Parse_context>> = { _vptr.Parse_tree_node_tmpl = 0x4853210 <vtable for Item_field+16> }, members of Item: next_free = 0x7fe68e74acc0, str_value = { m_ptr = 0x0, m_length = 0, m_charset = 0x4a6ffc0 <my_charset_bin>, m_alloced_length = 0, m_is_alloced = false }, collation = { collation = 0x4bcf320 <my_charset_utf8mb4_general_ci>, derivation = DERIVATION_IMPLICIT, repertoire = 3 }, item_name = { <Name_string> = { <Simple_cstring> = { m_str = 0x7fe68e74acb0 "ROLE_HOST", m_length = 9 }, <No data fields>}, members of Item_name_string: m_is_autogenerated = true }, orig_name = { <Name_string> = { <Simple_cstring> = { m_str = 0x0, m_length = 0 }, <No data fields>}, members of Item_name_string: m_is_autogenerated = true }, max_length = 1020, marker = Item::MARKER_NONE, cmp_context = INVALID_RESULT, is_parser_item = true, is_expensive_cache = -1 '\377', m_data_type = 15 '\017', fixed = true, decimals = 31 '\037', m_nullable = true, null_value = false, unsigned_flag = false, m_is_window_function = false, hidden = false, m_in_check_constraint_exec_ctx = false, derived_used = false, static PROP_SUBQUERY = 1 '\001', static PROP_STORED_PROGRAM = 2 '\002', static PROP_AGGREGATION = 4 '\004', static PROP_WINDOW_FUNCTION = 8 '\b', static PROP_ROLLUP_EXPR = 16 '\020', static PROP_GROUPING_FUNC = 32 ' ', static PROP_SAVED_AGGREGATION = 64 '@', m_accum_properties = 0 '\000' } ```
[12 Jun 2024 9:45]
MySQL Verification Team
Hi Mr. yue, Thank you for your bug report. However, let us inform you that this is a forum for the bugs with repeatable bugs reports. We have upgraded our server numerous times and never encountered an error that you report. Also, our database of bugs, which has more then hundred thousands bug reports does not have anything similar. Needless to say, current release is 8.0.37 and not 8.0.30. We are testing with the latest release only We can not go further without a fully repeatable test case. Can't repeat.
[12 Jun 2024 9:52]
lei yue
Initialize the database with default_collation_for_utf8mb4 = utf8mb4_general_ci, and then execute the following SQL statement, and an error will be reported ``` txsql> CREATE OR REPLACE DEFINER=`mysql.infoschema`@`localhost` VIEW information_schema.ENABLED_ROLES AS SELECT ROLE_NAME AS ROLE_NAME, ROLE_HOST AS ROLE_HOST, (SELECT IF(COUNT(*), 'YES', 'NO') FROM mysql.default_roles WHERE DEFAULT_ROLE_USER = ROLE_NAME AND CONVERT(DEFAULT_ROLE_HOST using utf8mb4) = ROLE_HOST AND USER = INTERNAL_GET_USERNAME() AND CONVERT(HOST using utf8mb4) = INTERNAL_GET_HOSTNAME()) AS IS_DEFAULT, IF(INTERNAL_IS_MANDATORY_ROLE(ROLE_NAME, ROLE_HOST), 'YES', 'NO') AS IS_MANDATORY FROM JSON_TABLE(INTERNAL_GET_ENABLED_ROLE_JSON(), '$[*]' COLUMNS ( ROLE_NAME VARCHAR(255) CHARSET utf8mb4 PATH '$.ROLE_NAME', ROLE_HOST VARCHAR(255) CHARSET utf8mb4 PATH '$.ROLE_HOST') ) current_user_enabled_roles; ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '=' ```
[12 Jun 2024 9:54]
lei yue
Need to add cs processing in Item_func_conv_charset ``` if (cs2 == &my_charset_utf8mb4_0900_ai_ci && cs2 != thd->variables.default_collation_for_utf8mb4) cs3 = thd->variables.default_collation_for_utf8mb4; ```
[12 Jun 2024 10:36]
MySQL Verification Team
Hi Mr. yue, Thank you for the feedback. However, this is not a bug. It is defined in SQL standard that two collations with the exactly same coercibility can not be converted, at all.. Hence, this error is expected behaviour , according to the SQL Standard. This is also described in our Reference Manual, section on collation and collation comparisons ...... Not a bug.
[13 Jun 2024 10:39]
MySQL Verification Team
Hi Mr. vue, Actually, we reconsidered the case and concluded that our upgrade procedure could be improved. Hence this is now a verified feature request for the Server Upgrade. Verified.
[13 Jun 2024 11:17]
lei yue
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index d49aaf0671c..6b81bc91fb3 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -47,7 +47,9 @@ #include "sql/item_func.h" // Item_func #include "sql/parse_location.h" // POS #include "sql/sql_const.h" +#include "sql/current_thd.h" #include "sql_string.h" +#include "sql_class.h" // THD #include "template_utils.h" // pointer_cast /* Changes from TXSQL start. */ @@ -983,6 +985,10 @@ class Item_charset_conversion : public Item_str_func { Item_charset_conversion(THD *thd, Item *a, const CHARSET_INFO *cs_arg, bool cache_if_const) : Item_str_func(a), m_cast_cs(cs_arg) { + if (m_cast_cs == &my_charset_utf8mb4_0900_ai_ci && + m_cast_cs != thd->variables.default_collation_for_utf8mb4) + m_cast_cs = thd->variables.default_collation_for_utf8mb4; + if (cache_if_const && args[0]->may_evaluate_const(thd)) { uint errors = 0; String tmp, *str = args[0]->val_str(&tmp); @@ -1001,7 +1007,11 @@ class Item_charset_conversion : public Item_str_func { } Item_charset_conversion(const POS &pos, Item *a, const CHARSET_INFO *cs_arg, bool to_char = false) - : Item_str_func(pos, a), m_cast_cs(cs_arg), is_to_char(to_char) {} + : Item_str_func(pos, a), m_cast_cs(cs_arg), is_to_char(to_char) { + if (m_cast_cs == &my_charset_utf8mb4_0900_ai_ci && + m_cast_cs != current_thd->variables.default_collation_for_utf8mb4) + m_cast_cs = current_thd->variables.default_collation_for_utf8mb4; + } String *val_str(String *) override; };
[13 Jun 2024 11:22]
MySQL Verification Team
Thank you Mr. yue for your effort. However, we shall make a fix in the upgrade procedure only.