mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-30164 System variable for default collations
This patch adds a way to override default collations (or "character set collations") for desired character sets. The SQL standard says: > Each collation known in an SQL-environment is applicable to one > or more character sets, and for each character set, one or more > collations are applicable to it, one of which is associated with > it as its character set collation. In MariaDB, character set collations has been hard-coded so far, e.g. utf8mb4_general_ci has been a hard-coded character set collation for utf8mb4. This patch allows to override (globally per server, or per session) character set collations, so for example, uca1400_ai_ci can be set as a character set collation for Unicode character sets (instead of compiled xxx_general_ci). The array of overridden character set collations is stored in a new (session and global) system variable @@character_set_collations and can be set as a comma separated list of charset=collation pairs, e.g.: SET @@character_set_collations='utf8mb3=uca1400_ai_ci,utf8mb4=uca1400_ai_ci'; The variable is empty by default, which mean use the hard-coded character set collations (e.g. utf8mb4_general_ci for utf8mb4). The variable can also be set globally by passing to the server startup command line, and/or in my.cnf.
This commit is contained in:
@ -2718,7 +2718,9 @@ Type_handler::Column_definition_set_attributes(THD *thd,
|
||||
column_definition_type_t type)
|
||||
const
|
||||
{
|
||||
def->set_charset_collation_attrs(attr.charset_collation_attrs());
|
||||
def->set_charset_collation_attrs(thd,
|
||||
thd->variables.character_set_collations,
|
||||
attr.charset_collation_attrs());
|
||||
def->set_length_and_dec(attr);
|
||||
return false;
|
||||
}
|
||||
@ -3026,7 +3028,9 @@ bool Type_handler_null::
|
||||
*derived_attr)
|
||||
const
|
||||
{
|
||||
def->prepare_charset_for_string(derived_attr);
|
||||
def->prepare_charset_for_string(thd,
|
||||
thd->variables.character_set_collations,
|
||||
derived_attr);
|
||||
def->create_length_to_internal_length_null();
|
||||
return false;
|
||||
}
|
||||
@ -3108,7 +3112,10 @@ bool Type_handler_typelib::
|
||||
*derived_attr)
|
||||
const
|
||||
{
|
||||
return def->prepare_charset_for_string(derived_attr) ||
|
||||
return def->prepare_charset_for_string(thd,
|
||||
thd->variables.
|
||||
character_set_collations,
|
||||
derived_attr) ||
|
||||
def->prepare_stage1_typelib(thd, mem_root, type);
|
||||
}
|
||||
|
||||
@ -3122,7 +3129,10 @@ bool Type_handler_string_result::
|
||||
*derived_attr)
|
||||
const
|
||||
{
|
||||
return def->prepare_charset_for_string(derived_attr) ||
|
||||
return def->prepare_charset_for_string(thd,
|
||||
thd->variables.
|
||||
character_set_collations,
|
||||
derived_attr) ||
|
||||
def->prepare_stage1_string(thd, mem_root);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user