mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-31948 Add class DBNameBuffer, split check_db_name() into stages
- Adding a class Lex_ident_fs, to store identifiers for on-disk database objects, such as databases, tables, triggers. - Moving the validation code from check_db_name() to non-modifying methods in Lex_ident_fs: Lex_ident_fs::check_body() Lex_ident_fs::check_db_name() Adding a new method Lex_ident_fs::check_db_name_with_error(), which performs validation and raises an error on validation failure. Unlike the old function check_db_name(), the new class Lex_ident_fs does not lower-case the identifier during the validation. Lower-casing must be done before calling Lex_ident_fs validation methods. - Adding a low level helper template class CharBuffer which can: * store exact or lower-cased strings with a short fixed maximum length * return the value as a LEX_CSTRING efficiently - Adding a helper template class DBNameBuffer (deriving from CharBuffer), to allocate optionally lower-cased database identifiers on stack when relevant. Useful for temporary values which don't need to be allocated on MEM_ROOT. - Using DBNameBuffer in mysql_change_db() - Using DBNameBuffer in show_create_db()
This commit is contained in:
@@ -6265,21 +6265,14 @@ static bool generate_incident_event(THD *thd)
|
||||
static int __attribute__ ((noinline))
|
||||
show_create_db(THD *thd, LEX *lex)
|
||||
{
|
||||
char db_name_buff[NAME_LEN+1];
|
||||
LEX_CSTRING db_name;
|
||||
DBUG_EXECUTE_IF("4x_server_emul",
|
||||
my_error(ER_UNKNOWN_ERROR, MYF(0)); return 1;);
|
||||
|
||||
db_name.str= db_name_buff;
|
||||
db_name.length= lex->name.length;
|
||||
strmov(db_name_buff, lex->name.str);
|
||||
|
||||
if (check_db_name((LEX_STRING*) &db_name))
|
||||
{
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
|
||||
DBNameBuffer dbbuf(lex->name, lower_case_table_names);
|
||||
if (Lex_ident_fs(dbbuf.to_lex_cstring()).check_db_name_with_error())
|
||||
return 1;
|
||||
}
|
||||
return mysqld_show_create_db(thd, &db_name, &lex->name, lex->create_info);
|
||||
LEX_CSTRING db= dbbuf.to_lex_cstring();
|
||||
return mysqld_show_create_db(thd, &db, &lex->name, lex->create_info);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user