MDEV-31974 Remove global function normalize_db_name()
The function normalize_db_name() fully repeated the functionality of the class DBNameBuffer. This patch removes normalize_db_name() and replaces it to a DBNameBuffer based code.
This commit is contained in:
parent
495c32d9ad
commit
7a7296bd1e
@ -823,9 +823,6 @@ Events::show_create_event(THD *thd, const LEX_CSTRING *dbname,
|
|||||||
int
|
int
|
||||||
Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
|
Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
|
||||||
{
|
{
|
||||||
const char *db= NULL;
|
|
||||||
int ret;
|
|
||||||
char db_tmp[SAFE_NAME_LEN];
|
|
||||||
DBUG_ENTER("Events::fill_schema_events");
|
DBUG_ENTER("Events::fill_schema_events");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -849,11 +846,11 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
|
|||||||
if (!is_infoschema_db(lexdb) && !is_perfschema_db(lexdb) &&
|
if (!is_infoschema_db(lexdb) && !is_perfschema_db(lexdb) &&
|
||||||
check_access(thd, EVENT_ACL, lexdb->str, NULL, NULL, 0, 0))
|
check_access(thd, EVENT_ACL, lexdb->str, NULL, NULL, 0, 0))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
db= normalize_db_name(lexdb->str, db_tmp, sizeof(db_tmp));
|
const DBNameBuffer db_tmp(*lexdb, lower_case_table_names);
|
||||||
|
const char *db= db_tmp.to_lex_cstring().str;
|
||||||
|
DBUG_RETURN(db_repository->fill_schema_events(thd, tables, db));
|
||||||
}
|
}
|
||||||
ret= db_repository->fill_schema_events(thd, tables, db);
|
DBUG_RETURN(db_repository->fill_schema_events(thd, tables, NULL));
|
||||||
|
|
||||||
DBUG_RETURN(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -744,10 +744,9 @@ mysql_create_db_internal(THD *thd, const LEX_CSTRING *db,
|
|||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char db_tmp[SAFE_NAME_LEN+1];
|
const DBNameBuffer db_tmp(*db, lower_case_table_names);
|
||||||
const char *dbnorm= normalize_db_name(db->str, db_tmp, sizeof(db_tmp));
|
|
||||||
|
|
||||||
if (lock_schema_name(thd, dbnorm))
|
if (lock_schema_name(thd, db_tmp.to_lex_cstring().str))
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
|
|
||||||
/* Check directory */
|
/* Check directory */
|
||||||
@ -1047,16 +1046,13 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists,
|
|||||||
TABLE_LIST *table;
|
TABLE_LIST *table;
|
||||||
DDL_LOG_STATE ddl_log_state;
|
DDL_LOG_STATE ddl_log_state;
|
||||||
Drop_table_error_handler err_handler;
|
Drop_table_error_handler err_handler;
|
||||||
LEX_CSTRING rm_db;
|
|
||||||
char db_tmp[SAFE_NAME_LEN+1];
|
|
||||||
const char *dbnorm;
|
|
||||||
DBUG_ENTER("mysql_rm_db");
|
DBUG_ENTER("mysql_rm_db");
|
||||||
|
|
||||||
dbnorm= normalize_db_name(db->str, db_tmp, sizeof(db_tmp));
|
const DBNameBuffer db_tmp(*db, lower_case_table_names);
|
||||||
lex_string_set(&rm_db, dbnorm);
|
const LEX_CSTRING rm_db= db_tmp.to_lex_cstring();
|
||||||
bzero(&ddl_log_state, sizeof(ddl_log_state));
|
bzero(&ddl_log_state, sizeof(ddl_log_state));
|
||||||
|
|
||||||
if (lock_schema_name(thd, dbnorm))
|
if (lock_schema_name(thd, rm_db.str))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
|
|
||||||
path_length= build_table_filename(path, sizeof(path) - 1, db->str, "", "", 0);
|
path_length= build_table_filename(path, sizeof(path) - 1, db->str, "", "", 0);
|
||||||
@ -1079,7 +1075,7 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (find_db_tables_and_rm_known_files(thd, dirp, dbnorm, path, &tables))
|
if (find_db_tables_and_rm_known_files(thd, dirp, rm_db.str, path, &tables))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1097,7 +1093,7 @@ mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists,
|
|||||||
/* Lock all tables and stored routines about to be dropped. */
|
/* Lock all tables and stored routines about to be dropped. */
|
||||||
if (lock_table_names(thd, tables, NULL, thd->variables.lock_wait_timeout,
|
if (lock_table_names(thd, tables, NULL, thd->variables.lock_wait_timeout,
|
||||||
0) ||
|
0) ||
|
||||||
lock_db_routines(thd, dbnorm))
|
lock_db_routines(thd, rm_db.str))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
if (!rm_mysql_schema)
|
if (!rm_mysql_schema)
|
||||||
@ -2139,14 +2135,3 @@ bool check_db_dir_existence(const char *db_name)
|
|||||||
mysql_rwlock_unlock(&rmdir_lock);
|
mysql_rwlock_unlock(&rmdir_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *normalize_db_name(const char *db, char *buffer, size_t buffer_size)
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(buffer_size > 1);
|
|
||||||
if (!lower_case_table_names)
|
|
||||||
return db;
|
|
||||||
strmake(buffer, db, buffer_size - 1);
|
|
||||||
my_casedn_str(system_charset_info, buffer);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
@ -44,9 +44,6 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
|
|||||||
bool my_dbopt_init(void);
|
bool my_dbopt_init(void);
|
||||||
void my_dbopt_cleanup(void);
|
void my_dbopt_cleanup(void);
|
||||||
|
|
||||||
const char *normalize_db_name(const char *db, char *buffer,
|
|
||||||
size_t buffer_size);
|
|
||||||
|
|
||||||
void drop_database_objects(THD *thd, const LEX_CSTRING *path,
|
void drop_database_objects(THD *thd, const LEX_CSTRING *path,
|
||||||
const LEX_CSTRING *db,
|
const LEX_CSTRING *db,
|
||||||
bool rm_mysql_schema);
|
bool rm_mysql_schema);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user