mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-31340 Remove MY_COLLATION_HANDLER::strcasecmp()
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")});
This commit is contained in:
105
sql/sql_class.h
105
sql/sql_class.h
@@ -330,7 +330,7 @@ typedef struct st_copy_info {
|
||||
|
||||
class Key_part_spec :public Sql_alloc {
|
||||
public:
|
||||
Lex_ident field_name;
|
||||
Lex_ident_column field_name;
|
||||
uint length;
|
||||
bool generated, asc;
|
||||
Key_part_spec(const LEX_CSTRING *name, uint len, bool gen= false)
|
||||
@@ -365,13 +365,15 @@ public:
|
||||
class Alter_drop :public Sql_alloc {
|
||||
public:
|
||||
enum drop_type { KEY, COLUMN, FOREIGN_KEY, CHECK_CONSTRAINT, PERIOD };
|
||||
const char *name;
|
||||
Lex_ident_column name;
|
||||
enum drop_type type;
|
||||
bool drop_if_exists;
|
||||
Alter_drop(enum drop_type par_type,const char *par_name, bool par_exists)
|
||||
Alter_drop(enum drop_type par_type,
|
||||
const LEX_CSTRING &par_name,
|
||||
bool par_exists)
|
||||
:name(par_name), type(par_type), drop_if_exists(par_exists)
|
||||
{
|
||||
DBUG_ASSERT(par_name != NULL);
|
||||
DBUG_ASSERT(par_name.str != NULL);
|
||||
}
|
||||
/**
|
||||
Used to make a clone of this object for ALTER/CREATE TABLE
|
||||
@@ -416,8 +418,8 @@ public:
|
||||
class Alter_rename_key : public Sql_alloc
|
||||
{
|
||||
public:
|
||||
LEX_CSTRING old_name;
|
||||
LEX_CSTRING new_name;
|
||||
const Lex_ident_column old_name;
|
||||
const Lex_ident_column new_name;
|
||||
bool alter_if_exists;
|
||||
|
||||
Alter_rename_key(LEX_CSTRING old_name_arg, LEX_CSTRING new_name_arg, bool exists)
|
||||
@@ -433,13 +435,14 @@ public:
|
||||
class Alter_index_ignorability: public Sql_alloc
|
||||
{
|
||||
public:
|
||||
Alter_index_ignorability(const char *name, bool is_ignored, bool if_exists) :
|
||||
Alter_index_ignorability(const LEX_CSTRING &name,
|
||||
bool is_ignored, bool if_exists) :
|
||||
m_name(name), m_is_ignored(is_ignored), m_if_exists(if_exists)
|
||||
{
|
||||
assert(name != NULL);
|
||||
DBUG_ASSERT(name.str != NULL);
|
||||
}
|
||||
|
||||
const char *name() const { return m_name; }
|
||||
const Lex_ident_column &name() const { return m_name; }
|
||||
bool if_exists() const { return m_if_exists; }
|
||||
|
||||
/* The ignorability after the operation is performed. */
|
||||
@@ -448,7 +451,7 @@ public:
|
||||
{ return new (mem_root) Alter_index_ignorability(*this); }
|
||||
|
||||
private:
|
||||
const char *m_name;
|
||||
const Lex_ident_column m_name;
|
||||
bool m_is_ignored;
|
||||
bool m_if_exists;
|
||||
};
|
||||
@@ -461,13 +464,13 @@ public:
|
||||
enum Keytype type;
|
||||
KEY_CREATE_INFO key_create_info;
|
||||
List<Key_part_spec> columns;
|
||||
LEX_CSTRING name;
|
||||
Lex_ident_column name;
|
||||
engine_option_value *option_list;
|
||||
bool generated;
|
||||
bool invisible;
|
||||
bool without_overlaps;
|
||||
bool old;
|
||||
Lex_ident period;
|
||||
Lex_ident_column period;
|
||||
|
||||
Key(enum Keytype type_par, const LEX_CSTRING *name_arg,
|
||||
ha_key_alg algorithm_arg, bool generated_arg, DDL_options_st ddl_options)
|
||||
@@ -1419,6 +1422,18 @@ public:
|
||||
lex_string_strmake_root(mem_root, src.str, src.length);
|
||||
}
|
||||
|
||||
template <typename Lex_ident_XXX>
|
||||
Lex_ident_XXX lex_ident_copy(const Lex_ident_XXX &src)
|
||||
{
|
||||
return Lex_ident_XXX(strmake_lex_cstring(src));
|
||||
}
|
||||
|
||||
template <typename Lex_ident_XXX>
|
||||
Lex_ident_XXX lex_ident_casedn(const Lex_ident_XXX &src)
|
||||
{
|
||||
return Lex_ident_XXX(make_ident_casedn(src));
|
||||
}
|
||||
|
||||
/*
|
||||
Convert a LEX_CSTRING to a valid database name:
|
||||
- validated with Lex_ident_fs::check_db_name()
|
||||
@@ -1436,7 +1451,7 @@ public:
|
||||
|
||||
/*
|
||||
Convert a LEX_CSTRING to a valid internal database name:
|
||||
- validated with Lex_ident_fs::check_db_name()
|
||||
- validated with Lex_ident_db::check_name()
|
||||
- optionally lower-cased when lower_case_table_names==1
|
||||
The lower-cased copy is created on Query_arena::mem_root, when needed.
|
||||
|
||||
@@ -1786,7 +1801,7 @@ public:
|
||||
@return True if the security context fulfills the access requirements.
|
||||
*/
|
||||
bool check_access(const privilege_t want_access, bool match_any = false);
|
||||
bool is_priv_user(const char *user, const char *host);
|
||||
bool is_priv_user(const LEX_CSTRING &user, const LEX_CSTRING &host);
|
||||
};
|
||||
|
||||
|
||||
@@ -5511,19 +5526,20 @@ public:
|
||||
|
||||
TABLE *create_and_open_tmp_table(LEX_CUSTRING *frm,
|
||||
const char *path,
|
||||
const char *db,
|
||||
const char *table_name,
|
||||
const Lex_ident_db &db,
|
||||
const Lex_ident_table &table_name,
|
||||
bool open_internal_tables);
|
||||
|
||||
TABLE *find_temporary_table(const char *db, const char *table_name,
|
||||
TABLE *find_temporary_table(const Lex_ident_db &db,
|
||||
const Lex_ident_table &table_name,
|
||||
Temporary_table_state state= TMP_TABLE_IN_USE);
|
||||
TABLE *find_temporary_table(const TABLE_LIST *tl,
|
||||
Temporary_table_state state= TMP_TABLE_IN_USE);
|
||||
|
||||
TMP_TABLE_SHARE *find_tmp_table_share_w_base_key(const char *key,
|
||||
uint key_length);
|
||||
TMP_TABLE_SHARE *find_tmp_table_share(const char *db,
|
||||
const char *table_name);
|
||||
TMP_TABLE_SHARE *find_tmp_table_share(const Lex_ident_db &db,
|
||||
const Lex_ident_table &table_name);
|
||||
TMP_TABLE_SHARE *find_tmp_table_share(const TABLE_LIST *tl);
|
||||
TMP_TABLE_SHARE *find_tmp_table_share(const char *key, size_t key_length);
|
||||
|
||||
@@ -5546,14 +5562,16 @@ private:
|
||||
/* Whether a lock has been acquired? */
|
||||
bool m_tmp_tables_locked;
|
||||
|
||||
uint create_tmp_table_def_key(char *key, const char *db,
|
||||
const char *table_name);
|
||||
uint create_tmp_table_def_key(char *key, const Lex_ident_db &db,
|
||||
const Lex_ident_table &table_name);
|
||||
TMP_TABLE_SHARE *create_temporary_table(LEX_CUSTRING *frm,
|
||||
const char *path, const char *db,
|
||||
const char *table_name);
|
||||
const char *path,
|
||||
const Lex_ident_db &db,
|
||||
const Lex_ident_table &table_name);
|
||||
TABLE *find_temporary_table(const char *key, uint key_length,
|
||||
Temporary_table_state state);
|
||||
TABLE *open_temporary_table(TMP_TABLE_SHARE *share, const char *alias);
|
||||
TABLE *open_temporary_table(TMP_TABLE_SHARE *share,
|
||||
const Lex_ident_table &alias);
|
||||
bool find_and_use_tmp_table(const TABLE_LIST *tl, TABLE **out_table);
|
||||
bool use_temporary_table(TABLE *table, TABLE **out_table);
|
||||
void close_temporary_table(TABLE *table);
|
||||
@@ -7316,7 +7334,7 @@ public:
|
||||
bool append_to(THD *thd, String *to) const;
|
||||
/*
|
||||
Convert Table_ident::m_db to a valid internal database name:
|
||||
- validated with Lex_ident_fs::check_db_name()
|
||||
- validated with Lex_ident_db::check_name()
|
||||
- optionally lower-cased when lower_case_table_names==1
|
||||
|
||||
@param arena - the arena to allocate the lower-cased copy on, when needed.
|
||||
@@ -7330,7 +7348,7 @@ public:
|
||||
class Qualified_column_ident: public Table_ident
|
||||
{
|
||||
public:
|
||||
LEX_CSTRING m_column;
|
||||
const Lex_ident_column m_column;
|
||||
public:
|
||||
Qualified_column_ident(const LEX_CSTRING *column)
|
||||
:Table_ident(&null_clex_str),
|
||||
@@ -8097,47 +8115,32 @@ public:
|
||||
class Database_qualified_name
|
||||
{
|
||||
public:
|
||||
LEX_CSTRING m_db;
|
||||
LEX_CSTRING m_name;
|
||||
Database_qualified_name(const LEX_CSTRING *db, const LEX_CSTRING *name)
|
||||
:m_db(*db), m_name(*name)
|
||||
Lex_ident_db m_db;
|
||||
Lex_cstring m_name; // no comparison semantics
|
||||
Database_qualified_name()
|
||||
{ }
|
||||
Database_qualified_name(const LEX_CSTRING &db, const LEX_CSTRING &name)
|
||||
Database_qualified_name(const Lex_ident_db &db, const LEX_CSTRING &name)
|
||||
:m_db(db), m_name(name)
|
||||
{ }
|
||||
Database_qualified_name(const char *db, size_t db_length,
|
||||
const char *name, size_t name_length)
|
||||
{
|
||||
m_db.str= db;
|
||||
m_db.length= db_length;
|
||||
m_name.str= name;
|
||||
m_name.length= name_length;
|
||||
}
|
||||
|
||||
Identifier_chain2 to_identifier_chain2() const
|
||||
{
|
||||
return Identifier_chain2(m_db, m_name);
|
||||
}
|
||||
|
||||
bool eq(const Database_qualified_name *other) const
|
||||
|
||||
bool eq_routine_name(const Database_qualified_name *other) const
|
||||
{
|
||||
CHARSET_INFO *cs= lower_case_table_names ?
|
||||
&my_charset_utf8mb3_general_ci :
|
||||
&my_charset_utf8mb3_bin;
|
||||
return
|
||||
m_db.length == other->m_db.length &&
|
||||
m_name.length == other->m_name.length &&
|
||||
!cs->strnncoll(m_db.str, m_db.length,
|
||||
other->m_db.str, other->m_db.length) &&
|
||||
!cs->strnncoll(m_name.str, m_name.length,
|
||||
other->m_name.str, other->m_name.length);
|
||||
|
||||
return m_db.streq(other->m_db) &&
|
||||
Lex_ident_routine(m_name).streq(other->m_name);
|
||||
}
|
||||
/*
|
||||
Make copies of "db" and "name" on the memory root in internal format:
|
||||
- Lower-case "db" if lower-case-table-names==1.
|
||||
- Preserve "name" as is.
|
||||
*/
|
||||
bool copy_sp_name_internal(MEM_ROOT *mem_root, const LEX_CSTRING &db,
|
||||
bool copy_sp_name_internal(MEM_ROOT *mem_root, const Lex_ident_db &db,
|
||||
const LEX_CSTRING &name);
|
||||
|
||||
bool make_package_routine_name(MEM_ROOT *mem_root,
|
||||
|
Reference in New Issue
Block a user