2019-06-16 05:51:59 +02:00
|
|
|
#ifndef SQL_I_S_INCLUDED
|
|
|
|
#define SQL_I_S_INCLUDED
|
|
|
|
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
|
|
|
|
Copyright (c) 2009, 2019, MariaDB
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
#include "sql_const.h" // MAX_FIELD_VARCHARLENGTH
|
|
|
|
#include "sql_basic_types.h" // enum_nullability
|
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
|
|
|
#include "sql_string.h" // strlen, MY_CS_CHARACTER_SET_NAME_SIZE
|
2019-06-16 05:51:59 +02:00
|
|
|
#include "lex_string.h" // LEX_CSTRING
|
|
|
|
#include "mysql_com.h" // enum_field_types
|
|
|
|
#include "my_time.h" // TIME_SECOND_PART_DIGITS
|
2019-06-22 07:15:37 +02:00
|
|
|
#include "sql_type.h" // Type_handler_xxx
|
2019-06-16 05:51:59 +02:00
|
|
|
|
|
|
|
struct TABLE_LIST;
|
|
|
|
struct TABLE;
|
|
|
|
typedef class Item COND;
|
|
|
|
|
|
|
|
#ifdef MYSQL_CLIENT
|
|
|
|
#error MYSQL_CLIENT must not be defined
|
|
|
|
#endif // MYSQL_CLIENT
|
|
|
|
|
|
|
|
|
|
|
|
bool schema_table_store_record(THD *thd, TABLE *table);
|
|
|
|
COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table);
|
|
|
|
|
|
|
|
|
|
|
|
enum enum_show_open_table
|
|
|
|
{
|
|
|
|
SKIP_OPEN_TABLE= 0U, // do not open table
|
|
|
|
OPEN_FRM_ONLY= 1U, // open FRM file only
|
|
|
|
OPEN_FULL_TABLE= 2U // open FRM,MYD, MYI files
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-06-22 07:15:37 +02:00
|
|
|
namespace Show {
|
|
|
|
class Type
|
2019-06-16 05:51:59 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
This denotes data type for the column. For the most part, there seems to
|
|
|
|
be one entry in the enum for each SQL data type, although there seem to
|
|
|
|
be a number of additional entries in the enum.
|
|
|
|
*/
|
2019-06-22 07:15:37 +02:00
|
|
|
const Type_handler *m_type_handler;
|
2019-06-16 05:51:59 +02:00
|
|
|
/**
|
2019-06-22 07:15:37 +02:00
|
|
|
For string-type columns, this is the maximum number of
|
|
|
|
characters. Otherwise, it is the 'display-length' for the column.
|
2019-06-16 05:51:59 +02:00
|
|
|
*/
|
2019-06-22 07:15:37 +02:00
|
|
|
uint m_char_length;
|
|
|
|
uint m_unsigned_flag;
|
2019-06-26 04:46:55 +02:00
|
|
|
const Typelib *m_typelib;
|
2019-06-22 07:15:37 +02:00
|
|
|
public:
|
2019-06-26 04:46:55 +02:00
|
|
|
Type(const Type_handler *th, uint length, uint unsigned_flag,
|
|
|
|
const Typelib *typelib= NULL)
|
|
|
|
:m_type_handler(th), m_char_length(length), m_unsigned_flag(unsigned_flag),
|
|
|
|
m_typelib(typelib)
|
2019-06-22 07:15:37 +02:00
|
|
|
{ }
|
|
|
|
const Type_handler *type_handler() const { return m_type_handler; }
|
|
|
|
uint char_length() const { return m_char_length; }
|
2020-08-27 11:24:32 +02:00
|
|
|
decimal_digits_t decimal_precision() const
|
|
|
|
{ return (decimal_digits_t) ((m_char_length / 100) % 100); }
|
|
|
|
decimal_digits_t decimal_scale() const
|
|
|
|
{ return (decimal_digits_t) (m_char_length % 10); }
|
2019-06-16 05:51:59 +02:00
|
|
|
uint fsp() const
|
|
|
|
{
|
2019-06-22 07:15:37 +02:00
|
|
|
DBUG_ASSERT(m_char_length <= TIME_SECOND_PART_DIGITS);
|
|
|
|
return m_char_length;
|
2019-06-16 05:51:59 +02:00
|
|
|
}
|
2019-06-22 07:15:37 +02:00
|
|
|
uint unsigned_flag() const { return m_unsigned_flag; }
|
2019-06-26 04:46:55 +02:00
|
|
|
const Typelib *typelib() const { return m_typelib; }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
2019-06-22 07:15:37 +02:00
|
|
|
} // namespace Show
|
2019-06-16 05:51:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-22 07:15:37 +02:00
|
|
|
class ST_FIELD_INFO: public Show::Type
|
2019-06-16 05:51:59 +02:00
|
|
|
{
|
2019-06-22 07:15:37 +02:00
|
|
|
protected:
|
2023-04-26 13:27:01 +02:00
|
|
|
Lex_ident_column m_name; // I_S column name
|
2019-06-22 07:15:37 +02:00
|
|
|
enum_nullability m_nullability; // NULLABLE or NOT NULL
|
2023-04-26 13:27:01 +02:00
|
|
|
Lex_ident_column m_old_name; // SHOW column name
|
2019-06-22 07:15:37 +02:00
|
|
|
enum_show_open_table m_open_method;
|
2019-06-16 05:51:59 +02:00
|
|
|
public:
|
2023-04-26 13:27:01 +02:00
|
|
|
ST_FIELD_INFO(const Lex_ident_column &name, const Type &type,
|
2019-06-22 07:15:37 +02:00
|
|
|
enum_nullability nullability,
|
2023-04-26 13:27:01 +02:00
|
|
|
const Lex_ident_column &old_name,
|
2019-06-22 07:15:37 +02:00
|
|
|
enum_show_open_table open_method)
|
2020-01-21 11:27:17 +01:00
|
|
|
:Type(type), m_name(name),
|
|
|
|
m_nullability(nullability),
|
|
|
|
m_old_name(old_name),
|
2019-06-22 07:15:37 +02:00
|
|
|
m_open_method(open_method)
|
2019-06-16 05:51:59 +02:00
|
|
|
{ }
|
2019-06-22 07:15:37 +02:00
|
|
|
ST_FIELD_INFO(const char *name, const Type &type,
|
|
|
|
enum_nullability nullability,
|
|
|
|
const char *old_name,
|
|
|
|
enum_show_open_table open_method)
|
2023-04-26 13:27:01 +02:00
|
|
|
:Type(type), m_name(Lex_cstring_strlen(name)),
|
2020-01-21 11:27:17 +01:00
|
|
|
m_nullability(nullability),
|
2023-04-26 13:27:01 +02:00
|
|
|
m_old_name(Lex_cstring_strlen(old_name)),
|
2020-01-21 11:27:17 +01:00
|
|
|
m_open_method(open_method)
|
2023-04-26 13:27:01 +02:00
|
|
|
{ }
|
|
|
|
const Lex_ident_column &name() const { return m_name; }
|
2019-06-22 07:15:37 +02:00
|
|
|
bool nullable() const { return m_nullability == NULLABLE; }
|
2023-04-26 13:27:01 +02:00
|
|
|
const Lex_ident_column &old_name() const { return m_old_name; }
|
2019-06-22 07:15:37 +02:00
|
|
|
enum_show_open_table open_method() const { return m_open_method; }
|
|
|
|
bool end_marker() const { return m_name.str == NULL; }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-06-22 07:15:37 +02:00
|
|
|
namespace Show
|
|
|
|
{
|
|
|
|
|
2019-06-26 04:46:55 +02:00
|
|
|
|
|
|
|
class Enum: public Type
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Enum(const Typelib *typelib) :Type(&type_handler_enum, 0, false, typelib) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-06-16 05:51:59 +02:00
|
|
|
class Blob: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Blob(uint length) :Type(&type_handler_blob, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Varchar: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Varchar(uint length) :Type(&type_handler_varchar, length, false)
|
2019-06-16 05:51:59 +02:00
|
|
|
{
|
|
|
|
DBUG_ASSERT(length * 3 <= MAX_FIELD_VARCHARLENGTH);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Longtext: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Longtext(uint length) :Type(&type_handler_varchar, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-04-28 09:23:12 +02:00
|
|
|
class Yes_or_empty: public Varchar
|
2019-06-16 05:51:59 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-04-28 09:23:12 +02:00
|
|
|
Yes_or_empty(): Varchar(3) { }
|
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
|
|
|
static LEX_CSTRING value(bool val)
|
|
|
|
{
|
|
|
|
return val ? Lex_cstring(STRING_WITH_LEN("Yes")) :
|
|
|
|
Lex_cstring();
|
|
|
|
}
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Catalog: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Catalog(): Varchar(FN_REFLEN) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Name: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Name(): Varchar(NAME_CHAR_LEN) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Definer: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Definer(): Varchar(DEFINER_CHAR_LENGTH) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Userhost: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Userhost(): Varchar(USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 2) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CSName: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
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
|
|
|
CSName(): Varchar(MY_CS_CHARACTER_SET_NAME_SIZE) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CLName: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLName(): Varchar(MY_CS_COLLATION_NAME_SIZE) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SQLMode: public Varchar
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SQLMode(): Varchar(32*256) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Datetime: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Datetime(uint dec) :Type(&type_handler_datetime2, dec, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Decimal: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Decimal(uint length) :Type(&type_handler_newdecimal, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ULonglong: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-08-15 11:16:00 +02:00
|
|
|
ULonglong(uint length) :Type(&type_handler_ulonglong, length, true) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
ULonglong() :ULonglong(MY_INT64_NUM_DECIMAL_DIGITS) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ULong: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-08-15 11:16:00 +02:00
|
|
|
ULong(uint length) :Type(&type_handler_ulong, length, true) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
ULong() :ULong(MY_INT32_NUM_DECIMAL_DIGITS) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SLonglong: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-08-15 11:16:00 +02:00
|
|
|
SLonglong(uint length) :Type(&type_handler_slonglong, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
SLonglong() :SLonglong(MY_INT64_NUM_DECIMAL_DIGITS) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SLong: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-08-15 11:16:00 +02:00
|
|
|
SLong(uint length) :Type(&type_handler_slong, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
SLong() :SLong(MY_INT32_NUM_DECIMAL_DIGITS) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SShort: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-08-15 11:16:00 +02:00
|
|
|
SShort(uint length) :Type(&type_handler_sshort, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class STiny: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-08-15 11:16:00 +02:00
|
|
|
STiny(uint length) :Type(&type_handler_stiny, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Double: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Double(uint length) :Type(&type_handler_double, length, false) { }
|
2019-06-16 05:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-06-19 08:49:49 +02:00
|
|
|
class Float: public Type
|
|
|
|
{
|
|
|
|
public:
|
2019-06-22 07:15:37 +02:00
|
|
|
Float(uint length) :Type(&type_handler_float, length, false) { }
|
2019-06-19 08:49:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-06-16 05:51:59 +02:00
|
|
|
|
|
|
|
class Column: public ST_FIELD_INFO
|
|
|
|
{
|
|
|
|
public:
|
2020-01-21 11:27:17 +01:00
|
|
|
Column(const char *name, const Type &type,
|
|
|
|
enum_nullability nullability,
|
|
|
|
const char *old_name,
|
|
|
|
enum_show_open_table open_method= SKIP_OPEN_TABLE)
|
2021-12-28 14:43:40 +01:00
|
|
|
:ST_FIELD_INFO(name, type, nullability,
|
2020-01-21 11:27:17 +01:00
|
|
|
old_name, open_method)
|
|
|
|
{ }
|
|
|
|
Column(const char *name, const Type &type,
|
|
|
|
enum_nullability nullability,
|
2019-06-16 05:51:59 +02:00
|
|
|
enum_show_open_table open_method= SKIP_OPEN_TABLE)
|
2021-12-28 14:43:40 +01:00
|
|
|
:ST_FIELD_INFO(name, type, nullability,
|
2020-01-21 11:27:17 +01:00
|
|
|
NullS, open_method)
|
2019-06-16 05:51:59 +02:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// End marker
|
|
|
|
class CEnd: public Column
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CEnd() :Column(NullS, Varchar(0), NOT_NULL, NullS, SKIP_OPEN_TABLE) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Show
|
|
|
|
|
|
|
|
|
|
|
|
struct TABLE_LIST;
|
|
|
|
typedef class Item COND;
|
|
|
|
|
|
|
|
typedef struct st_schema_table
|
|
|
|
{
|
2023-04-26 13:27:01 +02:00
|
|
|
Lex_ident_i_s_table table_name;
|
2019-06-16 05:51:59 +02:00
|
|
|
ST_FIELD_INFO *fields_info;
|
|
|
|
/* for FLUSH table_name */
|
|
|
|
int (*reset_table) ();
|
|
|
|
/* Fill table with data */
|
|
|
|
int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond);
|
|
|
|
/* Handle fileds for old SHOW */
|
|
|
|
int (*old_format) (THD *thd, struct st_schema_table *schema_table);
|
|
|
|
int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table,
|
|
|
|
bool res, const LEX_CSTRING *db_name,
|
|
|
|
const LEX_CSTRING *table_name);
|
|
|
|
int idx_field1, idx_field2;
|
|
|
|
bool hidden;
|
|
|
|
uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */
|
|
|
|
} ST_SCHEMA_TABLE;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SQL_I_S_INCLUDED
|