-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-39530 Collation mix issue after update #5396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # | ||
| # MDEV-39530 Collation mix issue after update | ||
| # | ||
| # Reproduce the environment from the report: character_set_collations | ||
| # maps utf8mb3 to utf8mb3_uca1400_ai_ci and the connection uses that | ||
| # collation. | ||
| SET NAMES utf8mb3 COLLATE utf8mb3_uca1400_ai_ci; | ||
| SELECT @@character_set_collations, @@collation_connection; | ||
| @@character_set_collations @@collation_connection | ||
| utf8mb3=utf8mb3_uca1400_ai_ci,ucs2=ucs2_uca1400_ai_ci,utf8mb4=utf8mb4_uca1400_ai_ci,utf16=utf16_uca1400_ai_ci,utf32=utf32_uca1400_ai_ci utf8mb3_uca1400_ai_ci | ||
| CREATE TABLE file ( | ||
| `ID` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
| `Path` varchar(800) NOT NULL DEFAULT '' | ||
| ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; | ||
| INSERT INTO file VALUES (1,"text"); | ||
| # This query used to work in 11.4 but raises | ||
| # ER_CANT_AGGREGATE_2COLLATIONS in 12.1+ | ||
| SELECT IF((@p:=(SELECT f.Path FROM file f WHERE f.ID=1 AND f.Path REGEXP "^xx"))!="",1,2); | ||
| IF((@p:=(SELECT f.Path FROM file f WHERE f.ID=1 AND f.Path REGEXP "^xx"))!="",1,2) | ||
| 2 | ||
| DROP TABLE file; | ||
| # | ||
| # End of test | ||
| # |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --echo # | ||
| --echo # MDEV-39530 Collation mix issue after update | ||
| --echo # | ||
|
|
||
| --echo # Reproduce the environment from the report: character_set_collations | ||
| --echo # maps utf8mb3 to utf8mb3_uca1400_ai_ci and the connection uses that | ||
| --echo # collation. | ||
| SET NAMES utf8mb3 COLLATE utf8mb3_uca1400_ai_ci; | ||
| SELECT @@character_set_collations, @@collation_connection; | ||
|
|
||
| CREATE TABLE file ( | ||
| `ID` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
| `Path` varchar(800) NOT NULL DEFAULT '' | ||
| ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; | ||
|
|
||
| INSERT INTO file VALUES (1,"text"); | ||
|
|
||
| --echo # This query used to work in 11.4 but raises | ||
| --echo # ER_CANT_AGGREGATE_2COLLATIONS in 12.1+ | ||
| SELECT IF((@p:=(SELECT f.Path FROM file f WHERE f.ID=1 AND f.Path REGEXP "^xx"))!="",1,2); | ||
|
|
||
| DROP TABLE file; | ||
|
|
||
| --echo # | ||
| --echo # End of test | ||
| --echo # | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4840,9 +4840,17 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) | |
| if (!m_var_entry->charset() || !null_item) | ||
| m_var_entry->set_charset(args[0]->collation.derivation == DERIVATION_NUMERIC ? | ||
| &my_charset_numeric : args[0]->collation.collation); | ||
| /* | ||
| A user variable assignment (e.g. @p:=expr) must expose the same collation | ||
| derivation as reading the variable back with Item_func_get_user_var, which | ||
| uses DERIVATION_USERVAR (see MDEV-35041). Using DERIVATION_COERCIBLE here | ||
| made the assignment as strong as a string literal, causing "Illegal mix of | ||
| collations" conflicts against literals that carry the (possibly different) | ||
| connection collation (MDEV-39530). | ||
| */ | ||
| collation.set(m_var_entry->charset(), | ||
| args[0]->collation.derivation == DERIVATION_NUMERIC ? | ||
| DERIVATION_NUMERIC : DERIVATION_COERCIBLE); | ||
| DERIVATION_NUMERIC : DERIVATION_USERVAR); | ||
| switch (args[0]->result_type()) { | ||
| case STRING_RESULT: | ||
| case TIME_RESULT: | ||
|
|
@@ -4907,7 +4915,7 @@ Item_func_set_user_var::fix_length_and_dec(THD *thd) | |
| } | ||
| else | ||
| { | ||
| collation.set(DERIVATION_COERCIBLE); | ||
| collation.set(DERIVATION_USERVAR); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is indeed a good suggestion. I'd fix the fix_fields's setting and remove these.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @gkodinov |
||
| fix_length_and_charset(args[0]->max_char_length(), | ||
| args[0]->collation.collation); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please format your tests according to this format
in your test the end marker is missing the correct mariadb version.
also, we dont create new test files for every bug, so please move the test into an existing file, for example,
ctype_collate*.testThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comments! I will make the change when I get time. Thanks!