1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-30164 System variable for default collations

This patch adds a way to override default collations
(or "character set collations") for desired character sets.

The SQL standard says:
> Each collation known in an SQL-environment is applicable to one
> or more character sets, and for each character set, one or more
> collations are applicable to it, one of which is associated with
> it as its character set collation.

In MariaDB, character set collations has been hard-coded so far,
e.g. utf8mb4_general_ci has been a hard-coded character set collation
for utf8mb4.

This patch allows to override (globally per server, or per session)
character set collations, so for example, uca1400_ai_ci can be set as a
character set collation for Unicode character sets
(instead of compiled xxx_general_ci).

The array of overridden character set collations is stored in a new
(session and global) system variable @@character_set_collations and
can be set as a comma separated list of charset=collation pairs, e.g.:

SET @@character_set_collations='utf8mb3=uca1400_ai_ci,utf8mb4=uca1400_ai_ci';

The variable is empty by default, which mean use the hard-coded
character set collations (e.g. utf8mb4_general_ci for utf8mb4).

The variable can also be set globally by passing to the server startup command
line, and/or in my.cnf.
This commit is contained in:
Alexander Barkov
2022-12-14 18:46:27 +04:00
parent 584c2351de
commit 75f25e4ca7
59 changed files with 2228 additions and 111 deletions

View File

@ -24,6 +24,7 @@
#include "dur_prop.h"
#include <waiting_threads.h>
#include "sql_const.h"
#include "sql_used.h"
#include <mysql/plugin_audit.h>
#include "log.h"
#include "rpl_tblmap.h"
@ -886,6 +887,8 @@ typedef struct system_variables
vers_asof_timestamp_t vers_asof_timestamp;
my_bool binlog_alter_two_phase;
Charset_collation_map_st character_set_collations;
} SV;
/**
@ -2603,6 +2606,7 @@ struct thd_async_state
*/
class THD: public THD_count, /* this must be first */
public Sql_used,
public Statement,
/*
This is to track items changed during execution of a prepared
@ -2925,12 +2929,6 @@ public:
*/
uint32 binlog_unsafe_warning_flags;
typedef uint used_t;
enum { RAND_USED=1, TIME_ZONE_USED=2, QUERY_START_SEC_PART_USED=4,
THREAD_SPECIFIC_USED=8 };
used_t used;
#ifndef MYSQL_CLIENT
binlog_cache_mngr * binlog_setup_trx_data();
/*