mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-25829 Change default Unicode collation to uca1400_ai_ci
Step#2 - Adding a new collation derivation level for CAST and CONVERT. Now character string cast functions: - CAST(string_expr AS CHAR) - CONVERT(expr USING charset_name) have a new collation derivation level between: - string literals - utf8 metadata functions, e.g. user() and database() Before the change these cast functions had collation derivation equal to table columns, which caused more illegal mix of collation conflicts. Note, binary string cast functions: - BINARY(expr) - CAST(string_expr AS BINARY) - CONVERT(expr USING binary) did not change their collation derivation, to preserve the behaviour of queries like these: SELECT database()=BINARY'test'; SELECT user()=CAST('root' AS BINARY); SELECT current_role()=CONVERT('role' USING binary); Derivation levels after the change look as follows: DERIVATION_IGNORABLE= 7, // Explicit NULL DERIVATION_NUMERIC= 6, // Numbers in string context, // Numeric user variables // CAST(numeric_expr AS CHAR) DERIVATION_COERCIBLE= 5, // Literals, string user variables DERIVATION_CAST= 4, // CAST(string_expr AS CHAR), // CONVERT(string_expr USING cs) DERIVATION_SYSCONST= 3, // utf8 metadata functions, e.g. user(), database() DERIVATION_IMPLICIT= 2, // Table columns, SP variables, BINARY(expr) DERIVATION_NONE= 1, // A mix (e.g. CONCAT) of two differrent collations DERIVATION_EXPLICIT= 0 // An explicit COLLATE clause
This commit is contained in:
@ -3019,13 +3019,46 @@ static inline my_repertoire_t &operator|=(my_repertoire_t &a,
|
||||
|
||||
enum Derivation
|
||||
{
|
||||
DERIVATION_IGNORABLE= 6,
|
||||
DERIVATION_NUMERIC= 5,
|
||||
DERIVATION_COERCIBLE= 4,
|
||||
DERIVATION_IGNORABLE= 7, // Explicit NULL
|
||||
|
||||
/*
|
||||
Explicit or implicit conversion from numeric/temporal data to string:
|
||||
- Numbers/temporals in string context
|
||||
- Numeric user variables
|
||||
- CAST(numeric_or_temporal_expr AS CHAR)
|
||||
*/
|
||||
DERIVATION_NUMERIC= 6,
|
||||
|
||||
/*
|
||||
- String literals
|
||||
- String user variables
|
||||
*/
|
||||
DERIVATION_COERCIBLE= 5,
|
||||
|
||||
/*
|
||||
String cast and conversion functions:
|
||||
- BINARY(expr)
|
||||
- CAST(string_expr AS CHAR)
|
||||
- CONVERT(expr USING cs)
|
||||
*/
|
||||
DERIVATION_CAST= 4,
|
||||
|
||||
/*
|
||||
utf8 metadata functions:
|
||||
- DATABASE()
|
||||
- CURRENT_ROLE()
|
||||
- USER()
|
||||
*/
|
||||
DERIVATION_SYSCONST= 3,
|
||||
|
||||
/*
|
||||
- Table columns
|
||||
- SP variables
|
||||
- BINARY(expr) and CAST(expr AS BINARY)
|
||||
*/
|
||||
DERIVATION_IMPLICIT= 2,
|
||||
DERIVATION_NONE= 1,
|
||||
DERIVATION_EXPLICIT= 0
|
||||
DERIVATION_NONE= 1, // A mix (e.g. CONCAT) of two differrent collations
|
||||
DERIVATION_EXPLICIT= 0 // An explicit COLLATE clause
|
||||
};
|
||||
|
||||
|
||||
@ -3079,6 +3112,12 @@ public:
|
||||
derivation(derivation_arg),
|
||||
repertoire(repertoire_arg)
|
||||
{ }
|
||||
static DTCollation string_typecast(CHARSET_INFO *collation_arg)
|
||||
{
|
||||
return DTCollation(collation_arg,
|
||||
collation_arg == &my_charset_bin ?
|
||||
DERIVATION_IMPLICIT : DERIVATION_CAST);
|
||||
}
|
||||
void set(const DTCollation &dt)
|
||||
{
|
||||
*this= dt;
|
||||
@ -3114,6 +3153,7 @@ public:
|
||||
case DERIVATION_NUMERIC: return "NUMERIC";
|
||||
case DERIVATION_IGNORABLE: return "IGNORABLE";
|
||||
case DERIVATION_COERCIBLE: return "COERCIBLE";
|
||||
case DERIVATION_CAST: return "CAST";
|
||||
case DERIVATION_IMPLICIT: return "IMPLICIT";
|
||||
case DERIVATION_SYSCONST: return "SYSCONST";
|
||||
case DERIVATION_EXPLICIT: return "EXPLICIT";
|
||||
|
Reference in New Issue
Block a user