summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2023-01-18 16:52:07 +0300
committerAleksey Midenkov <midenok@gmail.com>2023-01-26 17:15:20 +0300
commitd737fff42bd06be07fb865683019897d9c739777 (patch)
tree514b2358ff9d62dd87c7022c6e71917d2ea75023
parentb943ae6f856ec9b2ee00c28927b4cc6639faeb28 (diff)
downloadmariadb-git-d737fff42bd06be07fb865683019897d9c739777.tar.gz
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).
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/handler.h7
-rw-r--r--sql/sql_acl.cc3
-rw-r--r--sql/sql_base.cc5
-rw-r--r--sql/sql_db.cc3
-rw-r--r--sql/sql_rename.cc4
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_table.cc8
-rw-r--r--sql/sql_view.cc3
9 files changed, 23 insertions, 16 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index f331c6d02ce..53673cffe05 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -6203,7 +6203,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;
@@ -6258,7 +6258,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))
diff --git a/sql/handler.h b/sql/handler.h
index 99088dd2d28..0ad595e6bdb 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -5235,9 +5235,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 */
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index f686d12b9ea..81eb533a256 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -7210,7 +7210,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);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 91ab5456875..b8fcd508c7a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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)
@@ -4225,7 +4226,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())
{
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 452a01773e5..1ff891cec92 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -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",
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 33c8a77ae46..64d0cb3d1b4 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -282,7 +282,7 @@ rename_check_preconditions(THD *thd, rename_param *param,
if (!ha_table_exists(thd, &ren_table->db, &param->old_alias,
&param->old_version, NULL,
- &param->from_table_hton) ||
+ &param->from_table_hton, NULL, 0) ||
!param->from_table_hton)
{
my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0),
@@ -302,7 +302,7 @@ rename_check_preconditions(THD *thd, rename_param *param,
DBUG_RETURN(-1);
}
- if (ha_table_exists(thd, new_db, &param->new_alias, NULL, NULL, 0))
+ if (ha_table_exists(thd, new_db, &param->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
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 9510d74c86d..2d9c5c04eb9 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4813,7 +4813,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);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 03c7a49d314..9cbdca722fe 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4438,8 +4438,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"))
{
@@ -10141,7 +10142,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);
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 30fba1bcf98..29453a6a591 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1101,7 +1101,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())