Bug #105966 Contribution by Tencent:missing session track info when set names with collation
| Submitted: | 23 Dec 2021 3:41 | Modified: | 13 Jan 2022 7:33 |
|---|---|---|---|
| Reporter: | yuxiang jiang (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Charsets | Severity: | S4 (Feature request) |
| Version: | all | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | collation, Contribution, session track | ||
[23 Dec 2021 3:47]
yuxiang jiang
set names with more info added (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: 0001-feature-Return-more-infomation-when-set-names.patch (application/octet-stream, text), 2.46 KiB.
[23 Dec 2021 5:08]
MySQL Verification Team
Hello yuxiang jiang, Thank you for the report and contribution. regards, Umesh
[13 Jan 2022 7:33]
yuxiang jiang
Contribution by Tencent
[26 Jan 2022 8:40]
Frederic Descamps
This contribution has been processed by our development team and has been accepted. It will be included into a future release. Thank you again.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: After execute 'set names' statement with collation, session track do not return the newly specified collation. From code below we know that character_set_connection and collation_connection use the same CHARSET_INFO variables. --- static Sys_var_struct Sys_character_set_connection( "character_set_connection", "The character set used for " "literals that do not have a character set introducer and for " "number-to-string conversion", SESSION_VAR(collation_connection), NO_CMD_LINE, offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_not_null), ON_UPDATE(fix_thd_charset)); static Sys_var_struct Sys_collation_connection( "collation_connection", "The collation of the connection " "character set", SESSION_VAR(collation_connection), NO_CMD_LINE, offsetof(CHARSET_INFO, name), DEFAULT(&default_charset_info), NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_collation_not_null), ON_UPDATE(fix_thd_charset)); --- But as we show variables like collation_connection and character_set_connection, they have different value returned. So when execute set names with collation, although we know charset changed, but the detailed collation info is missing. How to repeat: set session_track_system_variables='time_zone,autocommit,character_set_client,character_set_results,character_set_connection,collation_connection'; set names 'utf8mb4' collate 'utf8mb4_unicode_ci'; then check session tracker return Suggested fix: Add collation_connection when set names. diff --git a/sql/set_var.cc b/sql/set_var.cc index 35fb210..5c7fcf7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1174,6 +1174,9 @@ int set_var_collation_client::update(THD *thd) LEX_CSTRING cs_connection= {"character_set_connection", sizeof("character_set_connection") - 1}; thd->session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->mark_as_changed(thd, &cs_c + LEX_CSTRING cs_collation= {"collation_connection", + sizeof("collation_connection") - 1}; + thd->session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->mark_as_changed(thd, &cs_c } if (thd->session_tracker.get_tracker(SESSION_STATE_CHANGE_TRACKER)->is_enabled()) thd->session_tracker.get_tracker(SESSION_STATE_CHANGE_TRACKER)->mark_as_changed(thd,