1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-35041 Simple comparison causes "Illegal mix of collations" even with default server settings

The task "MDEV-25829 Change default Unicode collation to uca1400_ai_ci"
previously changed collation derivation for string user variables
from DERIVATION_EXPLICIT to DERIVATION_COERCIBLE, to resolve illegal
collation mix conflicts between table columns and user variables
when they have different collations.

However, DERIVATION_COERCIBLE was a wrong choice because it caused
conflicts between string literals and user variables when they have
different collations.

Adding a new collation derivation level DERIVATION_USERVAR.
This makes the collation of a user variable:
- weaker than a table column (like it was intended by MDEV-25829)
- but stronger than a literal (like it was in pre-MDEV-25829)

Cleanup in sql_type.h:
  Removing the line "- BINARY(expr)" from the before-DERIVATION_CAST
  comment, as it was on a wrong place. It's also listed on the correct
  place before DERIVATION_IMPLICIT.
This commit is contained in:
Alexander Barkov
2024-10-22 11:10:58 +04:00
parent 4e1e9ea6f3
commit a88c71b294
31 changed files with 178 additions and 117 deletions

View File

@ -869,12 +869,21 @@ SELECT 0xE001 REGEXP CAST(@regCheck AS CHAR);
Warnings:
Warning 1139 Regex error 'UTF-8 error: 1 byte missing at end'
SELECT 0xE001 REGEXP CAST(@regCheck AS CHAR);
0xE001 REGEXP CAST(@regCheck AS CHAR)
0
0xE001 REGEXP CAST(@regCheck AS CHAR)
0
Warnings:
Warning 1139 Regex error 'UTF-8 error: 1 byte missing at end'
# Since 11.5 (MDEV-25829) user variables have DERIVATION_COERCIBLE
# so a user variable and a literal in the pattern gave equal results
# But since 11.6 (MDEV-35041) user variables have DERIVATION_USERVAR
# so the query with a literal is performece as binary:
SELECT 0xE001 REGEXP '\\xE0\\x01' AS c1;
c1
Warning 1139 Regex error 'UTF-8 error: 1 byte missing at end'
# Since 11.4 user variables have DERIVATION_COERCIBLE
# so a user variable and a literal in the pattern give equal results
1
# while the query with a user variable is performed as string
# with a warning, like in 11.4
SET @regCheck= '\\xE0\\x01';
SELECT 0xE001 REGEXP @regCheck AS c2;
c2
0
Warnings: