diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2021-09-03 12:00:57 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2021-09-03 12:01:03 +0300 |
commit | 60c4ec992971158fc7d0b467d134c49605da1b88 (patch) | |
tree | cf9a16dbd972cb21cd2e8705d3f4d56a3d1f06fc | |
parent | 31542084220b657c144ab9aa00f0d7572dfb2f92 (diff) | |
download | mariadb-git-bb-10.7-midenok-MDEV-25292-rebase.tar.gz |
Temporary table was not temporary fixbb-10.7-midenok-MDEV-25292-rebase
Tests affected: encryption.create_or_replace
-rw-r--r-- | mysql-test/main/create_or_replace.result | 7 | ||||
-rw-r--r-- | mysql-test/main/create_or_replace.test | 7 | ||||
-rw-r--r-- | sql/sql_rename.cc | 3 | ||||
-rw-r--r-- | sql/sql_table.cc | 1 | ||||
-rw-r--r-- | sql/sql_table.h | 4 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 22 | ||||
-rw-r--r-- | sql/sql_trigger.h | 2 |
7 files changed, 37 insertions, 9 deletions
diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 06b07eb53bd..2ce7d20b567 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -720,3 +720,10 @@ test t2 1 0 unlock tables; drop procedure sp; drop tables t1, t2, t3; +# Trigger +create table t1 (a int); +create trigger a before insert on t1 for each row set @s= 1; +create or replace table t1 (old int); +show create trigger a; +ERROR HY000: Trigger does not exist +drop table t1; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index a5cdbcd2790..1f6e61b773d 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -565,3 +565,10 @@ call sp; call sp; unlock tables; drop procedure sp; drop tables t1, t2, t3; +--echo # Trigger +create table t1 (a int); +create trigger a before insert on t1 for each row set @s= 1; +create or replace table t1 (old int); +--error ER_TRG_DOES_NOT_EXIST +show create trigger a; +drop table t1; diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 253b78a4d1e..cbb361268e3 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -367,7 +367,8 @@ rename_do(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state, debug_crash_here("ddl_log_rename_before_rename_table"); if (!(rc= mysql_rename_table(hton, &ren_table->db, old_alias, - new_db, new_alias, ¶m->old_version, 0))) + new_db, new_alias, ¶m->old_version, + param->rename_flags))) { /* Table rename succeded. It's safe to start recovery at rename trigger phase diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1e1e72103bc..7fd2308daa8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1474,6 +1474,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, } else { + param.rename_flags= FN_TO_IS_TMP; if (close_or_remove_table(thd, table) || rename_do(thd, ¶m, ddl_log_state_create, table, &table->db, false, &force_if_exists)) diff --git a/sql/sql_table.h b/sql/sql_table.h index 0dc105b7341..dc26498c24d 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -177,6 +177,10 @@ struct rename_param LEX_CSTRING old_alias, new_alias; LEX_CUSTRING old_version; handlerton *from_table_hton; + int rename_flags; /* FN_FROM_IS_TMP, FN_TO_IS_TMP, etc */ + rename_param() : + from_table_hton(NULL), + rename_flags(0) {} }; bool rename_do(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state, diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 7b3db324db7..a86c8f87269 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1174,9 +1174,10 @@ bool Trigger::add_to_file_list(void* param_arg) */ static bool rm_trigger_file(char *path, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, myf MyFlags) + const LEX_CSTRING *table_name, myf MyFlags, + uint flags= 0) { - build_table_filename(path, FN_REFLEN-1, db->str, table_name->str, TRG_EXT, 0); + build_table_filename(path, FN_REFLEN-1, db->str, table_name->str, TRG_EXT, flags); return mysql_file_delete(key_file_trg, path, MyFlags); } @@ -1502,7 +1503,8 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table) bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, TABLE *table, - bool names_only) + bool names_only, + uint flags) { char path_buff[FN_REFLEN]; LEX_CSTRING path; @@ -1511,7 +1513,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, DBUG_ENTER("Table_triggers_list::check_n_load"); path.length= build_table_filename(path_buff, FN_REFLEN - 1, - db->str, table_name->str, TRG_EXT, 0); + db->str, table_name->str, TRG_EXT, flags); path.str= path_buff; // QQ: should we analyze errno somehow ? @@ -2012,11 +2014,17 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, init_sql_alloc(key_memory_Table_trigger_dispatcher, &table.mem_root, 8192, 0, MYF(MY_WME)); - if (Table_triggers_list::check_n_load(thd, db, name, &table, 1)) + /* + Note: frm is already deleted and build_table_filename() will not detect + FN_IS_TMP flag. + */ + uint flags= is_prefix(name->str, tmp_file_prefix) ? FN_IS_TMP : 0; + + if (Table_triggers_list::check_n_load(thd, db, name, &table, 1, flags)) { result= 1; /* We couldn't parse trigger file, best to just remove it */ - rm_trigger_file(path, db, name, MyFlags); + rm_trigger_file(path, db, name, MyFlags, flags); goto end; } if (table.triggers) @@ -2050,7 +2058,7 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, } } } - if (rm_trigger_file(path, db, name, MyFlags)) + if (rm_trigger_file(path, db, name, MyFlags, flags)) result= 1; delete table.triggers; } diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 739669c86a5..c4b0247280d 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -258,7 +258,7 @@ public: bool save_trigger_file(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name); static bool check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, - TABLE *table, bool names_only); + TABLE *table, bool names_only, uint flags= 0); static bool drop_all_triggers(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, myf MyFlags); static bool prepare_for_rename(THD *thd, TRIGGER_RENAME_PARAM *param, |