mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
fd247cc21f
This patch also fixes: MDEV-33050 Build-in schemas like oracle_schema are accent insensitive MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0 MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0 MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0 MDEV-33088 Cannot create triggers in the database `MYSQL` MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0 MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0 MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0 MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0 - Removing the virtual function strnncoll() from MY_COLLATION_HANDLER - Adding a wrapper function CHARSET_INFO::streq(), to compare two strings for equality. For now it calls strnncoll() internally. In the future it will turn into a virtual function. - Adding new accent sensitive case insensitive collations: - utf8mb4_general1400_as_ci - utf8mb3_general1400_as_ci They implement accent sensitive case insensitive comparison. The weight of a character is equal to the code point of its upper case variant. These collations use Unicode-14.0.0 casefolding data. The result of my_charset_utf8mb3_general1400_as_ci.strcoll() is very close to the former my_charset_utf8mb3_general_ci.strcasecmp() There is only a difference in a couple dozen rare characters, because: - the switch from "tolower" to "toupper" comparison, to make utf8mb3_general1400_as_ci closer to utf8mb3_general_ci - the switch from Unicode-3.0.0 to Unicode-14.0.0 This difference should be tolarable. See the list of affected characters in the MDEV description. Note, utf8mb4_general1400_as_ci correctly handles non-BMP characters! Unlike utf8mb4_general_ci, it does not treat all BMP characters as equal. - Adding classes representing names of the file based database objects: Lex_ident_db Lex_ident_table Lex_ident_trigger Their comparison collation depends on the underlying file system case sensitivity and on --lower-case-table-names and can be either my_charset_bin or my_charset_utf8mb3_general1400_as_ci. - Adding classes representing names of other database objects, whose names have case insensitive comparison style, using my_charset_utf8mb3_general1400_as_ci: Lex_ident_column Lex_ident_sys_var Lex_ident_user_var Lex_ident_sp_var Lex_ident_ps Lex_ident_i_s_table Lex_ident_window Lex_ident_func Lex_ident_partition Lex_ident_with_element Lex_ident_rpl_filter Lex_ident_master_info Lex_ident_host Lex_ident_locale Lex_ident_plugin Lex_ident_engine Lex_ident_server Lex_ident_savepoint Lex_ident_charset engine_option_value::Name - All the mentioned Lex_ident_xxx classes implement a method streq(): if (ident1.streq(ident2)) do_equal(); This method works as a wrapper for CHARSET_INFO::streq(). - Changing a lot of "LEX_CSTRING name" to "Lex_ident_xxx name" in class members and in function/method parameters. - Replacing all calls like system_charset_info->coll->strcasecmp(ident1, ident2) to ident1.streq(ident2) - Taking advantage of the c++11 user defined literal operator for LEX_CSTRING (see m_strings.h) and Lex_ident_xxx (see lex_ident.h) data types. Use example: const Lex_ident_column primary_key_name= "PRIMARY"_Lex_ident_column; is now a shorter version of: const Lex_ident_column primary_key_name= Lex_ident_column({STRING_WITH_LEN("PRIMARY")});
121 lines
5.1 KiB
C++
121 lines
5.1 KiB
C++
/*
|
|
Copyright (c) 2013, Spaempresarial - Brazil, Roberto Spadim
|
|
http://www.spadim.com.br/
|
|
roberto@spadim.com.br
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions are met:
|
|
* Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in the
|
|
documentation and/or other materials provided with the distribution.
|
|
* Neither the name of the Roberto Spadim nor the
|
|
names of the contributors may be used to endorse or promote products
|
|
derived from this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
DISCLAIMED. IN NO EVENT SHALL ROBERTO SPADIM BE LIABLE FOR ANY
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#include <my_global.h>
|
|
#include <sql_class.h> // THD
|
|
#include <sql_i_s.h> // ST_SCHEMA_TABLE
|
|
#include <mysql/plugin.h>
|
|
#include <m_ctype.h>
|
|
#include "sql_locale.h"
|
|
|
|
static MY_LOCALE **locale_list;
|
|
|
|
namespace Show {
|
|
|
|
/* LOCALES */
|
|
static ST_FIELD_INFO locale_info_locale_fields_info[]=
|
|
{
|
|
Column("ID", SLonglong(4), NOT_NULL, "Id"),
|
|
Column("NAME", Varchar(255), NOT_NULL, "Name"),
|
|
Column("DESCRIPTION", Varchar(255), NOT_NULL, "Description"),
|
|
Column("MAX_MONTH_NAME_LENGTH", SLonglong(4), NOT_NULL),
|
|
Column("MAX_DAY_NAME_LENGTH", SLonglong(4), NOT_NULL),
|
|
Column("DECIMAL_POINT", Varchar(2), NOT_NULL),
|
|
Column("THOUSAND_SEP", Varchar(2), NOT_NULL),
|
|
Column("ERROR_MESSAGE_LANGUAGE", Varchar(64), NOT_NULL, "Error_Message_Language"),
|
|
CEnd()
|
|
};
|
|
|
|
} // namespace Show
|
|
|
|
static int locale_info_fill_table_locale(THD* thd, TABLE_LIST* tables, COND* cond)
|
|
{
|
|
TABLE *table= tables->table;
|
|
CHARSET_INFO *cs= system_charset_info;
|
|
|
|
for (MY_LOCALE **loc= locale_list; *loc; loc++)
|
|
{
|
|
/* ID */
|
|
table->field[0]->store((longlong) (*loc)->number, TRUE);
|
|
/* NAME */
|
|
table->field[1]->store((*loc)->name, cs);
|
|
/* DESCRIPTION */
|
|
table->field[2]->store((*loc)->description, strlen((*loc)->description), cs);
|
|
/* MAX_MONTH_NAME_LENGTH */
|
|
table->field[3]->store((longlong) (*loc)->max_month_name_length, TRUE);
|
|
/* MAX_DAY_NAME_LENGTH */
|
|
table->field[4]->store((longlong) (*loc)->max_day_name_length, TRUE);
|
|
/* DECIMAL_POINT */
|
|
char decimal= (*loc)->decimal_point;
|
|
table->field[5]->store(&decimal, decimal ? 1 : 0, cs);
|
|
/* THOUSAND_SEP */
|
|
char thousand= (*loc)->thousand_sep;
|
|
table->field[6]->store(&thousand, thousand ? 1 : 0, cs);
|
|
/* ERROR_MESSAGE_LANGUAGE */
|
|
table->field[7]->store((*loc)->errmsgs->language,
|
|
strlen((*loc)->errmsgs->language), cs);
|
|
if (schema_table_store_record(thd, table))
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int locale_info_plugin_init_locales(void *p)
|
|
{
|
|
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
|
|
schema->fields_info= Show::locale_info_locale_fields_info;
|
|
schema->fill_table= locale_info_fill_table_locale;
|
|
|
|
locale_list = my_locales;
|
|
|
|
return 0;
|
|
}
|
|
static struct st_mysql_information_schema locale_info_plugin=
|
|
{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
|
|
|
|
/*
|
|
Plugin library descriptor
|
|
*/
|
|
|
|
maria_declare_plugin(locales)
|
|
{
|
|
MYSQL_INFORMATION_SCHEMA_PLUGIN, /* the plugin type (see include/mysql/plugin.h) */
|
|
&locale_info_plugin, /* pointer to type-specific plugin descriptor */
|
|
"LOCALES", /* plugin name */
|
|
"Roberto Spadim, Spaempresarial - Brazil", /* plugin author */
|
|
"Lists all locales from server.", /* the plugin description */
|
|
PLUGIN_LICENSE_BSD, /* the plugin license (see include/mysql/plugin.h) */
|
|
locale_info_plugin_init_locales, /* Pointer to plugin initialization function */
|
|
0, /* Pointer to plugin deinitialization function */
|
|
0x0100, /* Numeric version 0xAABB means AA.BB version */
|
|
NULL, /* Status variables */
|
|
NULL, /* System variables */
|
|
"1.0", /* String version representation */
|
|
MariaDB_PLUGIN_MATURITY_STABLE /* Maturity (see include/mysql/plugin.h)*/
|
|
}
|
|
maria_declare_plugin_end;
|