diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
commit | a2a2e32c02643a0cec111511220227703fda1cd5 (patch) | |
tree | 69cc2b631234c2a8e026b9cd4d72676c61c594df /sql/sql_connect.cc | |
parent | Releasing progress-linux version 1:10.11.8-1~progress7.99u1. (diff) | |
download | mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.tar.xz mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.zip |
Merging upstream version 1:11.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/sql_connect.cc')
-rw-r--r-- | sql/sql_connect.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 6149cc49..f06a58a4 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -779,6 +779,10 @@ void update_global_user_stats(THD *thd, bool create_user, time_t now) bool thd_init_client_charset(THD *thd, uint cs_number) { CHARSET_INFO *cs; + + // Test a non-default collation ID. See also comments in this function below. + DBUG_EXECUTE_IF("thd_init_client_charset_utf8mb3_bin", cs_number= 83;); + /* Use server character set and collation if - opt_character_set_client_handshake is not set @@ -801,6 +805,25 @@ bool thd_init_client_charset(THD *thd, uint cs_number) cs->cs_name.str); return true; } + /* + Some connectors (e.g. JDBC, Node.js) can send non-default collation IDs + in the handshake packet, to set @@collation_connection right during + handshake. Although this is a non-documenting feature, + for better backward compatibility with such connectors let's: + a. resolve only default collations according to @@character_set_collations + b. preserve non-default collations as is + + Perhaps eventually we should change (b) also to resolve non-default + collations accoding to @@character_set_collations. Clients that used to + send a non-default collation ID in the handshake packet will have to set + @@character_set_collations instead. + */ + if (cs->state & MY_CS_PRIMARY) + { + Sql_used used; + cs= global_system_variables.character_set_collations. + get_collation_for_charset(&used, cs); + } thd->org_charset= cs; thd->update_charset(cs,cs,cs); } @@ -1077,7 +1100,6 @@ static int check_connection(THD *thd) statistic_increment(aborted_connects_preauth, &LOCK_status); return 1; /* The error is set by alloc(). */ } - auth_rc= acl_authenticate(thd, 0); if (auth_rc == 0 && connect_errors != 0) { @@ -1132,7 +1154,7 @@ void setup_connection_thread_globals(THD *thd) 1 error */ -bool login_connection(THD *thd) +static bool login_connection(THD *thd) { NET *net= &thd->net; int error= 0; |