Skip to content

Commit

Permalink
executor: fix set names with default_collation_for_utf8mb4 vars (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 authored Oct 8, 2024
1 parent 5f02b09 commit 0ab49be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/executor/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ func (e *SetExecutor) setCharset(cs, co string, isSetName bool) error {
var err error
sessionVars := e.Ctx().GetSessionVars()
if co == "" {
if co, err = charset.GetDefaultCollation(cs); err != nil {
if cs == mysql.UTF8MB4Charset {
co = sessionVars.DefaultCollationForUTF8MB4
} else if co, err = charset.GetDefaultCollation(cs); err != nil {
return err
}
} else {
Expand Down
20 changes: 20 additions & 0 deletions tests/integrationtest/r/new_character_set.result
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,23 @@ select hex('一a'), '一a';
hex('涓?') 涓?
E4B83F 涓?
set @@sql_mode=default;
set @@character_set_client=default;
set @@character_set_connection=default;
show variables like 'collation_connection';
Variable_name Value
collation_connection utf8mb4_bin
set default_collation_for_utf8mb4 = 'utf8mb4_general_ci';
set names utf8mb4;
show variables like 'collation_connection';
Variable_name Value
collation_connection utf8mb4_general_ci
set default_collation_for_utf8mb4 = 'utf8mb4_0900_ai_ci';
set names utf8mb4;
show variables like 'collation_connection';
Variable_name Value
collation_connection utf8mb4_0900_ai_ci
set default_collation_for_utf8mb4 = default;
set names utf8mb4;
show variables like 'collation_connection';
Variable_name Value
collation_connection utf8mb4_bin
13 changes: 13 additions & 0 deletions tests/integrationtest/t/new_character_set.test
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,16 @@ set @@character_set_connection=gbk;
select hex('一a'), '一a';

set @@sql_mode=default;
set @@character_set_client=default;
set @@character_set_connection=default;

show variables like 'collation_connection';
set default_collation_for_utf8mb4 = 'utf8mb4_general_ci';
set names utf8mb4;
show variables like 'collation_connection';
set default_collation_for_utf8mb4 = 'utf8mb4_0900_ai_ci';
set names utf8mb4;
show variables like 'collation_connection';
set default_collation_for_utf8mb4 = default;
set names utf8mb4;
show variables like 'collation_connection';

0 comments on commit 0ab49be

Please sign in to comment.