mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-25292 ha_table_exists() cleanup and improvement
Removed default values for arguments, added flags argument to specify filename flags (FN_TO_IS_TMP, FN_FROM_IS_TMP).
This commit is contained in:
parent
65e0d0ea66
commit
409b8a86de
9 changed files with 23 additions and 16 deletions
|
@ -6201,7 +6201,7 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin,
|
|||
bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *table_name, LEX_CUSTRING *table_id,
|
||||
LEX_CSTRING *partition_engine_name,
|
||||
handlerton **hton, bool *is_sequence)
|
||||
handlerton **hton, bool *is_sequence, uint flags)
|
||||
{
|
||||
handlerton *dummy;
|
||||
bool dummy2;
|
||||
|
@ -6256,7 +6256,7 @@ retry_from_frm:
|
|||
#endif
|
||||
char path[FN_REFLEN + 1];
|
||||
size_t path_len = build_table_filename(path, sizeof(path) - 1,
|
||||
db->str, table_name->str, "", 0);
|
||||
db->str, table_name->str, "", flags);
|
||||
st_discover_existence_args args= {path, path_len, db->str, table_name->str, 0, true};
|
||||
|
||||
if (file_ext_exists(path, path_len, reg_ext))
|
||||
|
|
|
@ -5289,9 +5289,10 @@ int ha_discover_table_names(THD *thd, 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,
|
||||
LEX_CUSTRING *table_version= 0,
|
||||
LEX_CSTRING *partition_engine_name= 0,
|
||||
handlerton **hton= 0, bool *is_sequence= 0);
|
||||
LEX_CUSTRING *table_version,
|
||||
LEX_CSTRING *partition_engine_name,
|
||||
handlerton **hton, bool *is_sequence,
|
||||
uint flags);
|
||||
bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton,
|
||||
const char *op);
|
||||
#endif /* MYSQL_SERVER */
|
||||
|
|
|
@ -7111,7 +7111,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
|||
{
|
||||
if (!(rights & CREATE_ACL))
|
||||
{
|
||||
if (!ha_table_exists(thd, &table_list->db, &table_list->table_name))
|
||||
if (!ha_table_exists(thd, &table_list->db, &table_list->table_name,
|
||||
NULL, NULL, NULL, NULL, 0))
|
||||
{
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str,
|
||||
table_list->alias.str);
|
||||
|
|
|
@ -2008,7 +2008,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
|
|||
|
||||
if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS)
|
||||
{
|
||||
if (!ha_table_exists(thd, &table_list->db, &table_list->table_name))
|
||||
if (!ha_table_exists(thd, &table_list->db, &table_list->table_name,
|
||||
NULL, NULL, NULL, NULL, 0))
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB)
|
||||
|
@ -4223,7 +4224,7 @@ static bool upgrade_lock_if_not_exists(THD *thd,
|
|||
DEBUG_SYNC(thd,"create_table_before_check_if_exists");
|
||||
if (!create_info.or_replace() &&
|
||||
ha_table_exists(thd, &create_table->db, &create_table->table_name,
|
||||
NULL, NULL, &create_table->db_type))
|
||||
NULL, NULL, &create_table->db_type, NULL, 0))
|
||||
{
|
||||
if (create_info.if_not_exists())
|
||||
{
|
||||
|
|
|
@ -1236,7 +1236,8 @@ update_binlog:
|
|||
char quoted_name[FN_REFLEN+3];
|
||||
|
||||
// Only write drop table to the binlog for tables that no longer exist.
|
||||
if (ha_table_exists(thd, &tbl->db, &tbl->table_name))
|
||||
if (ha_table_exists(thd, &tbl->db, &tbl->table_name,
|
||||
NULL, NULL, NULL, NULL, 0))
|
||||
continue;
|
||||
|
||||
tbl_name_len= my_snprintf(quoted_name, sizeof(quoted_name), "%`s",
|
||||
|
|
|
@ -281,7 +281,7 @@ rename_check_preconditions(THD *thd, rename_param *param,
|
|||
|
||||
if (!ha_table_exists(thd, &ren_table->db, ¶m->old_alias,
|
||||
¶m->old_version, NULL,
|
||||
¶m->from_table_hton) ||
|
||||
¶m->from_table_hton, NULL, 0) ||
|
||||
!param->from_table_hton)
|
||||
{
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0),
|
||||
|
@ -301,7 +301,7 @@ rename_check_preconditions(THD *thd, rename_param *param,
|
|||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, 0))
|
||||
if (ha_table_exists(thd, new_db, ¶m->new_alias, NULL, NULL, NULL, NULL, 0))
|
||||
{
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str);
|
||||
DBUG_RETURN(1); // This can't be skipped
|
||||
|
|
|
@ -4819,7 +4819,7 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
|
|||
bool is_sequence;
|
||||
|
||||
if (ha_table_exists(thd, db_name, table_name, NULL, NULL,
|
||||
&hton, &is_sequence))
|
||||
&hton, &is_sequence, 0))
|
||||
{
|
||||
if (hton == view_pseudo_hton)
|
||||
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
|
||||
|
|
|
@ -4427,8 +4427,9 @@ int create_table_impl(THD *thd,
|
|||
|
||||
handlerton *db_type;
|
||||
if (!internal_tmp_table &&
|
||||
ha_table_exists(thd, &db, &table_name,
|
||||
&create_info->org_tabledef_version, NULL, &db_type))
|
||||
ha_table_exists(thd, &orig_db, &orig_table_name,
|
||||
&create_info->org_tabledef_version,
|
||||
NULL, &db_type, NULL, 0))
|
||||
{
|
||||
if (ha_check_if_updates_are_ignored(thd, db_type, "CREATE"))
|
||||
{
|
||||
|
@ -10080,7 +10081,8 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
|
|||
on the name, now we can safely try to find out for sure.
|
||||
*/
|
||||
if (!(alter_info->partition_flags & ALTER_PARTITION_CONVERT_IN) &&
|
||||
ha_table_exists(thd, &alter_ctx.new_db, &alter_ctx.new_name))
|
||||
ha_table_exists(thd, &alter_ctx.new_db, &alter_ctx.new_name,
|
||||
NULL, NULL, NULL, NULL, 0))
|
||||
{
|
||||
/* Table will be closed in do_command() */
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alter_ctx.new_alias.str);
|
||||
|
|
|
@ -1091,7 +1091,8 @@ loop_out:
|
|||
fn_format(path_buff, file.str, dir.str, "", MY_UNPACK_FILENAME);
|
||||
path.length= strlen(path_buff);
|
||||
|
||||
if (ha_table_exists(thd, &view->db, &view->table_name))
|
||||
if (ha_table_exists(thd, &view->db, &view->table_name,
|
||||
NULL, NULL, NULL, NULL, 0))
|
||||
{
|
||||
old_view_exists= 1;
|
||||
if (lex->create_info.if_not_exists())
|
||||
|
|
Loading…
Reference in a new issue