summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2021-03-28 12:56:30 +0300
committerAleksey Midenkov <midenok@gmail.com>2021-03-29 23:37:47 +0300
commit7db28e9ae3e6388b89ee60850104e39a8b53bb5b (patch)
treed90ccd058cf3ce084a7dbb977206a7cceed9664d
parent36c4f7f3e5b4971567e023379c8a1d3f1cb51d9d (diff)
downloadmariadb-git-bb-10.6-midenok-tmp.tar.gz
-rw-r--r--sql/sql_rename.cc36
-rw-r--r--sql/sql_table.cc6
2 files changed, 21 insertions, 21 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index f319c05c1bd..2e2dd27006d 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -208,8 +208,7 @@ err:
static bool
-do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table,
- bool skip_error)
+do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
{
LEX_CSTRING *new_alias;
DBUG_ENTER("do_rename_temporary");
@@ -244,6 +243,12 @@ struct rename_param
- From table should exists
- To table should not exists.
+ SYNPOSIS
+ check_rename()
+ new_table_name The new table/view name
+ new_table_alias The new table/view alias
+ skip_error Whether to skip error
+
@return
@retval 0 ok
@retval >0 Error (from table doesn't exists or to table exists)
@@ -256,9 +261,10 @@ check_rename(THD *thd, rename_param *param,
const LEX_CSTRING *new_db,
const LEX_CSTRING *new_table_name,
const LEX_CSTRING *new_table_alias,
- bool skip_error, bool if_exists)
+ bool if_exists)
{
DBUG_ENTER("check_rename");
+ DBUG_PRINT("enter", ("if_exists: %d", (int) if_exists));
if (lower_case_table_names == 2)
{
@@ -276,9 +282,9 @@ check_rename(THD *thd, rename_param *param,
&param->from_table_hton) ||
!param->from_table_hton)
{
- my_error(ER_NO_SUCH_TABLE, MYF((skip_error | if_exists) ? ME_NOTE : 0),
+ my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0),
ren_table->db.str, param->old_alias.str);
- DBUG_RETURN(skip_error || if_exists ? -1 : 1);
+ DBUG_RETURN(if_exists ? -1 : 1);
}
if (param->from_table_hton != view_pseudo_hton &&
@@ -310,9 +316,6 @@ check_rename(THD *thd, rename_param *param,
thd Thread handle
ren_table A table/view to be renamed
new_db The database to which the table to be moved to
- new_table_name The new table/view name
- new_table_alias The new table/view alias
- skip_error Whether to skip error
if_exists Skip error, but only if the table didn't exists
force_if_exists Set to 1 if we have to log the query with 'IF EXISTS'
Otherwise don't touch the value
@@ -329,17 +332,14 @@ check_rename(THD *thd, rename_param *param,
static bool
do_rename(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state,
TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
- const LEX_CSTRING *new_table_name,
- const LEX_CSTRING *new_table_alias,
- bool skip_error, bool if_exists, bool *force_if_exists)
+ bool skip_error, bool *force_if_exists)
{
int rc= 1;
handlerton *hton;
LEX_CSTRING *old_alias, *new_alias;
TRIGGER_RENAME_PARAM rename_param;
DBUG_ENTER("do_rename");
- DBUG_PRINT("enter", ("skip_error: %d if_exists: %d", (int) skip_error,
- (int) if_exists));
+ DBUG_PRINT("enter", ("skip_error: %d", (int) skip_error));
old_alias= &param->old_alias;
new_alias= &param->new_alias;
@@ -510,7 +510,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state,
pair->from= ren_table;
pair->to= new_table;
- if (do_rename_temporary(thd, ren_table, new_table, skip_error))
+ if (do_rename_temporary(thd, ren_table, new_table))
goto revert_rename;
}
else
@@ -519,7 +519,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state,
rename_param param;
error= check_rename(thd, &param, ren_table, &new_table->db,
&new_table->table_name,
- &new_table->alias, skip_error, if_exists);
+ &new_table->alias, (skip_error || if_exists));
if (error < 0)
continue; // Ignore rename (if exists)
if (error > 0)
@@ -527,8 +527,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state,
if (do_rename(thd, &param, ddl_log_state,
ren_table,
- &new_table->db, &new_table->table_name, &new_table->alias,
- skip_error, if_exists, force_if_exists))
+ &new_table->db,
+ skip_error, force_if_exists))
goto revert_rename;
}
}
@@ -538,7 +538,7 @@ revert_rename:
/* Revert temporary tables. Normal tables are reverted in the caller */
List_iterator_fast<TABLE_PAIR> it(tmp_tables);
while (TABLE_PAIR *pair= it++)
- do_rename_temporary(thd, pair->to, pair->from, 1);
+ do_rename_temporary(thd, pair->to, pair->from);
DBUG_RETURN(1);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b0122da4408..563189eedff 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1068,7 +1068,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
@retval >0 the lenght of the comment found
*/
-static uint32 comment_length(THD *thd, uint32 comment_pos,
+static uint32 get_comment(THD *thd, uint32 comment_pos,
const char **comment_start)
{
/* We use uchar * here to make array indexing portable */
@@ -1099,7 +1099,7 @@ static uint32 comment_length(THD *thd, uint32 comment_pos,
}
/**
- Execute the drop of a normal or temporary table.
+ Execute the drop of sequence, view or table (normal or temporary).
@param thd Thread handler
@param tables Tables to drop
@@ -1174,7 +1174,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
}
unknown_tables.length(0);
- comment_len= comment_length(thd, if_exists ? 17:9,
+ comment_len= get_comment(thd, if_exists ? 17:9,
&comment_start);
/*