Commit 21218d3c authored by Alexander Barkov's avatar Alexander Barkov

MDEV-31986 Remove old check_db_name() from make_table_name_list()

- Replacing the old style inplace check_db_name() in make_table_name_list()
  to the new style non-modifying code
- Adding "const" qualifier to the "db" parameter to ha_discover_table_names()
  and its dependency functions.
parent d15e2902
......@@ -532,7 +532,8 @@ static int full_discover_for_existence(handlerton *, const char *, const char *)
static int ext_based_existence(handlerton *, const char *, const char *)
{ return 0; }
static int hton_ext_based_table_discovery(handlerton *hton, LEX_CSTRING *db,
static int hton_ext_based_table_discovery(handlerton *hton,
const LEX_CSTRING *db,
MY_DIR *dir, handlerton::discovered_list *result)
{
/*
......@@ -6679,7 +6680,7 @@ void Discovered_table_list::remove_duplicates()
struct st_discover_names_args
{
LEX_CSTRING *db;
const LEX_CSTRING *db;
MY_DIR *dirp;
Discovered_table_list *result;
uint possible_duplicates;
......@@ -6724,7 +6725,7 @@ static my_bool discover_names(THD *thd, plugin_ref plugin,
for DROP DATABASE (as it needs to know and delete non-table files).
*/
int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
int ha_discover_table_names(THD *thd, const LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable)
{
int error;
......
......@@ -1621,7 +1621,8 @@ struct handlerton
Returns 0 on success and 1 on error.
*/
int (*discover_table_names)(handlerton *hton, LEX_CSTRING *db, MY_DIR *dir,
int (*discover_table_names)(handlerton *hton, const LEX_CSTRING *db,
MY_DIR *dir,
discovered_list *result);
/*
......@@ -5574,7 +5575,7 @@ class Discovered_table_list: public handlerton::discovered_list
};
int ha_discover_table(THD *thd, TABLE_SHARE *share);
int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
int ha_discover_table_names(THD *thd, const LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable);
bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
const LEX_CSTRING *table_name,
......
......@@ -87,9 +87,16 @@ class DBNameBuffer: public CharBuffer<SAFE_NAME_LEN + MY_CS_MBMAXLEN>
{
copy_casedn(&my_charset_utf8mb3_general_ci, db, casedn);
}
Lex_ident_db to_lex_ident_db() const
{
const LEX_CSTRING tmp= to_lex_cstring();
if (Lex_ident_fs(tmp).check_db_name())
return Lex_ident_db();
return Lex_ident_db(tmp.str, tmp.length);
}
Lex_ident_db to_lex_ident_db_with_error() const
{
LEX_CSTRING tmp= to_lex_cstring();
const LEX_CSTRING tmp= to_lex_cstring();
if (Lex_ident_fs(tmp).check_db_name_with_error())
return Lex_ident_db();
return Lex_ident_db(tmp.str, tmp.length);
......
......@@ -948,7 +948,8 @@ enum find_files_result {
static find_files_result
find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files, LEX_CSTRING *db,
find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files,
const Lex_ident_db *db,
const char *path, const LEX_CSTRING *wild)
{
MY_DIR *dirp;
......@@ -4537,7 +4538,7 @@ int schema_tables_add(THD *thd, Dynamic_array<LEX_CSTRING*> *files,
static int
make_table_name_list(THD *thd, Dynamic_array<LEX_CSTRING*> *table_names,
LEX *lex, LOOKUP_FIELD_VALUES *lookup_field_vals,
LEX_CSTRING *db_name)
const LEX_CSTRING *db_name)
{
char path[FN_REFLEN + 1];
build_table_filename(path, sizeof(path) - 1, db_name->str, "", "", 0);
......@@ -4583,10 +4584,12 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_CSTRING*> *table_names,
return (schema_tables_add(thd, table_names,
lookup_field_vals->table_value.str));
if (check_db_name((LEX_STRING*)db_name))
DBNameBuffer dbbuf(*db_name, lower_case_table_names);
const Lex_ident_db dbnorm= dbbuf.to_lex_ident_db();
if (!dbnorm.str)
return 0; // Impossible TABLE_SCHEMA name
find_files_result res= find_files(thd, table_names, db_name, path,
find_files_result res= find_files(thd, table_names, &dbnorm, path,
&lookup_field_vals->table_value);
if (res != FIND_FILES_OK)
{
......
......@@ -827,7 +827,7 @@ static int s3_discover_table_existence(handlerton *hton, const char *db,
*/
static int s3_discover_table_names(handlerton *hton __attribute__((unused)),
LEX_CSTRING *db,
const LEX_CSTRING *db,
MY_DIR *dir __attribute__((unused)),
handlerton::discovered_list *result)
{
......
......@@ -1960,7 +1960,7 @@ bool pfs_show_status(handlerton *hton, THD *thd,
}
int pfs_discover_table_names(handlerton *hton __attribute__((unused)),
LEX_CSTRING *db,
const LEX_CSTRING *db,
MY_DIR *dir __attribute__((unused)),
handlerton::discovered_list *result)
{
......
......@@ -619,7 +619,7 @@ struct PFS_triple_index
bool pfs_show_status(handlerton *hton, THD *thd,
stat_print_fn *print, enum ha_stat_type stat);
int pfs_discover_table_names(handlerton *hton, LEX_CSTRING *db,
int pfs_discover_table_names(handlerton *hton, const LEX_CSTRING *db,
MY_DIR *dir,
handlerton::discovered_list *result);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment