2022-02-09 18:21:39 +01:00
|
|
|
/* Copyright (c) 2021, 2022, MariaDB Corporation.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
|
|
|
|
|
|
|
#ifndef LEX_CHARSET_INCLUDED
|
|
|
|
#define LEX_CHARSET_INCLUDED
|
|
|
|
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
#include "charset_collations.h"
|
2022-05-23 09:05:33 +02:00
|
|
|
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
/*
|
|
|
|
An extention for Charset_loader_mysys,
|
|
|
|
with server error and warning support.
|
|
|
|
*/
|
|
|
|
class Charset_loader_server: public Charset_loader_mysys
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Charset_loader_mysys::Charset_loader_mysys;
|
|
|
|
void raise_unknown_collation_error(const char *name) const;
|
|
|
|
void raise_not_applicable_error(const char *cs, const char *cl) const;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find an exact collation by name.
|
|
|
|
Raise an error on a faulure.
|
|
|
|
|
|
|
|
@param cs - the character set
|
|
|
|
@param collation_name - the collation name, e.g. "utf8_bin"
|
|
|
|
@param my_flags - my flags, e.g. MYF(WME)
|
|
|
|
@returns - a NULL pointer in case of failure, or
|
|
|
|
a CHARSET_INFO pointer on success.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CHARSET_INFO *
|
|
|
|
get_exact_collation_or_error(const char *name, myf my_flags= MYF(0))
|
|
|
|
{
|
|
|
|
CHARSET_INFO *ci= get_exact_collation(name, my_flags);
|
|
|
|
if (!ci)
|
|
|
|
raise_unknown_collation_error(name);
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find an exact collation by a character set and a
|
|
|
|
contextually typed collation name.
|
|
|
|
Raise an error on in case of a faulure.
|
|
|
|
|
|
|
|
@param cs - the character set
|
|
|
|
@param context_cl_name - the context name, e.g. "uca1400_cs_ci"
|
|
|
|
@param my_flags - my flags, e.g. MYF(WME)
|
|
|
|
@returns - a NULL pointer in case of failure, or
|
|
|
|
a CHARSET_INFO pointer on success.
|
|
|
|
*/
|
|
|
|
CHARSET_INFO *
|
|
|
|
get_exact_collation_by_context_name_or_error(CHARSET_INFO *cs,
|
|
|
|
const char *name,
|
|
|
|
myf my_flags= MYF(0))
|
|
|
|
{
|
|
|
|
CHARSET_INFO *ci= get_exact_collation_by_context_name(cs, name, my_flags);
|
|
|
|
if (!ci)
|
|
|
|
raise_not_applicable_error(cs->cs_name.str, name);
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find an abstract context collation by name.
|
|
|
|
Raise an error on a faulure.
|
|
|
|
The returned pointer needs to be resolved to a character set name.
|
|
|
|
It should not be passed directly to the character set routines.
|
|
|
|
|
|
|
|
@param cs - the character set
|
|
|
|
@param context_cl_name - the context name, e.g. "uca1400_cs_ci"
|
|
|
|
@param my_flags - my flags, e.g. MYF(WME)
|
|
|
|
@returns - a NULL pointer in case of failure, or
|
|
|
|
a CHARSET_INFO pointer on success.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CHARSET_INFO *
|
|
|
|
get_context_collation_or_error(const char *collation_name,
|
|
|
|
myf my_flags= MYF(0))
|
|
|
|
{
|
|
|
|
CHARSET_INFO *ci= get_context_collation(collation_name, my_flags);
|
|
|
|
if (!ci)
|
|
|
|
raise_unknown_collation_error(collation_name);
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find an exact binary collation in the given character set.
|
|
|
|
Raise an error on a faulure.
|
|
|
|
|
|
|
|
@param cs - the character set
|
|
|
|
@param my_flags - my flags, e.g. MYF(WME)
|
|
|
|
@returns - a NULL pointer in case of failure, or
|
|
|
|
a CHARSET_INFO pointer on success.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CHARSET_INFO *
|
|
|
|
get_bin_collation_or_error(CHARSET_INFO *cs,
|
|
|
|
myf my_flags= MYF(0))
|
|
|
|
{
|
|
|
|
const char *cs_name= cs->cs_name.str;
|
|
|
|
if (!(cs= get_bin_collation(cs, my_flags)))
|
|
|
|
{
|
|
|
|
char tmp[65];
|
|
|
|
strxnmov(tmp, sizeof(tmp)-1, cs_name, "_bin", NULL);
|
|
|
|
raise_unknown_collation_error(tmp);
|
|
|
|
}
|
|
|
|
return cs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Find an exact default collation in the given character set.
|
|
|
|
This routine does not fail.
|
|
|
|
Any character set must have a default collation.
|
|
|
|
|
|
|
|
@param cs - the character set
|
|
|
|
@param my_flags - my flags, e.g. MYF(WME)
|
|
|
|
@returns - a CHARSET_INFO pointer
|
|
|
|
*/
|
|
|
|
|
|
|
|
CHARSET_INFO *get_default_collation(CHARSET_INFO *cs,
|
|
|
|
myf my_flags= MYF(0))
|
|
|
|
{
|
|
|
|
return Charset_loader_mysys::get_default_collation(cs, my_flags);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-02-09 18:21:39 +01:00
|
|
|
/*
|
2022-05-23 09:05:33 +02:00
|
|
|
An exact character set, e.g:
|
|
|
|
CHARACTER SET latin1
|
|
|
|
*/
|
|
|
|
class Lex_exact_charset
|
|
|
|
{
|
|
|
|
CHARSET_INFO *m_ci;
|
|
|
|
public:
|
|
|
|
explicit Lex_exact_charset(CHARSET_INFO *ci)
|
|
|
|
:m_ci(ci)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(m_ci);
|
|
|
|
DBUG_ASSERT(m_ci->state & MY_CS_PRIMARY);
|
|
|
|
}
|
|
|
|
CHARSET_INFO *charset_info() const { return m_ci; }
|
|
|
|
bool raise_if_not_equal(const Lex_exact_charset &rhs) const;
|
|
|
|
bool raise_if_not_applicable(const class Lex_exact_collation &cl) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-17 10:52:23 +02:00
|
|
|
/*
|
|
|
|
An optional contextually typed character set:
|
|
|
|
[ CHARACTER SET DEFAULT ]
|
|
|
|
*/
|
|
|
|
class Lex_opt_context_charset_st
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Currently we support only DEFAULT as a possible value.
|
|
|
|
So "bool" is enough.
|
|
|
|
*/
|
|
|
|
bool m_had_charset_default;
|
|
|
|
public:
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
m_had_charset_default= false;
|
|
|
|
}
|
|
|
|
void merge_charset_default()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Ok to specify CHARACTER SET DEFAULT multiple times.
|
|
|
|
No error raised here.
|
|
|
|
*/
|
|
|
|
m_had_charset_default= true;
|
|
|
|
}
|
|
|
|
bool is_empty() const
|
|
|
|
{
|
|
|
|
return !m_had_charset_default;
|
|
|
|
}
|
|
|
|
bool is_contextually_typed_charset_default() const
|
|
|
|
{
|
|
|
|
return m_had_charset_default;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-23 09:05:33 +02:00
|
|
|
/*
|
|
|
|
A contextually typed collation, e.g.:
|
|
|
|
COLLATE DEFAULT
|
|
|
|
CHAR(10) BINARY
|
|
|
|
*/
|
|
|
|
class Lex_context_collation
|
|
|
|
{
|
|
|
|
CHARSET_INFO *m_ci;
|
|
|
|
public:
|
|
|
|
explicit Lex_context_collation(CHARSET_INFO *ci)
|
|
|
|
:m_ci(ci)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(ci);
|
|
|
|
}
|
|
|
|
CHARSET_INFO *charset_info() const { return m_ci; }
|
|
|
|
bool is_contextually_typed_collate_default() const
|
|
|
|
{
|
|
|
|
return m_ci == &my_collation_contextually_typed_default;
|
|
|
|
}
|
|
|
|
bool is_contextually_typed_binary_style() const
|
|
|
|
{
|
|
|
|
return m_ci == &my_collation_contextually_typed_binary;
|
|
|
|
}
|
|
|
|
bool raise_if_not_equal(const Lex_context_collation &cl) const;
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
/*
|
|
|
|
Skip the character set prefix, return the suffix.
|
|
|
|
utf8mb4_uca1400_as_ci -> uca1400_as_ci
|
|
|
|
*/
|
|
|
|
LEX_CSTRING collation_name_context_suffix() const
|
|
|
|
{
|
|
|
|
return m_ci->get_collation_name(MY_COLLATION_NAME_MODE_CONTEXT);
|
|
|
|
}
|
|
|
|
LEX_CSTRING collation_name_for_show() const;
|
2022-05-23 09:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
An exact collation, e.g.
|
|
|
|
COLLATE latin1_swedish_ci
|
|
|
|
*/
|
|
|
|
class Lex_exact_collation
|
|
|
|
{
|
|
|
|
CHARSET_INFO *m_ci;
|
|
|
|
public:
|
|
|
|
explicit Lex_exact_collation(CHARSET_INFO *ci)
|
|
|
|
:m_ci(ci)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(ci);
|
|
|
|
}
|
|
|
|
CHARSET_INFO *charset_info() const { return m_ci; }
|
|
|
|
// EXACT + EXACT
|
|
|
|
bool raise_if_not_equal(const Lex_exact_collation &cl) const;
|
|
|
|
// EXACT + CONTEXT
|
|
|
|
// CONTEXT + EXACT
|
|
|
|
bool raise_if_conflicts_with_context_collation(const Lex_context_collation &,
|
|
|
|
bool reverse_order) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Parse time COLLATE clause:
|
|
|
|
COLLATE colation_name
|
|
|
|
The collation can be either exact or contextual:
|
|
|
|
COLLATE latin1_bin
|
|
|
|
COLLATE DEFAULT
|
|
|
|
*/
|
|
|
|
class Lex_extended_collation_st
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TYPE_EXACT,
|
|
|
|
TYPE_CONTEXTUALLY_TYPED
|
|
|
|
};
|
|
|
|
protected:
|
|
|
|
CHARSET_INFO *m_ci;
|
|
|
|
Type m_type;
|
|
|
|
public:
|
|
|
|
void init(CHARSET_INFO *ci, Type type)
|
|
|
|
{
|
|
|
|
m_ci= ci;
|
|
|
|
m_type= type;
|
|
|
|
}
|
|
|
|
CHARSET_INFO *charset_info() const { return m_ci; }
|
|
|
|
Type type() const { return m_type; }
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
LEX_CSTRING collation_name_for_show() const
|
|
|
|
{
|
|
|
|
switch (m_type) {
|
|
|
|
case TYPE_CONTEXTUALLY_TYPED:
|
|
|
|
return Lex_context_collation(m_ci).collation_name_for_show();
|
|
|
|
case TYPE_EXACT:
|
|
|
|
return m_ci->coll_name;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return m_ci->coll_name;
|
|
|
|
}
|
2024-06-04 10:00:20 +02:00
|
|
|
static Lex_extended_collation_st collate_default()
|
|
|
|
{
|
|
|
|
Lex_extended_collation_st res;
|
|
|
|
res.set_collate_default();
|
|
|
|
return res;
|
|
|
|
}
|
2022-05-23 09:05:33 +02:00
|
|
|
void set_collate_default()
|
|
|
|
{
|
|
|
|
m_ci= &my_collation_contextually_typed_default;
|
|
|
|
m_type= TYPE_CONTEXTUALLY_TYPED;
|
|
|
|
}
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
bool set_by_name(const char *name, myf my_flags); // e.g. MY_UTF8_IS_UTF8MB3
|
2022-05-23 09:05:33 +02:00
|
|
|
bool raise_if_conflicts_with_context_collation(const Lex_context_collation &)
|
|
|
|
const;
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_exact_charset(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_exact_charset &rhs);
|
2022-05-23 09:05:33 +02:00
|
|
|
bool merge_exact_collation(const Lex_exact_collation &rhs);
|
|
|
|
bool merge(const Lex_extended_collation_st &rhs);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Lex_extended_collation: public Lex_extended_collation_st
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Lex_extended_collation(CHARSET_INFO *ci, Type type)
|
|
|
|
{
|
|
|
|
init(ci, type);
|
|
|
|
}
|
|
|
|
Lex_extended_collation(const Lex_exact_collation &rhs)
|
|
|
|
{
|
|
|
|
init(rhs.charset_info(), TYPE_EXACT);
|
|
|
|
}
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
Lex_extended_collation(const Lex_context_collation &rhs)
|
|
|
|
{
|
|
|
|
init(rhs.charset_info(), TYPE_CONTEXTUALLY_TYPED);
|
|
|
|
}
|
2022-05-23 09:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
CHARACTER SET cs_exact [COLLATE cl_exact_or_context]
|
|
|
|
*/
|
|
|
|
class Lex_exact_charset_opt_extended_collate
|
|
|
|
{
|
|
|
|
CHARSET_INFO *m_ci;
|
|
|
|
bool m_with_collate;
|
|
|
|
public:
|
|
|
|
Lex_exact_charset_opt_extended_collate(CHARSET_INFO *ci, bool with_collate)
|
|
|
|
:m_ci(ci), m_with_collate(with_collate)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(m_ci);
|
|
|
|
DBUG_ASSERT((m_ci->state & MY_CS_PRIMARY) || m_with_collate);
|
|
|
|
}
|
|
|
|
Lex_exact_charset_opt_extended_collate(const Lex_exact_charset &cs)
|
|
|
|
:m_ci(cs.charset_info()), m_with_collate(false)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(m_ci);
|
|
|
|
DBUG_ASSERT(m_ci->state & MY_CS_PRIMARY);
|
|
|
|
}
|
|
|
|
Lex_exact_charset_opt_extended_collate(const Lex_exact_collation &cl)
|
|
|
|
:m_ci(cl.charset_info()), m_with_collate(true)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(m_ci);
|
|
|
|
}
|
|
|
|
bool with_collate() const { return m_with_collate; }
|
|
|
|
CHARSET_INFO *find_bin_collation() const;
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
CHARSET_INFO *find_compiled_default_collation() const;
|
|
|
|
CHARSET_INFO *find_mapped_default_collation(
|
|
|
|
Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map) const;
|
2022-05-25 09:07:04 +02:00
|
|
|
bool raise_if_charsets_differ(const Lex_exact_charset &cs) const;
|
2022-05-23 09:05:33 +02:00
|
|
|
bool raise_if_not_applicable(const Lex_exact_collation &cl) const;
|
|
|
|
/*
|
|
|
|
Add another COLLATE clause (exact or context).
|
|
|
|
So the full syntax looks like:
|
|
|
|
CHARACTER SET cs [COLLATE cl] ... COLLATE cl2
|
|
|
|
*/
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_collation(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_extended_collation_st &cl)
|
2022-05-23 09:05:33 +02:00
|
|
|
{
|
|
|
|
switch (cl.type()) {
|
|
|
|
case Lex_extended_collation_st::TYPE_EXACT:
|
|
|
|
return merge_exact_collation(Lex_exact_collation(cl.charset_info()));
|
|
|
|
case Lex_extended_collation_st::TYPE_CONTEXTUALLY_TYPED:
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
return merge_context_collation(used, map,
|
|
|
|
Lex_context_collation(cl.charset_info()));
|
2022-05-23 09:05:33 +02:00
|
|
|
}
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return false;
|
|
|
|
}
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_collation_override(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_extended_collation_st &cl)
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
{
|
|
|
|
switch (cl.type()) {
|
|
|
|
case Lex_extended_collation_st::TYPE_EXACT:
|
|
|
|
return merge_exact_collation_override(
|
|
|
|
Lex_exact_collation(cl.charset_info()));
|
|
|
|
case Lex_extended_collation_st::TYPE_CONTEXTUALLY_TYPED:
|
|
|
|
return merge_context_collation_override(
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
used, map, Lex_context_collation(cl.charset_info()));
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
}
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return false;
|
|
|
|
}
|
2022-05-23 09:05:33 +02:00
|
|
|
/*
|
|
|
|
Add a context collation:
|
|
|
|
CHARACTER SET cs [COLLATE cl] ... COLLATE DEFAULT
|
|
|
|
*/
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_context_collation(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_context_collation &cl);
|
|
|
|
bool merge_context_collation_override(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_context_collation &cl);
|
2022-05-23 09:05:33 +02:00
|
|
|
/*
|
|
|
|
Add an exact collation:
|
|
|
|
CHARACTER SET cs [COLLATE cl] ... COLLATE latin1_bin
|
|
|
|
*/
|
|
|
|
bool merge_exact_collation(const Lex_exact_collation &cl);
|
MDEV-27009 Add UCA-14.0.0 collations
- Added one neutral and 22 tailored (language specific) collations based on
Unicode Collation Algorithm version 14.0.0.
Collations were added for Unicode character sets
utf8mb3, utf8mb4, ucs2, utf16, utf32.
Every tailoring was added with four accent and case
sensitivity flag combinations, e.g:
* utf8mb4_uca1400_swedish_as_cs
* utf8mb4_uca1400_swedish_as_ci
* utf8mb4_uca1400_swedish_ai_cs
* utf8mb4_uca1400_swedish_ai_ci
and their _nopad_ variants:
* utf8mb4_uca1400_swedish_nopad_as_cs
* utf8mb4_uca1400_swedish_nopad_as_ci
* utf8mb4_uca1400_swedish_nopad_ai_cs
* utf8mb4_uca1400_swedish_nopad_ai_ci
- Introducing a conception of contextually typed named collations:
CREATE DATABASE db1 CHARACTER SET utf8mb4;
CREATE TABLE db1.t1 (a CHAR(10) COLLATE uca1400_as_ci);
The idea is that there is no a need to specify the character set prefix
in the new collation names. It's enough to type just the suffix
"uca1400_as_ci". The character set is taken from the context.
In the above example script the context character set is utf8mb4.
So the CREATE TABLE will make a column with the collation
utf8mb4_uca1400_as_ci.
Short collations names can be used in any parts of the SQL syntax
where the COLLATE clause is understood.
- New collations are displayed only one time
(without character set combinations) by these statements:
SELECT * FROM INFORMATION_SCHEMA.COLLATIONS;
SHOW COLLATION;
For example, all these collations:
- utf8mb3_uca1400_swedish_as_ci
- utf8mb4_uca1400_swedish_as_ci
- ucs2_uca1400_swedish_as_ci
- utf16_uca1400_swedish_as_ci
- utf32_uca1400_swedish_as_ci
have just one entry in INFORMATION_SCHEMA.COLLATIONS and SHOW COLLATION,
with COLLATION_NAME equal to "uca1400_swedish_as_ci", which is the suffix
without the character set name:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+
| COLLATION_NAME |
+-----------------------+
| uca1400_swedish_as_ci |
+-----------------------+
Note, the behaviour of old collations did not change.
Non-unicode collations (e.g. latin1_swedish_ci) and
old UCA-4.0.0 collations (e.g. utf8mb4_unicode_ci)
are still displayed with the character set prefix, as before.
- The structure of the table INFORMATION_SCHEMA.COLLATIONS was changed.
The NOT NULL constraint was removed from these columns:
- CHARACTER_SET_NAME
- ID
- IS_DEFAULT
and from the corresponding columns in SHOW COLLATION.
For example:
SELECT COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATIONS
WHERE COLLATION_NAME LIKE '%uca1400_swedish_as_ci';
+-----------------------+--------------------+------+------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------+--------------------+------+------------+
| uca1400_swedish_as_ci | NULL | NULL | NULL |
+-----------------------+--------------------+------+------------+
The NULL value in these columns now means that the collation
is applicable to multiple character sets.
The behavioir of old collations did not change.
Make sure your client programs can handle NULL values in these columns.
- The structure of the table
INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY was changed.
Three new NOT NULL columns were added:
- FULL_COLLATION_NAME
- ID
- IS_DEFAULT
New collations have multiple entries in COLLATION_CHARACTER_SET_APPLICABILITY.
The column COLLATION_NAME contains the collation name without the character
set prefix. The column FULL_COLLATION_NAME contains the collation name with
the character set prefix.
Old collations have full collation name in both FULL_COLLATION_NAME and
COLLATION_NAME.
SELECT COLLATION_NAME, FULL_COLLATION_NAME, CHARACTER_SET_NAME, ID, IS_DEFAULT
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE FULL_COLLATION_NAME RLIKE '^(utf8mb4|latin1).*swedish.*ci$';
+-----------------------------+-------------------------------------+--------------------+------+------------+
| COLLATION_NAME | FULL_COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT |
+-----------------------------+-------------------------------------+--------------------+------+------------+
| latin1_swedish_ci | latin1_swedish_ci | latin1 | 8 | Yes |
| latin1_swedish_nopad_ci | latin1_swedish_nopad_ci | latin1 | 1032 | |
| utf8mb4_swedish_ci | utf8mb4_swedish_ci | utf8mb4 | 232 | |
| uca1400_swedish_ai_ci | utf8mb4_uca1400_swedish_ai_ci | utf8mb4 | 2368 | |
| uca1400_swedish_as_ci | utf8mb4_uca1400_swedish_as_ci | utf8mb4 | 2370 | |
| uca1400_swedish_nopad_ai_ci | utf8mb4_uca1400_swedish_nopad_ai_ci | utf8mb4 | 2372 | |
| uca1400_swedish_nopad_as_ci | utf8mb4_uca1400_swedish_nopad_as_ci | utf8mb4 | 2374 | |
+-----------------------------+-------------------------------------+--------------------+------+------------+
- Other INFORMATION_SCHEMA queries:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.PARAMETERS;
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES;
SELECT DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.EVENTS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.EVENTS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.ROUTINES;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT DATABASE_COLLATION FROM INFORMATION_SCHEMA.TRIGGERS;
SELECT COLLATION_CONNECTION FROM INFORMATION_SCHEMA.VIEWS;
display full collation names, including character sets prefix,
for all collations, including new collations.
Corresponding SHOW commands also display full collation names
in collation related columns:
SHOW CREATE TABLE t1;
SHOW CREATE DATABASE db1;
SHOW TABLE STATUS;
SHOW CREATE FUNCTION f1;
SHOW CREATE PROCEDURE p1;
SHOW CREATE EVENT ev1;
SHOW CREATE TRIGGER tr1;
SHOW CREATE VIEW;
These INFORMATION_SCHEMA queries and SHOW statements may change in
the future, to display show collation names.
2021-11-28 13:55:15 +01:00
|
|
|
bool merge_exact_collation_override(const Lex_exact_collation &cl);
|
2022-05-23 09:05:33 +02:00
|
|
|
Lex_exact_collation collation() const
|
|
|
|
{
|
|
|
|
return Lex_exact_collation(m_ci);
|
|
|
|
}
|
|
|
|
Lex_exact_charset charset() const
|
|
|
|
{
|
|
|
|
if ((m_ci->state & MY_CS_PRIMARY))
|
|
|
|
return Lex_exact_charset(m_ci);
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
return Lex_exact_charset(find_compiled_default_collation());
|
2022-05-23 09:05:33 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Parse time character set and collation for:
|
|
|
|
[CHARACTER SET cs_exact] [COLLATE cl_exact_or_context]
|
2022-02-09 18:21:39 +01:00
|
|
|
|
|
|
|
Can be:
|
|
|
|
|
|
|
|
1. Empty (not specified on the column level):
|
|
|
|
CREATE TABLE t1 (a CHAR(10)) CHARACTER SET latin2; -- (1a)
|
|
|
|
CREATE TABLE t1 (a CHAR(10)); -- (1b)
|
|
|
|
|
|
|
|
2. Precisely typed:
|
|
|
|
CREATE TABLE t1 (a CHAR(10) COLLATE latin1_bin); -- (2a)
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a CHAR(10) CHARACTER SET latin1 COLLATE latin1_bin); -- (2b)
|
|
|
|
|
|
|
|
3. Contextually typed:
|
|
|
|
CREATE TABLE t2 (a CHAR(10) BINARY) CHARACTER SET latin2; -- (3a)
|
|
|
|
CREATE TABLE t2 (a CHAR(10) BINARY); -- (3b)
|
|
|
|
CREATE TABLE t2 (a CHAR(10) COLLATE DEFAULT)
|
|
|
|
CHARACER SET latin2 COLLATE latin2_bin; -- (3c)
|
|
|
|
|
|
|
|
In case of an empty or a contextually typed collation,
|
|
|
|
it is a subject to later resolution, when the context
|
|
|
|
character set becomes known in the end of the CREATE statement:
|
|
|
|
- either after the explicit table level CHARACTER SET, like in (1a,3a,3c)
|
|
|
|
- or by the inhereted database level CHARACTER SET, like in (1b,3b)
|
|
|
|
|
|
|
|
Resolution happens in Type_handler::Column_definition_prepare_stage1().
|
|
|
|
*/
|
2022-05-23 06:40:26 +02:00
|
|
|
struct Lex_exact_charset_extended_collation_attrs_st
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TYPE_EMPTY= 0,
|
|
|
|
TYPE_CHARACTER_SET= 1,
|
|
|
|
TYPE_COLLATE_EXACT= 2,
|
2022-05-25 09:07:04 +02:00
|
|
|
TYPE_CHARACTER_SET_COLLATE_EXACT= 3,
|
|
|
|
TYPE_COLLATE_CONTEXTUALLY_TYPED= 4
|
2022-02-09 18:21:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Number of bits required to store enum Type values
|
|
|
|
|
2022-05-25 09:07:04 +02:00
|
|
|
#define LEX_CHARSET_COLLATION_TYPE_BITS 3
|
|
|
|
#define LEX_CHARSET_COLLATION_TYPE_MASK ((1<<LEX_CHARSET_COLLATION_TYPE_BITS)-1)
|
|
|
|
|
|
|
|
static_assert(LEX_CHARSET_COLLATION_TYPE_MASK >=
|
|
|
|
TYPE_COLLATE_CONTEXTUALLY_TYPED,
|
2022-05-23 06:40:26 +02:00
|
|
|
"Lex_exact_charset_extended_collation_attrs_st::Type bits");
|
2022-02-09 18:21:39 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CHARSET_INFO *m_ci;
|
|
|
|
Type m_type;
|
2022-05-23 09:05:33 +02:00
|
|
|
protected:
|
|
|
|
static Type type_from_lex_collation_type(Lex_extended_collation_st::Type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case Lex_extended_collation_st::TYPE_EXACT:
|
|
|
|
return TYPE_COLLATE_EXACT;
|
|
|
|
case Lex_extended_collation_st::TYPE_CONTEXTUALLY_TYPED:
|
|
|
|
return TYPE_COLLATE_CONTEXTUALLY_TYPED;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return TYPE_COLLATE_EXACT;
|
|
|
|
}
|
2022-02-09 18:21:39 +01:00
|
|
|
public:
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
m_ci= NULL;
|
|
|
|
m_type= TYPE_EMPTY;
|
|
|
|
}
|
2022-05-23 06:40:26 +02:00
|
|
|
void init(CHARSET_INFO *cs, Type type)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(cs || type == TYPE_EMPTY);
|
|
|
|
m_ci= cs;
|
|
|
|
m_type= type;
|
|
|
|
}
|
2022-05-23 09:05:33 +02:00
|
|
|
void init(const Lex_exact_charset &cs)
|
|
|
|
{
|
|
|
|
m_ci= cs.charset_info();
|
|
|
|
m_type= TYPE_CHARACTER_SET;
|
|
|
|
}
|
|
|
|
void init(const Lex_exact_collation &cs)
|
|
|
|
{
|
|
|
|
m_ci= cs.charset_info();
|
|
|
|
m_type= TYPE_COLLATE_EXACT;
|
|
|
|
}
|
|
|
|
void init(const Lex_exact_charset_opt_extended_collate &cscl)
|
|
|
|
{
|
2022-05-25 09:07:04 +02:00
|
|
|
if (cscl.with_collate())
|
|
|
|
init(cscl.collation().charset_info(), TYPE_CHARACTER_SET_COLLATE_EXACT);
|
|
|
|
else
|
|
|
|
init(cscl.charset());
|
2022-05-23 09:05:33 +02:00
|
|
|
}
|
2022-02-09 18:21:39 +01:00
|
|
|
bool is_empty() const
|
|
|
|
{
|
|
|
|
return m_type == TYPE_EMPTY;
|
|
|
|
}
|
2022-05-25 09:07:04 +02:00
|
|
|
void set_charset(const Lex_exact_charset &cs)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
2022-05-25 09:07:04 +02:00
|
|
|
m_ci= cs.charset_info();
|
2022-02-09 18:21:39 +01:00
|
|
|
m_type= TYPE_CHARACTER_SET;
|
|
|
|
}
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool set_charset_collate_default(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_exact_charset &cs)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
2022-05-25 09:07:04 +02:00
|
|
|
CHARSET_INFO *ci;
|
|
|
|
if (!(ci= Lex_exact_charset_opt_extended_collate(cs).
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
find_mapped_default_collation(used, map)))
|
2022-05-23 09:05:33 +02:00
|
|
|
return true;
|
2022-05-25 09:07:04 +02:00
|
|
|
m_ci= ci;
|
|
|
|
m_type= TYPE_CHARACTER_SET_COLLATE_EXACT;
|
2022-05-23 09:05:33 +02:00
|
|
|
return false;
|
2022-02-09 18:21:39 +01:00
|
|
|
}
|
2022-05-25 09:07:04 +02:00
|
|
|
bool set_charset_collate_binary(const Lex_exact_charset &cs)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
2022-05-25 09:07:04 +02:00
|
|
|
CHARSET_INFO *ci;
|
|
|
|
if (!(ci= Lex_exact_charset_opt_extended_collate(cs).find_bin_collation()))
|
2022-02-09 18:21:39 +01:00
|
|
|
return true;
|
2022-05-25 09:07:04 +02:00
|
|
|
m_ci= ci;
|
|
|
|
m_type= TYPE_CHARACTER_SET_COLLATE_EXACT;
|
2022-02-09 18:21:39 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void set_collate_default()
|
|
|
|
{
|
|
|
|
m_ci= &my_collation_contextually_typed_default;
|
|
|
|
m_type= TYPE_COLLATE_CONTEXTUALLY_TYPED;
|
|
|
|
}
|
|
|
|
void set_contextually_typed_binary_style()
|
|
|
|
{
|
|
|
|
m_ci= &my_collation_contextually_typed_binary;
|
|
|
|
m_type= TYPE_COLLATE_CONTEXTUALLY_TYPED;
|
|
|
|
}
|
|
|
|
bool is_contextually_typed_collate_default() const
|
|
|
|
{
|
2022-05-23 09:05:33 +02:00
|
|
|
return Lex_context_collation(m_ci).is_contextually_typed_collate_default();
|
2022-02-09 18:21:39 +01:00
|
|
|
}
|
2022-05-23 06:40:26 +02:00
|
|
|
CHARSET_INFO *charset_info() const
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
|
|
|
return m_ci;
|
|
|
|
}
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
CHARSET_INFO *charset_info(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map) const
|
|
|
|
{
|
|
|
|
switch (m_type)
|
|
|
|
{
|
|
|
|
case TYPE_CHARACTER_SET:
|
|
|
|
return map.get_collation_for_charset(used, m_ci);
|
|
|
|
case TYPE_EMPTY:
|
|
|
|
case TYPE_CHARACTER_SET_COLLATE_EXACT:
|
|
|
|
case TYPE_COLLATE_CONTEXTUALLY_TYPED:
|
|
|
|
case TYPE_COLLATE_EXACT:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return m_ci;
|
|
|
|
}
|
2022-02-09 18:21:39 +01:00
|
|
|
Type type() const
|
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
|
|
|
bool is_contextually_typed_collation() const
|
|
|
|
{
|
|
|
|
return m_type == TYPE_COLLATE_CONTEXTUALLY_TYPED;
|
|
|
|
}
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
CHARSET_INFO *resolved_to_character_set(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
CHARSET_INFO *cs) const;
|
2022-05-23 09:05:33 +02:00
|
|
|
/*
|
|
|
|
Merge the column CHARACTER SET clause to:
|
|
|
|
- an exact collation name
|
|
|
|
- a contextually typed collation
|
|
|
|
"this" corresponds to `CHARACTER SET xxx [BINARY]`
|
|
|
|
"cl" corresponds to the COLLATE clause
|
|
|
|
*/
|
|
|
|
bool merge_column_charset_clause_and_collate_clause(
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
2022-05-23 09:05:33 +02:00
|
|
|
const Lex_exact_charset_extended_collation_attrs_st &cl)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
2022-05-23 09:05:33 +02:00
|
|
|
switch (cl.type()) {
|
|
|
|
case TYPE_EMPTY:
|
|
|
|
return false;
|
|
|
|
case TYPE_COLLATE_EXACT:
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
return merge_exact_collation(Lex_exact_collation(cl.m_ci));
|
2022-05-23 09:05:33 +02:00
|
|
|
case TYPE_COLLATE_CONTEXTUALLY_TYPED:
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
return merge_context_collation(used, map, Lex_context_collation(cl.m_ci));
|
2022-05-23 09:05:33 +02:00
|
|
|
case TYPE_CHARACTER_SET:
|
2022-05-25 09:07:04 +02:00
|
|
|
case TYPE_CHARACTER_SET_COLLATE_EXACT:
|
2022-05-23 09:05:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return false;
|
2022-02-09 18:21:39 +01:00
|
|
|
}
|
|
|
|
/*
|
2022-05-23 09:05:33 +02:00
|
|
|
This method is used in the "attribute_list" rule to merge two independent
|
|
|
|
COLLATE clauses (not belonging to a CHARACTER SET clause).
|
|
|
|
"BINARY" and "COLLATE DEFAULT" are not possible
|
|
|
|
in an independent COLLATE clause in a column attribute.
|
2022-02-09 18:21:39 +01:00
|
|
|
*/
|
2022-05-23 09:05:33 +02:00
|
|
|
bool merge_column_collate_clause_and_collate_clause(
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
2022-05-23 09:05:33 +02:00
|
|
|
const Lex_exact_charset_extended_collation_attrs_st &cl)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
2022-05-23 09:05:33 +02:00
|
|
|
DBUG_ASSERT(m_type != TYPE_CHARACTER_SET);
|
|
|
|
switch (cl.type()) {
|
|
|
|
case TYPE_EMPTY:
|
2022-02-09 18:21:39 +01:00
|
|
|
return false;
|
2022-05-23 09:05:33 +02:00
|
|
|
case TYPE_COLLATE_EXACT:
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
return merge_exact_collation(Lex_exact_collation(cl.m_ci));
|
2022-05-23 09:05:33 +02:00
|
|
|
case TYPE_COLLATE_CONTEXTUALLY_TYPED:
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
return merge_context_collation(used, map, Lex_context_collation(cl.m_ci));
|
2022-05-23 09:05:33 +02:00
|
|
|
case TYPE_CHARACTER_SET:
|
2022-05-25 09:07:04 +02:00
|
|
|
case TYPE_CHARACTER_SET_COLLATE_EXACT:
|
2022-05-23 09:05:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return false;
|
2022-02-09 18:21:39 +01: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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_exact_charset(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_exact_charset &cs);
|
2022-05-23 09:05:33 +02:00
|
|
|
bool merge_exact_collation(const Lex_exact_collation &cl);
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_context_collation(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_context_collation &cl);
|
|
|
|
bool merge_collation(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_extended_collation_st &cl);
|
2022-02-09 18:21:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-17 10:52:23 +02:00
|
|
|
class Charset_collation_context
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Although the goal of m_charset_default is to store the meaning
|
|
|
|
of CHARACTER SET DEFAULT, it does not necessarily point to a
|
|
|
|
default collation of CHARACTER SET DEFAULT. It can point to its any
|
|
|
|
arbitrary collation.
|
|
|
|
For performance purposes we don't need to find the default
|
|
|
|
collation at the instantiation time of "this", because:
|
|
|
|
- m_charset_default may not be even needed during the resolution
|
|
|
|
- when it's needed, in many cases it's passed to my_charset_same(),
|
|
|
|
which does not need the default collation again.
|
|
|
|
|
|
|
|
Note, m_charset_default and m_collate_default are not necessarily equal.
|
|
|
|
|
|
|
|
- The default value for CHARACTER SET is taken from the upper level:
|
|
|
|
CREATE DATABASE db1 CHARACTER SET DEFAULT; <-- @@character_set_server
|
|
|
|
ALTER DATABASE db1 CHARACTER SET DEFAULT; <-- @@character_set_server
|
|
|
|
|
|
|
|
- The default value for COLLATE is taken from the upper level for CREATE:
|
|
|
|
CREATE DATABASE db1 COLLATE DEFAULT; <-- @@collation_server
|
|
|
|
CREATE TABLE db1.t1 COLLATE DEFAULT; <-- character set of "db1"
|
|
|
|
|
|
|
|
- The default value for COLLATE is taken from the same level for ALTER:
|
|
|
|
ALTER DATABASE db1 COLLATE DEFAULT; <-- the default collation of the
|
|
|
|
current db1 character set
|
|
|
|
ALTER TABLE db1.t1 COLLATE DEFAULT; <-- the default collation of the
|
|
|
|
current db1.t1 character set
|
|
|
|
*/
|
|
|
|
|
|
|
|
// comes from the upper level
|
|
|
|
Lex_exact_charset_opt_extended_collate m_charset_default;
|
|
|
|
|
|
|
|
// comes from the upper or the current level
|
|
|
|
Lex_exact_collation m_collate_default;
|
|
|
|
public:
|
|
|
|
Charset_collation_context(CHARSET_INFO *charset_default,
|
|
|
|
CHARSET_INFO *collate_default)
|
|
|
|
:m_charset_default(charset_default,
|
|
|
|
!(charset_default->state & MY_CS_PRIMARY)),
|
|
|
|
m_collate_default(collate_default)
|
|
|
|
{ }
|
|
|
|
const Lex_exact_charset_opt_extended_collate charset_default() const
|
|
|
|
{
|
|
|
|
return m_charset_default;
|
|
|
|
}
|
|
|
|
const Lex_exact_collation collate_default() const
|
|
|
|
{
|
|
|
|
return m_collate_default;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
A universal container. It can store at the same time:
|
|
|
|
- CHARACTER SET DEFAULT
|
|
|
|
- CHARACTER SET cs_exact
|
|
|
|
- COLLATE {cl_exact|cl_context}
|
|
|
|
All three parts can co-exist.
|
|
|
|
All three parts are optional.
|
|
|
|
Parts can come in any arbitrary order, e.g:
|
|
|
|
|
|
|
|
CHARACTER SET DEFAULT [CHARACTER SET latin1] COLLATE latin1_bin
|
|
|
|
CHARACTER SET latin1 CHARACTER SET DEFAULT COLLATE latin1_bin
|
|
|
|
COLLATE latin1_bin [CHARACTER SET latin1] CHARACTER SET DEFAULT
|
|
|
|
COLLATE latin1_bin CHARACTER SET DEFAULT [CHARACTER SET latin1]
|
|
|
|
*/
|
|
|
|
class Lex_extended_charset_extended_collation_attrs_st:
|
|
|
|
public Lex_opt_context_charset_st,
|
|
|
|
public Lex_exact_charset_extended_collation_attrs_st
|
|
|
|
{
|
|
|
|
enum charset_type_t
|
|
|
|
{
|
|
|
|
CHARSET_TYPE_EMPTY,
|
|
|
|
CHARSET_TYPE_CONTEXT,
|
|
|
|
CHARSET_TYPE_EXACT
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
Which part came first:
|
|
|
|
- CHARACTER SET DEFAULT or
|
|
|
|
- CHARACTER SET cs_exact
|
|
|
|
e.g. to produce error messages preserving the user typed
|
|
|
|
order of CHARACTER SET clauses in case of conflicts.
|
|
|
|
*/
|
|
|
|
charset_type_t m_charset_order;
|
|
|
|
public:
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
Lex_opt_context_charset_st::init();
|
|
|
|
Lex_exact_charset_extended_collation_attrs_st::init();
|
|
|
|
m_charset_order= CHARSET_TYPE_EMPTY;
|
|
|
|
}
|
|
|
|
void init(const Lex_exact_charset_opt_extended_collate &c)
|
|
|
|
{
|
|
|
|
Lex_opt_context_charset_st::init();
|
|
|
|
Lex_exact_charset_extended_collation_attrs_st::init(c);
|
|
|
|
m_charset_order= CHARSET_TYPE_EXACT;
|
|
|
|
}
|
|
|
|
bool is_empty() const
|
|
|
|
{
|
|
|
|
return Lex_opt_context_charset_st::is_empty() &&
|
|
|
|
Lex_exact_charset_extended_collation_attrs_st::is_empty();
|
|
|
|
}
|
|
|
|
bool raise_if_charset_conflicts_with_default(
|
|
|
|
const Lex_exact_charset_opt_extended_collate &def) const;
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
CHARSET_INFO *resolved_to_context(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Charset_collation_context &ctx) const;
|
2022-05-17 10:52:23 +02:00
|
|
|
bool merge_charset_default();
|
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.
2022-12-14 15:46:27 +01:00
|
|
|
bool merge_exact_charset(Sql_used *used,
|
|
|
|
const Charset_collation_map_st &map,
|
|
|
|
const Lex_exact_charset &cs);
|
2022-05-17 10:52:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-23 06:40:26 +02:00
|
|
|
class Lex_exact_charset_extended_collation_attrs:
|
|
|
|
public Lex_exact_charset_extended_collation_attrs_st
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
|
|
|
public:
|
2022-05-23 06:40:26 +02:00
|
|
|
Lex_exact_charset_extended_collation_attrs()
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2022-05-23 06:40:26 +02:00
|
|
|
Lex_exact_charset_extended_collation_attrs(CHARSET_INFO *collation, Type type)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
2022-05-23 06:40:26 +02:00
|
|
|
init(collation, type);
|
2022-02-09 18:21:39 +01:00
|
|
|
}
|
2022-05-23 09:05:33 +02:00
|
|
|
explicit
|
|
|
|
Lex_exact_charset_extended_collation_attrs(const Lex_exact_charset &cs)
|
|
|
|
{
|
|
|
|
init(cs.charset_info(), TYPE_CHARACTER_SET);
|
|
|
|
}
|
|
|
|
explicit
|
|
|
|
Lex_exact_charset_extended_collation_attrs(const Lex_exact_collation &cl)
|
|
|
|
{
|
|
|
|
init(cl.charset_info(), TYPE_COLLATE_EXACT);
|
|
|
|
}
|
|
|
|
explicit
|
|
|
|
Lex_exact_charset_extended_collation_attrs(const Lex_context_collation &cl)
|
|
|
|
{
|
|
|
|
init(cl.charset_info(), TYPE_COLLATE_CONTEXTUALLY_TYPED);
|
|
|
|
}
|
|
|
|
explicit
|
|
|
|
Lex_exact_charset_extended_collation_attrs(
|
|
|
|
const Lex_exact_charset_opt_extended_collate &cscl)
|
|
|
|
{
|
|
|
|
init(cscl);
|
|
|
|
}
|
|
|
|
explicit
|
|
|
|
Lex_exact_charset_extended_collation_attrs(const Lex_extended_collation_st &cl)
|
|
|
|
{
|
|
|
|
init(cl.charset_info(), type_from_lex_collation_type(cl.type()));
|
|
|
|
}
|
2022-05-23 06:40:26 +02:00
|
|
|
static Lex_exact_charset_extended_collation_attrs national(bool bin_mod)
|
2022-02-09 18:21:39 +01:00
|
|
|
{
|
|
|
|
return bin_mod ?
|
2022-05-23 06:40:26 +02:00
|
|
|
Lex_exact_charset_extended_collation_attrs(&my_charset_utf8mb3_bin,
|
|
|
|
TYPE_COLLATE_EXACT) :
|
|
|
|
Lex_exact_charset_extended_collation_attrs(&my_charset_utf8mb3_general_ci,
|
|
|
|
TYPE_CHARACTER_SET);
|
2022-02-09 18:21:39 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-17 10:52:23 +02:00
|
|
|
class Lex_extended_charset_extended_collation_attrs:
|
|
|
|
public Lex_extended_charset_extended_collation_attrs_st
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Lex_extended_charset_extended_collation_attrs()
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
explicit Lex_extended_charset_extended_collation_attrs(
|
|
|
|
const Lex_exact_charset_opt_extended_collate &c)
|
|
|
|
{
|
|
|
|
init(c);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-23 06:40:26 +02:00
|
|
|
using Lex_column_charset_collation_attrs_st =
|
|
|
|
Lex_exact_charset_extended_collation_attrs_st;
|
|
|
|
|
|
|
|
using Lex_column_charset_collation_attrs =
|
|
|
|
Lex_exact_charset_extended_collation_attrs;
|
2022-05-22 19:25:31 +02:00
|
|
|
|
|
|
|
|
2022-05-17 10:52:23 +02:00
|
|
|
using Lex_table_charset_collation_attrs_st =
|
|
|
|
Lex_extended_charset_extended_collation_attrs_st;
|
|
|
|
|
|
|
|
using Lex_table_charset_collation_attrs =
|
|
|
|
Lex_extended_charset_extended_collation_attrs;
|
|
|
|
|
|
|
|
|
2022-02-09 18:21:39 +01:00
|
|
|
#endif // LEX_CHARSET_INCLUDED
|