From 34b9dc4f4d5539b83baf56d7fd8e8afca532cf59 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 3 Jan 2025 14:34:21 +0200 Subject: [PATCH 1/2] MDEV-25292 Atomic CREATE OR REPLACE TABLE Atomic CREATE OR REPLACE allows to keep an old table intact if the command fails or during the crash. That is done by renaming the original table to temporary name, as a backup and restoring it if the CREATE fails. When the command is complete and logged the backup table is deleted. Atomic replace algorithm Two DDL chains are used for CREATE OR REPLACE: ddl_log_state_create (C) and ddl_log_state_rm (D). 1. (C) Log rename of ORIG to TMP table (Rename TMP to original). 2. Rename orignal to TMP. 3. (C) Log CREATE_TABLE_ACTION of ORIG (drops ORIG); 4. Do everything with ORIG (like insert data) 5. (D) Log drop of TMP 6. Write query to binlog (this marks (C) to be closed in case of failure) 7. Execute drop of TMP through (D) 8. Close (C) and (D) If there is a failure before 6) we revert the changes in (C) Chain (D) is only executed if 6) succeded (C is closed on crash recovery). Foreign key errors will be found at the 1) stage. Additional notes - CREATE TABLE without REPLACE and temporary tables is not affected by this commit. set @@drop_before_create_or_replace=1 can be used to get old behaviour where existing tables are dropped in CREATE OR REPLACE. - CREATE TABLE is reverted if binlogging the query fails. - Engines having HTON_EXPENSIVE_RENAME flag set are not affected by this commit. Conflicting tables marked with this flag will be deleted with CREATE OR REPLACE. - Replication execution is not affected by this commit. - Replication will first drop the conflicting table and then creating the new one. - CREATE TABLE .. SELECT XID usage is fixed and now there is no need to log DROP TABLE via DDL_CREATE_TABLE_PHASE_LOG (see comments in do_postlock()). XID is now correctly updated so it disables DDL_LOG_DROP_TABLE_ACTION. Note that binary log is flushed at the final stage when the table is ready. So if we have XID in the binary log we don't need to drop the table. - Three variations of CREATE OR REPLACE handled: 1. CREATE OR REPLACE TABLE t1 (..); 2. CREATE OR REPLACE TABLE t1 LIKE t2; 3. CREATE OR REPLACE TABLE t1 SELECT ..; - Test case uses 6 combinations for engines (aria, aria_notrans, myisam, ib, lock_tables, expensive_rename) and 2 combinations for binlog types (row, stmt). Combinations help to check differences between the results. Error failures are tested for the above three variations. - expensive_rename tests CREATE OR REPLACE without atomic replace. The effect should be the same as with the old behaviour before this commit. - Triggers mechanism is unaffected by this change. This is tested in create_replace.test. - LOCK TABLES is affected. Lock restoration must be done after new table is created or TMP is renamed back to ORIG - Moved ddl_log_complete() from send_eof() to finalize_ddl(). This checkpoint was not executed before for normal CREATE TABLE but is executed now. - CREATE TABLE will now rollback also if writing to the binary logging failed. See rpl_gtid_strict.test backup ddl log changes - In case of a successfull CREATE OR REPLACE we only log the CREATE event, not the DROP TABLE event of the old table. ddl_log.cc changes ddl_log_execute_action() now properly return error conditions. ddl_log_disable_entry() added to allow one to disable one entry. The entry on disk is still reserved until ddl_log_complete() is executed. On XID usage Like with all other atomic DDL operations XID is used to avoid inconsistency between master and slave in the case of a crash after binary log is written and before ddl_log_state_create is closed. On recovery XIDs are taken from binary log and corresponding DDL log events get disabled. That is done by ddl_log_close_binlogged_events(). On linking two chains together Chains are executed in the ascending order of entry_pos of execute entries. But entry_pos assignment order is undefined: it may assign bigger number for the first chain and then smaller number for the second chain. So the execution order in that case will be reverse: second chain will be executed first. To avoid that we link one chain to another. While the base chain (ddl_log_state_create) is active the secondary chain (ddl_log_state_rm) is not executed. That is: only one chain can be executed in two linked chains. The interface ddl_log_link_chains() was defined in "MDEV-22166 ddl_log_write_execute_entry() extension". Atomic info parameters in HA_CREATE_INFO Many functions in CREATE TABLE pass the same parameters. These parameters are part of table creation info and should be in HA_CREATE_INFO (or whatever). Passing parameters via single structure is much easier for adding new data and refactoring. InnoDB changes Added ha_innobase::can_be_renamed_to_backup() to check if a table with foreign keys can be renamed. Aria changes: - Fixed issue in Aria engine with CREATE + locked tables that data was not properly commited in some cases in case of crashes. Other changes: - Removed some auto variables in log.cc for better code readability. - Fixed old bug that CREATE ... SELECT would not be able to auto repair a table that is part of the SELECT. - Marked MyISAM that it does not support ROLLBACK (not required but done for better consistency with other engines). Known issues: - InnoDB tables with foreign key definitions are not fully supported with atomic create and replace: - ha_innobase::can_be_renamed_to_backup() can detect some cases where InnoDB does not support renaming table with foreign key constraints. In this case MariaDB will drop the old table before creating the new one. The detected cases are: - The new and old table is using the same foreign key constraint name. - The old table has self referencing constraints. - If the old and new table uses the same name for a constraint the create of the new table will fail. The orignal table will be restored in this case. - The above issues will be fixed in a future commit. - CREATE OR REPLACE TEMPORARY table is not full atomic. Any conflicting table will always be dropped before creating a new one. (Old behaviour). Bug fixes related to this MDEV: MDEV-36435 Assertion failure in finalize_locked_tables() MDEV-36439 Assertion `thd_arg->lex->sql_command != SQLCOM_CREATE_SEQUENCE... MDEV-36498 Failed CoR in non-atomic mode no longer generates DROP in RBR... MDEV-36508 Temporary files #sql-create-....frm occasionally stay after crash recovery MDEV-38479 Crash in CREATE OR REPLACE SEQUENCE when new sequence cannot be created MDEV-36497 Assertion failure after atomic CoR with Aria under lock in transactional context MDEV-36501 EITS data is lost after failed attempt to CREATE OR REPLACE table MDEV-36493 Atomic CREATE OR REPLACE ... SELECT blocks InnoDB purge MDEV-39367 MSAN/valgrind errors in temp_file_size_cb_func, main.tmp_space_usage fails MDEV-39446 Atomic CREATE OR REPLACE fails if a table cannot be decrypted InnoDB related changes: - ha_innodb::rename_table() does not handle foreign key constraint when renaming an normal table to internal tempory tables. This causes problems for CREATE OR REPLACE as the old constraints causes failure when creating a new table with the same constraints. This is fixed inside InnoDB by not threating tempfiles (#sql-create-..), created as part of CREATE OR REPLACE, as temporary files. - In ha_innobase::delete_table(), ignore checking of constraints when dropping a #sql-create temporary table. - In tablename_to_filename() and filename_to_tablename(), don't do filename conversion for internal temporary tables (#sql-...) Other things: - maria_create_trn_for_mysql() does not register a new transaction handler for commits. This was needed to ensure create or replace will not end with an active transaction. - We do not get anymore warnings about "Engine not supporting atomic create" when doing a legal CREATE OR REPLACE on a table with foreign key constraints. - Updated VIDEX engine flags to disable CREATE SEQUENCE. Reverted commits: MDEV-36685 "CREATE-SELECT may lose in binlog side-effects of stored-routine" as it did not take into account that it safe to clear binlogs if the created table is non transactional and there are no other non transactional tables used. - This was done because it caused extra logging when it is not needed (not using any non transactional tables) and it also did not solve side effects when using statement based loggging. Other things: - EITS data is preserved if create or replace fails if drop_before_create_or_replace=OFF. If ON, then create or replace will drop EITS before the drop of the original table (as before). - Using CREATE OR REPLACE on a encrypted table that the user cannot decrypt will fail instead of replacing the encrypted table. The encrypted table will unchanged. --- mysql-test/include/binlog_inject_error.inc | 6 +- ...inlog_format_row_or_statement.combinations | 5 + .../have_binlog_format_row_or_statement.inc | 7 - mysql-test/main/backup_log.inc | 24 + mysql-test/main/backup_log.result | 191 +-- mysql-test/main/backup_log.test | 6 + mysql-test/main/backup_log_print.inc | 7 + mysql-test/main/create_notembedded.result | 33 + mysql-test/main/create_notembedded.test | 65 + mysql-test/main/create_or_replace.result | 660 +++++++++- mysql-test/main/create_or_replace.test | 437 ++++++- mysql-test/main/create_or_replace2.result | 23 + mysql-test/main/create_or_replace2.test | 25 +- mysql-test/main/create_replace_debug.result | 74 ++ mysql-test/main/create_replace_debug.test | 84 ++ mysql-test/main/default.result | 12 +- mysql-test/main/default.test | 8 +- mysql-test/main/long_unique_bugs.result | 3 +- mysql-test/main/long_unique_bugs.test | 3 +- mysql-test/main/mdev19198.result | 4 + mysql-test/main/mdev19198.test | 4 + mysql-test/main/mysqld--help.result | 6 + mysql-test/suite/atomic/alter_table.inc | 10 +- mysql-test/suite/atomic/create_fk.result | 51 + mysql-test/suite/atomic/create_fk.test | 54 + mysql-test/suite/atomic/create_replace.result | 898 +++++++++++++ mysql-test/suite/atomic/create_replace.test | 23 + .../atomic/create_replace2,aria,row.result | 456 +++++++ .../create_replace2,aria_notrans,row.result | 456 +++++++ .../create_replace2,aria_notrans,stmt.result | 432 +++++++ .../create_replace2,aria_notrans.result | 432 +++++++ .../atomic/create_replace2,ib,row.result | 420 +++++++ .../suite/atomic/create_replace2,ib.result | 396 ++++++ .../create_replace2,lock_tables,row.result | 456 +++++++ .../create_replace2,lock_tables,stmt.result | 432 +++++++ .../atomic/create_replace2,myisam,row.result | 456 +++++++ .../atomic/create_replace2,myisam,stmt.result | 432 +++++++ .../suite/atomic/create_replace2,row.result | 456 +++++++ .../suite/atomic/create_replace2.combinations | 5 + .../suite/atomic/create_replace2.result | 432 +++++++ mysql-test/suite/atomic/create_replace2.test | 208 ++++ .../suite/atomic/create_replace_drop.opt | 1 + .../suite/atomic/create_replace_drop.result | 464 +++++++ .../suite/atomic/create_replace_drop.test | 17 + .../suite/atomic/create_replace_memory.result | 59 + .../suite/atomic/create_replace_memory.test | 13 + .../atomic/create_replace_no_binlog.result | 306 +++++ .../atomic/create_replace_no_binlog.test | 14 + mysql-test/suite/atomic/create_table.inc | 187 +++ mysql-test/suite/atomic/create_table.result | 449 +++---- mysql-test/suite/atomic/create_table.test | 143 +-- .../suite/atomic/create_table_binlog.opt | 1 + .../suite/atomic/create_table_binlog.result | 60 + .../suite/atomic/create_table_binlog.test | 41 + .../atomic/create_table_no_binlog.result | 174 +++ .../suite/atomic/create_table_no_binlog.test | 14 + mysql-test/suite/atomic/disabled.def | 1 - .../suite/atomic/encrypted_tables.result | 28 + mysql-test/suite/atomic/encrypted_tables.test | 44 + .../suite/atomic/rename_trigger2.result | 35 + mysql-test/suite/atomic/rename_trigger2.test | 27 + mysql-test/suite/binlog/include/binlog.test | 9 + .../suite/binlog/r/binlog_row_binlog.result | 12 +- .../suite/binlog/r/binlog_stm_binlog.result | 48 +- .../suite/binlog/r/binlog_tmp_table.result | 4 +- .../suite/binlog/r/binlog_write_error.result | 76 +- .../binlog/r/binlog_write_error_tmp.result | 33 + mysql-test/suite/binlog/r/create_like.result | 3 - .../suite/binlog/t/binlog_stm_binlog.test | 2 +- .../suite/binlog/t/binlog_tmp_table.test | 20 +- .../suite/binlog/t/binlog_write_error.test | 16 + .../binlog/t/binlog_write_error_tmp.test | 37 + mysql-test/suite/binlog/t/create_like.test | 1 - .../binlog_write_error.result | 76 +- mysql-test/suite/maria/create.result | 43 +- mysql-test/suite/maria/create.test | 30 +- mysql-test/suite/parts/r/backup_log.result | 211 ++-- mysql-test/suite/period/r/create.result | 2 +- .../suite/rpl/r/create_or_replace_mix.result | 11 +- .../suite/rpl/r/create_or_replace_mix2.result | 13 +- .../suite/rpl/r/create_or_replace_row.result | 15 +- .../rpl/r/create_or_replace_statement.result | 13 +- .../rpl/r/create_table_binlog_mixed.result | 64 + .../rpl/r/create_table_binlog_row.result | 72 ++ .../rpl/r/rpl_create_or_replace_fail.result | 2 +- .../suite/rpl/r/rpl_create_select_row.result | 92 +- .../rpl_create_tmp_table_if_not_exists.result | 4 - mysql-test/suite/rpl/r/rpl_gtid_strict.result | 5 +- mysql-test/suite/rpl/t/create_or_replace.inc | 2 + .../suite/rpl/t/create_table_binlog.inc | 69 + .../rpl/t/create_table_binlog_mixed.test | 2 + .../suite/rpl/t/create_table_binlog_row.test | 2 + .../suite/rpl/t/rpl_create_select_row.test | 25 +- mysql-test/suite/rpl/t/rpl_gtid_strict.test | 7 +- mysql-test/suite/sql_sequence/create.result | 5 + mysql-test/suite/sql_sequence/create.test | 4 + .../suite/sql_sequence/create_archive.result | 12 +- .../suite/sql_sequence/create_archive.test | 4 - .../sys_vars/r/sysvars_server_embedded.result | 10 + .../r/sysvars_server_notembedded.result | 10 + .../suite/vcol/r/innodb_virtual_fk.result | 2 - mysql-test/suite/versioning/t/partition.test | 1 - sql/ddl_log.cc | 377 ++++-- sql/ddl_log.h | 30 +- sql/ha_partition.cc | 14 + sql/ha_partition.h | 8 +- sql/handler.cc | 86 +- sql/handler.h | 52 +- sql/log.cc | 61 +- sql/mysqld.cc | 10 +- sql/sql_admin.cc | 2 +- sql/sql_base.cc | 72 +- sql/sql_class.cc | 4 +- sql/sql_class.h | 25 +- sql/sql_insert.cc | 299 +++-- sql/sql_partition.cc | 6 + sql/sql_partition_admin.cc | 2 +- sql/sql_rename.cc | 128 +- sql/sql_rename.h | 18 + sql/sql_select.cc | 2 + sql/sql_sequence.cc | 23 +- sql/sql_show.cc | 3 +- sql/sql_table.cc | 1107 +++++++++++------ sql/sql_table.h | 18 +- sql/sql_trigger.cc | 74 +- sql/sql_trigger.h | 21 +- sql/sql_truncate.cc | 3 +- sql/sys_vars.cc | 10 + sql/table.h | 8 +- sql/wsrep_var.cc | 6 +- storage/innobase/handler/ha_innodb.cc | 8 +- storage/innobase/handler/ha_innodb.h | 1 + storage/innobase/handler/handler0alter.cc | 2 +- storage/innobase/include/dict0mem.h | 27 +- storage/innobase/include/dict0types.h | 5 +- storage/maria/ha_maria.cc | 35 +- storage/maria/ha_s3.cc | 3 +- storage/maria/ma_init.c | 3 +- storage/maria/ma_state.c | 11 +- storage/maria/ma_state.h | 2 +- storage/maria/ma_static.c | 2 +- storage/maria/maria_def.h | 2 +- storage/myisam/ha_myisam.cc | 2 +- storage/videx/ha_videx.cc | 2 +- .../videx/create-table-and-index.result | 11 + .../videx/create-table-and-index.test | 15 + strings/is_prefix.c | 2 +- 147 files changed, 12313 insertions(+), 1628 deletions(-) create mode 100644 mysql-test/include/have_binlog_format_row_or_statement.combinations create mode 100644 mysql-test/main/backup_log_print.inc create mode 100644 mysql-test/main/create_notembedded.result create mode 100644 mysql-test/main/create_notembedded.test create mode 100644 mysql-test/main/create_replace_debug.result create mode 100644 mysql-test/main/create_replace_debug.test create mode 100644 mysql-test/suite/atomic/create_fk.result create mode 100644 mysql-test/suite/atomic/create_fk.test create mode 100644 mysql-test/suite/atomic/create_replace.result create mode 100644 mysql-test/suite/atomic/create_replace.test create mode 100644 mysql-test/suite/atomic/create_replace2,aria,row.result create mode 100644 mysql-test/suite/atomic/create_replace2,aria_notrans,row.result create mode 100644 mysql-test/suite/atomic/create_replace2,aria_notrans,stmt.result create mode 100644 mysql-test/suite/atomic/create_replace2,aria_notrans.result create mode 100644 mysql-test/suite/atomic/create_replace2,ib,row.result create mode 100644 mysql-test/suite/atomic/create_replace2,ib.result create mode 100644 mysql-test/suite/atomic/create_replace2,lock_tables,row.result create mode 100644 mysql-test/suite/atomic/create_replace2,lock_tables,stmt.result create mode 100644 mysql-test/suite/atomic/create_replace2,myisam,row.result create mode 100644 mysql-test/suite/atomic/create_replace2,myisam,stmt.result create mode 100644 mysql-test/suite/atomic/create_replace2,row.result create mode 100644 mysql-test/suite/atomic/create_replace2.combinations create mode 100644 mysql-test/suite/atomic/create_replace2.result create mode 100644 mysql-test/suite/atomic/create_replace2.test create mode 100644 mysql-test/suite/atomic/create_replace_drop.opt create mode 100644 mysql-test/suite/atomic/create_replace_drop.result create mode 100644 mysql-test/suite/atomic/create_replace_drop.test create mode 100644 mysql-test/suite/atomic/create_replace_memory.result create mode 100644 mysql-test/suite/atomic/create_replace_memory.test create mode 100644 mysql-test/suite/atomic/create_replace_no_binlog.result create mode 100644 mysql-test/suite/atomic/create_replace_no_binlog.test create mode 100644 mysql-test/suite/atomic/create_table.inc create mode 100644 mysql-test/suite/atomic/create_table_binlog.opt create mode 100644 mysql-test/suite/atomic/create_table_binlog.result create mode 100644 mysql-test/suite/atomic/create_table_binlog.test create mode 100644 mysql-test/suite/atomic/create_table_no_binlog.result create mode 100644 mysql-test/suite/atomic/create_table_no_binlog.test create mode 100644 mysql-test/suite/atomic/encrypted_tables.result create mode 100644 mysql-test/suite/atomic/encrypted_tables.test create mode 100644 mysql-test/suite/atomic/rename_trigger2.result create mode 100644 mysql-test/suite/atomic/rename_trigger2.test create mode 100644 mysql-test/suite/binlog/r/binlog_write_error_tmp.result create mode 100644 mysql-test/suite/binlog/t/binlog_write_error_tmp.test create mode 100644 mysql-test/suite/rpl/r/create_table_binlog_mixed.result create mode 100644 mysql-test/suite/rpl/r/create_table_binlog_row.result create mode 100644 mysql-test/suite/rpl/t/create_table_binlog.inc create mode 100644 mysql-test/suite/rpl/t/create_table_binlog_mixed.test create mode 100644 mysql-test/suite/rpl/t/create_table_binlog_row.test diff --git a/mysql-test/include/binlog_inject_error.inc b/mysql-test/include/binlog_inject_error.inc index ce94035272358..4389859a9f94d 100644 --- a/mysql-test/include/binlog_inject_error.inc +++ b/mysql-test/include/binlog_inject_error.inc @@ -13,9 +13,11 @@ # let query= 'CREATE TABLE t1 (a INT)'; # source include/binlog_inject_error.inc; # + +--source include/have_debug.inc + set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; ---echo $query; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; --replace_regex /(errno: .*)/(errno: #)/ --error ER_ERROR_ON_WRITE --eval $query diff --git a/mysql-test/include/have_binlog_format_row_or_statement.combinations b/mysql-test/include/have_binlog_format_row_or_statement.combinations new file mode 100644 index 0000000000000..524d66e86bc78 --- /dev/null +++ b/mysql-test/include/have_binlog_format_row_or_statement.combinations @@ -0,0 +1,5 @@ +[row] +binlog-format=row + +[stmt] +binlog-format=statement diff --git a/mysql-test/include/have_binlog_format_row_or_statement.inc b/mysql-test/include/have_binlog_format_row_or_statement.inc index 6ea0ecd686949..4b5bec7d1d427 100644 --- a/mysql-test/include/have_binlog_format_row_or_statement.inc +++ b/mysql-test/include/have_binlog_format_row_or_statement.inc @@ -1,8 +1 @@ source include/have_log_bin.inc; - - -if (`SELECT @@binlog_format = 'MIXED'`) -{ - --skip Neither ROW nor STATEMENT binlog format -} - diff --git a/mysql-test/main/backup_log.inc b/mysql-test/main/backup_log.inc index f553a3b952743..dbf212a791ee6 100644 --- a/mysql-test/main/backup_log.inc +++ b/mysql-test/main/backup_log.inc @@ -20,6 +20,8 @@ repair table t1; optimize table t1; drop table t1; +--source backup_log_print.inc + eval create table t1_innodb (a int) engine=innodb $part_int; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -30,6 +32,8 @@ repair table t1_innodb; optimize table t1_innodb; drop table t1_innodb; +--source backup_log_print.inc + --echo # --echo # Testing with temporary tables (should not be logged) --echo # @@ -41,6 +45,8 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; +--source backup_log_print.inc + --echo # --echo # Testing with mix of normal and temporary tables --echo # @@ -54,6 +60,8 @@ eval create table t21 (a int) $part_int; drop temporary table if exists tmp_t21,t21; drop table if exists tmp_t21,t21; +--source backup_log_print.inc + --echo # --echo # Testing create select --echo # @@ -68,6 +76,8 @@ eval create or replace table t31 (a int primary key) $part_int select * from t30 eval create table t32 (a int) $part_int; drop table if exists t30,t31,t32,tmp_t30; +--source backup_log_print.inc + --echo # --echo # Testing create LIKE --echo # @@ -81,6 +91,8 @@ create or replace table t42 like t41; show create table t42; drop table t40, t41, t42; +--source backup_log_print.inc + --echo # --echo # Testing rename --echo # @@ -91,6 +103,8 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; +--source backup_log_print.inc + --echo # --echo # Testing enable/disable keys --echo # @@ -107,6 +121,8 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; +--source backup_log_print.inc + --echo # --echo # Testing load data --echo # @@ -128,6 +144,8 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; +--source backup_log_print.inc + --echo # --echo # Testing strange table names --echo # @@ -135,6 +153,8 @@ drop table t70,t71; eval create table `t 1` (a int) $part_int; drop table `t 1`; +--source backup_log_print.inc + --echo # --echo # Testing views and triggers --echo # @@ -146,6 +166,8 @@ drop trigger trg; drop view v1; drop table t80; +--source backup_log_print.inc + --echo # --echo # Testing alter to a new storage engine --echo # @@ -153,3 +175,5 @@ drop table t80; eval create table t85 (a int primary key, b int) engine=myisam $part_int; alter table t85 engine=innodb; drop table t85; + +--source backup_log_print.inc diff --git a/mysql-test/main/backup_log.result b/mysql-test/main/backup_log.result index df6592a9b3466..890d4befdef90 100644 --- a/mysql-test/main/backup_log.result +++ b/mysql-test/main/backup_log.result @@ -19,6 +19,16 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; +# +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t1,id: 1,,0,,, +ALTER,MyISAM,0,test,t1,id: 1,MyISAM,0,test,t1,id: 2 +RENAME,MyISAM,0,test,t1,id: 2,MyISAM,0,test,t2,id: 2 +RENAME,MyISAM,0,test,t2,id: 2,MyISAM,0,test,t1,id: 2 +repair,MyISAM,0,test,t1,id: 2,,0,,, +optimize,MyISAM,0,test,t1,id: 2,,0,,, +DROP,MyISAM,0,test,t1,id: 2,,0,,, create table t1_innodb (a int) engine=innodb ; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -34,6 +44,17 @@ test.t1_innodb optimize note Table does not support optimize, doing recreate + a test.t1_innodb optimize status OK drop table t1_innodb; # +# Reading backup ddl log file +# +CREATE,InnoDB,0,test,t1_innodb,id: 1,,0,,, +ALTER,InnoDB,0,test,t1_innodb,id: 1,InnoDB,0,test,t1_innodb,id: 2 +RENAME,InnoDB,0,test,t1_innodb,id: 2,InnoDB,0,test,t2_innodb,id: 2 +RENAME,InnoDB,0,test,t2_innodb,id: 2,InnoDB,0,test,t1_innodb,id: 2 +TRUNCATE,InnoDB,0,test,t1_innodb,id: 2,,0,,, +repair,InnoDB,0,test,t1_innodb,id: 2,,0,test,t1_innodb,id: 3 +optimize,InnoDB,0,test,t1_innodb,id: 3,,0,test,t1_innodb,id: 4 +DROP,InnoDB,0,test,t1_innodb,id: 4,,0,,, +# # Testing with temporary tables (should not be logged) # create temporary table tmp_t10 (a int) engine=myisam; @@ -43,6 +64,9 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; # +# Reading backup ddl log file +# +# # Testing with mix of normal and temporary tables # create temporary table tmp_t20 (a int); @@ -57,6 +81,13 @@ drop table if exists tmp_t21,t21; Warnings: Note 1051 Unknown table 'test.tmp_t21' # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t20,id: 1,,0,,, +DROP,MyISAM,0,test,t20,id: 1,,0,,, +CREATE,MyISAM,0,test,t21,id: 2,,0,,, +DROP,MyISAM,0,test,t21,id: 2,,0,,, +# # Testing create select # create table t30 (a int) ; @@ -69,7 +100,17 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' create table t32 (a int) ; drop table if exists t30,t31,t32,tmp_t30; Warnings: -Note 1051 Unknown table 'test.t31,test.tmp_t30' +Note 1051 Unknown table 'test.tmp_t30' +# +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t30,id: 1,,0,,, +CREATE,MyISAM,0,test,t31,id: 2,,0,,, +CREATE,MyISAM,0,test,t31,id: 3,,0,,, +CREATE,MyISAM,0,test,t32,id: 4,,0,,, +DROP,MyISAM,0,test,t30,id: 1,,0,,, +DROP,MyISAM,0,test,t31,id: 3,,0,,, +DROP,MyISAM,0,test,t32,id: 4,,0,,, # # Testing create LIKE # @@ -86,6 +127,16 @@ t42 CREATE TABLE `t42` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci drop table t40, t41, t42; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t40,id: 1,,0,,, +CREATE,InnoDB,0,test,t41,id: 2,,0,,, +CREATE,MyISAM,0,test,t42,id: 3,,0,,, +CREATE,InnoDB,0,test,t42,id: 4,,0,,, +DROP,MyISAM,0,test,t40,id: 1,,0,,, +DROP,InnoDB,0,test,t41,id: 2,,0,,, +DROP,InnoDB,0,test,t42,id: 4,,0,,, +# # Testing rename # create table t50 (a int) ; @@ -94,6 +145,18 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t50,id: 1,,0,,, +CREATE,MyISAM,0,test,t51,id: 2,,0,,, +RENAME,MyISAM,0,test,t50,id: 1,MyISAM,0,test,t52,id: 1 +RENAME,MyISAM,0,test,t51,id: 2,MyISAM,0,test,t53,id: 2 +RENAME,MyISAM,0,test,t52,id: 1,MyISAM,0,test,tmp,id: 1 +RENAME,MyISAM,0,test,t53,id: 2,MyISAM,0,test,t52,id: 2 +RENAME,MyISAM,0,test,tmp,id: 1,MyISAM,0,test,t53,id: 1 +DROP,MyISAM,0,test,t52,id: 2,,0,,, +DROP,MyISAM,0,test,t53,id: 1,,0,,, +# # Testing enable/disable keys # CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria ; @@ -107,6 +170,13 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; # +# Reading backup ddl log file +# +CREATE,Aria,0,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,0,test,t60,id: 1,,0,,, +DROP,Aria,0,test,t60,id: 1,,0,,, +# # Testing load data # create table t70 (a date, b date, c date not null, d date) engine=aria ; @@ -123,11 +193,26 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; # +# Reading backup ddl log file +# +CREATE,Aria,0,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,0,test,t70,id: 1,,0,,, +CREATE,Aria,0,test,t71,id: 2,,0,,, +BULK_INSERT,Aria,0,test,t71,id: 2,,0,,, +DROP,Aria,0,test,t70,id: 1,,0,,, +DROP,Aria,0,test,t71,id: 2,,0,,, +# # Testing strange table names # create table `t 1` (a int) ; drop table `t 1`; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t@00201,id: 1,,0,,, +DROP,MyISAM,0,test,t@00201,id: 1,,0,,, +# # Testing views and triggers # create table t80 (a int, b int) engine=myisam ; @@ -137,12 +222,27 @@ drop trigger trg; drop view v1; drop table t80; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t80,id: 1,,0,,, +CREATE,VIEW,0,test,v1,,,0,,, +CREATE,TRIGGER,0,test,trg,,,0,,, +DROP,TRIGGER,0,test,trg,,,0,,, +DROP,VIEW,0,test,v1,,,0,,, +DROP,MyISAM,0,test,t80,id: 1,,0,,, +# # Testing alter to a new storage engine # create table t85 (a int primary key, b int) engine=myisam ; alter table t85 engine=innodb; drop table t85; # +# Reading backup ddl log file +# +CREATE,MyISAM,0,test,t85,id: 1,,0,,, +ALTER,MyISAM,0,test,t85,id: 1,InnoDB,0,test,t85,id: 2 +DROP,InnoDB,0,test,t85,id: 2,,0,,, +# # Testing create/drop/alter database # create database mysqltest; @@ -151,6 +251,16 @@ create table mysqltest.t91 (a int primary key, b int) engine=innodb; alter database mysqltest character set utf8; drop database mysqltest; # +# Reading backup ddl log file +# +CREATE,DATABASE,0,mysqltest,,,,0,,, +CREATE,MyISAM,0,mysqltest,t90,id: 1,,0,,, +CREATE,InnoDB,0,mysqltest,t91,id: 2,,0,,, +ALTER,DATABASE,0,mysqltest,,,,0,,, +DROP,MyISAM,0,mysqltest,t90,id: 1,,0,,, +DROP,InnoDB,0,mysqltest,t91,id: 2,,0,,, +DROP,DATABASE,0,mysqltest,,,,0,,, +# # MENT-222 bug testing # CREATE TABLE IF NOT EXISTS t_exists LIKE t_exists_template; @@ -159,83 +269,14 @@ Note 1050 Table 't_exists' already exists # # Reading backup ddl log file # -CREATE,MyISAM,0,test,t1,id: 1,,0,,, -ALTER,MyISAM,0,test,t1,id: 1,MyISAM,0,test,t1,id: 2 -RENAME,MyISAM,0,test,t1,id: 2,MyISAM,0,test,t2,id: 2 -RENAME,MyISAM,0,test,t2,id: 2,MyISAM,0,test,t1,id: 2 -repair,MyISAM,0,test,t1,id: 2,,0,,, -optimize,MyISAM,0,test,t1,id: 2,,0,,, -DROP,MyISAM,0,test,t1,id: 2,,0,,, -CREATE,InnoDB,0,test,t1_innodb,id: 3,,0,,, -ALTER,InnoDB,0,test,t1_innodb,id: 3,InnoDB,0,test,t1_innodb,id: 4 -RENAME,InnoDB,0,test,t1_innodb,id: 4,InnoDB,0,test,t2_innodb,id: 4 -RENAME,InnoDB,0,test,t2_innodb,id: 4,InnoDB,0,test,t1_innodb,id: 4 -TRUNCATE,InnoDB,0,test,t1_innodb,id: 4,,0,,, -repair,InnoDB,0,test,t1_innodb,id: 4,,0,test,t1_innodb,id: 5 -optimize,InnoDB,0,test,t1_innodb,id: 5,,0,test,t1_innodb,id: 6 -DROP,InnoDB,0,test,t1_innodb,id: 6,,0,,, -CREATE,MyISAM,0,test,t20,id: 7,,0,,, -DROP,MyISAM,0,test,t20,id: 7,,0,,, -CREATE,MyISAM,0,test,t21,id: 8,,0,,, -DROP,MyISAM,0,test,t21,id: 8,,0,,, -CREATE,MyISAM,0,test,t30,id: 9,,0,,, -CREATE,MyISAM,0,test,t31,id: 10,,0,,, -DROP,MyISAM,0,test,t31,id: 10,,0,,, -CREATE,MyISAM,0,test,t31,id: 11,,0,,, -DROP,MyISAM,0,test,t31,id: 11,,0,,, -DROP_AFTER_CREATE,MyISAM,0,test,t31,id: 12,,0,,, -CREATE,MyISAM,0,test,t32,id: 13,,0,,, -DROP,MyISAM,0,test,t30,id: 9,,0,,, -DROP,MyISAM,0,test,t32,id: 13,,0,,, -CREATE,MyISAM,0,test,t40,id: 14,,0,,, -CREATE,InnoDB,0,test,t41,id: 15,,0,,, -CREATE,MyISAM,0,test,t42,id: 16,,0,,, -DROP,MyISAM,0,test,t42,id: 16,,0,,, -CREATE,InnoDB,0,test,t42,id: 17,,0,,, -DROP,MyISAM,0,test,t40,id: 14,,0,,, -DROP,InnoDB,0,test,t41,id: 15,,0,,, -DROP,InnoDB,0,test,t42,id: 17,,0,,, -CREATE,MyISAM,0,test,t50,id: 18,,0,,, -CREATE,MyISAM,0,test,t51,id: 19,,0,,, -RENAME,MyISAM,0,test,t50,id: 18,MyISAM,0,test,t52,id: 18 -RENAME,MyISAM,0,test,t51,id: 19,MyISAM,0,test,t53,id: 19 -RENAME,MyISAM,0,test,t52,id: 18,MyISAM,0,test,tmp,id: 18 -RENAME,MyISAM,0,test,t53,id: 19,MyISAM,0,test,t52,id: 19 -RENAME,MyISAM,0,test,tmp,id: 18,MyISAM,0,test,t53,id: 18 -DROP,MyISAM,0,test,t52,id: 19,,0,,, -DROP,MyISAM,0,test,t53,id: 18,,0,,, -CREATE,Aria,0,test,t60,id: 20,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 20,,0,,, -CHANGE_INDEX,Aria,0,test,t60,id: 20,,0,,, -DROP,Aria,0,test,t60,id: 20,,0,,, -CREATE,Aria,0,test,t70,id: 21,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 21,,0,,, -BULK_INSERT,Aria,0,test,t70,id: 21,,0,,, -CREATE,Aria,0,test,t71,id: 22,,0,,, -BULK_INSERT,Aria,0,test,t71,id: 22,,0,,, -DROP,Aria,0,test,t70,id: 21,,0,,, -DROP,Aria,0,test,t71,id: 22,,0,,, -CREATE,MyISAM,0,test,t@00201,id: 23,,0,,, -DROP,MyISAM,0,test,t@00201,id: 23,,0,,, -CREATE,MyISAM,0,test,t80,id: 24,,0,,, -CREATE,VIEW,0,test,v1,,,0,,, -CREATE,TRIGGER,0,test,trg,,,0,,, -DROP,TRIGGER,0,test,trg,,,0,,, -DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,0,test,t80,id: 24,,0,,, -CREATE,MyISAM,0,test,t85,id: 25,,0,,, -ALTER,MyISAM,0,test,t85,id: 25,InnoDB,0,test,t85,id: 26 -DROP,InnoDB,0,test,t85,id: 26,,0,,, -CREATE,DATABASE,0,mysqltest,,,,0,,, -CREATE,MyISAM,0,mysqltest,t90,id: 27,,0,,, -CREATE,InnoDB,0,mysqltest,t91,id: 28,,0,,, -ALTER,DATABASE,0,mysqltest,,,,0,,, -DROP,MyISAM,0,mysqltest,t90,id: 27,,0,,, -DROP,InnoDB,0,mysqltest,t91,id: 28,,0,,, -DROP,DATABASE,0,mysqltest,,,,0,,, # # Cleanup # DROP TABLE t_exists; DROP TABLE t_exists_template; +# +# Reading backup ddl log file +# +DROP,MyISAM,0,test,t_exists,id: 1,,0,,, +DROP,MyISAM,0,test,t_exists_template,id: 2,,0,,, disconnect con1; diff --git a/mysql-test/main/backup_log.test b/mysql-test/main/backup_log.test index ee34484e92bf9..b36032da20663 100644 --- a/mysql-test/main/backup_log.test +++ b/mysql-test/main/backup_log.test @@ -24,6 +24,8 @@ create table mysqltest.t91 (a int primary key, b int) engine=innodb; alter database mysqltest character set utf8; drop database mysqltest; +--source backup_log_print.inc + --echo # --echo # MENT-222 bug testing --echo # @@ -36,4 +38,8 @@ CREATE TABLE IF NOT EXISTS t_exists LIKE t_exists_template; --echo # DROP TABLE t_exists; DROP TABLE t_exists_template; + +--source include/print_ddl_log.inc + disconnect con1; + \ No newline at end of file diff --git a/mysql-test/main/backup_log_print.inc b/mysql-test/main/backup_log_print.inc new file mode 100644 index 0000000000000..ad46dde49f938 --- /dev/null +++ b/mysql-test/main/backup_log_print.inc @@ -0,0 +1,7 @@ +--disable_query_log +--source include/print_ddl_log.inc +--connection con1 +backup stage end; +backup stage start; +--connection default +--enable_query_log diff --git a/mysql-test/main/create_notembedded.result b/mysql-test/main/create_notembedded.result new file mode 100644 index 0000000000000..f9e82b4ca2538 --- /dev/null +++ b/mysql-test/main/create_notembedded.result @@ -0,0 +1,33 @@ +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +# Test multi-byte characters in table name +set names utf8; +# Filename is too long because it is converted to @274e@274e@274e@274e... +# so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes +create table ❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); +ERROR HY000: Can't create table `test`.`❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` (errno: 36 "File name too long") +# Let's find out max length for '❎'... +# Acceptable name length: 50; Filename length: 254 +# OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes +create table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); +# Not OK with 65-characters table name +create table ttttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (x int); +ERROR 42000: Incorrect table name 'ttttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎' +show tables; +Tables_in_test +tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ +create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (y int); +show create table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; +Table Create Table +tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ CREATE TABLE `tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎` ( + `y` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +set @@debug_dbug="+d,ddl_log_create_before_binlog", @debug_crash_counter=1; +create or replace table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎ (z int); +ERROR HY000: Lost connection to server during query +#sql-create-PID-TID-SEQ.MYD +#sql-create-PID-TID-SEQ.MYI +#sql-create-PID-TID-SEQ.frm +drop table tttttttttttttttttttttttt❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎❎; +set @@debug_dbug=""; diff --git a/mysql-test/main/create_notembedded.test b/mysql-test/main/create_notembedded.test new file mode 100644 index 0000000000000..22281de2a3638 --- /dev/null +++ b/mysql-test/main/create_notembedded.test @@ -0,0 +1,65 @@ +--source include/not_windows.inc +--source include/have_debug.inc +--source include/not_valgrind.inc +--source include/not_embedded.inc + +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # + +# This does not work on Windows because of max path limit 255 +# (actually it does not work for path 254 already) +# Note: on Windows use ER_BAD_DB_ERROR instead of ER_CANT_CREATE_TABLE +# unless MDEV-28746 is fixed. + +--echo # Test multi-byte characters in table name +set names utf8; +let $save_debug=`select @@debug_dbug`; +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # Filename is too long because it is converted to @274e@274e@274e@274e... +--echo # so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes +let $t= `select repeat('❎', 51)`; +--error ER_CANT_CREATE_TABLE +eval create table $t (x int); +# The below case is useful for experimenting on Windows +--echo # Let's find out max length for '❎'... +--disable_query_log +let $i= 50; +while ($i) +{ + let $t= `select repeat('❎', $i)`; + --error 0,ER_CANT_CREATE_TABLE + eval create table $t (x int); + let $good_len= $i; + dec $i; + if (!$mysql_errno) + { + let $i= 0; + } +} +let $fn_len= `select $good_len * 5 + 4`; # 4 is extension length +eval drop table $t; +--enable_query_log +--echo # Acceptable name length: $good_len; Filename length: $fn_len +--echo # OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes +let $t= `select concat(repeat('t', 24), repeat('❎', 40))`; +eval create table $t (x int); +--echo # Not OK with 65-characters table name +let $t2= `select concat(repeat('t', 25), repeat('❎', 40))`; +--error ER_WRONG_TABLE_NAME +eval create table $t2 (x int); +show tables; +# Let's try atomic replace with such long name and see what happens +eval create or replace table $t (y int); +eval show create table $t; +set @@debug_dbug="+d,ddl_log_create_before_binlog", @debug_crash_counter=1; +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--disable_reconnect +--error 2013 +eval create or replace table $t (z int); +--replace_regex /#sql-create-\w+-\w+-\w+\./#sql-create-PID-TID-SEQ./ +--list_files $MYSQLD_DATADIR/test *sql* +--enable_reconnect +--source include/wait_until_connected_again.inc +eval drop table $t; +eval set @@debug_dbug="$save_debug"; diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index eed0eaa251da1..d76f2808ef5f6 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -146,6 +146,7 @@ t1 CREATE TABLE `t1` ( `1` int(1) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci DROP TABLE t1; +# Using lock tables with CREATE OR REPLACE CREATE OR REPLACE TABLE t1 (a int); LOCK TABLES t1 write,t2 write; CREATE OR REPLACE TABLE t1 (a int, b int); @@ -154,10 +155,14 @@ a b INSERT INTO t1 values(1,1); CREATE OR REPLACE TABLE t1 (a int, b int, c int); INSERT INTO t1 values(1,1,1); +SELECT count(*) from t2; +count(*) +3 CREATE OR REPLACE TABLE t3 (a int); ERROR HY000: Table 't3' was not locked with LOCK TABLES UNLOCK TABLES; DROP TABLE t1; +# Using lock tables with CREATE OR REPLACE ... SELECT CREATE OR REPLACE TABLE t1 (a int); LOCK TABLES t1 write,t2 write; CREATE OR REPLACE TABLE t1 (a int, b int) select a,1 from t2; @@ -179,10 +184,37 @@ NULL 3 1 INSERT INTO t1 values(1,1,1); CREATE OR REPLACE TABLE t1 (a int, b int, c int, d int); INSERT INTO t1 values(1,1,1,1); +CREATE OR REPLACE TABLE t1 SELECT * from t2; +SELECT * from t1; +a +1 +2 +3 +INSERT INTO t1 values(4); +set @@drop_before_create_or_replace=0; +CREATE OR REPLACE TABLE t1 (a int primary key) SELECT 1 as a from t2; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT * from t1; +a +1 +2 +3 +4 +set @@drop_before_create_or_replace=1; +CREATE OR REPLACE TABLE t1 (a int primary key) SELECT 1 as a from t2; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT * from t1; +ERROR HY000: Table 't1' was not locked with LOCK TABLES +set @@drop_before_create_or_replace=default; +SELECT count(*) from t2; +count(*) +3 CREATE OR REPLACE TABLE t3 (a int); ERROR HY000: Table 't3' was not locked with LOCK TABLES UNLOCK TABLES; -DROP TABLE t1; +SELECT * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +# Testing write and read locks with CREATE OR REPLACE CREATE OR REPLACE TABLE t1 (a int); LOCK TABLES t1 write,t2 write, t1 as t1_read read; CREATE OR REPLACE TABLE t1 (a int, b int) select a,1 from t2; @@ -273,6 +305,7 @@ create or replace table test.t1; ERROR 42000: A table must have at least 1 column show tables; Tables_in_test +t1 t2 select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME @@ -281,12 +314,24 @@ MDL_BACKUP_DML Backup lock MDL_INTENTION_EXCLUSIVE Schema metadata lock mysqltest2 MDL_INTENTION_EXCLUSIVE Schema metadata lock test MDL_SHARED_NO_READ_WRITE Table metadata lock mysqltest2 t2 +MDL_SHARED_NO_READ_WRITE Table metadata lock test t1 create or replace table mysqltest2.t2; ERROR 42000: A table must have at least 1 column select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME -create table t1 (i int); -drop table t1; +MDL_BACKUP_DDL Backup lock +MDL_BACKUP_DML Backup lock +MDL_INTENTION_EXCLUSIVE Schema metadata lock mysqltest2 +MDL_INTENTION_EXCLUSIVE Schema metadata lock test +MDL_SHARED_NO_READ_WRITE Table metadata lock mysqltest2 t2 +MDL_SHARED_NO_READ_WRITE Table metadata lock test t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +drop table t1,mysqltest2.t2; +unlock tables; create table test.t1 (i int); create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; @@ -302,6 +347,7 @@ create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; ERROR 42S21: Duplicate column name 'a' show tables; Tables_in_test +t1 t2 select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME @@ -310,6 +356,9 @@ MDL_BACKUP_DML Backup lock MDL_INTENTION_EXCLUSIVE Schema metadata lock mysqltest2 MDL_INTENTION_EXCLUSIVE Schema metadata lock test MDL_SHARED_NO_READ_WRITE Table metadata lock mysqltest2 t2 +MDL_SHARED_NO_READ_WRITE Table metadata lock test t1 +create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; +ERROR 42S21: Duplicate column name 'a' select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME MDL_BACKUP_DDL Backup lock @@ -317,12 +366,14 @@ MDL_BACKUP_DML Backup lock MDL_INTENTION_EXCLUSIVE Schema metadata lock mysqltest2 MDL_INTENTION_EXCLUSIVE Schema metadata lock test MDL_SHARED_NO_READ_WRITE Table metadata lock mysqltest2 t2 -create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; -ERROR 42S21: Duplicate column name 'a' -select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; -LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME -create table t1 (i int); -drop table t1; +MDL_SHARED_NO_READ_WRITE Table metadata lock test t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +drop table t1,mysqltest2.t2; +unlock tables; create table test.t1 (i int) engine=innodb; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; @@ -365,11 +416,21 @@ create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; ERROR 22001: Data too long for column 'a' at row 1 show tables; Tables_in_test +t1 t2 select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME -create table t1 (i int); +MDL_BACKUP_DDL Backup lock +MDL_BACKUP_DML Backup lock +MDL_INTENTION_EXCLUSIVE Schema metadata lock test +MDL_SHARED_NO_READ_WRITE Table metadata lock test t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci drop table t1; +unlock tables; # # Testing CREATE .. LIKE # @@ -587,12 +648,453 @@ DROP TABLE IF EXISTS tm, t; # # End of 10.3 tests # +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +# Test triggers +create table t1 (a int); +insert into t1 values (1); +create trigger trg1 before insert on t1 for each row set @a:=1; +create trigger trg2 before update on t1 for each row set @a:=1; +select trigger_name from information_schema.triggers where trigger_schema="test" and event_object_table='t1'; +trigger_name +trg1 +trg2 +create or replace table t1 (b int); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select trigger_name from information_schema.triggers where trigger_schema="test" and event_object_table='t1'; +trigger_name +drop table t1; +create table t1 (a int); +insert into t1 values (1); +create trigger trg1 before insert on t1 for each row set @a:=1; +create trigger trg2 before update on t1 for each row set @a:=1; +create or replace table t1; +ERROR 42000: A table must have at least 1 column +select * from t1; +a +1 +select trigger_name from information_schema.triggers where trigger_schema="test" and event_object_table='t1'; +trigger_name +trg1 +trg2 +drop table t1; +# Test table locks +create table t1 (a int); +create table t2 (a int); +insert into t1 values (1); +lock tables t1 write, t2 write; +create or replace table t1 (b int); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +create or replace table t1 (c int); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select * from t1,t2; +c a +select * from t3; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +insert into t1 values (1); +create or replace table t1; +ERROR 42000: A table must have at least 1 column +select * from t1; +c +1 +lock tables t1 write, t2 write; +create or replace table t1 (d int); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +unlock tables; +drop table t1,t2; +# +# End of 11.8 tests +# +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +create table t1 (a int); +insert t1 values (1), (1); +create table t2 (c int); +create or replace table t2 (a int, b int, key k (a), key k (b)); +ERROR 42000: Duplicate key name 'k' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1; +ERROR 42000: Duplicate key name 'k' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +create or replace table t2 (a int primary key) as select * from t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +set @old_mode= @@sql_mode; +set @@sql_mode='ALLOW_INVALID_DATES'; +create table t3 (dt datetime default '2008-02-31 00:00:00'); +set @@sql_mode= @old_mode; +create or replace table t2 like t3; +ERROR 42000: Invalid default value for 'dt' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +# LOCK TABLES +lock tables t2 write, t1 write; +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +create or replace table t2 (y int); +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +create or replace table t2 like t1; +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +create or replace table t2 (y int) as select * from t1; +flush tables; +show open tables like 't2'; +Database Table In_use Name_locked +test t2 1 0 +unlock tables; +# SP +create or replace procedure sp(n int) +begin +select concat('sp call ', n, ':') as ''; +show open tables like 't2'; +create or replace table t2 (y int); +select 'create or replace table t2 (y int);' as ''; +show open tables like 't2'; +insert into t2 values (2); +select 'insert into t2 values (2);' as ''; +show open tables like 't2'; +create or replace table t2 like t1; +select 'create or replace table t2 like t1;' as ''; +show open tables like 't2'; +create or replace table t2 (y int) as select * from t1; +select 'create or replace table t2 (y int) as select * from t1;' as ''; +show open tables like 't2'; +select 'select * from t2;' as ''; +select * from t2; +show open tables like 't2'; +end $ +flush tables; +call sp(1); + +sp call 1: +Database Table In_use Name_locked + +create or replace table t2 (y int); +Database Table In_use Name_locked + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 0 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked +test t2 0 0 + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 0 0 +call sp(2); + +sp call 2: +Database Table In_use Name_locked +test t2 0 0 + +create or replace table t2 (y int); +Database Table In_use Name_locked + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 0 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked +test t2 0 0 + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 0 0 +# SP under LOCK TABLES +lock tables t2 write, t1 write; +call sp(3); + +sp call 3: +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int); +Database Table In_use Name_locked +test t2 1 0 + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked +test t2 1 0 + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +test t2 1 0 +call sp(4); + +sp call 4: +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int); +Database Table In_use Name_locked +test t2 1 0 + +insert into t2 values (2); +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 like t1; +Database Table In_use Name_locked +test t2 1 0 + +create or replace table t2 (y int) as select * from t1; +Database Table In_use Name_locked +test t2 1 0 + +select * from t2; +y a +NULL 1 +NULL 1 +Database Table In_use Name_locked +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; +# PS: check thd->change_list sanity +create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin; +prepare stmt from 'insert into t1 (b) values (2)'; +create or replace table t1 (x int); +drop table t1; +drop prepare stmt; +# Foreign keys +create table t1 (x int primary key, y int) engine innodb; +create table t2 (x int references t1(x)) engine innodb; +create or replace table t1 (x int primary key); +create table t3 (x int); +create or replace table t1 like t3; +create or replace table t1 select * from t3; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +drop tables t3, t2, t1; +# UNIQUE +create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria character set latin1; +insert into t1 (a) values ('a'), ('b'), ('c'); +create table t2 (x int); +create or replace table t2 engine aria select * from t1; +select * from t2; +pk a +1 a +2 b +3 c +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `pk` int(11) NOT NULL DEFAULT 0, + `a` varchar(2300) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +drop tables t2, t1; +# +# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +# +# Atomic CREATE OR REPLACE part: +# +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; +create or replace table `t3#` (a int primary key references t1 (pk)) engine=innodb; +lock tables t1 write, t2 write, `t3#` write; +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create or replace table `t3#` (c1 int not null, c1 varchar(255) ) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +select * from t1; +pk +select * from t2; +a +select * from `t3#`; +a +unlock tables; +select * from t2; +a +select * from `t3#`; +a +drop tables if exists t2, `t3#`, t1; +# +# MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name +# +use test; +create table t (a int primary key) engine=innodb; +insert into t values (1),(2),(3); +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a)) engine=innodb; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +c test/u test/t 1 0 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +c a a 0 +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a)) engine=innodb; +insert into u values (1),(2),(3); +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a), e int, unique key(e)) engine=innodb select seq as a, seq as e, if(seq < 4,seq,1) from seq_1_to_3; +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a), e int, unique key(e)) engine=innodb select seq as a, seq as e, if(seq < 4,seq,1) from seq_1_to_4; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`u`, CONSTRAINT `c` FOREIGN KEY (`a`) REFERENCES `t` (`a`)) +create or replace table u ( +a int primary key, +constraint c foreign key d (a) references t (a), e int, unique key(e)) engine=innodb select seq as a, if(seq < 3,seq,1) as e from seq_1_to_3; +ERROR 23000: Duplicate entry '1' for key 'e' +select * from u; +a e if(seq < 4,seq,1) +1 1 1 +2 2 2 +3 3 3 +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +c test/u test/t 1 0 +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +c a a 0 +drop tables u, t; +select * from information_schema.innodb_sys_foreign; +ID FOR_NAME REF_NAME N_COLS TYPE +select * from information_schema.innodb_sys_foreign_cols; +ID FOR_COL_NAME REF_COL_NAME POS +# +# MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables +# +call mtr.add_suppression("mysql.innodb_index_stats"); +set sql_mode= ''; +create table t (x int) engine innodb; +insert into t values (77); +alter table mysql.innodb_index_stats modify stat_description char(10); +lock table t write; +create or replace table t (y int); +ERROR HY000: Error on rename of './test/t' to './test/#sql-create...' (errno: 168 "Unknown (generic) error from engine") +unlock tables; +alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null; +select * from t; +x +77 +drop table t; +set sql_mode= default; +# +# MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock +# +create or replace table t1 (i serial) as select * from (values(1), (2)) dt; +drop table t1; +# +# MDEV-36435 Assertion failure in +# Table_specification_st::finalize_locked_tables upon attempt +# to create an already existing table under lock +# +CREATE TABLE t1 (a INT); +LOCK TABLE t1 WRITE; +CREATE TABLE IF NOT EXISTS t1 (a INT); +Warnings: +Note 1050 Table 't1' already exists +UNLOCK TABLES; +CREATE TABLE t2 LIKE t1; +LOCK TABLE t1 WRITE, t2 write; +CREATE TABLE IF NOT EXISTS t2 LIKE t1; +Warnings: +Note 1050 Table 't2' already exists +UNLOCK TABLES; +DROP TABLE t1,t2; +# +# MDEV-36439 Assertion `thd_arg->lex->sql_command != +# SQLCOM_CREATE_SEQUENCE || (flags2 & FL_DDL) || thd_arg->in_mult +# i_stmt_transaction_mode()' failed +# +create sequence s2 engine=innodb; +create or replace sequence s2 engine=innodb; +drop sequence s2; +CREATE SEQUENCE s1 ENGINE=InnoDB; +RENAME TABLE s1 TO s2; +CREATE OR REPLACE SEQUENCE s2 ENGINE=InnoDB; +FLUSH TABLES; +CREATE OR REPLACE SEQUENCE s2 ENGINE=InnoDB; +DROP SEQUENCE s2; +# +# End of 12.0 tests +# SET GLOBAL innodb_stats_persistent=@save_persistent; # # MDEV-23298 Assertion `table_list->prelocking_placeholder == # TABLE_LIST::PRELOCK_NONE' failed in check_lock_and_start_stmt on # CREATE OR REPLACE TABLE # +set @@session.drop_before_create_or_replace='ON'; create table t2 (a int); insert into t2 values(1),(2); CREATE TABLE t1 (a INT); @@ -621,6 +1123,144 @@ CREATE OR REPLACE TABLE t1 AS SELECT f(1); drop temporary table t1; drop table t1; drop function f; +set @@session.drop_before_create_or_replace=default; # # End of 10.6 tests # +# +# MDEV-36497 Assertion failure after atomic CoR with Aria under lock +# in transactional context +# +CREATE TABLE t1 (a INT) engine=aria; +LOCK TABLE t1 WRITE; +SET AUTOCOMMIT = OFF; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +1 +1 +UNLOCK TABLES; +DROP TABLE t1; +CREATE TABLE t1 (a INT) engine=myisam; +LOCK TABLE t1 WRITE; +SET AUTOCOMMIT = OFF; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +1 +1 +UNLOCK TABLES; +DROP TABLE t1; +CREATE TABLE t1 (a INT) engine=myisam; +LOCK TABLE t1 WRITE; +SET AUTOCOMMIT = ON; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +1 +1 +UNLOCK TABLES; +DROP TABLE t1; +CREATE TABLE t1 (a INT) engine=myisam; +SET AUTOCOMMIT = ON; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +1 +1 +DROP TABLE t1; +CREATE TABLE t1 (a INT) engine=myisam; +SET AUTOCOMMIT = OFF; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +1 +1 +DROP TABLE t1; +# +# MDEV-36501 EITS data is lost after failed attempt to +# CREATE OR REPLACE table +# +create table t1 (a int primary key); +insert into t1 values (1),(2); +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +select count(*) from mysql.table_stats where table_name = 't1'; +count(*) +1 +select count(*) from mysql.index_stats where table_name = 't1'; +count(*) +1 +select count(*) from mysql.column_stats where table_name = 't1'; +count(*) +1 +create or replace table t1 (b int primary key) as select 1 as b union all select 1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select count(*) from mysql.table_stats where table_name = 't1'; +count(*) +1 +select count(*) from mysql.index_stats where table_name = 't1'; +count(*) +1 +select count(*) from mysql.column_stats where table_name = 't1'; +count(*) +1 +create or replace table t1 (b int primary key); +select count(*) from mysql.table_stats where table_name = 't1'; +count(*) +0 +select count(*) from mysql.index_stats where table_name = 't1'; +count(*) +0 +select count(*) from mysql.column_stats where table_name = 't1'; +count(*) +0 +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +set @@session.drop_before_create_or_replace='ON'; +create or replace table t1 (c int primary key) as select 1 as c union all select 1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select count(*) from mysql.table_stats where table_name = 't1'; +count(*) +0 +select count(*) from mysql.index_stats where table_name = 't1'; +count(*) +0 +select count(*) from mysql.column_stats where table_name = 't1'; +count(*) +0 +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +set @@session.drop_before_create_or_replace=default; +# +# End of 12.3 tests +# +# +# MDEV-40157 Atomic CoR: Server crash in drop_open_table upon +# CREATE OR REPLACE with table name containing non-alpha-num +# +CREATE TABLE `t-t` (a INT); +insert into `t-t`values (2),(3); +CREATE TRIGGER tr BEFORE INSERT ON `t-t` FOR EACH ROW SET new.a = 1; +CREATE OR REPLACE TABLE `t-t` AS SELECT 1 AS b; +select * from `t-t`; +b +1 +insert into `t-t`values (2),(3); +select * from `t-t`; +b +1 +2 +3 +drop table `t-t`; +CREATE TABLE t (x INT); +CREATE TABLE `t-t` (a INT); +CREATE TRIGGER tr BEFORE INSERT ON `t-t` FOR EACH ROW INSERT INTO t VALUES (1); +CREATE OR REPLACE TABLE `t-t` AS SELECT 1 AS b; +select * from `t-t`; +b +1 +DROP TABLE `t-t`, t; +# +# End of 13.1 tests +# diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 9a631499b466f..dc1f999bf23af 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -4,9 +4,11 @@ --source include/have_innodb.inc --source include/have_metadata_lock_info.inc +--source include/have_sequence.inc SET @save_persistent=@@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent=OFF; +let $MYSQLD_DATADIR= `SELECT @@datadir`; # # Create help table @@ -128,7 +130,7 @@ SHOW CREATE TABLE t1; DROP TABLE t1; --disable_service_connection -# Using lock tables with CREATE OR REPLACE +--echo # Using lock tables with CREATE OR REPLACE CREATE OR REPLACE TABLE t1 (a int); LOCK TABLES t1 write,t2 write; CREATE OR REPLACE TABLE t1 (a int, b int); @@ -137,12 +139,14 @@ SELECT * FROM t1; INSERT INTO t1 values(1,1); CREATE OR REPLACE TABLE t1 (a int, b int, c int); INSERT INTO t1 values(1,1,1); +# End checks that locking is still in effect +SELECT count(*) from t2; --error ER_TABLE_NOT_LOCKED CREATE OR REPLACE TABLE t3 (a int); UNLOCK TABLES; DROP TABLE t1; -# Using lock tables with CREATE OR REPLACE ... SELECT +--echo # Using lock tables with CREATE OR REPLACE ... SELECT CREATE OR REPLACE TABLE t1 (a int); LOCK TABLES t1 write,t2 write; CREATE OR REPLACE TABLE t1 (a int, b int) select a,1 from t2; @@ -153,11 +157,32 @@ SELECT * FROM t1; INSERT INTO t1 values(1,1,1); CREATE OR REPLACE TABLE t1 (a int, b int, c int, d int); INSERT INTO t1 values(1,1,1,1); + +CREATE OR REPLACE TABLE t1 SELECT * from t2; +SELECT * from t1; +INSERT INTO t1 values(4); +set @@drop_before_create_or_replace=0; +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t1 (a int primary key) SELECT 1 as a from t2; +# Should have original content +SELECT * from t1; +set @@drop_before_create_or_replace=1; +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t1 (a int primary key) SELECT 1 as a from t2; +--error ER_TABLE_NOT_LOCKED +SELECT * from t1; +set @@drop_before_create_or_replace=default; + +# End checks that locking is still in effect +SELECT count(*) from t2; --error ER_TABLE_NOT_LOCKED CREATE OR REPLACE TABLE t3 (a int); UNLOCK TABLES; -DROP TABLE t1; +# The last CREATE OR REPLACE removed table t1 +--error ER_NO_SUCH_TABLE +SELECT * from t1; +--echo # Testing write and read locks with CREATE OR REPLACE CREATE OR REPLACE TABLE t1 (a int); LOCK TABLES t1 write,t2 write, t1 as t1_read read; CREATE OR REPLACE TABLE t1 (a int, b int) select a,1 from t2; @@ -228,8 +253,9 @@ select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.meta create or replace table mysqltest2.t2; --sorted_result select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; -create table t1 (i int); -drop table t1; +show create table t1; +drop table t1,mysqltest2.t2; +unlock tables; create table test.t1 (i int); create table mysqltest2.t2 like test.t1; @@ -241,14 +267,13 @@ create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; show tables; --sorted_result select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; ---sorted_result -select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; --error ER_DUP_FIELDNAME create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; --sorted_result select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; -create table t1 (i int); -drop table t1; +show create table t1; +drop table t1,mysqltest2.t2; +unlock tables; create table test.t1 (i int) engine=innodb; create table mysqltest2.t2 like test.t1; @@ -283,8 +308,9 @@ create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; show tables; --sorted_result select LOCK_MODE,LOCK_TYPE, TABLE_SCHEMA,TABLE_NAME from information_schema.metadata_lock_info; -create table t1 (i int); +show create table t1; drop table t1; +unlock tables; --enable_view_protocol --echo # @@ -517,6 +543,290 @@ DROP TABLE IF EXISTS tm, t; --echo # End of 10.3 tests --echo # +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # + +--echo # Test triggers + +create table t1 (a int); +insert into t1 values (1); +create trigger trg1 before insert on t1 for each row set @a:=1; +create trigger trg2 before update on t1 for each row set @a:=1; +select trigger_name from information_schema.triggers where trigger_schema="test" and event_object_table='t1'; +create or replace table t1 (b int); +show create table t1; +select trigger_name from information_schema.triggers where trigger_schema="test" and event_object_table='t1'; +drop table t1; + +create table t1 (a int); +insert into t1 values (1); +create trigger trg1 before insert on t1 for each row set @a:=1; +create trigger trg2 before update on t1 for each row set @a:=1; +--error ER_TABLE_MUST_HAVE_COLUMNS +create or replace table t1; +select * from t1; +select trigger_name from information_schema.triggers where trigger_schema="test" and event_object_table='t1'; +drop table t1; + +--echo # Test table locks + +create table t1 (a int); +create table t2 (a int); +insert into t1 values (1); +lock tables t1 write, t2 write; +create or replace table t1 (b int); +show create table t1; +create or replace table t1 (c int); +show create table t1; +--disable_service_connection +select * from t1,t2; +--enable_service_connection +--error ER_TABLE_NOT_LOCKED +select * from t3; +insert into t1 values (1); +--error ER_TABLE_MUST_HAVE_COLUMNS +create or replace table t1; +--disable_service_connection +select * from t1; +--enable_service_connection +lock tables t1 write, t2 write; +create or replace table t1 (d int); +show create table t1; +unlock tables; +drop table t1,t2; + +--echo # +--echo # End of 11.8 tests +--echo # + +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # +create table t1 (a int); +insert t1 values (1), (1); +create table t2 (c int); +--error ER_DUP_KEYNAME +create or replace table t2 (a int, b int, key k (a), key k (b)); +show create table t2; +--error ER_DUP_KEYNAME +create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1; +show create table t2; +--error ER_DUP_ENTRY +create or replace table t2 (a int primary key) as select * from t1; +show create table t2; +set @old_mode= @@sql_mode; +set @@sql_mode='ALLOW_INVALID_DATES'; +create table t3 (dt datetime default '2008-02-31 00:00:00'); +set @@sql_mode= @old_mode; +--error ER_INVALID_DEFAULT +create or replace table t2 like t3; +show create table t2; +--echo # LOCK TABLES +lock tables t2 write, t1 write; +flush tables; +show open tables like 't2'; +create or replace table t2 (y int); +flush tables; +show open tables like 't2'; +create or replace table t2 like t1; +flush tables; +show open tables like 't2'; +create or replace table t2 (y int) as select * from t1; +flush tables; +show open tables like 't2'; +unlock tables; +--echo # SP +--delimiter $ +create or replace procedure sp(n int) +begin + select concat('sp call ', n, ':') as ''; + show open tables like 't2'; + create or replace table t2 (y int); + select 'create or replace table t2 (y int);' as ''; + show open tables like 't2'; + insert into t2 values (2); + select 'insert into t2 values (2);' as ''; + show open tables like 't2'; + create or replace table t2 like t1; + select 'create or replace table t2 like t1;' as ''; + show open tables like 't2'; + create or replace table t2 (y int) as select * from t1; + select 'create or replace table t2 (y int) as select * from t1;' as ''; + show open tables like 't2'; + select 'select * from t2;' as ''; + select * from t2; + show open tables like 't2'; +end $ +--delimiter ; +flush tables; +call sp(1); call sp(2); +--echo # SP under LOCK TABLES +lock tables t2 write, t1 write; +call sp(3); call sp(4); +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; +--echo # PS: check thd->change_list sanity +create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin; +prepare stmt from 'insert into t1 (b) values (2)'; +create or replace table t1 (x int); +drop table t1; +drop prepare stmt; +--echo # Foreign keys +--list_files $MYSQLD_DATADIR/test *sql* +create table t1 (x int primary key, y int) engine innodb; +create table t2 (x int references t1(x)) engine innodb; +create or replace table t1 (x int primary key); +create table t3 (x int); +create or replace table t1 like t3; +create or replace table t1 select * from t3; +show create table t1; +drop tables t3, t2, t1; +--echo # UNIQUE +create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria character set latin1; +insert into t1 (a) values ('a'), ('b'), ('c'); +create table t2 (x int); +create or replace table t2 engine aria select * from t1; +select * from t2; +show create table t2; +drop tables t2, t1; + +--echo # +--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +--echo # +--echo # Atomic CREATE OR REPLACE part: +--echo # +--disable_service_connection +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; +create or replace table `t3#` (a int primary key references t1 (pk)) engine=innodb; + +lock tables t1 write, t2 write, `t3#` write; +--error ER_DUP_FIELDNAME +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +--error ER_DUP_FIELDNAME +create or replace table `t3#` (c1 int not null, c1 varchar(255) ) engine=innodb; +select * from t1; +select * from t2; +select * from `t3#`; +unlock tables; + +select * from t2; +select * from `t3#`; + +drop tables if exists t2, `t3#`, t1; +--enable_service_connection + +--echo # +--echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name +--echo # +use test; +create table t (a int primary key) engine=innodb; +insert into t values (1),(2),(3); +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a)) engine=innodb; + +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; + +# This works thanks to MDEV-28933 and MDEV-25292 +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a)) engine=innodb; +insert into u values (1),(2),(3); + +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a), e int, unique key(e)) engine=innodb select seq as a, seq as e, if(seq < 4,seq,1) from seq_1_to_3; + +--error ER_NO_REFERENCED_ROW_2 +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a), e int, unique key(e)) engine=innodb select seq as a, seq as e, if(seq < 4,seq,1) from seq_1_to_4; + +--error ER_DUP_ENTRY +create or replace table u ( + a int primary key, + constraint c foreign key d (a) references t (a), e int, unique key(e)) engine=innodb select seq as a, if(seq < 3,seq,1) as e from seq_1_to_3; + +select * from u; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; +drop tables u, t; +select * from information_schema.innodb_sys_foreign; +select * from information_schema.innodb_sys_foreign_cols; + +--echo # +--echo # MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables +--echo # +call mtr.add_suppression("mysql.innodb_index_stats"); +set sql_mode= ''; +create table t (x int) engine innodb; +insert into t values (77); +alter table mysql.innodb_index_stats modify stat_description char(10); +lock table t write; +--replace_regex /#sql-create.*'/#sql-create...'/ +--replace_result $MYSQLD_DATADIR ./ +--error ER_ERROR_ON_RENAME +create or replace table t (y int); +# cleanup +unlock tables; +alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null; +select * from t; +drop table t; +set sql_mode= default; + +--echo # +--echo # MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock +--echo # +create or replace table t1 (i serial) as select * from (values(1), (2)) dt; +drop table t1; + +--echo # +--echo # MDEV-36435 Assertion failure in +--echo # Table_specification_st::finalize_locked_tables upon attempt +--echo # to create an already existing table under lock +--echo # + +CREATE TABLE t1 (a INT); +LOCK TABLE t1 WRITE; +CREATE TABLE IF NOT EXISTS t1 (a INT); +UNLOCK TABLES; +CREATE TABLE t2 LIKE t1; +LOCK TABLE t1 WRITE, t2 write; +CREATE TABLE IF NOT EXISTS t2 LIKE t1; +UNLOCK TABLES; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-36439 Assertion `thd_arg->lex->sql_command != +--echo # SQLCOM_CREATE_SEQUENCE || (flags2 & FL_DDL) || thd_arg->in_mult +--echo # i_stmt_transaction_mode()' failed +--echo # +create sequence s2 engine=innodb; +create or replace sequence s2 engine=innodb; +drop sequence s2; + +CREATE SEQUENCE s1 ENGINE=InnoDB; +RENAME TABLE s1 TO s2; +CREATE OR REPLACE SEQUENCE s2 ENGINE=InnoDB; +FLUSH TABLES; +CREATE OR REPLACE SEQUENCE s2 ENGINE=InnoDB; +DROP SEQUENCE s2; + +--echo # +--echo # End of 12.0 tests +--echo # + SET GLOBAL innodb_stats_persistent=@save_persistent; --echo # @@ -525,7 +835,7 @@ SET GLOBAL innodb_stats_persistent=@save_persistent; --echo # CREATE OR REPLACE TABLE --echo # -#set @@session.drop_before_create_or_replace='ON'; +set @@session.drop_before_create_or_replace='ON'; create table t2 (a int); insert into t2 values(1),(2); @@ -551,8 +861,111 @@ drop temporary table t1; drop table t1; drop function f; -#set @@session.drop_before_create_or_replace=default; +set @@session.drop_before_create_or_replace=default; --echo # --echo # End of 10.6 tests --echo # + +--echo # +--echo # MDEV-36497 Assertion failure after atomic CoR with Aria under lock +--echo # in transactional context +--echo # + +CREATE TABLE t1 (a INT) engine=aria; +LOCK TABLE t1 WRITE; +SET AUTOCOMMIT = OFF; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +UNLOCK TABLES; +DROP TABLE t1; + +CREATE TABLE t1 (a INT) engine=myisam; +LOCK TABLE t1 WRITE; +SET AUTOCOMMIT = OFF; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +UNLOCK TABLES; +DROP TABLE t1; + +CREATE TABLE t1 (a INT) engine=myisam; +LOCK TABLE t1 WRITE; +SET AUTOCOMMIT = ON; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +UNLOCK TABLES; +DROP TABLE t1; + +CREATE TABLE t1 (a INT) engine=myisam; +SET AUTOCOMMIT = ON; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT) engine=myisam; +SET AUTOCOMMIT = OFF; +CREATE OR REPLACE TABLE t1 (b INT) ENGINE=aria; +SELECT 1; +DROP TABLE t1; + +--echo # +--echo # MDEV-36501 EITS data is lost after failed attempt to +--echo # CREATE OR REPLACE table +--echo # +create table t1 (a int primary key); +insert into t1 values (1),(2); +analyze table t1 persistent for all; +select count(*) from mysql.table_stats where table_name = 't1'; +select count(*) from mysql.index_stats where table_name = 't1'; +select count(*) from mysql.column_stats where table_name = 't1'; + +--error ER_DUP_ENTRY +create or replace table t1 (b int primary key) as select 1 as b union all select 1; +select count(*) from mysql.table_stats where table_name = 't1'; +select count(*) from mysql.index_stats where table_name = 't1'; +select count(*) from mysql.column_stats where table_name = 't1'; + +create or replace table t1 (b int primary key); +select count(*) from mysql.table_stats where table_name = 't1'; +select count(*) from mysql.index_stats where table_name = 't1'; +select count(*) from mysql.column_stats where table_name = 't1'; +analyze table t1 persistent for all; + +set @@session.drop_before_create_or_replace='ON'; + +--error ER_DUP_ENTRY +create or replace table t1 (c int primary key) as select 1 as c union all select 1; +select count(*) from mysql.table_stats where table_name = 't1'; +select count(*) from mysql.index_stats where table_name = 't1'; +select count(*) from mysql.column_stats where table_name = 't1'; +drop table if exists t1; +set @@session.drop_before_create_or_replace=default; + +--echo # +--echo # End of 12.3 tests +--echo # + +--echo # +--echo # MDEV-40157 Atomic CoR: Server crash in drop_open_table upon +--echo # CREATE OR REPLACE with table name containing non-alpha-num +--echo # + +CREATE TABLE `t-t` (a INT); +insert into `t-t`values (2),(3); +CREATE TRIGGER tr BEFORE INSERT ON `t-t` FOR EACH ROW SET new.a = 1; +CREATE OR REPLACE TABLE `t-t` AS SELECT 1 AS b; +select * from `t-t`; +insert into `t-t`values (2),(3); +select * from `t-t`; +drop table `t-t`; + +CREATE TABLE t (x INT); +CREATE TABLE `t-t` (a INT); +CREATE TRIGGER tr BEFORE INSERT ON `t-t` FOR EACH ROW INSERT INTO t VALUES (1); +CREATE OR REPLACE TABLE `t-t` AS SELECT 1 AS b; +select * from `t-t`; +DROP TABLE `t-t`, t; + +--echo # +--echo # End of 13.1 tests +--echo # diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_or_replace2.result index d656cff7f020d..16238b1931205 100644 --- a/mysql-test/main/create_or_replace2.result +++ b/mysql-test/main/create_or_replace2.result @@ -25,4 +25,27 @@ t1 connection master; drop temporary table if exists tmp; drop table t1; +# +# MDEV-36498 Failed CoR in non-atomic mode no longer generates DROP +# in RBR, replica diverges +# +set drop_before_create_or_replace= on; +include/rpl_reset.inc +create table t1 (a int); +create or replace table t1 (a int primary key) as select 1 as a from seq_1_to_2; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +show tables; +Tables_in_test +connection slave; +show tables; +Tables_in_test +connection master; +set drop_before_create_or_replace= default; include/rpl_end.inc diff --git a/mysql-test/main/create_or_replace2.test b/mysql-test/main/create_or_replace2.test index fc951aa8b0f62..83719f455b69a 100644 --- a/mysql-test/main/create_or_replace2.test +++ b/mysql-test/main/create_or_replace2.test @@ -1,11 +1,12 @@ # -# Check CREATE OR REPLACE TABLE for test that requires DEBUG +# Check CREATE OR REPLACE TABLE for test that requires DEBUG or binlog format # --source include/have_debug.inc --source include/have_binlog_format_row.inc --source include/have_innodb.inc --source include/master-slave.inc +--source include/have_sequence.inc --disable_warnings drop table if exists t1; @@ -32,4 +33,26 @@ SHOW TABLES; drop temporary table if exists tmp; --enable_warnings drop table t1; + +--echo # +--echo # MDEV-36498 Failed CoR in non-atomic mode no longer generates DROP +--echo # in RBR, replica diverges +--echo # + +set drop_before_create_or_replace= on; + +--source include/rpl_reset.inc + +create table t1 (a int); +--error ER_DUP_ENTRY +create or replace table t1 (a int primary key) as select 1 as a from seq_1_to_2; +--source include/show_binlog_events.inc +show tables; +--sync_slave_with_master +show tables; +--connection master + +set drop_before_create_or_replace= default; + --source include/rpl_end.inc + diff --git a/mysql-test/main/create_replace_debug.result b/mysql-test/main/create_replace_debug.result new file mode 100644 index 0000000000000..8854da4485a39 --- /dev/null +++ b/mysql-test/main/create_replace_debug.result @@ -0,0 +1,74 @@ +include/master-slave.inc +[connection master] +drop table if exists t1; +SET @old_debug= @@session.debug; +CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB; +CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam; +SET debug_dbug='+d,send_kill_after_delete'; +CREATE OR REPLACE TABLE t1 LIKE tmp; +SET debug_dbug=@old_debug; +SHOW TABLES; +Tables_in_test +tmp +t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +connection slave; +SHOW TABLES; +Tables_in_test +t1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +connection master; +drop temporary table if exists tmp; +drop table t1; +include/rpl_end.inc +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +# Test entry_pos in higher position, so drop chain executes before create chain +# (see commit message: On linking two chains together) +create table t1 (c int); +create or replace table t1 (a int, b int, key k (a), key k (b)); +ERROR 42000: Duplicate key name 'k' +create or replace table t1 (a int, b int, key k (a), key k (b)); +ERROR 42000: Duplicate key name 'k' +drop table t1; +# +# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +# +# Non-atomic CREATE OR REPLACE part: +# +set @@drop_before_create_or_replace=1; +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; +lock tables t1 write, t2 write; +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +select * from t1; +pk +select * from t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop table t1; +set @@drop_before_create_or_replace=default; +# +# MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection +# +create table t1 (x int); +set @old_dbug= @@debug_dbug; +set @@debug_dbug= '+d,ha_end_bulk_insert_fail'; +create or replace table t2 (y int) engine innodb select * from t1; +ERROR HY000: Out of memory. +set @@debug_dbug= @old_dbug; +drop table t1; diff --git a/mysql-test/main/create_replace_debug.test b/mysql-test/main/create_replace_debug.test new file mode 100644 index 0000000000000..f313adf469adc --- /dev/null +++ b/mysql-test/main/create_replace_debug.test @@ -0,0 +1,84 @@ +# +# Check CREATE OR REPLACE TABLE for test that requires DEBUG +# + +--source include/have_debug.inc +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings +SET @old_debug= @@session.debug; + +# +# MDEV-5854 +# Interrupted CREATE OR REPLACE is written into binlog, and in a wrong format +# + +CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB; +CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam; +SET debug_dbug='+d,send_kill_after_delete'; +CREATE OR REPLACE TABLE t1 LIKE tmp; +SET debug_dbug=@old_debug; +SHOW TABLES; +show create table t1; +--sync_slave_with_master +SHOW TABLES; +show create table t1; +--connection master + +--disable_warnings +drop temporary table if exists tmp; +--enable_warnings +drop table t1; +--source include/rpl_end.inc + +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # + +--echo # Test entry_pos in higher position, so drop chain executes before create chain +--echo # (see commit message: On linking two chains together) +create table t1 (c int); +--error ER_DUP_KEYNAME +create or replace table t1 (a int, b int, key k (a), key k (b)); +--error ER_DUP_KEYNAME +create or replace table t1 (a int, b int, key k (a), key k (b)); +drop table t1; + +--echo # +--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +--echo # +--echo # Non-atomic CREATE OR REPLACE part: +--echo # + +# Simulate expensive rename +set @@drop_before_create_or_replace=1; + +create table t1 (pk int primary key) engine=innodb; +create or replace table t2 (a int primary key references t1 (pk)) engine=innodb; + +lock tables t1 write, t2 write; +--error ER_DUP_FIELDNAME +create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb; +select * from t1; +--error ER_TABLE_NOT_LOCKED +select * from t2; +unlock tables; +drop table t1; + +set @@drop_before_create_or_replace=default; + +--echo # +--echo # MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection +--echo # + +create table t1 (x int); +set @old_dbug= @@debug_dbug; +set @@debug_dbug= '+d,ha_end_bulk_insert_fail'; +--error ER_OUT_OF_RESOURCES +create or replace table t2 (y int) engine innodb select * from t1; +set @@debug_dbug= @old_dbug; +drop table t1; diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result index f67da7bec31c5..0214e31b5882a 100644 --- a/mysql-test/main/default.result +++ b/mysql-test/main/default.result @@ -435,7 +435,11 @@ create table t1 (a int); create or replace table t1 (a int default b, b int default a); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` show create table t1; -ERROR 42S02: Table 'test.t1' doesn't exist +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table t1; # # Referring to other columns # @@ -454,11 +458,11 @@ ERROR 01000: Expression for field `a` is referring to uninitialized field `a` create or replace table t1 (a int default b, b int default (1+1)); create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); ERROR 01000: Expression for field `b` is referring to uninitialized field `c` -CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT (DEFAULT(a))); ERROR 01000: Expression for field `a` is referring to uninitialized field `a` -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); ERROR 01000: Expression for field `a` is referring to uninitialized field `b` # # Allow defaults to refer to not default fields diff --git a/mysql-test/main/default.test b/mysql-test/main/default.test index 81dfaeb27ff36..ac4d425183512 100644 --- a/mysql-test/main/default.test +++ b/mysql-test/main/default.test @@ -316,8 +316,8 @@ drop table t1; create table t1 (a int); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD create or replace table t1 (a int default b, b int default a); ---error ER_NO_SUCH_TABLE show create table t1; +drop table t1; --echo # --echo # Referring to other columns @@ -341,11 +341,11 @@ create or replace table t1 (a int default b, b int default (1+1)); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT (DEFAULT(a))); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD -CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); +CREATE OR REPLACE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); --echo # --echo # Allow defaults to refer to not default fields diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 405343c86629f..44a15c68d7ca9 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -553,7 +553,8 @@ c d create or replace table t2 (a int, b blob, unique(b)) as select * from t1; ERROR 23000: Duplicate entry 'bar' for key 'b' select * from t2; -ERROR 42S02: Table 'test.t2' doesn't exist +c d +3 bar create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; Warnings: Warning 1062 Duplicate entry 'bar' for key 'b' diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index b6411ff8b1127..138df020ce985 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -532,8 +532,7 @@ delete from t2 using t1, t2 where t1.a=t2.c and t1.b='foo'; # CREATE...SELECT --error ER_DUP_ENTRY create or replace table t2 (a int, b blob, unique(b)) as select * from t1; ---error ER_NO_SUCH_TABLE - select * from t2; + select * from t2; create or replace table t2 (a int, b blob, unique(b)) ignore as select * from t1; select * from t2; create or replace table t2 (a int, b blob, unique(b)) replace as select * from t1; diff --git a/mysql-test/main/mdev19198.result b/mysql-test/main/mdev19198.result index 77c08ca0fb78b..2230a74df30bc 100644 --- a/mysql-test/main/mdev19198.result +++ b/mysql-test/main/mdev19198.result @@ -8,6 +8,10 @@ UNLOCK TABLES; LOCK TABLES t1 READ , t2 READ; CREATE TABLE IF NOT EXISTS t1 LIKE t2; ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +CREATE TABLE IF NOT EXISTS t1 (a int); +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +CREATE TABLE IF NOT EXISTS t1 select * from t2; +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated UNLOCK TABLES; CREATE TABLE IF NOT EXISTS t1 LIKE t2; Warnings: diff --git a/mysql-test/main/mdev19198.test b/mysql-test/main/mdev19198.test index 19b45ed7510ce..84274c037026c 100644 --- a/mysql-test/main/mdev19198.test +++ b/mysql-test/main/mdev19198.test @@ -8,6 +8,10 @@ UNLOCK TABLES; LOCK TABLES t1 READ , t2 READ; --error ER_TABLE_NOT_LOCKED_FOR_WRITE CREATE TABLE IF NOT EXISTS t1 LIKE t2; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +CREATE TABLE IF NOT EXISTS t1 (a int); +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +CREATE TABLE IF NOT EXISTS t1 select * from t2; UNLOCK TABLES; CREATE TABLE IF NOT EXISTS t1 LIKE t2; diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 702d11161480e..429b983b9a266 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -317,6 +317,11 @@ The following specify which files/extra groups are read (specified before remain --div-precision-increment=# Precision of the result of '/' operator will be increased on that value + --drop-before-create-or-replace + CREATE OR REPLACE should drop old tables before creating + new ones. If not set then old table will be temporarly + renamed until create table succeeeds. If create does not + succeed the old table will be renamed back --encrypt-binlog Encrypt binary logs (including relay logs) --encrypt-tmp-disk-tables Encrypt temporary on-disk tables (created as part of @@ -1804,6 +1809,7 @@ delayed-insert-timeout 300 delayed-queue-size 1000 disconnect-on-expired-password FALSE div-precision-increment 4 +drop-before-create-or-replace FALSE encrypt-binlog FALSE encrypt-tmp-disk-tables FALSE encrypt-tmp-files FALSE diff --git a/mysql-test/suite/atomic/alter_table.inc b/mysql-test/suite/atomic/alter_table.inc index 02f98367e0076..76437418696cd 100644 --- a/mysql-test/suite/atomic/alter_table.inc +++ b/mysql-test/suite/atomic/alter_table.inc @@ -2,17 +2,13 @@ --source include/have_debug.inc --source include/have_log_bin.inc --source include/default_charset.inc - -if (!$BIG_TEST) -{ - --source include/not_valgrind.inc -} +--source include/test_db_charset_latin1.inc +--source include/big_test.inc +--source include/not_valgrind.inc # Starting with 11.7, this will hit the 900-second timeout on WITH_MSAN=ON CMAKE_BUILD_TYPE=Debug --source include/not_msan.inc ---source include/test_db_charset_latin1.inc - # # Testing of atomic create table with crashes in a lot of different places # diff --git a/mysql-test/suite/atomic/create_fk.result b/mysql-test/suite/atomic/create_fk.result new file mode 100644 index 0000000000000..b3111de818a5d --- /dev/null +++ b/mysql-test/suite/atomic/create_fk.result @@ -0,0 +1,51 @@ +CREATE TABLE t1( +id SERIAL, +msg VARCHAR(100) CHARACTER SET utf8mb3, +KEY(msg))ENGINE=InnoDB; +insert into t1 values(1,"a"),(2,"b"); +CREATE TABLE t2( +id SERIAL, +msg varchar(100) CHARACTER SET utf8mb3, +msg_1 varchar(100) CHARACTER SET utf8mb3, +INDEX (msg_1), +INDEX (msg), +CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg) +ON DELETE CASCADE)ENGINE=InnoDB; +insert into t2 values(1,"a","aa"),(2,"b","bb"); +CREATE OR REPLACE TABLE t2( +id SERIAL, +id2 int, +msg varchar(100) CHARACTER SET utf8mb3, +msg_1 varchar(100) CHARACTER SET utf8mb3, +INDEX (msg_1), +INDEX (msg), +unique (id2), +CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg) +ON DELETE CASCADE)ENGINE=InnoDB SELECT 1 as id2 from seq_1_to_2; +ERROR 23000: Duplicate entry '1' for key 'id2' +select * from t2; +id msg msg_1 +1 a aa +2 b bb +CREATE OR REPLACE TABLE t2( +id SERIAL, +msg varchar(100) CHARACTER SET utf8mb3, +msg_1 varchar(100) CHARACTER SET utf8mb3, +INDEX (msg_1), +INDEX (msg), +CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg) +ON DELETE CASCADE)ENGINE=InnoDB; +select * from t2; +id msg msg_1 +drop table t2,t1; +# +# Test foreign key references to same table +# +create or replace table t1 (a int primary key, b int, c int, constraint d foreign key e (b) references t1 (a)) engine=innodb; +insert into t1 values (1,1,1); +create or replace table t1 (a int primary key, b int, c int, g int, constraint d foreign key e (b) references t1 (a)) engine=innodb select 1 as a ,2 as b,3 as c; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `d` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)) +select * from t1; +a b c +1 1 1 +drop table t1; diff --git a/mysql-test/suite/atomic/create_fk.test b/mysql-test/suite/atomic/create_fk.test new file mode 100644 index 0000000000000..83fbd4e3352c2 --- /dev/null +++ b/mysql-test/suite/atomic/create_fk.test @@ -0,0 +1,54 @@ +--source include/have_innodb.inc +--source include/have_sequence.inc + +CREATE TABLE t1( + id SERIAL, + msg VARCHAR(100) CHARACTER SET utf8mb3, + KEY(msg))ENGINE=InnoDB; +insert into t1 values(1,"a"),(2,"b"); + +CREATE TABLE t2( +id SERIAL, +msg varchar(100) CHARACTER SET utf8mb3, +msg_1 varchar(100) CHARACTER SET utf8mb3, +INDEX (msg_1), +INDEX (msg), +CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg) +ON DELETE CASCADE)ENGINE=InnoDB; + +insert into t2 values(1,"a","aa"),(2,"b","bb"); + +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t2( +id SERIAL, +id2 int, +msg varchar(100) CHARACTER SET utf8mb3, +msg_1 varchar(100) CHARACTER SET utf8mb3, +INDEX (msg_1), +INDEX (msg), +unique (id2), +CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg) +ON DELETE CASCADE)ENGINE=InnoDB SELECT 1 as id2 from seq_1_to_2; +select * from t2; + +CREATE OR REPLACE TABLE t2( +id SERIAL, +msg varchar(100) CHARACTER SET utf8mb3, +msg_1 varchar(100) CHARACTER SET utf8mb3, +INDEX (msg_1), +INDEX (msg), +CONSTRAINT fk_t1 FOREIGN KEY (msg) REFERENCES t1 (msg) +ON DELETE CASCADE)ENGINE=InnoDB; +select * from t2; +drop table t2,t1; + +--echo # +--echo # Test foreign key references to same table +--echo # + +create or replace table t1 (a int primary key, b int, c int, constraint d foreign key e (b) references t1 (a)) engine=innodb; +insert into t1 values (1,1,1); +--error ER_NO_REFERENCED_ROW_2 +create or replace table t1 (a int primary key, b int, c int, g int, constraint d foreign key e (b) references t1 (a)) engine=innodb select 1 as a ,2 as b,3 as c; +select * from t1; +drop table t1; diff --git a/mysql-test/suite/atomic/create_replace.result b/mysql-test/suite/atomic/create_replace.result new file mode 100644 index 0000000000000..0ce6523380e50 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace.result @@ -0,0 +1,898 @@ +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; +engine: myisam +query: CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_finalize_create +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_revert +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_finalize_create +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_revert +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_send_data +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create_after_link +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_prepare_eof +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_prepare_eof +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_after_revert +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +query: CREATE OR REPLACE TABLE t2 (fail int primary key) select 1 as fail from const_table +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_binlog +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_binlog +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_revert +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_middle_complete +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_complete +"No crash!" +t2.MYD +t2.MYI +t2.frm +engine: innodb +query: CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_send_data +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_finalize_create +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_revert +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_middle_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_finalize_create +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_revert +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_send_data +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create_after_link +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_prepare_eof +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_prepare_eof +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_after_revert +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_middle_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +query: CREATE OR REPLACE TABLE t2 (fail int primary key) select 1 as fail from const_table +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_send_data +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_prepare_eof +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_after_binlog +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_after_revert +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_middle_complete +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_complete +"No crash!" +t2.frm +t2.ibd diff --git a/mysql-test/suite/atomic/create_replace.test b/mysql-test/suite/atomic/create_replace.test new file mode 100644 index 0000000000000..aa261b58ca2be --- /dev/null +++ b/mysql-test/suite/atomic/create_replace.test @@ -0,0 +1,23 @@ +--source include/have_log_bin.inc + +# Testing of atomic CREATE OR REPLACE TABLE with binary logging. + +if ($engines == "") +{ + let $engines='myisam','innodb'; +} + +if ($crash_points == "") +{ + let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_create_after_send_data', 'ddl_log_finalize_create', 'ddl_log_finalize_create_after_link', 'ddl_log_create_before_binlog', 'ddl_log_create_before_prepare_eof','ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_after_revert', 'ddl_log_create_middle_complete', 'ddl_log_create_complete'; +} + +let $show_table_t2=1; # All tests are using t2 + +let $statement_count=4; +let $statements='CREATE OR REPLACE TABLE t2 (new int)', + 'CREATE OR REPLACE TABLE t2 LIKE const_table', + 'CREATE OR REPLACE TABLE t2 SELECT * from const_table', + 'CREATE OR REPLACE TABLE t2 (fail int primary key) select 1 as fail from const_table'; + +--source create_table.inc diff --git a/mysql-test/suite/atomic/create_replace2,aria,row.result b/mysql-test/suite/atomic/create_replace2,aria,row.result new file mode 100644 index 0000000000000..ca0e117552c16 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,aria,row.result @@ -0,0 +1,456 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: row +# Extra: +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,aria_notrans,row.result b/mysql-test/suite/atomic/create_replace2,aria_notrans,row.result new file mode 100644 index 0000000000000..e608a1c676a5a --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,aria_notrans,row.result @@ -0,0 +1,456 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: row +# Extra: transactional=0 +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 TRANSACTIONAL=0 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,aria_notrans,stmt.result b/mysql-test/suite/atomic/create_replace2,aria_notrans,stmt.result new file mode 100644 index 0000000000000..6093e05a259af --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,aria_notrans,stmt.result @@ -0,0 +1,432 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: statement +# Extra: transactional=0 +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,aria_notrans.result b/mysql-test/suite/atomic/create_replace2,aria_notrans.result new file mode 100644 index 0000000000000..6093e05a259af --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,aria_notrans.result @@ -0,0 +1,432 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: statement +# Extra: transactional=0 +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) engine=aria,transactional=0 +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 engine=aria,transactional=0 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,ib,row.result b/mysql-test/suite/atomic/create_replace2,ib,row.result new file mode 100644 index 0000000000000..6a32f0e031bee --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,ib,row.result @@ -0,0 +1,420 @@ +# Crash recovery +# Engine: InnoDB +# Binlog_format: row +# Extra: +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,ib.result b/mysql-test/suite/atomic/create_replace2,ib.result new file mode 100644 index 0000000000000..e31ac3b5a1016 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,ib.result @@ -0,0 +1,396 @@ +# Crash recovery +# Engine: InnoDB +# Binlog_format: statement +# Extra: +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.TRG +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.frm +t1.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,lock_tables,row.result b/mysql-test/suite/atomic/create_replace2,lock_tables,row.result new file mode 100644 index 0000000000000..b95ca19fd642a --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,lock_tables,row.result @@ -0,0 +1,456 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: row +# Extra: lock tables +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,lock_tables,stmt.result b/mysql-test/suite/atomic/create_replace2,lock_tables,stmt.result new file mode 100644 index 0000000000000..7e046a798b4db --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,lock_tables,stmt.result @@ -0,0 +1,432 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: statement +# Extra: lock tables +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,myisam,row.result b/mysql-test/suite/atomic/create_replace2,myisam,row.result new file mode 100644 index 0000000000000..af7b8a5da0b0a --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,myisam,row.result @@ -0,0 +1,456 @@ +# Crash recovery +# Engine: MyISAM +# Binlog_format: row +# Extra: +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,myisam,stmt.result b/mysql-test/suite/atomic/create_replace2,myisam,stmt.result new file mode 100644 index 0000000000000..727a40a5cd988 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,myisam,stmt.result @@ -0,0 +1,432 @@ +# Crash recovery +# Engine: MyISAM +# Binlog_format: statement +# Extra: +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2,row.result b/mysql-test/suite/atomic/create_replace2,row.result new file mode 100644 index 0000000000000..b95ca19fd642a --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2,row.result @@ -0,0 +1,456 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: row +# Extra: lock tables +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t1 SELECT * from const_table +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2.combinations b/mysql-test/suite/atomic/create_replace2.combinations new file mode 100644 index 0000000000000..ea192813323f5 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2.combinations @@ -0,0 +1,5 @@ +[ib] +[myisam] +[aria] +[aria_notrans] +[lock_tables] diff --git a/mysql-test/suite/atomic/create_replace2.result b/mysql-test/suite/atomic/create_replace2.result new file mode 100644 index 0000000000000..b69a69f1b4fd0 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2.result @@ -0,0 +1,432 @@ +# Crash recovery +# Engine: Aria +# Binlog_format: statement +# Extra: +# +Table Create Table +const_table CREATE TABLE `const_table` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +insert into const_table values (1, 1), (2, 2); +flush tables; +# QUERY: CREATE OR REPLACE TABLE t1 (new int) +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 (new int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 LIKE const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_prepare_eof +# No crash! +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 LIKE const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# QUERY: CREATE OR REPLACE TABLE t1 SELECT * from const_table +# CRASH POINT: ddl_log_finalize_create +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_frm +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_create_table +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_send_data +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_binlog +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_before_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_prepare_eof +t1.DATA1 +t1.DATA2 +t1.TRG +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `old` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +old +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +a INSERT t1 set @s= 1 BEFORE +# CRASH POINT: ddl_log_create_after_binlog +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_after_revert +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_middle_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +# CRASH POINT: ddl_log_create_complete +t1.DATA1 +t1.DATA2 +t1.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t1 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +new b +1 1 +2 2 +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/atomic/create_replace2.test b/mysql-test/suite/atomic/create_replace2.test new file mode 100644 index 0000000000000..1e3ec36e92742 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace2.test @@ -0,0 +1,208 @@ +--source include/have_debug.inc +--source include/have_sequence.inc +--source include/have_innodb.inc +--source include/have_binlog_format_row_or_statement.inc +--source include/big_test.inc +--source include/not_valgrind.inc + +--disable_query_log +let $default_engine=InnoDB; +let $extra_option= ''; +let $save_debug=`select @@debug_dbug`; +let $show_error=0; +let $drop_error=0; + +if ($MTR_COMBINATION_MYISAM) +{ + let $default_engine=MyISAM; +} +if ($MTR_COMBINATION_ARIA) +{ + let $default_engine=Aria; + call mtr.add_suppression("Checking table"); + call mtr.add_suppression("marked as crashed"); + call mtr.add_suppression("UNDO records skipped"); +} +if ($MTR_COMBINATION_ARIA_NOTRANS) +{ + let $default_engine=Aria; + let $extra_option=' engine=aria,transactional=0'; + call mtr.add_suppression("Checking table"); + call mtr.add_suppression("marked as crashed"); + let $extra=transactional=0; +} +if ($MTR_COMBINATION_LOCK_TABLES) +{ + let $default_engine=Aria; + call mtr.add_suppression("Checking table"); + call mtr.add_suppression("marked as crashed"); + call mtr.add_suppression("UNDO records skipped"); + let $extra=lock tables; +} + +if ($MTR_COMBINATION_STMT) +{ + let $binlog_format=include/set_binlog_format_statement.sql; + let $format=statement; +} +if ($MTR_COMBINATION_ROW) +{ + let $binlog_format=include/set_binlog_format_row.sql; + let $format=row; +} +if ($MTR_COMBINATION_MIX) +{ + --die +} + +--eval set @@default_storage_engine=$default_engine + +--enable_query_log + +--echo # Crash recovery +--echo # Engine: $default_engine +--echo # Binlog_format: $format +--echo # Extra: $extra +--echo # + +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +let $crash_count=12; +let $crash_points='ddl_log_finalize_create', + 'ddl_log_create_before_create_frm', + 'ddl_log_create_before_create_table', + 'ddl_log_create_after_create_table', + 'ddl_log_create_after_send_data', + 'ddl_log_create_before_binlog', + 'ddl_log_create_before_prepare_eof', + 'ddl_log_create_after_prepare_eof', + 'ddl_log_create_after_binlog', + 'ddl_log_create_after_revert', + 'ddl_log_create_middle_complete', + 'ddl_log_create_complete'; + +#let $crash_count=1; +#let $crash_points='ddl_log_create_fk_fail'; +# 'ddl_log_create_before_binlog3', +# 'ddl_log_create_before_binlog4'; + +let $statement_count=3; +let $statements='CREATE OR REPLACE TABLE t1 (new int) EXTRA_OPTION', + 'CREATE OR REPLACE TABLE t1 LIKE const_table', + 'CREATE OR REPLACE TABLE t1 EXTRA_OPTION SELECT * from const_table'; + +#let $statement_count=1; +#let $statements='CREATE OR REPLACE TABLE t1 EXTRA_OPTION SELECT * from const_table'; + +--disable_query_log +let create_const=`select REPLACE('create table const_table (new int, b int) EXTRA_OPTION', ' EXTRA_OPTION', $extra_option)`; +eval $create_const; +--replace_result $default_engine ENGINE ' PAGE_CHECKSUM=1' '' ' TRANSACTIONAL=0' '' +show create table const_table; +--enable_query_log +insert into const_table values (1, 1), (2, 2); +flush tables; + +let $old_debug=`select @@debug_dbug`; + +let $keep_include_silent=1; +let $grep_script=CREATE|DROP|table_id; +--disable_query_log + +let $r=0; +while ($r < $statement_count) +{ + inc $r; + let $STATEMENT=`select REPLACE(ELT($r, $statements), ' EXTRA_OPTION', $extra_option)`; + --echo # QUERY: $STATEMENT + + let $c=0; + while ($c < $crash_count) + { + inc $c; + let $crash= `select ELT($c, $crash_points)`; + let $fk_error= `select '$crash' like 'ddl_log_create_fk_fail%'`; + + --eval set @@default_storage_engine=$default_engine + create or replace table t1 (old int); +# if ($fk_error) +# { +# create or replace table t1 (old int primary key, y int) engine innodb; +# create table t2 (x int references t1(old)) engine innodb; +# } + create trigger a before insert on t1 for each row set @s= 1; + flush tables; + if ($MTR_COMBINATION_LOCK_TABLES) + { + lock tables t1 write, const_table read; + } + + --source $binlog_format + + RESET MASTER; + --echo # CRASH POINT: $crash + --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --disable_reconnect + --eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 + let $errno=0; + --error 0,2013 + eval $STATEMENT; + let $error=$errno; + --enable_reconnect + --source include/wait_until_connected_again.inc + --disable_query_log + --eval set @@debug_dbug="$old_debug" + + if ($error == 0) + { + --echo # No crash! + if ($MTR_COMBINATION_LOCK_TABLES) + { + unlock tables; + } + } + # Check which tables still exists + --replace_result .MAD .DATA1 .MYD .DATA1 .MAI .DATA2 .MYI .DATA2 + --list_files $MYSQLD_DATADIR/test t* + --list_files $MYSQLD_DATADIR/test *sql* + + --let $binlog_file=master-bin.000001 + --source include/show_binlog_events.inc + if ($error) + { + --let $binlog_file=master-bin.000002 + --source include/show_binlog_events.inc + } + + if ($default_engine == Aria) + { + # Again we suppress 'marked as crashed', it works differently in --ps + --disable_warnings + } + --replace_result $default_engine ENGINE InnoDB ENGINE ' PAGE_CHECKSUM=1' '' ' TRANSACTIONAL=0' '' + --error $show_error + show create table t1; + --enable_warnings + if (`select locate('SELECT', '$STATEMENT')`) + { + --error $show_error + select * from t1; + } + --enable_warnings + --replace_column 6 '' 7 '' 8 '' 9 '' 10 '' 11 '' + show triggers; + # Drop the tables. The warnings will show what was dropped +# if ($fk_error) +# { +# drop table t2; +# } + --disable_warnings + --error $drop_error + drop table t1; + --enable_warnings + } +} +drop table if exists t1,const_table; +--eval set @@debug_dbug="$save_debug" + +--enable_query_log diff --git a/mysql-test/suite/atomic/create_replace_drop.opt b/mysql-test/suite/atomic/create_replace_drop.opt new file mode 100644 index 0000000000000..008070b4d7990 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_drop.opt @@ -0,0 +1 @@ +--drop_before_create_or_replace \ No newline at end of file diff --git a/mysql-test/suite/atomic/create_replace_drop.result b/mysql-test/suite/atomic/create_replace_drop.result new file mode 100644 index 0000000000000..ab95e4eae6d07 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_drop.result @@ -0,0 +1,464 @@ +select @@drop_before_create_or_replace; +@@drop_before_create_or_replace +1 +call mtr.add_suppression("mariadbd.*UNDO records skipped in UNDO phase"); +call mtr.add_suppression("mariadbd.*File.*t2.* not found"); +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; +engine: aria +query: CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MAD +t2.MAI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_finalize_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.MAD +t2.MAI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MAD +t2.MAI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_binlog +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_middle_complete +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_complete +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_finalize_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.MAD +t2.MAI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_binlog +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_middle_complete +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_complete +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table +query: CREATE OR REPLACE TABLE t2 (fail int primary key) select 1 as fail from const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_finalize_create +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_after_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_middle_complete +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_complete +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +engine: innodb +query: CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_finalize_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_middle_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (new int) +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_finalize_create +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create +master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +t2.frm +t2.ibd +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_middle_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table +query: CREATE OR REPLACE TABLE t2 (fail int primary key) select 1 as fail from const_table +crash point: ddl_log_create_before_create_frm +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: storage_engine_middle_of_create +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_before_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_create_table +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_send_data +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_after_drop +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_finalize_create_after_link +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_before_binlog +master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +crash point: ddl_log_create_after_prepare_eof +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_after_binlog +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_middle_complete +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ +crash point: ddl_log_create_complete +"No crash!" +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t2`/* Generated to handle failed CREATE OR REPLACE */ diff --git a/mysql-test/suite/atomic/create_replace_drop.test b/mysql-test/suite/atomic/create_replace_drop.test new file mode 100644 index 0000000000000..0a07317eb16eb --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_drop.test @@ -0,0 +1,17 @@ +--source include/have_log_bin.inc + +# Testing of atomic CREATE OR REPLACE TABLE with DROP of conflicting table +# Binary logging is used +# In case of failure, the old t2 table should not exist anymore + +select @@drop_before_create_or_replace; + +let $engines='aria','innodb'; + +# Ignore warnings from Aria recovery phase +call mtr.add_suppression("mariadbd.*UNDO records skipped in UNDO phase"); +call mtr.add_suppression("mariadbd.*File.*t2.* not found"); + +let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_create_after_send_data', 'ddl_log_finalize_create', 'ddl_log_create_after_drop', 'ddl_log_finalize_create_after_link', 'ddl_log_create_before_binlog', 'ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_middle_complete', 'ddl_log_create_complete'; + +--source create_replace.test diff --git a/mysql-test/suite/atomic/create_replace_memory.result b/mysql-test/suite/atomic/create_replace_memory.result new file mode 100644 index 0000000000000..a15c3ffc836d4 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_memory.result @@ -0,0 +1,59 @@ +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; +engine: memory +query: CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_frm +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_create_table +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_revert +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_middle_complete +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_complete +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci diff --git a/mysql-test/suite/atomic/create_replace_memory.test b/mysql-test/suite/atomic/create_replace_memory.test new file mode 100644 index 0000000000000..4e62f62fa3a80 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_memory.test @@ -0,0 +1,13 @@ +# Testing of atomic CREATE OR REPLACE TABLE on memory without binary logging +# Not binary logging is important as it exposes other possible bugs in the code + +let $engines='memory'; + +let $crash_points='ddl_log_create_before_create_frm', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_finalize_create', 'ddl_log_finalize_create_after_link', 'ddl_log_create_before_binlog', 'ddl_log_create_after_revert', 'ddl_log_create_middle_complete', 'ddl_log_create_complete'; + +let $show_table_t2=1; # All tests are using t2 + +let $statement_count=1; +let $statements='CREATE OR REPLACE TABLE t2 (new int)'; + +--source create_table.inc diff --git a/mysql-test/suite/atomic/create_replace_no_binlog.result b/mysql-test/suite/atomic/create_replace_no_binlog.result new file mode 100644 index 0000000000000..bc8d8a9d6fb82 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_no_binlog.result @@ -0,0 +1,306 @@ +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; +engine: innodb +query: CREATE OR REPLACE TABLE t2 (new int) +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_send_data +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_finalize_create +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_revert +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_middle_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +query: CREATE OR REPLACE TABLE t2 LIKE const_table +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: storage_engine_middle_of_create +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_send_data +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_finalize_create_after_link +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_before_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_after_revert +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_middle_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_complete +t2.MYD +t2.MYI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +crash point: ddl_log_create_before_create_frm +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: storage_engine_middle_of_create +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_before_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_create_table +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_send_data +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_finalize_create_after_link +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_before_prepare_eof +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_prepare_eof +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_binlog +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `old` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_after_revert +crash point: ddl_log_create_middle_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +crash point: ddl_log_create_complete +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 diff --git a/mysql-test/suite/atomic/create_replace_no_binlog.test b/mysql-test/suite/atomic/create_replace_no_binlog.test new file mode 100644 index 0000000000000..5f72d5b54a758 --- /dev/null +++ b/mysql-test/suite/atomic/create_replace_no_binlog.test @@ -0,0 +1,14 @@ +# Testing of atomic CREATE TABLE REPLACE without binary logging. + +let $engines='innodb'; + +let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_create_after_send_data', 'ddl_log_finalize_create', 'ddl_log_finalize_create_after_link', 'ddl_log_create_before_binlog', 'ddl_log_create_before_prepare_eof','ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_after_revert', 'ddl_log_create_middle_complete', 'ddl_log_create_complete'; + +let $show_table_t2=1; # All tests are using t2 + +let $statement_count=3; +let $statements='CREATE OR REPLACE TABLE t2 (new int)', + 'CREATE OR REPLACE TABLE t2 LIKE const_table', + 'CREATE OR REPLACE TABLE t2 SELECT * from const_table'; + +--source create_table.inc diff --git a/mysql-test/suite/atomic/create_table.inc b/mysql-test/suite/atomic/create_table.inc new file mode 100644 index 0000000000000..20ef2de7e0783 --- /dev/null +++ b/mysql-test/suite/atomic/create_table.inc @@ -0,0 +1,187 @@ +--source include/have_debug.inc +--source include/have_sequence.inc +--source include/have_innodb.inc +--source include/not_valgrind.inc +--source include/not_embedded.inc + +# +# Testing of atomic CREATE TABLE with crashes in a lot of different places +# +# We test both statement based logging and row logging as CREATE ... SELECT +# works a bit differently depending on the logging format +# +# If more than one engines are specified, the first engine will use row +# logging and second engine will use statement based logging +# +# Parameters: +# $engines List of quoted engines separated by , +# $crash_points List of crash points separated by , +# $statement_count Number of statements +# $statements List of quoted statements to test, separated by , +# $show_table_t1 Set to 1 to show table t1 at end of tests +# $show_table_t2 Set to 1 to show table t2 at end of test + +--disable_query_log +call mtr.add_suppression("InnoDB: .* does not exist in the InnoDB internal"); +let $log_bin=`select @@log_bin`; + +if ($log_bin == 1) +{ + RESET MASTER; +} +# Speed up wait_until_connected_again.inc +let NO_WSREP=1; +let $save_binlog_format=`select @@binlog_format`; + +let $engine_count=`select FIND_IN_SET("end", concat("$engines",",end"))-1`; +let $crash_count=`select FIND_IN_SET("end", concat("$crash_points",",end"))-1`; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +--enable_query_log + +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; + +let $old_debug=`select @@debug_dbug`; + +let $e=0; +let $keep_include_silent=1; +let $grep_script=CREATE|DROP; +--disable_query_log + +while ($e < $engine_count) +{ + inc $e; + let $engine=`select ELT($e, $engines)`; + let $default_engine=$engine; + + # Note: $extra_option is not used. This dead code here is for conformity with + # other tests. + let $extra_option=; + if ($engine == "aria") + { + let $extra_option=transactional=1; + } + if ($engine == "aria_notrans") + { + let $default_engine="aria"; + let $extra_option=transactional=0; + } + --echo engine: $engine + + let $r=0; + while ($r < $statement_count) + { + inc $r; + let $statement=`select ELT($r, $statements)`; + --echo query: $statement + let $create_select=`select INSTR("$statement", "SELECT") > 0`; + + let $c=0; + while ($c < $crash_count) + { + inc $c; + let $crash=`select ELT($c, $crash_points)`; + + --eval set @@default_storage_engine=$default_engine + create or replace table t2 select seq as old from seq_1_to_2; + flush tables; + + if ($e == 1) + { + --source include/set_binlog_format_row.sql + } + if ($e == 2) + { + --source include/set_binlog_format_statement.sql + } + if ($log_bin == 1) + { + FLUSH BINARY LOGS; + --let $start_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) + } + + --echo crash point: $crash + --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --disable_reconnect + --eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 + let $errno=0; + --error 0,2013,1062 + --eval $statement; + let $error=$errno; + if ($error == 1062) + { + # Duplicate key test + let $error= 0; + } + --enable_reconnect + --source include/wait_until_connected_again.inc + --disable_query_log + --eval set @@debug_dbug="$old_debug" + + if ($error == 0) + { + echo "No crash!"; + } + # Check which tables still exists + --list_files $MYSQLD_DATADIR/test t* + --list_files $MYSQLD_DATADIR/test *sql* + + if ($error != 0) + { + if ($show_table_t1 == 1) + { + --error 0,1146 + show create table t1; + if ($create_select == 1) + { + if ($errno == 0) + { + select count(*) from t1; + } + } + } + if ($show_table_t2 == 1) + { + --error 0,1146 + show create table t2; + if ($create_select == 1) + { + if ($errno == 0) + { + select count(*) from t2; + } + } + } + } + + if ($log_bin == 1) + { + --let $binlog_file=$start_binlog_file + --let $binlog_output_name=master-bin.000001 + --source include/show_binlog_events.inc + if ($error) + { + --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) + --let $binlog_output_name=master-bin.000002 + if ($binlog_file != $start_binlog_file) + { + --source include/show_binlog_events.inc + } + } + } + # Drop the tables. The warnings will show what was dropped + --disable_warnings + drop table if exists t1,t2; + --enable_warnings + } + } +} +--disable_warnings +drop table if exists t1,t2,const_table; +--enable_warnings +eval set @@global.binlog_format=$save_binlog_format; + +--enable_query_log diff --git a/mysql-test/suite/atomic/create_table.result b/mysql-test/suite/atomic/create_table.result index 3d7943d6e5e72..80c3d18bac435 100644 --- a/mysql-test/suite/atomic/create_table.result +++ b/mysql-test/suite/atomic/create_table.result @@ -1,8 +1,8 @@ -create table const_table (a int, b int) engine=myisam; +create table const_table (new int, new2 int) engine=myisam; insert into const_table values (1,1),(2,2); flush tables; engine: myisam -query: CREATE TABLE t1 (a int) +query: CREATE TABLE t1 (new int) crash point: ddl_log_create_before_create_frm t2.MYD t2.MYI @@ -15,7 +15,7 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) crash point: ddl_log_create_before_create_table t2.MYD t2.MYI @@ -24,15 +24,10 @@ crash point: ddl_log_create_after_create_table t2.MYD t2.MYI t2.frm -crash point: ddl_log_create_after_drop -"No crash!" -t1.MYD -t1.MYI -t1.frm +crash point: ddl_log_finalize_create t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) crash point: ddl_log_create_before_binlog t2.MYD t2.MYI @@ -45,7 +40,7 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) crash point: ddl_log_create_after_binlog t1.MYD t1.MYI @@ -53,17 +48,24 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) -crash point: ddl_log_create_log_complete -"No crash!" +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) +crash point: ddl_log_create_complete t1.MYD t1.MYI t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) -query: CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) +query: CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) crash point: ddl_log_create_before_create_frm t2.MYD t2.MYI @@ -78,7 +80,7 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) crash point: ddl_log_create_before_create_table t2.MYD t2.MYI @@ -87,17 +89,10 @@ crash point: ddl_log_create_after_create_table t2.MYD t2.MYI t2.frm -crash point: ddl_log_create_after_drop -"No crash!" -t1#i#00.MYD -t1#i#00.MYI -t1.MYD -t1.MYI -t1.frm +crash point: ddl_log_finalize_create t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) crash point: ddl_log_create_before_binlog t2.MYD t2.MYI @@ -112,7 +107,7 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) crash point: ddl_log_create_after_binlog t1#i#00.MYD t1#i#00.MYI @@ -122,9 +117,13 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) -crash point: ddl_log_create_log_complete -"No crash!" +Table Create Table +t1 CREATE TABLE `t1` ( + `new` vector(5) NOT NULL, + VECTOR KEY `new` (`new`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) +crash point: ddl_log_create_complete t1#i#00.MYD t1#i#00.MYI t1.MYD @@ -133,41 +132,12 @@ t1.frm t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) -query: CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_log_complete -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` vector(5) NOT NULL, + VECTOR KEY `new` (`new`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) query: CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_create_frm t2.MYD @@ -190,15 +160,10 @@ crash point: ddl_log_create_after_create_table t2.MYD t2.MYI t2.frm -crash point: ddl_log_create_after_drop -"No crash!" -t1.MYD -t1.MYI -t1.frm +crash point: ddl_log_finalize_create t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_binlog t2.MYD t2.MYI @@ -219,51 +184,26 @@ t1.frm t2.MYD t2.MYI t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table -crash point: ddl_log_create_log_complete -"No crash!" +crash point: ddl_log_create_complete t1.MYD t1.MYI t1.frm t2.MYD t2.MYI t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table -query: CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_log_complete -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -query: CREATE TABLE t1 SELECT * from t2 +query: CREATE TABLE t1 SELECT old as new from t2 crash point: ddl_log_create_before_create_frm t2.MYD t2.MYI @@ -277,9 +217,9 @@ t2.MYD t2.MYI t2.frm master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( - `seq` bigint(20) unsigned NOT NULL + `new` bigint(20) unsigned NOT NULL ) -master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 +master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT old as new from t2 crash point: ddl_log_create_before_create_table t2.MYD t2.MYI @@ -288,18 +228,10 @@ crash point: ddl_log_create_after_create_table t2.MYD t2.MYI t2.frm -crash point: ddl_log_create_after_drop -"No crash!" -t1.MYD -t1.MYI -t1.frm +crash point: ddl_log_finalize_create t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( - `seq` bigint(20) unsigned NOT NULL -) -master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_before_binlog t2.MYD t2.MYI @@ -315,64 +247,78 @@ t1.frm t2.MYD t2.MYI t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( - `seq` bigint(20) unsigned NOT NULL + `new` bigint(20) unsigned NOT NULL ) -master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 -crash point: ddl_log_create_log_complete +master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT old as new from t2 +crash point: ddl_log_create_complete t1.MYD t1.MYI t1.frm t2.MYD t2.MYI t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( - `seq` bigint(20) unsigned NOT NULL + `new` bigint(20) unsigned NOT NULL ) -master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT * from t2 -query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +master-bin.000001 # Annotate_rows # # CREATE TABLE t1 SELECT old as new from t2 +query: CREATE TABLE t1 (fail int primary key) select 1 as fail from const_table crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.MYD +t2.MYI +t2.frm crash point: storage_engine_middle_of_create "No crash!" t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.MYD +t2.MYI +t2.frm crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create +"No crash!" +t2.MYD +t2.MYI +t2.frm crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +"No crash!" +t2.MYD +t2.MYI +t2.frm crash point: ddl_log_create_after_prepare_eof -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +"No crash!" +t2.MYD +t2.MYI +t2.frm crash point: ddl_log_create_after_binlog +"No crash!" t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table -crash point: ddl_log_create_log_complete +crash point: ddl_log_create_complete +"No crash!" t2.MYD t2.MYI t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) -master-bin.000001 # Annotate_rows # # CREATE OR REPLACE TABLE t2 SELECT * from const_table engine: innodb -query: CREATE TABLE t1 (a int) +query: CREATE TABLE t1 (new int) crash point: ddl_log_create_before_create_frm t2.frm t2.ibd @@ -382,20 +328,16 @@ t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) crash point: ddl_log_create_before_create_table t2.frm t2.ibd crash point: ddl_log_create_after_create_table t2.frm t2.ibd -crash point: ddl_log_create_after_drop -"No crash!" -t1.frm -t1.ibd +crash point: ddl_log_finalize_create t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) crash point: ddl_log_create_before_binlog t2.frm t2.ibd @@ -405,21 +347,28 @@ t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) crash point: ddl_log_create_after_binlog t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) -crash point: ddl_log_create_log_complete -"No crash!" +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) +crash point: ddl_log_create_complete t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int) -query: CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new int) +query: CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) crash point: ddl_log_create_before_create_frm t2.frm t2.ibd @@ -430,21 +379,16 @@ t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) crash point: ddl_log_create_before_create_table t2.frm t2.ibd crash point: ddl_log_create_after_create_table t2.frm t2.ibd -crash point: ddl_log_create_after_drop -"No crash!" -t1#i#00.ibd -t1.frm -t1.ibd +crash point: ddl_log_finalize_create t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) crash point: ddl_log_create_before_binlog t2.frm t2.ibd @@ -455,52 +399,31 @@ t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) crash point: ddl_log_create_after_binlog t1#i#00.ibd t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) -crash point: ddl_log_create_log_complete -"No crash!" +Table Create Table +t1 CREATE TABLE `t1` ( + `new` vector(5) NOT NULL, + VECTOR KEY `new` (`new`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) +crash point: ddl_log_create_complete t1#i#00.ibd t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a)) -query: CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_after_binlog -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) -crash point: ddl_log_create_log_complete -"No crash!" -t2.frm -t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 (a int) +Table Create Table +t1 CREATE TABLE `t1` ( + `new` vector(5) NOT NULL, + VECTOR KEY `new` (`new`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new)) query: CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_create_frm t2.frm @@ -519,14 +442,9 @@ t2.ibd crash point: ddl_log_create_after_create_table t2.frm t2.ibd -crash point: ddl_log_create_after_drop -"No crash!" -t1.MYD -t1.MYI -t1.frm +crash point: ddl_log_finalize_create t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table crash point: ddl_log_create_before_binlog t2.frm t2.ibd @@ -544,50 +462,25 @@ t1.MYI t1.frm t2.frm t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table -crash point: ddl_log_create_log_complete -"No crash!" +crash point: ddl_log_create_complete t1.MYD t1.MYI t1.frm t2.frm t2.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `new2` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table -query: CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: storage_engine_middle_of_create -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_prepare_eof -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_after_binlog -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -crash point: ddl_log_create_log_complete -"No crash!" -t2.MYD -t2.MYI -t2.frm -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 LIKE const_table -query: CREATE TABLE t1 SELECT * from t2 +query: CREATE TABLE t1 SELECT old as new from t2 crash point: ddl_log_create_before_create_frm t2.frm t2.ibd @@ -597,64 +490,76 @@ t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT old as new from t2 crash point: ddl_log_create_before_create_table t2.frm t2.ibd crash point: ddl_log_create_after_create_table t2.frm t2.ibd -crash point: ddl_log_create_after_drop -"No crash!" -t1.frm -t1.ibd +crash point: ddl_log_finalize_create t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 crash point: ddl_log_create_before_binlog t2.frm t2.ibd crash point: ddl_log_create_after_prepare_eof t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t1` /* generated by ddl recovery */ crash point: ddl_log_create_after_binlog +t1.frm +t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t1` /* generated by ddl recovery */ -crash point: ddl_log_create_log_complete +Table Create Table +t1 CREATE TABLE `t1` ( + `new` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT old as new from t2 +crash point: ddl_log_create_complete t1.frm t1.ibd t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * from t2 -query: CREATE OR REPLACE TABLE t2 SELECT * from const_table +Table Create Table +t1 CREATE TABLE `t1` ( + `new` bigint(20) unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT old as new from t2 +query: CREATE TABLE t1 (fail int primary key) select 1 as fail from const_table crash point: ddl_log_create_before_create_frm -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.frm +t2.ibd crash point: storage_engine_middle_of_create "No crash!" t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table crash point: ddl_log_create_before_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.frm +t2.ibd crash point: ddl_log_create_after_create_table -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ -crash point: ddl_log_create_after_drop -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.frm +t2.ibd +crash point: ddl_log_finalize_create +"No crash!" +t2.frm +t2.ibd crash point: ddl_log_create_before_binlog -master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */ +t2.frm +t2.ibd crash point: ddl_log_create_after_prepare_eof -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ +"No crash!" +t2.frm +t2.ibd crash point: ddl_log_create_after_binlog -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table -master-bin.000002 # Query # # DROP TABLE IF EXISTS `test`.`t2` /* generated by ddl recovery */ -crash point: ddl_log_create_log_complete +"No crash!" +t2.frm +t2.ibd +crash point: ddl_log_create_complete +"No crash!" t2.frm t2.ibd -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE t2 SELECT * from const_table -Warnings: -Note 1051 Unknown table 'test.t1,test.t2' diff --git a/mysql-test/suite/atomic/create_table.test b/mysql-test/suite/atomic/create_table.test index a6af216207bdc..2771c46ba1594 100644 --- a/mysql-test/suite/atomic/create_table.test +++ b/mysql-test/suite/atomic/create_table.test @@ -3,140 +3,21 @@ --source include/have_sequence.inc --source include/have_innodb.inc --source include/have_log_bin.inc ---source include/not_valgrind.inc -# -# Testing of atomic create table with crashes in a lot of different places -# -# We test both statement based logging and row logging as CREATE ... SELECT -# works a bit differently depending on the logging format -# First engine will use row logging and second engine will use statement -# based logging -# +# Testing of atomic CREATE TABLE with binary logging. +# CREATE TABLE, CREATE TABLE ...LIKE and CREATE_TABLE ... SELECT are tested ---disable_query_log -call mtr.add_suppression("InnoDB: .* does not exist in the InnoDB internal"); -# Speed up wait_until_connected_again.inc -let NO_WSREP=1; -RESET MASTER; ---enable_query_log -let $MYSQLD_DATADIR= `SELECT @@datadir`; +let $engines='myisam','innodb'; -if ($engine_count == "") -{ - let $engine_count=2; - let $engines='myisam','innodb'; -} +let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_finalize_create', 'ddl_log_create_before_binlog', 'ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_complete'; -let $crash_count=9; -let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_create_after_drop', 'ddl_log_create_before_binlog', 'ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_log_complete'; - -let $statement_count=7; -let $statements='CREATE TABLE t1 (a int)', - 'CREATE TABLE t1 (a vector(5) not null, VECTOR INDEX(a))', - 'CREATE OR REPLACE TABLE t2 (a int)', +let $show_table_t1=1; +let $statement_count=5; # TODO: Fix CREATE SEQUENCE crashes in InnoDB. +let $statements='CREATE TABLE t1 (new int)', + 'CREATE TABLE t1 (new vector(5) not null, VECTOR INDEX(new))', 'CREATE TABLE t1 LIKE const_table', - 'CREATE OR REPLACE TABLE t2 LIKE const_table', - 'CREATE TABLE t1 SELECT * from t2', - 'CREATE OR REPLACE TABLE t2 SELECT * from const_table'; - -create table const_table (a int, b int) engine=myisam; -insert into const_table values (1,1),(2,2); -flush tables; - -let $old_debug=`select @@debug_dbug`; - -let $e=0; -let $keep_include_silent=1; -let $grep_script=CREATE|DROP; ---disable_query_log - -while ($e < $engine_count) -{ - inc $e; - let $engine=`select ELT($e, $engines)`; - let $default_engine=$engine; - let $extra_option=; - - if ($engine == "aria") - { - let $extra_option=transactional=1; - } - if ($engine == "aria_notrans") - { - let $default_engine="aria"; - let $extra_option=transactional=0; - } - --echo engine: $engine - - let $r=0; - while ($r < $statement_count) - { - inc $r; - let $statement=`select ELT($r, $statements)`; - --echo query: $statement - - let $c=0; - while ($c < $crash_count) - { - inc $c; - let $crash=`select ELT($c, $crash_points)`; - - --eval set @@default_storage_engine=$default_engine - create or replace table t2 select * from seq_1_to_2; - flush tables; - - if ($e == 1) - { - --source include/set_binlog_format_row.sql - } - if ($e == 2) - { - --source include/set_binlog_format_statement.sql - } - FLUSH BINARY LOGS; - --let $start_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) - - --echo crash point: $crash - --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect - --disable_reconnect - --eval set @@debug_dbug="+d,$crash",@debug_crash_counter=1 - let $errno=0; - --error 0,2013,2026 - --eval $statement; - let $error=$errno; - --enable_reconnect - --source include/wait_until_connected_again.inc - --disable_query_log - --eval set @@debug_dbug="$old_debug" - - if ($error == 0) - { - echo "No crash!"; - } - # Check which tables still exists - --list_files $MYSQLD_DATADIR/test t* - --list_files $MYSQLD_DATADIR/test *sql* - - --let $binlog_file=$start_binlog_file - --let $binlog_output_name=master-bin.000001 - --source include/show_binlog_events.inc - if ($error) - { - --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) - --let $binlog_output_name=master-bin.000002 - if ($binlog_file != $start_binlog_file) - { - --source include/show_binlog_events.inc - } - } - # Drop the tables. The warnings will show what was dropped - --disable_warnings - drop table if exists t1,t2; - --enable_warnings - } - } -} -drop table if exists t1,t2,const_table; + 'CREATE TABLE t1 SELECT old as new from t2', + 'CREATE TABLE t1 (fail int primary key) select 1 as fail from const_table', + 'CREATE SEQUENCE t1'; ---enable_query_log +--source create_table.inc diff --git a/mysql-test/suite/atomic/create_table_binlog.opt b/mysql-test/suite/atomic/create_table_binlog.opt new file mode 100644 index 0000000000000..e0ff8057a0fb8 --- /dev/null +++ b/mysql-test/suite/atomic/create_table_binlog.opt @@ -0,0 +1 @@ +--myisam-recover-options=DEFAULT,FORCE diff --git a/mysql-test/suite/atomic/create_table_binlog.result b/mysql-test/suite/atomic/create_table_binlog.result new file mode 100644 index 0000000000000..93797fcb64961 --- /dev/null +++ b/mysql-test/suite/atomic/create_table_binlog.result @@ -0,0 +1,60 @@ +call mtr.add_suppression("marked as crashed"); +call mtr.add_suppression("client is using"); +call mtr.add_suppression("Size of datafile is"); +call mtr.add_suppression("Record-count is not ok"); +call mtr.add_suppression("Found.*key parts"); +call mtr.add_suppression("Number of rows changed"); +call mtr.add_suppression("Got an error from unknown thread"); +call mtr.add_suppression("Checking table"); +call mtr.add_suppression("Recovering table"); +create table t10 (p int primary key, new int) engine=innodb; +insert into t10 values (1,1),(2,2),(3,1); +create table t11 (new int) engine=myisam; +create function func_with_sideeffect(arg int) +returns integer +begin +insert into t11 set new=arg; +return arg+1; +end | +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; +engine: myisam +query: CREATE TABLE t1 (new int) select new,func_with_sideeffect(p) from t10 +crash point: ddl_log_create_before_binlog +t10.frm +t10.ibd +t11.MYD +t11.MYI +t11.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_complete +t1.MYD +t1.MYI +t1.frm +t10.frm +t10.ibd +t11.MYD +t11.MYI +t11.frm +t2.MYD +t2.MYI +t2.frm +master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL, + `func_with_sideeffect(p)` int(11) DEFAULT NULL +) +select count(*) > 0 from t11; +count(*) > 0 +1 +Warnings: +Error 145 Table './test/t11' is marked as crashed and should be repaired +Warning 1034 1 client is using or hasn't closed the table properly +Warning 1034 Size of datafile is: 42 Should be: 21 +Error 1034 Record-count is not ok; is 6 Should be: 3 +Warning 1034 Found 6 key parts. Should be: 3 +Warning 1034 Number of rows changed from 3 to 6 +drop table t10,t11; +drop function func_with_sideeffect; diff --git a/mysql-test/suite/atomic/create_table_binlog.test b/mysql-test/suite/atomic/create_table_binlog.test new file mode 100644 index 0000000000000..d71ee570c03da --- /dev/null +++ b/mysql-test/suite/atomic/create_table_binlog.test @@ -0,0 +1,41 @@ +# Testing of atomic CREATE TABLE with binary logging and side effects +# The test found an error in Open_table_context::recover_from_failed_open + +--source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/have_binlog_format_mixed.inc + +call mtr.add_suppression("marked as crashed"); +call mtr.add_suppression("client is using"); +call mtr.add_suppression("Size of datafile is"); +call mtr.add_suppression("Record-count is not ok"); +call mtr.add_suppression("Found.*key parts"); +call mtr.add_suppression("Number of rows changed"); +call mtr.add_suppression("Got an error from unknown thread"); +call mtr.add_suppression("Checking table"); +call mtr.add_suppression("Recovering table"); + +create table t10 (p int primary key, new int) engine=innodb; +insert into t10 values (1,1),(2,2),(3,1); +create table t11 (new int) engine=myisam; + +delimiter |; +create function func_with_sideeffect(arg int) +returns integer +begin + insert into t11 set new=arg; + return arg+1; +end | +delimiter ;| + +let $engines='myisam'; +let $crash_points='ddl_log_create_before_binlog', 'ddl_log_create_complete'; +let $statement_count=1; +let $statements='CREATE TABLE t1 (new int) select new,func_with_sideeffect(p) from t10'; + +--source create_table.inc + +select count(*) > 0 from t11; + +drop table t10,t11; +drop function func_with_sideeffect; diff --git a/mysql-test/suite/atomic/create_table_no_binlog.result b/mysql-test/suite/atomic/create_table_no_binlog.result new file mode 100644 index 0000000000000..6ec6f75b2b5d9 --- /dev/null +++ b/mysql-test/suite/atomic/create_table_no_binlog.result @@ -0,0 +1,174 @@ +create table const_table (new int, new2 int) engine=myisam; +insert into const_table values (1,1),(2,2); +flush tables; +engine: myisam +query: CREATE TABLE t1 (new int) +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +crash point: storage_engine_middle_of_create +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_binlog +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_binlog +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +crash point: ddl_log_create_complete +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +query: CREATE TABLE t1 LIKE const_table +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +crash point: storage_engine_middle_of_create +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_binlog +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_prepare_eof +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_binlog +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_complete +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +query: CREATE TABLE t1 SELECT old as new from t2 +crash point: ddl_log_create_before_create_frm +t2.MYD +t2.MYI +t2.frm +crash point: storage_engine_middle_of_create +"No crash!" +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_create_table +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_create_table +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_finalize_create +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_before_binlog +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_prepare_eof +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_after_binlog +t2.MYD +t2.MYI +t2.frm +crash point: ddl_log_create_complete +t1.MYD +t1.MYI +t1.frm +t2.MYD +t2.MYI +t2.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `new` bigint(20) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +count(*) +2 diff --git a/mysql-test/suite/atomic/create_table_no_binlog.test b/mysql-test/suite/atomic/create_table_no_binlog.test new file mode 100644 index 0000000000000..dc7e070c310a5 --- /dev/null +++ b/mysql-test/suite/atomic/create_table_no_binlog.test @@ -0,0 +1,14 @@ +# Testing of atomic CREATE TABLE without binary logging. +# CREATE TABLE, CREATE TABLE ...LIKE and CREATE_TABLE ... SELECT are tested + +let $engines='myisam'; + +let $crash_points='ddl_log_create_before_create_frm', 'storage_engine_middle_of_create', 'ddl_log_create_before_create_table', 'ddl_log_create_after_create_table', 'ddl_log_finalize_create', 'ddl_log_create_before_binlog', 'ddl_log_create_after_prepare_eof', 'ddl_log_create_after_binlog', 'ddl_log_create_complete'; + +let $show_table_t1=1; +let $statement_count=3; +let $statements='CREATE TABLE t1 (new int)', + 'CREATE TABLE t1 LIKE const_table', + 'CREATE TABLE t1 SELECT old as new from t2'; + +--source create_table.inc diff --git a/mysql-test/suite/atomic/disabled.def b/mysql-test/suite/atomic/disabled.def index 3e1f2d6a2c391..888298bbb09e2 100644 --- a/mysql-test/suite/atomic/disabled.def +++ b/mysql-test/suite/atomic/disabled.def @@ -9,4 +9,3 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -rename_trigger : MDEV-29282 2022:-08-16 Igor Babaev diff --git a/mysql-test/suite/atomic/encrypted_tables.result b/mysql-test/suite/atomic/encrypted_tables.result new file mode 100644 index 0000000000000..d802a8854bddb --- /dev/null +++ b/mysql-test/suite/atomic/encrypted_tables.result @@ -0,0 +1,28 @@ +# +# MDEV-39446 Atomic CREATE OR REPLACE fails if a table cannot be +# decrypted +# +# restart: --plugin-load-add=file_key_management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys.txt --aria-encrypt-tables=on --innodb-encrypt-tables=on +create table t_inno (a int) engine=innodb; +insert into t_inno values (1); +create table t_aria (b int) engine=aria; +insert into t_aria values (2); +# restart +show tables; +Tables_in_test +t_aria +t_inno +create or replace table t_inno (c int) engine=innodb; +create or replace table t_aria (d int) engine=aria; +# restart: --plugin-load-add=file_key_management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys.txt --aria-encrypt-tables=on --innodb-encrypt-tables=on +select * from t_inno; +a +1 +select * from t_aria; +b +2 +show tables; +Tables_in_test +t_aria +t_inno +drop table if exists t_inno, t_aria; diff --git a/mysql-test/suite/atomic/encrypted_tables.test b/mysql-test/suite/atomic/encrypted_tables.test new file mode 100644 index 0000000000000..15fde655a9298 --- /dev/null +++ b/mysql-test/suite/atomic/encrypted_tables.test @@ -0,0 +1,44 @@ +# Test create and replace on encrypted tables without encryption enabled. + +--source include/have_innodb.inc + +--disable_query_log +call mtr.add_suppression("Encrypted page.*looks corrupted"); +call mtr.add_suppression("InnoDB: Failed to read page"); +call mtr.add_suppression("InnoDB: File.*is corrupted"); +call mtr.add_suppression("Table.*is corrupted"); +call mtr.add_suppression("Initialization of encryption failed for.*t_aria"); + +--enable_query_log + +--echo # +--echo # MDEV-39446 Atomic CREATE OR REPLACE fails if a table cannot be +--echo # decrypted +--echo # + +--let $restart_parameters = --plugin-load-add=file_key_management --file-key-management-filename=$SECURE_LOAD_PATH/keys.txt --aria-encrypt-tables=on --innodb-encrypt-tables=on + +--source include/restart_mysqld.inc + +create table t_inno (a int) engine=innodb; +insert into t_inno values (1); +create table t_aria (b int) engine=aria; +insert into t_aria values (2); + +--let $restart_parameters = +--source include/restart_mysqld.inc + +show tables; + +--error 0,ER_TABLE_CORRUPT +create or replace table t_inno (c int) engine=innodb; +--error 0,HA_ERR_NO_ENCRYPTION +create or replace table t_aria (d int) engine=aria; + +--let $restart_parameters = --plugin-load-add=file_key_management --file-key-management-filename=$SECURE_LOAD_PATH/keys.txt --aria-encrypt-tables=on --innodb-encrypt-tables=on +--source include/restart_mysqld.inc + +select * from t_inno; +select * from t_aria; +show tables; +drop table if exists t_inno, t_aria; diff --git a/mysql-test/suite/atomic/rename_trigger2.result b/mysql-test/suite/atomic/rename_trigger2.result new file mode 100644 index 0000000000000..2469441ec1720 --- /dev/null +++ b/mysql-test/suite/atomic/rename_trigger2.result @@ -0,0 +1,35 @@ +create table t1 (a int not null); +create trigger t1_trg before insert on t1 for each row +begin +if isnull(new.a) then +set new.a:= 1000; +end if; +end| +insert into t1 values(1),(2),(3),(NULL); +select * from t1; +a +1 +2 +3 +1000 +set @@debug_dbug="+d,rename_trigger_fail"; +create or replace table t1 select 1 as 'b'; +ERROR HY000: Error on rename of 't1' to 'hidden-name' (errno: 2 "No such file or directory") +set @@debug_dbug="";; +select * from t1; +a +1 +2 +3 +1000 +select count(*) from information_schema.triggers where trigger_name="t1_trg"; +count(*) +1 +create or replace table t1 select 1 as 'c'; +select * from t1; +c +1 +select count(*) from information_schema.triggers where trigger_name="t1_trg"; +count(*) +0 +drop table t1; diff --git a/mysql-test/suite/atomic/rename_trigger2.test b/mysql-test/suite/atomic/rename_trigger2.test new file mode 100644 index 0000000000000..94d41a11c6001 --- /dev/null +++ b/mysql-test/suite/atomic/rename_trigger2.test @@ -0,0 +1,27 @@ +# Test of rename table when renaming of trigger fails + +--source include/have_debug.inc + +create table t1 (a int not null); + +delimiter |; +create trigger t1_trg before insert on t1 for each row +begin + if isnull(new.a) then + set new.a:= 1000; + end if; +end| +delimiter ;| +insert into t1 values(1),(2),(3),(NULL); +select * from t1; + +--eval set @@debug_dbug="+d,rename_trigger_fail" +--error ER_ERROR_ON_RENAME +create or replace table t1 select 1 as 'b'; +--eval set @@debug_dbug=""; +select * from t1; +select count(*) from information_schema.triggers where trigger_name="t1_trg"; +create or replace table t1 select 1 as 'c'; +select * from t1; +select count(*) from information_schema.triggers where trigger_name="t1_trg"; +drop table t1; diff --git a/mysql-test/suite/binlog/include/binlog.test b/mysql-test/suite/binlog/include/binlog.test index a4fc8e6fb2d7f..c6c8ec650e77a 100644 --- a/mysql-test/suite/binlog/include/binlog.test +++ b/mysql-test/suite/binlog/include/binlog.test @@ -420,7 +420,16 @@ create table t (old_table_field int); create or replace table t as select 1 as b, 2 as b; --error ER_DUP_FIELDNAME create or replace temporary table t as select 1 as b, 2 as b; + +create or replace temporary table t as select 1 as temp; +--error ER_DUP_FIELDNAME +create or replace temporary table t as select 1 as b, 2 as b; +--error ER_BAD_TABLE_ERROR +drop temporary table t; + +--error ER_TABLE_EXISTS_ERROR create table t (new_table_field int); +create or replace table t (new_table_field int); --source include/show_binlog_events.inc diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index 034ffa4ddbcbb..822008bc16727 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -1088,14 +1088,18 @@ create or replace table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' create or replace temporary table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' +create or replace temporary table t as select 1 as temp; +create or replace temporary table t as select 1 as b, 2 as b; +ERROR 42S21: Duplicate column name 'b' +drop temporary table t; +ERROR 42S02: Unknown table 'test.t' create table t (new_table_field int); +ERROR 42S01: Table 't' already exists +create or replace table t (new_table_field int); include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t (old_table_field int) -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t (new_table_field int) +master-bin.000001 # Query # # use `test`; create or replace table t (new_table_field int) drop table t; diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index 57da10db28148..07e7254b31e01 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -359,6 +359,11 @@ COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, COERCIBILITY(s1) d3; DROP TEMPORARY TABLE tmp1; END +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `bug39182`; CREATE TEMPORARY TABLE tmp1 +SELECT * FROM t1 WHERE a LIKE CONCAT("%", NAME_CONST('s1',_utf8mb4'test' COLLATE 'utf8mb4_unicode_ci'), "%") +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `bug39182`.`tmp1` /* generated by server */ DROP PROCEDURE p1; DROP TABLE t1; DROP DATABASE bug39182; @@ -443,7 +448,7 @@ create table t1 (a int); create table if not exists t2 select * from t1; select @@binlog_format; @@binlog_format -MIXED +STATEMENT create temporary table tt1 (a int); create table if not exists t3 like tt1; USE mysql; @@ -493,9 +498,9 @@ master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table if not exists t2 select * from t1 master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t3` ( - `a` int(11) DEFAULT NULL -) ENGINE=MyISAM +master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table if not exists t3 like tt1 master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `mysql`; INSERT db SET host='localhost', user='@#@', db='Just a test' master-bin.000001 # Query # # COMMIT @@ -505,6 +510,7 @@ master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `mysql`; DELETE FROM db WHERE host='localhost' AND user='@#@' master-bin.000001 # Query # # COMMIT +master-bin.000001 # Rotate # # master-bin.000002;pos=POS drop table t1,t2,t3,tt1; reset master; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; @@ -517,22 +523,33 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; insert /* before delayed */ /* after delayed */ into t1 values (207) master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Intvar # # INSERT_ID=208 +master-bin.000001 # Query # # use `test`; insert /*! */ into t1 values (null) master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; insert into t1 values (300) master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; FLUSH TABLES RESET MASTER; insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null); insert /*! delayed */ into t1 values (null),(null),(400),(null); +FLUSH TABLES; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Intvar # # INSERT_ID=301 +master-bin.000001 # Query # # use `test`; insert /* before delayed */ /* after delayed */ into t1 values (null),(null),(null),(null) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Intvar # # INSERT_ID=305 +master-bin.000001 # Query # # use `test`; insert /*! */ into t1 values (null),(null),(400),(null) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; FLUSH TABLES select * from t1; a 207 @@ -680,15 +697,22 @@ create or replace table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' create or replace temporary table t as select 1 as b, 2 as b; ERROR 42S21: Duplicate column name 'b' +create or replace temporary table t as select 1 as temp; +create or replace temporary table t as select 1 as b, 2 as b; +ERROR 42S21: Duplicate column name 'b' +drop temporary table t; +ERROR 42S02: Unknown table 'test.t' create table t (new_table_field int); +ERROR 42S01: Table 't' already exists +create or replace table t (new_table_field int); include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t (old_table_field int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; create or replace temporary table t as select 1 as temp master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create table t (new_table_field int) +master-bin.000001 # Query # # use `test`; create or replace table t (new_table_field int) drop table t; diff --git a/mysql-test/suite/binlog/r/binlog_tmp_table.result b/mysql-test/suite/binlog/r/binlog_tmp_table.result index 7653b4dbd4a9b..9577951819372 100644 --- a/mysql-test/suite/binlog/r/binlog_tmp_table.result +++ b/mysql-test/suite/binlog/r/binlog_tmp_table.result @@ -54,16 +54,16 @@ set @@binlog_format="statement"; create temporary table t1(i int); connection con2; use b51226; +set @@binlog_format="statement"; create temporary table t1(i int); connection con1; -set @@binlog_format="statement"; create temporary table t1(i int); ERROR 42S01: Table 't1' already exists disconnect con1; connection default; connection con2; insert into t1 values(1); -disconnect con2; connection default; +disconnect con2; DROP DATABASE b51226; FLUSH LOGS; diff --git a/mysql-test/suite/binlog/r/binlog_write_error.result b/mysql-test/suite/binlog/r/binlog_write_error.result index 46a233718d982..7dd5f2d908717 100644 --- a/mysql-test/suite/binlog/r/binlog_write_error.result +++ b/mysql-test/suite/binlog/r/binlog_write_error.result @@ -3,111 +3,115 @@ call mtr.add_suppression("Write to binary log failed: Error writing file*"); # Test injecting binlog write error when executing queries # set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE TABLE t1 (a INT); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE TABLE t1 (a INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; INSERT INTO t1 VALUES (1),(2),(3); +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE TABLE t1(a int); set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -INSERT INTO t1 VALUES (4),(5),(6); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE OR REPLACE TABLE t1 (a INT); +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +INSERT INTO t1 (a) VALUES (1); +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE OR REPLACE TABLE t1 (b INT) select seq as b from seq_1_to_2; +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +INSERT INTO t1 (a) VALUES (2),(3); +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; INSERT INTO t1 VALUES (4),(5),(6); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -UPDATE t1 set a=a+1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; UPDATE t1 set a=a+1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; +select * from t1; +a +2 +3 +4 +5 +6 +7 set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DELETE FROM t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DELETE FROM t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP TRIGGER tr1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP TRIGGER tr1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -ALTER TABLE t1 ADD (b INT); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; ALTER TABLE t1 ADD (b INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE VIEW v1 AS SELECT a FROM t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE VIEW v1 AS SELECT a FROM t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP VIEW v1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP VIEW v1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP PROCEDURE p1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP PROCEDURE p1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP TABLE t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP TABLE t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE FUNCTION f1() RETURNS INT return 1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE FUNCTION f1() RETURNS INT return 1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP FUNCTION f1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP FUNCTION f1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE USER user1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE USER user1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -SET PASSWORD FOR user1=PASSWORD('foobar'); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; SET PASSWORD FOR user1=PASSWORD('foobar'); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP USER user1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP USER user1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; diff --git a/mysql-test/suite/binlog/r/binlog_write_error_tmp.result b/mysql-test/suite/binlog/r/binlog_write_error_tmp.result new file mode 100644 index 0000000000000..8957d16dc244a --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_write_error_tmp.result @@ -0,0 +1,33 @@ +# +# MDEV-25292 Atomic CREATE OR REPLACE TABLE +# +create temporary table t2 (b int); +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE TEMPORARY TABLE t1 (a int); +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +INSERT INTO t1 VALUES (1),(2),(3); +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE TEMPORARY TABLE t1 (b int); +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE OR REPLACE TEMPORARY TABLE t1 (c int); +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +SELECT * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE TEMPORARY TABLE t1 like t2; +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +SELECT * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE TEMPORARY TABLE t1 select seq as b from seq_1_to_2; +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +SELECT * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist diff --git a/mysql-test/suite/binlog/r/create_like.result b/mysql-test/suite/binlog/r/create_like.result index 9614bea9c18e9..f4438c924c6e1 100644 --- a/mysql-test/suite/binlog/r/create_like.result +++ b/mysql-test/suite/binlog/r/create_like.result @@ -18,9 +18,6 @@ drop temporary table t1,t2_tmp,t3; set @@binlog_format="mixed"; set @@create_tmp_table_binlog_formats="statement,mixed"; CREATE TEMPORARY TABLE t1 LIKE information_schema.processlist; -select benchmark(1,1); -benchmark(1,1) -0 CREATE TEMPORARY TABLE t2_tmp like t2; CREATE TEMPORARY TABLE t3 like t3_hidden; drop temporary table t1,t2_tmp,t3; diff --git a/mysql-test/suite/binlog/t/binlog_stm_binlog.test b/mysql-test/suite/binlog/t/binlog_stm_binlog.test index 045be97d3ae3a..af729f4bc6c24 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_binlog.test +++ b/mysql-test/suite/binlog/t/binlog_stm_binlog.test @@ -1,5 +1,5 @@ -- source include/not_embedded.inc --- source include/have_binlog_format_mixed.inc +-- source include/have_binlog_format_statement.inc let collation=utf8mb3_unicode_ci; --source include/have_collation.inc diff --git a/mysql-test/suite/binlog/t/binlog_tmp_table.test b/mysql-test/suite/binlog/t/binlog_tmp_table.test index 40c33a68f5a34..38ad8ad11cb17 100644 --- a/mysql-test/suite/binlog/t/binlog_tmp_table.test +++ b/mysql-test/suite/binlog/t/binlog_tmp_table.test @@ -98,8 +98,6 @@ drop table foo; RESET MASTER; --- let $dbname=b51226 - connect (con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); connect (con2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); @@ -107,8 +105,8 @@ connect (con2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); # action: on con1 create the database and the tmp table # -- connection con1 --- eval create database $dbname --- eval use $dbname +create database b51226; +use b51226; set @@binlog_format="statement"; create temporary table t1(i int); @@ -116,7 +114,8 @@ create temporary table t1(i int); # action: on con1 create the tmp table # -- connection con2 --- eval use $dbname +use b51226; +set @@binlog_format="statement"; create temporary table t1(i int); # action: at this point, the last event binlogged contains the @@ -131,8 +130,7 @@ create temporary table t1(i int); # in its header). -- connection con1 -set @@binlog_format="statement"; --- error 1050 +-- error ER_TABLE_EXISTS_ERROR create temporary table t1(i int); -- disconnect con1 @@ -146,13 +144,17 @@ create temporary table t1(i int); # pseudo_thread_id, dropping the tmp table on con2. -- connection con2 insert into t1 values(1); --- disconnect con2 -- connection default +-- let $wait_binlog_event= COMMIT +-- source include/wait_for_binlog_event.inc + +-- disconnect con2 + -- let $wait_binlog_event= DROP -- source include/wait_for_binlog_event.inc --- eval DROP DATABASE $dbname +DROP DATABASE b51226; FLUSH LOGS; # assertion: assert that when replaying the binary log will succeed, diff --git a/mysql-test/suite/binlog/t/binlog_write_error.test b/mysql-test/suite/binlog/t/binlog_write_error.test index bd1cb5301b3d4..12792e5867c74 100644 --- a/mysql-test/suite/binlog/t/binlog_write_error.test +++ b/mysql-test/suite/binlog/t/binlog_write_error.test @@ -20,6 +20,7 @@ source include/have_debug.inc; source include/have_binlog_format_mixed_or_statement.inc; +source include/have_sequence.inc; call mtr.add_suppression("Write to binary log failed: Error writing file*"); @@ -30,14 +31,29 @@ call mtr.add_suppression("Write to binary log failed: Error writing file*"); let $query= CREATE TABLE t1 (a INT); source include/binlog_inject_error.inc; +--error ER_NO_SUCH_TABLE INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t1(a int); + +let $query= CREATE OR REPLACE TABLE t1 (a INT); +source include/binlog_inject_error.inc; + +INSERT INTO t1 (a) VALUES (1); + +let $query= CREATE OR REPLACE TABLE t1 (b INT) select seq as b from seq_1_to_2; +source include/binlog_inject_error.inc; + +INSERT INTO t1 (a) VALUES (2),(3); + let $query= INSERT INTO t1 VALUES (4),(5),(6); source include/binlog_inject_error.inc; let $query= UPDATE t1 set a=a+1; source include/binlog_inject_error.inc; +select * from t1; + let $query= DELETE FROM t1; source include/binlog_inject_error.inc; diff --git a/mysql-test/suite/binlog/t/binlog_write_error_tmp.test b/mysql-test/suite/binlog/t/binlog_write_error_tmp.test new file mode 100644 index 0000000000000..56973ffcb73e5 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_write_error_tmp.test @@ -0,0 +1,37 @@ +# This test case check if the error of writing binlog file is properly +# reported and handled when executing statements with temporary tables. + +--source include/have_binlog_format_statement.inc +--source include/have_sequence.inc + +--echo # +--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE +--echo # + +create temporary table t2 (b int); + +let $query= CREATE TEMPORARY TABLE t1 (a int); +source include/binlog_inject_error.inc; + +--error ER_NO_SUCH_TABLE +INSERT INTO t1 VALUES (1),(2),(3); + +# Check that the create tempory will delete the old table +CREATE TEMPORARY TABLE t1 (b int); +let $query= CREATE OR REPLACE TEMPORARY TABLE t1 (c int); +source include/binlog_inject_error.inc; + +--error ER_NO_SUCH_TABLE +SELECT * from t1; + +let $query= CREATE TEMPORARY TABLE t1 like t2; +source include/binlog_inject_error.inc; + +--error ER_NO_SUCH_TABLE +SELECT * from t1; + +let $query= CREATE TEMPORARY TABLE t1 select seq as b from seq_1_to_2; +source include/binlog_inject_error.inc; + +--error ER_NO_SUCH_TABLE +SELECT * from t1; diff --git a/mysql-test/suite/binlog/t/create_like.test b/mysql-test/suite/binlog/t/create_like.test index 86aa0da33f21e..0a0d59ea1427c 100644 --- a/mysql-test/suite/binlog/t/create_like.test +++ b/mysql-test/suite/binlog/t/create_like.test @@ -24,7 +24,6 @@ drop temporary table t1,t2_tmp,t3; set @@binlog_format="mixed"; set @@create_tmp_table_binlog_formats="statement,mixed"; CREATE TEMPORARY TABLE t1 LIKE information_schema.processlist; -select benchmark(1,1); CREATE TEMPORARY TABLE t2_tmp like t2; CREATE TEMPORARY TABLE t3 like t3_hidden; drop temporary table t1,t2_tmp,t3; diff --git a/mysql-test/suite/binlog_encryption/binlog_write_error.result b/mysql-test/suite/binlog_encryption/binlog_write_error.result index 46a233718d982..7dd5f2d908717 100644 --- a/mysql-test/suite/binlog_encryption/binlog_write_error.result +++ b/mysql-test/suite/binlog_encryption/binlog_write_error.result @@ -3,111 +3,115 @@ call mtr.add_suppression("Write to binary log failed: Error writing file*"); # Test injecting binlog write error when executing queries # set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE TABLE t1 (a INT); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE TABLE t1 (a INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; INSERT INTO t1 VALUES (1),(2),(3); +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE TABLE t1(a int); set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -INSERT INTO t1 VALUES (4),(5),(6); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE OR REPLACE TABLE t1 (a INT); +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +INSERT INTO t1 (a) VALUES (1); +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; +CREATE OR REPLACE TABLE t1 (b INT) select seq as b from seq_1_to_2; +ERROR HY000: Error writing file 'master-bin' ((errno: #) +set @@global.debug_dbug = @saved_dbug; +INSERT INTO t1 (a) VALUES (2),(3); +set @saved_dbug = @@global.debug_dbug; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; INSERT INTO t1 VALUES (4),(5),(6); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -UPDATE t1 set a=a+1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; UPDATE t1 set a=a+1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; +select * from t1; +a +2 +3 +4 +5 +6 +7 set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DELETE FROM t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DELETE FROM t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP TRIGGER tr1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP TRIGGER tr1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -ALTER TABLE t1 ADD (b INT); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; ALTER TABLE t1 ADD (b INT); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE VIEW v1 AS SELECT a FROM t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE VIEW v1 AS SELECT a FROM t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP VIEW v1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP VIEW v1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP PROCEDURE p1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP PROCEDURE p1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP TABLE t1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP TABLE t1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE FUNCTION f1() RETURNS INT return 1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE FUNCTION f1() RETURNS INT return 1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP FUNCTION f1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP FUNCTION f1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -CREATE USER user1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; CREATE USER user1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -SET PASSWORD FOR user1=PASSWORD('foobar'); +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; SET PASSWORD FOR user1=PASSWORD('foobar'); ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug='d,injecting_fault_writing'; -DROP USER user1; +SET GLOBAL debug_dbug='+d,injecting_fault_writing'; DROP USER user1; ERROR HY000: Error writing file 'master-bin' ((errno: #) set @@global.debug_dbug = @saved_dbug; diff --git a/mysql-test/suite/maria/create.result b/mysql-test/suite/maria/create.result index 801812b647ff9..b7288496d1728 100644 --- a/mysql-test/suite/maria/create.result +++ b/mysql-test/suite/maria/create.result @@ -76,31 +76,50 @@ DROP TABLE t1; # End of 10.3 tests # CREATE TABLE t1 (a INT) ENGINE=Aria; -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1),(1); CREATE TABLE t2 (b INT); CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; -SELECT * from t1; -a -1 -SELECT * from t2; -a -1 +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT count(*) from t1; +count(*) +2 +SELECT count(*) from t2; +count(*) +2 BEGIN; CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; -SELECT * from t2; -a -1 +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT count(*) from t2; +count(*) +2 COMMIT; +set @@drop_before_create_or_replace=0; LOCK TABLES t1 read, t2 write; CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT count(*) from t2; +count(*) +2 +UNLOCK TABLES; +set @@drop_before_create_or_replace=1; +LOCK TABLES t1 read, t2 write; +CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' SELECT * from t2; -a -1 +ERROR HY000: Table 't2' was not locked with LOCK TABLES UNLOCK TABLES; +SELECT count(*) from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +set @@drop_before_create_or_replace=default; CREATE TABLE t3 (a INT) engine=Aria; INSERT INTO t3 values(2); CREATE OR REPLACE TABLE t2 AS SELECT t1.a,t3.a as b FROM t1,t3; SELECT * from t2; a b 1 2 +1 2 DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/maria/create.test b/mysql-test/suite/maria/create.test index 3937d800fed21..a7a1301505374 100644 --- a/mysql-test/suite/maria/create.test +++ b/mysql-test/suite/maria/create.test @@ -97,25 +97,47 @@ DROP TABLE t1; # CREATE TABLE t1 (a INT) ENGINE=Aria; -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1),(1); CREATE TABLE t2 (b INT); CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; -SELECT * from t1; -SELECT * from t2; +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +SELECT count(*) from t1; +SELECT count(*) from t2; # Check also BEGIN/COMMIT BEGIN; CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; -SELECT * from t2; +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +SELECT count(*) from t2; COMMIT; # Check also LOCK TABLES +set @@drop_before_create_or_replace=0; + +LOCK TABLES t1 read, t2 write; +CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +SELECT count(*) from t2; +UNLOCK TABLES; + +set @@drop_before_create_or_replace=1; + LOCK TABLES t1 read, t2 write; CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1; +--error ER_DUP_ENTRY +CREATE OR REPLACE TABLE t2 (seq int primary key) as select 1 as seq from t1; +--error ER_TABLE_NOT_LOCKED SELECT * from t2; UNLOCK TABLES; +--error ER_NO_SUCH_TABLE +SELECT count(*) from t2; + +set @@drop_before_create_or_replace=default; # Check with 3 tables CREATE TABLE t3 (a INT) engine=Aria; diff --git a/mysql-test/suite/parts/r/backup_log.result b/mysql-test/suite/parts/r/backup_log.result index 6c007f613f940..736618d95daa5 100644 --- a/mysql-test/suite/parts/r/backup_log.result +++ b/mysql-test/suite/parts/r/backup_log.result @@ -17,6 +17,17 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK drop table t1; +# +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t1,id: 1,,0,,, +ALTER,MyISAM,1,test,t1,id: 1,MyISAM,1,test,t1,id: 2 +RENAME,MyISAM,1,test,t1,id: 2,MyISAM,1,test,t2,id: 2 +RENAME,MyISAM,1,test,t2,id: 2,MyISAM,1,test,t1,id: 2 +TRUNCATE,MyISAM,1,test,t1,id: 2,,0,,, +repair,MyISAM,1,test,t1,id: 2,,0,,, +optimize,MyISAM,1,test,t1,id: 2,,0,,, +DROP,MyISAM,1,test,t1,id: 2,,0,,, create table t1_innodb (a int) engine=innodb PARTITION BY HASH(a) PARTITIONS 2; insert into t1_innodb values (1),(2); alter table t1_innodb add column b int; @@ -32,6 +43,17 @@ test.t1_innodb optimize note Table does not support optimize, doing recreate + a test.t1_innodb optimize status OK drop table t1_innodb; # +# Reading backup ddl log file +# +CREATE,InnoDB,1,test,t1_innodb,id: 1,,0,,, +ALTER,InnoDB,1,test,t1_innodb,id: 1,InnoDB,1,test,t1_innodb,id: 2 +RENAME,InnoDB,1,test,t1_innodb,id: 2,InnoDB,1,test,t2_innodb,id: 2 +RENAME,InnoDB,1,test,t2_innodb,id: 2,InnoDB,1,test,t1_innodb,id: 2 +TRUNCATE,InnoDB,1,test,t1_innodb,id: 2,,0,,, +repair,InnoDB,1,test,t1_innodb,id: 2,,0,,, +optimize,InnoDB,1,test,t1_innodb,id: 2,,0,test,t1_innodb,id: 3 +DROP,InnoDB,1,test,t1_innodb,id: 3,,0,,, +# # Testing with temporary tables (should not be logged) # create temporary table tmp_t10 (a int) engine=myisam; @@ -41,6 +63,9 @@ rename table tmp_t11 to tmp_t10; truncate table tmp_t10; drop table tmp_t10; # +# Reading backup ddl log file +# +# # Testing with mix of normal and temporary tables # create temporary table tmp_t20 (a int); @@ -55,6 +80,13 @@ drop table if exists tmp_t21,t21; Warnings: Note 1051 Unknown table 'test.tmp_t21' # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t20,id: 1,,0,,, +DROP,MyISAM,1,test,t20,id: 1,,0,,, +CREATE,MyISAM,1,test,t21,id: 2,,0,,, +DROP,MyISAM,1,test,t21,id: 2,,0,,, +# # Testing create select # create table t30 (a int) PARTITION BY HASH(a) PARTITIONS 2; @@ -67,7 +99,17 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' create table t32 (a int) PARTITION BY HASH(a) PARTITIONS 2; drop table if exists t30,t31,t32,tmp_t30; Warnings: -Note 1051 Unknown table 'test.t31,test.tmp_t30' +Note 1051 Unknown table 'test.tmp_t30' +# +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t30,id: 1,,0,,, +CREATE,MyISAM,1,test,t31,id: 2,,0,,, +CREATE,MyISAM,0,test,t31,id: 3,,0,,, +CREATE,MyISAM,1,test,t32,id: 4,,0,,, +DROP,MyISAM,1,test,t30,id: 1,,0,,, +DROP,MyISAM,0,test,t31,id: 3,,0,,, +DROP,MyISAM,1,test,t32,id: 4,,0,,, # # Testing create LIKE # @@ -85,6 +127,16 @@ t42 CREATE TABLE `t42` ( PARTITIONS 2 drop table t40, t41, t42; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t40,id: 1,,0,,, +CREATE,InnoDB,1,test,t41,id: 2,,0,,, +CREATE,partition,0,test,t42,id: 3,,0,,, +CREATE,partition,0,test,t42,id: 4,,0,,, +DROP,MyISAM,1,test,t40,id: 1,,0,,, +DROP,InnoDB,1,test,t41,id: 2,,0,,, +DROP,InnoDB,1,test,t42,id: 4,,0,,, +# # Testing rename # create table t50 (a int) PARTITION BY HASH(a) PARTITIONS 2; @@ -93,6 +145,18 @@ rename table t50 to t52, t51 to t53; rename table t52 to tmp, t53 to t52, tmp to t53; drop table t52,t53; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t50,id: 1,,0,,, +CREATE,MyISAM,1,test,t51,id: 2,,0,,, +RENAME,MyISAM,1,test,t50,id: 1,MyISAM,1,test,t52,id: 1 +RENAME,MyISAM,1,test,t51,id: 2,MyISAM,1,test,t53,id: 2 +RENAME,MyISAM,1,test,t52,id: 1,MyISAM,1,test,tmp,id: 1 +RENAME,MyISAM,1,test,t53,id: 2,MyISAM,1,test,t52,id: 2 +RENAME,MyISAM,1,test,tmp,id: 1,MyISAM,1,test,t53,id: 1 +DROP,MyISAM,1,test,t52,id: 2,,0,,, +DROP,MyISAM,1,test,t53,id: 1,,0,,, +# # Testing enable/disable keys # CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria PARTITION BY HASH(a) PARTITIONS 2; @@ -106,6 +170,13 @@ INSERT INTO t61 VALUES(1),(2),(3); ALTER TABLE t61 DISABLE KEYS; DROP TABLE t61; # +# Reading backup ddl log file +# +CREATE,Aria,1,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 1,,0,,, +CHANGE_INDEX,Aria,1,test,t60,id: 1,,0,,, +DROP,Aria,1,test,t60,id: 1,,0,,, +# # Testing load data # create table t70 (a date, b date, c date not null, d date) engine=aria PARTITION BY HASH(YEAR(a)) PARTITIONS 2; @@ -122,11 +193,30 @@ insert into t71 select * from t70; unlock tables; drop table t70,t71; # +# Reading backup ddl log file +# +CREATE,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +TRUNCATE,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +BULK_INSERT,Aria,1,test,t70,id: 1,,0,,, +CREATE,Aria,1,test,t71,id: 2,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 2,,0,,, +BULK_INSERT,Aria,1,test,t71,id: 2,,0,,, +DROP,Aria,1,test,t70,id: 1,,0,,, +DROP,Aria,1,test,t71,id: 2,,0,,, +# # Testing strange table names # create table `t 1` (a int) PARTITION BY HASH(a) PARTITIONS 2; drop table `t 1`; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t@00201,id: 1,,0,,, +DROP,MyISAM,1,test,t@00201,id: 1,,0,,, +# # Testing views and triggers # create table t80 (a int, b int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; @@ -136,12 +226,27 @@ drop trigger trg; drop view v1; drop table t80; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t80,id: 1,,0,,, +CREATE,VIEW,0,test,v1,,,0,,, +CREATE,TRIGGER,0,test,trg,,,0,,, +DROP,TRIGGER,0,test,trg,,,0,,, +DROP,VIEW,0,test,v1,,,0,,, +DROP,MyISAM,1,test,t80,id: 1,,0,,, +# # Testing alter to a new storage engine # create table t85 (a int primary key, b int) engine=myisam PARTITION BY HASH(a) PARTITIONS 2; alter table t85 engine=innodb; drop table t85; # +# Reading backup ddl log file +# +CREATE,MyISAM,1,test,t85,id: 1,,0,,, +ALTER,MyISAM,1,test,t85,id: 1,InnoDB,1,test,t85,id: 2 +DROP,InnoDB,1,test,t85,id: 2,,0,,, +# # Testing backup ddl log for partitioned tables # CREATE TABLE t200(a INT, b INT) ENGINE ARIA TRANSACTIONAL = 1 PAGE_CHECKSUM = 1; @@ -184,94 +289,22 @@ DROP TABLE t220; # # Reading backup ddl log file # -CREATE,MyISAM,1,test,t1,id: 1,,0,,, -ALTER,MyISAM,1,test,t1,id: 1,MyISAM,1,test,t1,id: 2 -RENAME,MyISAM,1,test,t1,id: 2,MyISAM,1,test,t2,id: 2 -RENAME,MyISAM,1,test,t2,id: 2,MyISAM,1,test,t1,id: 2 -TRUNCATE,MyISAM,1,test,t1,id: 2,,0,,, -repair,MyISAM,1,test,t1,id: 2,,0,,, -optimize,MyISAM,1,test,t1,id: 2,,0,,, -DROP,MyISAM,1,test,t1,id: 2,,0,,, -CREATE,InnoDB,1,test,t1_innodb,id: 3,,0,,, -ALTER,InnoDB,1,test,t1_innodb,id: 3,InnoDB,1,test,t1_innodb,id: 4 -RENAME,InnoDB,1,test,t1_innodb,id: 4,InnoDB,1,test,t2_innodb,id: 4 -RENAME,InnoDB,1,test,t2_innodb,id: 4,InnoDB,1,test,t1_innodb,id: 4 -TRUNCATE,InnoDB,1,test,t1_innodb,id: 4,,0,,, -repair,InnoDB,1,test,t1_innodb,id: 4,,0,,, -optimize,InnoDB,1,test,t1_innodb,id: 4,,0,test,t1_innodb,id: 5 -DROP,InnoDB,1,test,t1_innodb,id: 5,,0,,, -CREATE,MyISAM,1,test,t20,id: 6,,0,,, -DROP,MyISAM,1,test,t20,id: 6,,0,,, -CREATE,MyISAM,1,test,t21,id: 7,,0,,, -DROP,MyISAM,1,test,t21,id: 7,,0,,, -CREATE,MyISAM,1,test,t30,id: 8,,0,,, -CREATE,MyISAM,1,test,t31,id: 9,,0,,, -DROP,MyISAM,1,test,t31,id: 9,,0,,, -CREATE,MyISAM,0,test,t31,id: 10,,0,,, -DROP,MyISAM,0,test,t31,id: 10,,0,,, -DROP_AFTER_CREATE,MyISAM,1,test,t31,id: 11,,0,,, -CREATE,MyISAM,1,test,t32,id: 12,,0,,, -DROP,MyISAM,1,test,t30,id: 8,,0,,, -DROP,MyISAM,1,test,t32,id: 12,,0,,, -CREATE,MyISAM,1,test,t40,id: 13,,0,,, -CREATE,InnoDB,1,test,t41,id: 14,,0,,, -CREATE,partition,0,test,t42,id: 15,,0,,, -DROP,MyISAM,1,test,t42,id: 15,,0,,, -CREATE,partition,0,test,t42,id: 16,,0,,, -DROP,MyISAM,1,test,t40,id: 13,,0,,, -DROP,InnoDB,1,test,t41,id: 14,,0,,, -DROP,InnoDB,1,test,t42,id: 16,,0,,, -CREATE,MyISAM,1,test,t50,id: 17,,0,,, -CREATE,MyISAM,1,test,t51,id: 18,,0,,, -RENAME,MyISAM,1,test,t50,id: 17,MyISAM,1,test,t52,id: 17 -RENAME,MyISAM,1,test,t51,id: 18,MyISAM,1,test,t53,id: 18 -RENAME,MyISAM,1,test,t52,id: 17,MyISAM,1,test,tmp,id: 17 -RENAME,MyISAM,1,test,t53,id: 18,MyISAM,1,test,t52,id: 18 -RENAME,MyISAM,1,test,tmp,id: 17,MyISAM,1,test,t53,id: 17 -DROP,MyISAM,1,test,t52,id: 18,,0,,, -DROP,MyISAM,1,test,t53,id: 17,,0,,, -CREATE,Aria,1,test,t60,id: 19,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 19,,0,,, -CHANGE_INDEX,Aria,1,test,t60,id: 19,,0,,, -DROP,Aria,1,test,t60,id: 19,,0,,, -CREATE,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -TRUNCATE,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -BULK_INSERT,Aria,1,test,t70,id: 20,,0,,, -CREATE,Aria,1,test,t71,id: 21,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 21,,0,,, -BULK_INSERT,Aria,1,test,t71,id: 21,,0,,, -DROP,Aria,1,test,t70,id: 20,,0,,, -DROP,Aria,1,test,t71,id: 21,,0,,, -CREATE,MyISAM,1,test,t@00201,id: 22,,0,,, -DROP,MyISAM,1,test,t@00201,id: 22,,0,,, -CREATE,MyISAM,1,test,t80,id: 23,,0,,, -CREATE,VIEW,0,test,v1,,,0,,, -CREATE,TRIGGER,0,test,trg,,,0,,, -DROP,TRIGGER,0,test,trg,,,0,,, -DROP,VIEW,0,test,v1,,,0,,, -DROP,MyISAM,1,test,t80,id: 23,,0,,, -CREATE,MyISAM,1,test,t85,id: 24,,0,,, -ALTER,MyISAM,1,test,t85,id: 24,InnoDB,1,test,t85,id: 25 -DROP,InnoDB,1,test,t85,id: 25,,0,,, -CREATE,Aria,0,test,t200,id: 26,,0,,, -ALTER,Aria,0,test,t200,id: 26,Aria,1,test,t200,id: 27 -CREATE,Aria,0,test,t210,id: 28,,0,,, -EXCHANGE_PARTITION,Aria,1,test,t200,id: 27,Aria,0,test,t210,id: 28 -ALTER,Aria,1,test,t200,id: 27,Aria,1,test,t200,id: 29 -ALTER,Aria,1,test,t200,id: 29,Aria,1,test,t200,id: 30 -ALTER,Aria,1,test,t200,id: 30,Aria,1,test,t200,id: 31 -ALTER,Aria,1,test,t200,id: 31,Aria,1,test,t200,id: 32 -ALTER,Aria,1,test,t200,id: 32,Aria,1,test,t200,id: 33 -ALTER,Aria,1,test,t200,id: 33,Aria,1,test,t200,id: 34 -ALTER,Aria,1,test,t200,id: 34,Aria,1,test,t200,id: 35 -ALTER,Aria,1,test,t200,id: 35,Aria,0,test,t200,id: 36 -DROP,Aria,0,test,t200,id: 36,,0,,, -DROP,Aria,0,test,t210,id: 28,,0,,, -CREATE,Aria,1,test,t220,id: 37,,0,,, -DROP,Aria,1,test,t220,id: 37,,0,,, +CREATE,Aria,0,test,t200,id: 1,,0,,, +ALTER,Aria,0,test,t200,id: 1,Aria,1,test,t200,id: 2 +CREATE,Aria,0,test,t210,id: 3,,0,,, +EXCHANGE_PARTITION,Aria,1,test,t200,id: 2,Aria,0,test,t210,id: 3 +ALTER,Aria,1,test,t200,id: 2,Aria,1,test,t200,id: 4 +ALTER,Aria,1,test,t200,id: 4,Aria,1,test,t200,id: 5 +ALTER,Aria,1,test,t200,id: 5,Aria,1,test,t200,id: 6 +ALTER,Aria,1,test,t200,id: 6,Aria,1,test,t200,id: 7 +ALTER,Aria,1,test,t200,id: 7,Aria,1,test,t200,id: 8 +ALTER,Aria,1,test,t200,id: 8,Aria,1,test,t200,id: 9 +ALTER,Aria,1,test,t200,id: 9,Aria,1,test,t200,id: 10 +ALTER,Aria,1,test,t200,id: 10,Aria,0,test,t200,id: 11 +DROP,Aria,0,test,t200,id: 11,,0,,, +DROP,Aria,0,test,t210,id: 3,,0,,, +CREATE,Aria,1,test,t220,id: 12,,0,,, +DROP,Aria,1,test,t220,id: 12,,0,,, # # Cleanup # diff --git a/mysql-test/suite/period/r/create.result b/mysql-test/suite/period/r/create.result index d2fac1fe8708e..441cea381d9e0 100644 --- a/mysql-test/suite/period/r/create.result +++ b/mysql-test/suite/period/r/create.result @@ -113,7 +113,7 @@ insert t values (2, '2001-01-01', '2001-01-01'); ERROR 23000: CONSTRAINT `mytime_1` failed for `test`.`t` show status like "Feature_application_time_periods"; Variable_name Value -Feature_application_time_periods 6 +Feature_application_time_periods 10 drop table t; # MDEV-29387: Period name with more than 32 symbols crashes the server # diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result index ffc0eeb53d35e..513a5e0daf57a 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_mix.result +++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result @@ -75,8 +75,6 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create table t1 (a int); @@ -85,19 +83,18 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; binlog from server 1 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ connection server_2; show tables; Tables_in_test @@ -110,11 +107,7 @@ include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix2.result b/mysql-test/suite/rpl/r/create_or_replace_mix2.result index 5a34b9807cd94..7af2fc59a1ae2 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_mix2.result +++ b/mysql-test/suite/rpl/r/create_or_replace_mix2.result @@ -81,8 +81,6 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create table t1 (a int); @@ -91,23 +89,22 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; binlog from server 1 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create temporary table t9 (a int) master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t9`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ connection server_2; show tables; Tables_in_test @@ -120,11 +117,7 @@ include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' diff --git a/mysql-test/suite/rpl/r/create_or_replace_row.result b/mysql-test/suite/rpl/r/create_or_replace_row.result index c2acbfcc566a3..a00d127dd6ab8 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_row.result +++ b/mysql-test/suite/rpl/r/create_or_replace_row.result @@ -103,8 +103,6 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create table t1 (a int); @@ -113,20 +111,18 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; binlog from server 1 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ connection server_2; show tables; Tables_in_test @@ -139,12 +135,7 @@ include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result index a1ed0132e0113..da8032cf9f760 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_statement.result +++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result @@ -75,8 +75,6 @@ create table t1 (a int); create or replace table t1; ERROR 42000: A table must have at least 1 column drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' create or replace table t1 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create table t1 (a int); @@ -85,23 +83,22 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY' create temporary table t9 (a int); create or replace temporary table t9 (a int primary key) select a from t2; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +drop table t1; binlog from server 1 include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; create or replace table t1 -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create temporary table t9 (a int) master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t9`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ connection server_2; show tables; Tables_in_test @@ -114,11 +111,7 @@ include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 'test.t1' drop temporary table if exists t9; Warnings: Note 1051 Unknown table 'test.t9' diff --git a/mysql-test/suite/rpl/r/create_table_binlog_mixed.result b/mysql-test/suite/rpl/r/create_table_binlog_mixed.result new file mode 100644 index 0000000000000..a7f3665b00e6b --- /dev/null +++ b/mysql-test/suite/rpl/r/create_table_binlog_mixed.result @@ -0,0 +1,64 @@ +include/master-slave.inc +[connection master] +create table t10 (p int primary key, new int) engine=innodb; +insert into t10 values (1,1),(2,2),(3,1); +create table t11 (new int) engine=myisam; +create function func_with_sideeffect(arg int) +returns integer +begin +insert into t11 set new=arg; +return arg+1; +end | +set @@global.binlog_annotate_row_events=1; +include/rpl_reset.inc +# Tables innodb, innodb, myisam +# Should be logged +CREATE TABLE t1 (new int primary key, dup int) engine=innodb; +insert into t1 select new,func_with_sideeffect(p) as 'dup' from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +drop table t1; +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +# Tables myisam, innodb, myisam +# Should be logged +CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+10) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +alter table t11 engine=innodb; +# Tables myisam, innodb, innodb +# Should not be logged +CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+20) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +alter table t10 engine=myisam; +# Tables innodb, innodb, innodb +# Should not be logged +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p+30) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +# Tables innodb, myisam, innodb +# Should not be logged +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p+40) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +master-bin.000001 # Binlog_checkpoint 1 # master-bin.000001 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (new int primary key, dup int) engine=innodb +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Query 1 # use `test`; insert into t1 select new,func_with_sideeffect(p) as 'dup' from t10 +master-bin.000001 # Query 1 # ROLLBACK +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p) from t10 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+10) from t10 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; alter table t11 engine=innodb +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; alter table t10 engine=myisam +drop table t10,t11; +drop function func_with_sideeffect; +set @@global.binlog_annotate_row_events=default; +connection slave; +End of the tests +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/create_table_binlog_row.result b/mysql-test/suite/rpl/r/create_table_binlog_row.result new file mode 100644 index 0000000000000..be4e070df0783 --- /dev/null +++ b/mysql-test/suite/rpl/r/create_table_binlog_row.result @@ -0,0 +1,72 @@ +include/master-slave.inc +[connection master] +create table t10 (p int primary key, new int) engine=innodb; +insert into t10 values (1,1),(2,2),(3,1); +create table t11 (new int) engine=myisam; +create function func_with_sideeffect(arg int) +returns integer +begin +insert into t11 set new=arg; +return arg+1; +end | +set @@global.binlog_annotate_row_events=1; +include/rpl_reset.inc +# Tables innodb, innodb, myisam +# Should be logged +CREATE TABLE t1 (new int primary key, dup int) engine=innodb; +insert into t1 select new,func_with_sideeffect(p) as 'dup' from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +drop table t1; +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +# Tables myisam, innodb, myisam +# Should be logged +CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+10) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +alter table t11 engine=innodb; +# Tables myisam, innodb, innodb +# Should not be logged +CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+20) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +alter table t10 engine=myisam; +# Tables innodb, innodb, innodb +# Should not be logged +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p+30) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +# Tables innodb, myisam, innodb +# Should not be logged +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p+40) from t10; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +master-bin.000001 # Binlog_checkpoint 1 # master-bin.000001 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (new int primary key, dup int) engine=innodb +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows 1 # insert into t11 set new= NAME_CONST('arg',1) +master-bin.000001 # Table_map 1 # table_id: # (test.t11) +master-bin.000001 # Write_rows_v1 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows 1 # insert into t11 set new= NAME_CONST('arg',1) +master-bin.000001 # Table_map 1 # table_id: # (test.t11) +master-bin.000001 # Write_rows_v1 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows 1 # insert into t11 set new= NAME_CONST('arg',11) +master-bin.000001 # Table_map 1 # table_id: # (test.t11) +master-bin.000001 # Write_rows_v1 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; alter table t11 engine=innodb +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; alter table t10 engine=myisam +drop table t10,t11; +drop function func_with_sideeffect; +set @@global.binlog_annotate_row_events=default; +connection slave; +End of the tests +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result b/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result index a85b286328b72..f7e46c1584aa0 100644 --- a/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result +++ b/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result @@ -11,7 +11,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE t1 (a INT NOT NULL) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TEMPORARY TABLE t1 (x INT) PARTITION BY HASH(x) +master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */ CREATE TABLE t1 (b INT); INSERT INTO t1 VALUES (NULL); connection slave; diff --git a/mysql-test/suite/rpl/r/rpl_create_select_row.result b/mysql-test/suite/rpl/r/rpl_create_select_row.result index fb0e3922b9e10..c0d1fe0635451 100644 --- a/mysql-test/suite/rpl/r/rpl_create_select_row.result +++ b/mysql-test/suite/rpl/r/rpl_create_select_row.result @@ -12,14 +12,22 @@ connect conn_err,localhost,root,,; call mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage"); create table t engine=myisam select repeat ('a',4096*3) AS a; ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +drop table if exists t; +Warnings: +Note 1051 Unknown table 'test.t' create table t engine=innodb select repeat ('a',4096*3) AS a; ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +drop table if exists t; +Warnings: +Note 1051 Unknown table 'test.t' create table t (a int unique, b char) select 1 AS a, 'b' as b union select 1 as a, 'c' as b; ERROR 23000: Duplicate entry '1' for key 'a' select * from t; ERROR 42S02: Table 'test.t' doesn't exist disconnect conn_err; connection master; +connection slave; +connection master; # # MDEV-35499 errored CREATE-OR-REPLACE-SELECT does not DROP table in binlog @@ -31,38 +39,37 @@ set statement binlog_format=statement for create table t (a int) select 1 as a; set statement binlog_format=row for create or replace table t (a int primary key, b char) engine=innodb select 1 AS a, 'b' as b union select 1 as a, 'c' as b; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t; -ERROR 42S02: Table 'test.t' doesn't exist -# -# Prove an expected lonely `DROP table t' +a +1 +drop table t; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK -set statement binlog_format=statement for create table t (a int) select 1 as a; +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +connection slave; +connection master; +set statement binlog_format=statement for create table t (a int) select 2 as a; set statement binlog_format=row for create or replace table t (a text) engine=innodb select repeat ('a',1024) AS a union select repeat ('a',3*4096) AS a union select repeat ('a',3*4096) AS a; ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again select * from t; -ERROR 42S02: Table 'test.t' doesn't exist -# -# Prove an expected lonely `DROP table t' +a +2 +drop table t; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK -set statement binlog_format=statement for create table t (a int) select 1 as a; +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +set statement binlog_format=statement for create table t (a int) select 3 as a; set statement binlog_format=row for create or replace table t (a text) engine=innodb select repeat ('a',4096*3) AS a;; ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again select * from t; -ERROR 42S02: Table 'test.t' doesn't exist -# -# Prove an expected lonely `DROP table t' +a +3 +drop table t; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ # # Engine = myisam # @@ -70,38 +77,39 @@ set statement binlog_format=statement for create table t (a int) select 1 as a; set statement binlog_format=row for create or replace table t (a int primary key, b char) engine=myisam select 1 AS a, 'b' as b union select 1 as a, 'c' as b; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t; -ERROR 42S02: Table 'test.t' doesn't exist -# -# Prove an expected lonely `DROP table t' +a +1 +drop table t; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK -set statement binlog_format=statement for create table t (a int) select 1 as a; +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +connection slave; +connection master; +set statement binlog_format=statement for create table t (a int) select 2 as a; set statement binlog_format=row for create or replace table t (a text) engine=myisam select repeat ('a',1024) AS a union select repeat ('a',3*4096) AS a union select repeat ('a',3*4096) AS a; ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again select * from t; -ERROR 42S02: Table 'test.t' doesn't exist -# -# Prove an expected lonely `DROP table t' +a +2 +drop table t; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK -set statement binlog_format=statement for create table t (a int) select 1 as a; +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +set statement binlog_format=statement for create table t (a int) select 3 as a; set statement binlog_format=row for create or replace table t (a text) engine=myisam select repeat ('a',4096*3) AS a;; ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again select * from t; -ERROR 42S02: Table 'test.t' doesn't exist -# -# Prove an expected lonely `DROP table t' +a +3 +drop table t; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t` /* generated by server */ +connection slave; +connection master; create table ti_pk (a int primary key) engine=innodb; create table ta (a int) engine=aria; create function f_ia(arg int) @@ -141,6 +149,9 @@ select * from t_y; ERROR 42S02: Table 'test.t_y' doesn't exist # ***TODO: fix MDEV-36027***. As of now `ta` is modified but that's not binlogged include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; set statement binlog_format = STATEMENT for create table t_y (a int) engine=aria select f_ia(1 /* err */) as a select *,'on_master' from ta; a on_master 1 on_master @@ -149,6 +160,7 @@ a connection slave; select *,'on_slave' from ta; a on_slave +1 on_slave connection master; drop function f_ia; drop table ti_pk, ta; diff --git a/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result b/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result index 257c16845dda1..f1a1d3ed4317c 100644 --- a/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result +++ b/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result @@ -14,10 +14,6 @@ master-bin.000001 # Query # # DROP DATABASE IF EXISTS mysqltest master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int) -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp -master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp diff --git a/mysql-test/suite/rpl/r/rpl_gtid_strict.result b/mysql-test/suite/rpl/r/rpl_gtid_strict.result index 988d191adb66d..7fb8c9c5a6394 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_strict.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_strict.result @@ -59,7 +59,7 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4) master-bin.000001 # Xid # # COMMIT /* XID */ -*** Test non-transactional GTID error (cannot be rolled back). *** +*** Test non-transactional GTID error *** SET server_id= 3; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled @@ -68,9 +68,6 @@ SET gtid_seq_no= 1; SET SESSION debug_dbug=@old_dbug; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled -SET sql_log_bin= 0; -DROP TABLE t2; -SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled diff --git a/mysql-test/suite/rpl/t/create_or_replace.inc b/mysql-test/suite/rpl/t/create_or_replace.inc index 1b7f97b362967..298adf5d76b81 100644 --- a/mysql-test/suite/rpl/t/create_or_replace.inc +++ b/mysql-test/suite/rpl/t/create_or_replace.inc @@ -77,6 +77,8 @@ create temporary table t9 (a int); --error ER_DUP_ENTRY create or replace temporary table t9 (a int primary key) select a from t2; +drop table t1; + --echo binlog from server 1 --source include/show_binlog_events.inc save_master_pos; diff --git a/mysql-test/suite/rpl/t/create_table_binlog.inc b/mysql-test/suite/rpl/t/create_table_binlog.inc new file mode 100644 index 0000000000000..83528f9f3909f --- /dev/null +++ b/mysql-test/suite/rpl/t/create_table_binlog.inc @@ -0,0 +1,69 @@ +# Testing of atomic CREATE TABLE with binary logging and side effects + +--source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/master-slave.inc + +create table t10 (p int primary key, new int) engine=innodb; +insert into t10 values (1,1),(2,2),(3,1); +create table t11 (new int) engine=myisam; + +delimiter |; +create function func_with_sideeffect(arg int) +returns integer +begin + insert into t11 set new=arg; + return arg+1; +end | +delimiter ;| + +set @@global.binlog_annotate_row_events=1; +--source include/rpl_reset.inc + +--echo # Tables innodb, innodb, myisam +--echo # Should be logged + +# Test for the that insert_select works properly +CREATE TABLE t1 (new int primary key, dup int) engine=innodb; +--error ER_DUP_ENTRY +insert into t1 select new,func_with_sideeffect(p) as 'dup' from t10; +drop table t1; + +--error ER_DUP_ENTRY +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p) from t10; + +--echo # Tables myisam, innodb, myisam +--echo # Should be logged +--error ER_DUP_ENTRY +CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+10) from t10; + +alter table t11 engine=innodb; + +--echo # Tables myisam, innodb, innodb +--echo # Should not be logged +--error ER_DUP_ENTRY +CREATE TABLE t1 (new int primary key) engine=myisam select new,func_with_sideeffect(p+20) from t10; + +alter table t10 engine=myisam; + +--echo # Tables innodb, innodb, innodb +--echo # Should not be logged +--error ER_DUP_ENTRY +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p+30) from t10; + +--echo # Tables innodb, myisam, innodb +--echo # Should not be logged +--error ER_DUP_ENTRY +CREATE TABLE t1 (new int primary key) engine=innodb select new,func_with_sideeffect(p+40) from t10; + +--source include/show_binlog_events2.inc + +drop table t10,t11; +drop function func_with_sideeffect; +set @@global.binlog_annotate_row_events=default; + +# test that binlog replicates correctly to slave +--sync_slave_with_master + +--echo End of the tests +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/create_table_binlog_mixed.test b/mysql-test/suite/rpl/t/create_table_binlog_mixed.test new file mode 100644 index 0000000000000..79f365451e9d2 --- /dev/null +++ b/mysql-test/suite/rpl/t/create_table_binlog_mixed.test @@ -0,0 +1,2 @@ +--source include/have_binlog_format_mixed.inc +--source create_table_binlog.inc diff --git a/mysql-test/suite/rpl/t/create_table_binlog_row.test b/mysql-test/suite/rpl/t/create_table_binlog_row.test new file mode 100644 index 0000000000000..65885f3521f44 --- /dev/null +++ b/mysql-test/suite/rpl/t/create_table_binlog_row.test @@ -0,0 +1,2 @@ +--source include/have_binlog_format_row.inc +--source create_table_binlog.inc diff --git a/mysql-test/suite/rpl/t/rpl_create_select_row.test b/mysql-test/suite/rpl/t/rpl_create_select_row.test index 90d2b85d4e89f..e095953ff6e7b 100644 --- a/mysql-test/suite/rpl/t/rpl_create_select_row.test +++ b/mysql-test/suite/rpl/t/rpl_create_select_row.test @@ -21,9 +21,11 @@ connect (conn_err,localhost,root,,); call mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage"); --error ER_TRANS_CACHE_FULL create table t engine=myisam select repeat ('a',4096*3) AS a; +drop table if exists t; --error ER_TRANS_CACHE_FULL create table t engine=innodb select repeat ('a',4096*3) AS a; +drop table if exists t; --error ER_DUP_ENTRY create table t (a int unique, b char) select 1 AS a, 'b' as b union select 1 as a, 'c' as b; @@ -43,6 +45,9 @@ if (!$cmp) --die } +--sync_slave_with_master +--connection master + --echo --echo # --echo # MDEV-35499 errored CREATE-OR-REPLACE-SELECT does not DROP table in binlog @@ -59,38 +64,36 @@ while ($i) --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) --error ER_DUP_ENTRY --eval set statement binlog_format=row for create or replace table t (a int primary key, b char) engine=$engine select 1 AS a, 'b' as b union select 1 as a, 'c' as b - --error ER_NO_SUCH_TABLE select * from t; - --echo # - --echo # Prove an expected lonely `DROP table t' + drop table t; --source include/show_binlog_events.inc + --sync_slave_with_master + --connection master # error before stmt commit - set statement binlog_format=statement for create table t (a int) select 1 as a; + set statement binlog_format=statement for create table t (a int) select 2 as a; --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) --error ER_TRANS_CACHE_FULL --eval set statement binlog_format=row for create or replace table t (a text) engine=$engine select repeat ('a',1024) AS a union select repeat ('a',3*4096) AS a union select repeat ('a',3*4096) AS a - --error ER_NO_SUCH_TABLE select * from t; - --echo # - --echo # Prove an expected lonely `DROP table t' + drop table t; --source include/show_binlog_events.inc # error at stmt commit - set statement binlog_format=statement for create table t (a int) select 1 as a; + set statement binlog_format=statement for create table t (a int) select 3 as a; --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) --error ER_TRANS_CACHE_FULL --eval set statement binlog_format=row for create or replace table t (a text) engine=$engine select repeat ('a',4096*3) AS a; - --error ER_NO_SUCH_TABLE select * from t; - --echo # - --echo # Prove an expected lonely `DROP table t' + drop table t; --source include/show_binlog_events.inc --dec $i } +--sync_slave_with_master +--connection master # Tests of mixed engines to demonstrate non-transaction table updates # are binlogged or otherwise MDEV-36027. diff --git a/mysql-test/suite/rpl/t/rpl_gtid_strict.test b/mysql-test/suite/rpl/t/rpl_gtid_strict.test index 56ebba824c481..37a707a3f1456 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_strict.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_strict.test @@ -49,7 +49,7 @@ INSERT INTO t1 VALUES (4); SELECT * FROM t1 ORDER BY 1; --source include/show_binlog_events.inc ---echo *** Test non-transactional GTID error (cannot be rolled back). *** +--echo *** Test non-transactional GTID error *** SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; @@ -58,11 +58,6 @@ SET gtid_seq_no= 1; SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; -# The table is still created, DDL cannot be rolled back. -# Fix it up for replication. -SET sql_log_bin= 0; -DROP TABLE t2; -SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; --error ER_GTID_STRICT_OUT_OF_ORDER diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result index b90b8e2787a1d..43b73d30722aa 100644 --- a/mysql-test/suite/sql_sequence/create.result +++ b/mysql-test/suite/sql_sequence/create.result @@ -58,6 +58,11 @@ t1 CREATE TABLE `t1` ( select * from t1; next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count 1 1 9223372036854775806 1 1 1000 0 0 +create or replace sequence t1 engine=archive; +ERROR HY000: Table storage engine 'ARCHIVE' does not support the create option 'SEQUENCE' +select * from t1; +next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count +1 1 9223372036854775806 1 1 1000 0 0 create or replace sequence t1 start with 10; show create sequence t1; Table Create Table diff --git a/mysql-test/suite/sql_sequence/create.test b/mysql-test/suite/sql_sequence/create.test index 526b0c5be84fd..e75a9a79a070c 100644 --- a/mysql-test/suite/sql_sequence/create.test +++ b/mysql-test/suite/sql_sequence/create.test @@ -2,6 +2,7 @@ # Test create options with sequences # --source include/have_innodb.inc +--source include/have_archive.inc drop table if exists t1; @@ -21,6 +22,9 @@ create or replace sequence t1 engine=maria; show create sequence t1; show create table t1; select * from t1; +--error ER_ILLEGAL_HA_CREATE_OPTION +create or replace sequence t1 engine=archive; +select * from t1; # Check start values create or replace sequence t1 start with 10; diff --git a/mysql-test/suite/sql_sequence/create_archive.result b/mysql-test/suite/sql_sequence/create_archive.result index 242ffd760454b..8c95c6adca791 100644 --- a/mysql-test/suite/sql_sequence/create_archive.result +++ b/mysql-test/suite/sql_sequence/create_archive.result @@ -20,4 +20,14 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si create or replace sequence t1 engine=archive; ERROR HY000: Table storage engine 'ARCHIVE' does not support the create option 'SEQUENCE' show create table t1; -ERROR 42S02: Table 'test.t1' doesn't exist +Table Create Table +t1 CREATE TABLE `t1` ( + `next_not_cached_value` bigint(21) NOT NULL, + `minimum_value` bigint(21) NOT NULL, + `maximum_value` bigint(21) NOT NULL, + `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', + `increment` bigint(21) NOT NULL COMMENT 'increment value', + `cache_size` bigint(21) unsigned NOT NULL, + `cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed', + `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' +) ENGINE=Aria SEQUENCE=1 diff --git a/mysql-test/suite/sql_sequence/create_archive.test b/mysql-test/suite/sql_sequence/create_archive.test index ddf7171b71a66..7fea19eb7fce5 100644 --- a/mysql-test/suite/sql_sequence/create_archive.test +++ b/mysql-test/suite/sql_sequence/create_archive.test @@ -5,8 +5,4 @@ show create table t1; select * from t1; --error ER_ILLEGAL_HA_CREATE_OPTION create or replace sequence t1 engine=archive; -# -# The following error should be fixed. We shouldn't delete old table on errors -# ---error ER_NO_SUCH_TABLE show create table t1; diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 900217485ef99..cd0b17639d668 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -942,6 +942,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME DROP_BEFORE_CREATE_OR_REPLACE +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT CREATE OR REPLACE should drop old tables before creating new ones. If not set then old table will be temporarly renamed until create table succeeeds. If create does not succeed the old table will be renamed back +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ENCRYPT_BINLOG VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 87972c6c8776d..dd2cf44524ccd 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -1022,6 +1022,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME DROP_BEFORE_CREATE_OR_REPLACE +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT CREATE OR REPLACE should drop old tables before creating new ones. If not set then old table will be temporarly renamed until create table succeeeds. If create does not succeed the old table will be renamed back +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ENCRYPT_BINLOG VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN diff --git a/mysql-test/suite/vcol/r/innodb_virtual_fk.result b/mysql-test/suite/vcol/r/innodb_virtual_fk.result index 43767c897d167..683adcbe379d8 100644 --- a/mysql-test/suite/vcol/r/innodb_virtual_fk.result +++ b/mysql-test/suite/vcol/r/innodb_virtual_fk.result @@ -75,8 +75,6 @@ ERROR HY000: Function or expression 'id2' cannot be used in the CHECK clause of create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update set null); ERROR HY000: Function or expression 'id2' cannot be used in the CHECK clause of `CONSTRAINT_1` drop table if exists t2, t1; -Warnings: -Note 1051 Unknown table 'test.t2' # # MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK # diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 6ce769d43351f..7a383a5dee39a 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -51,7 +51,6 @@ with system versioning partition by hash(i); --error ER_VERS_ALTER_ENGINE_PROHIBITED eval alter table t1 engine=$non_default_engine; - --echo ## CREATE TABLE --error ER_VERS_NOT_VERSIONED diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index dfcfe4e27c2d1..59f0453d2eee5 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -28,6 +28,7 @@ #include "strfunc.h" // strconvert #include "sql_show.h" // append_identifier() #include "sql_db.h" // drop_database_objects() +#include "table_cache.h" // tdc_share_is_cached() #include // EE_LINK @@ -135,6 +136,13 @@ class st_ddl_recovery { char current_db[NAME_LEN]; uint execute_entry_pos; ulonglong xid; + void free() + { + drop_table.free(); + drop_view.free(); + query.free(); + db.free(); + } }; static st_global_ddl_log global_ddl_log; @@ -426,7 +434,7 @@ static bool disable_execute_entry(uint entry_pos) { uchar buff[1]; DBUG_ENTER("disable_execute_entry"); - DBUG_PRINT("ddl_log", ("pos: {%u}", entry_pos)); + DBUG_PRINT("ddl_log", ("pos: %u", entry_pos)); buff[0]= DDL_LOG_IGNORE_ENTRY_CODE; DBUG_RETURN(mysql_file_pwrite(global_ddl_log.file_id, buff, sizeof(buff), @@ -450,20 +458,20 @@ bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry) /* Check if an executive entry is active - @return 0 Entry is active - @return 1 Entry is not active + @return 1 Entry is active + @return 0 Entry is not active */ static bool is_execute_entry_active(uint entry_pos) { uchar buff[1]; - DBUG_ENTER("disable_execute_entry"); + DBUG_ENTER("is_execute_entry_active"); if (mysql_file_pread(global_ddl_log.file_id, buff, sizeof(buff), global_ddl_log.io_size * entry_pos + DDL_LOG_ENTRY_TYPE_POS, MYF(MY_WME | MY_NABP))) - DBUG_RETURN(1); + DBUG_RETURN(0); DBUG_RETURN(buff[0] == (uchar) DDL_LOG_EXECUTE_CODE); } @@ -884,6 +892,7 @@ static bool ddl_log_increment_phase_no_lock(uint entry_pos) } else { + /* Failed read/write already raised. Write an entry to error log */ sql_print_error("DDL_LOG: Failed in reading entry before updating it"); DBUG_RETURN(TRUE); } @@ -966,11 +975,12 @@ static bool build_filename_and_delete_tmp_file(char *path, size_t path_length, const LEX_CSTRING *db, const LEX_CSTRING *name, const char *ext, - PSI_file_key psi_key) + PSI_file_key psi_key, + uint flags) { bool deleted= 1; uint length= build_table_filename(path, path_length-1, - db->str, name->str, ext, 0); + db->str, name->str, ext, flags); if (length) { path[length]= '~'; @@ -1073,10 +1083,13 @@ static handler *create_handler(THD *thd, MEM_ROOT *mem_root, if (!ha_storage_engine_is_enabled(hton)) { my_error(ER_STORAGE_ENGINE_DISABLED, MYF(ME_ERROR_LOG), name->str); + plugin_unlock(thd, plugin); return 0; } if ((file= hton->create(hton, (TABLE_SHARE*) 0, mem_root))) file->init(); + else + plugin_unlock(thd, plugin); return file; } @@ -1088,18 +1101,22 @@ static handler *create_handler(THD *thd, MEM_ROOT *mem_root, like connect, needs the .frm file to exists to be able to do an rename. */ -static void execute_rename_table(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, - handler *file, - const LEX_CSTRING *from_db, - const LEX_CSTRING *from_table, - const LEX_CSTRING *to_db, - const LEX_CSTRING *to_table, - uint flags, - char *from_path, char *to_path) +static int execute_rename_table(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, + handler *file, + const LEX_CSTRING *from_db, + const LEX_CSTRING *from_table, + const LEX_CSTRING *to_db, + const LEX_CSTRING *to_table, + uint flags, + char *from_path, char *to_path) { uint to_length=0, fr_length=0; + uint keys, total_keys; + int error= 0, err2; + MDL_request mdl_request_from, mdl_request_to; DBUG_ENTER("execute_rename_table"); + thd->lex->part_info= 0; if (file->needs_lower_case_filenames()) { build_lower_case_table_filename(from_path, FN_REFLEN, @@ -1118,7 +1135,15 @@ static void execute_rename_table(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, flags & FN_TO_IS_TMP); } - uint keys, total_keys; + /* Take mdl locks on both tables. These should always succeed */ + MDL_REQUEST_INIT(&mdl_request_from, MDL_key::TABLE, + from_db->str, from_table->str, + MDL_EXCLUSIVE, MDL_EXPLICIT); + MDL_REQUEST_INIT(&mdl_request_to, MDL_key::TABLE, + to_db->str, to_table->str, + MDL_EXCLUSIVE, MDL_EXPLICIT); + thd->mdl_context.acquire_lock(&mdl_request_from, 0); + thd->mdl_context.acquire_lock(&mdl_request_to, 0); if (!get_hlindex_keys_by_open(thd, from_db, from_table, from_path, &keys, &total_keys)) @@ -1131,11 +1156,13 @@ static void execute_rename_table(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, { my_snprintf(idx_from_end, HLINDEX_BUF_LEN, HLINDEX_TEMPLATE, i); my_snprintf(idx_to_end, HLINDEX_BUF_LEN, HLINDEX_TEMPLATE, i); - file->ha_rename_table(idx_from, idx_to); + if ((err2= file->ha_rename_table(idx_from, idx_to)) && ! error) + error= err2; } } - file->ha_rename_table(from_path, to_path); + if ((err2= file->ha_rename_table(from_path, to_path)) && ! error) + error= err2; if (file->needs_lower_case_filenames()) { /* @@ -1155,8 +1182,15 @@ static void execute_rename_table(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, strmov(to_path+to_length, reg_ext); } if (!access(from_path, F_OK)) - (void) mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); - DBUG_VOID_RETURN; + if ((err2= mysql_file_rename(key_file_frm, from_path, to_path, + MYF(MY_WME))) && !error) + error= err2; + + if (mdl_request_from.ticket) + thd->mdl_context.release_lock(mdl_request_from.ticket); + if (mdl_request_to.ticket) + thd->mdl_context.release_lock(mdl_request_to.ticket); + DBUG_RETURN(error); } @@ -1165,8 +1199,19 @@ static int execute_drop_table(THD *thd, handlerton *hton, const LEX_CSTRING *db, { uint keys, total_keys; int error, first_error= 0; + MDL_request mdl_request; DBUG_ENTER("execute_drop_table"); + /* + Under an unexpected error conditions, like server shutdown, there may + still be an open table definition for the table when we come here. + To make things safe, remove the table definition if it exists. + */ + MDL_REQUEST_INIT(&mdl_request, MDL_key::TABLE, db->str, table->str, + MDL_EXCLUSIVE, MDL_EXPLICIT); + if (!(thd->mdl_context.acquire_lock(&mdl_request, 0))) + tdc_remove_table(thd, db->str, table->str); + if (get_hlindex_keys_by_open(thd, db, table, path, &keys, &total_keys) == 0) { char idx_path[FN_REFLEN + 1]; @@ -1186,6 +1231,9 @@ static int execute_drop_table(THD *thd, handlerton *hton, const LEX_CSTRING *db, if (!non_existing_table_error(error)) first_error= error; } + if (mdl_request.ticket) + thd->mdl_context.release_lock(mdl_request.ticket); + DBUG_ASSERT(!tdc_share_is_cached(thd, db->str, table->str)); DBUG_RETURN(first_error); } @@ -1200,11 +1248,13 @@ static int execute_drop_table(THD *thd, handlerton *hton, const LEX_CSTRING *db, */ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, - bool swap_tables) + bool swap_tables, uint flags) { Lex_ident_table to_table, from_table, from_converted_name; Lex_ident_db to_db, from_db; char to_path[FN_REFLEN+1], from_path[FN_REFLEN+1], conv_path[FN_REFLEN+1]; + DBUG_ENTER("rename_triggers"); + DBUG_PRINT("enter", ("swap: %d flags: %u", (int) swap_tables, flags)); if (!swap_tables) { @@ -1223,10 +1273,24 @@ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, build_filename_and_delete_tmp_file(from_path, sizeof(from_path), &from_db, &from_table, - TRG_EXT, key_file_trg); + TRG_EXT, key_file_trg, + flags & FN_FROM_IS_TMP); build_filename_and_delete_tmp_file(to_path, sizeof(to_path), &to_db, &to_table, - TRG_EXT, key_file_trg); + TRG_EXT, key_file_trg, + flags & FN_TO_IS_TMP); + if (flags & FN_IS_TMP) + { + /* + Trigger file was renamed. No conversion of the content of the + file is needed. + Rename it back to its original name. + */ + if (!access(from_path, F_OK)) + my_rename(from_path, to_path, MYF(MY_WME)); + DBUG_VOID_RETURN; + } + if (lower_case_table_names) { uint errors; @@ -1280,6 +1344,7 @@ static void rename_triggers(THD *thd, DDL_LOG_ENTRY *ddl_log_entry, &to_table); thd->mdl_context.release_lock(mdl_ticket); } + DBUG_VOID_RETURN; } @@ -1350,15 +1415,15 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, handlerton *hton= 0; ddl_log_error_handler no_such_table_handler; uint entry_pos= ddl_log_entry->entry_pos; - int error; + int error= 0; + uint fn_flags= 0, invers_fn_flags= 0; bool frm_action= FALSE; DBUG_ENTER("ddl_log_execute_action"); mysql_mutex_assert_owner(&LOCK_gdl); DBUG_PRINT("ddl_log", - ("pos: %u=>%u->%u type: %u action: %u (%s) phase: %u " + ("pos: %u->%u type: %u action: %u (%s) phase: %u " "handler: '%s' name: '%s' from_name: '%s' tmp_name: '%s'", - recovery_state.execute_entry_pos, ddl_log_entry->entry_pos, ddl_log_entry->next_entry, (uint) ddl_log_entry->entry_type, @@ -1386,6 +1451,17 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, hton= file->ht; } + if (ddl_log_entry->flags & DDL_LOG_FLAG_FROM_IS_TMP) + { + fn_flags|= FN_FROM_IS_TMP; + invers_fn_flags|= FN_TO_IS_TMP; + } + if (ddl_log_entry->flags & DDL_LOG_FLAG_TO_IS_TMP) + { + fn_flags|= FN_TO_IS_TMP; + invers_fn_flags|= FN_FROM_IS_TMP; + } + switch (ddl_log_entry->action_type) { case DDL_LOG_REPLACE_ACTION: case DDL_LOG_DELETE_ACTION: @@ -1413,9 +1489,9 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, break; } } + error= 0; if (increment_phase(entry_pos)) break; - error= 0; if (ddl_log_entry->action_type == DDL_LOG_DELETE_ACTION) break; } @@ -1429,24 +1505,25 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, /* fall through */ case DDL_LOG_RENAME_ACTION: { - error= TRUE; if (frm_action) { strxmov(to_path, ddl_log_entry->name.str, reg_ext, NullS); strxmov(from_path, ddl_log_entry->from_name.str, reg_ext, NullS); - (void) mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); + error= mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)); #ifdef WITH_PARTITION_STORAGE_ENGINE strxmov(to_path, ddl_log_entry->name.str, PAR_EXT, NullS); strxmov(from_path, ddl_log_entry->from_name.str, PAR_EXT, NullS); - (void) mysql_file_rename(key_file_partition_ddl_log, from_path, to_path, - MYF(MY_WME)); + int err2= mysql_file_rename(key_file_partition_ddl_log, from_path, + to_path, MYF(MY_WME)); + if (!error) + error= err2; #endif } else - (void) file->ha_rename_table(ddl_log_entry->from_name.str, + error= file->ha_rename_table(ddl_log_entry->from_name.str, ddl_log_entry->name.str); - if (increment_phase(entry_pos)) - break; + error= 0; + increment_phase(entry_pos); break; } case DDL_LOG_EXCHANGE_ACTION: @@ -1500,25 +1577,40 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, */ switch (ddl_log_entry->phase) { case DDL_RENAME_PHASE_TRIGGER: - rename_triggers(thd, ddl_log_entry, 0); + rename_triggers(thd, ddl_log_entry, 0, invers_fn_flags); if (increment_phase(entry_pos)) break; /* fall through */ case DDL_RENAME_PHASE_STAT: - /* - Stat tables must be updated last so that we can handle a rename of - a stat table. For now we just remember that we have to update it - */ - update_flags(ddl_log_entry->entry_pos, DDL_LOG_FLAG_UPDATE_STAT); - ddl_log_entry->flags|= DDL_LOG_FLAG_UPDATE_STAT; + if (fn_flags & FN_TO_IS_TMP) + { + /* + Only executed in case of CREATE OR REPLACE table when renaming + the original table to a temporary name. + + If new code is added here please finish this block like this: + + if (increment_phase(entry_pos)) + break; + */ + } + else + { + /* + Stat tables must be updated last so that we can handle a rename of + a stat table. For now we just remember that we have to update it. + */ + update_flags(ddl_log_entry->entry_pos, DDL_LOG_FLAG_UPDATE_STAT); + ddl_log_entry->flags|= DDL_LOG_FLAG_UPDATE_STAT; + } /* fall through */ case DDL_RENAME_PHASE_TABLE: /* Restore frm and table to original names */ - execute_rename_table(thd, ddl_log_entry, file, - &ddl_log_entry->db, &ddl_log_entry->name, - &ddl_log_entry->from_db, &ddl_log_entry->from_name, - 0, - from_path, to_path); + error= execute_rename_table(thd, ddl_log_entry, file, + &ddl_log_entry->db, &ddl_log_entry->name, + &ddl_log_entry->from_db, + &ddl_log_entry->from_name, + invers_fn_flags, from_path, to_path); if (ddl_log_entry->flags & DDL_LOG_FLAG_UPDATE_STAT) { @@ -1546,11 +1638,13 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, &ddl_log_entry->db, &ddl_log_entry->name, reg_ext, - key_file_fileparser); + key_file_fileparser, + 0); build_filename_and_delete_tmp_file(from_path, sizeof(from_path) - 1, &ddl_log_entry->from_db, &ddl_log_entry->from_name, - reg_ext, key_file_fileparser); + reg_ext, key_file_fileparser, + 0); /* Rename view back if the original rename did succeed */ if (!access(to_path, F_OK)) @@ -1604,8 +1698,6 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, no_such_table_handler.only_ignore_non_existing_errors= 1; error= execute_drop_table(thd, hton, &db, &table, path.str); no_such_table_handler.only_ignore_non_existing_errors= 0; - if (error) - break; } else error= ha_delete_table_force(thd, path.str, &db, &table); @@ -1621,29 +1713,48 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, /* Fall through */ case DDL_DROP_PHASE_TRIGGER: Table_triggers_list::drop_all_triggers(thd, &db, &table, + fn_flags, MYF(MY_WME | MY_IGNORE_ENOENT)); if (increment_phase(entry_pos)) break; /* Fall through */ case DDL_DROP_PHASE_BINLOG: - if (strcmp(recovery_state.current_db, db.str)) + if (fn_flags & FN_IS_TMP) { - append_identifier(thd, &recovery_state.drop_table, &db); - recovery_state.drop_table.append('.'); - } - append_identifier(thd, &recovery_state.drop_table, &table); - recovery_state.drop_table.append(','); - /* We don't increment phase as we want to retry this in case of crash */ + /* + If new code is added here please finish this block like this: - if (ddl_log_drop_to_binary_log(thd, ddl_log_entry, - &recovery_state.drop_table)) + if (increment_phase(entry_pos)) + break; + */ + } + else { - if (increment_phase(entry_pos)) - break; + if (strcmp(recovery_state.current_db, db.str)) + { + append_identifier(thd, &recovery_state.drop_table, &db); + recovery_state.drop_table.append('.'); + } + append_identifier(thd, &recovery_state.drop_table, &table); + recovery_state.drop_table.append(','); + /* + We don't increment phase as we want to retry this in case of crash. + */ + if (ddl_log_drop_to_binary_log(thd, ddl_log_entry, + &recovery_state.drop_table)) + { + if (increment_phase(entry_pos)) + break; + } } + if (ddl_log_entry->extra_name.str) + delete_statistics_for_table(thd, &db, &ddl_log_entry->extra_name); break; case DDL_DROP_PHASE_RESET: - /* We have already logged all previous drop's. Clear the query */ + /* + We only come here if DDL_DROP_PHASE_BINLOG fails. + We have already logged all previous drop's. Clear the query + */ recovery_state.drop_table.length(recovery_state.drop_table_init_length); recovery_state.drop_view.length(recovery_state.drop_view_init_length); break; @@ -1695,7 +1806,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, &ddl_log_entry->db, &ddl_log_entry->name, TRG_EXT, - key_file_fileparser)) + key_file_fileparser, 0)) { /* Temporary file existed and was deleted, nothing left to do */ (void) update_phase(entry_pos, DDL_LOG_FINAL_PHASE); @@ -1914,11 +2025,11 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, (void) build_filename_and_delete_tmp_file(to_path, sizeof(to_path) - 1, &db, &table, TRG_EXT, - key_file_fileparser); + key_file_fileparser, 0); (void) build_filename_and_delete_tmp_file(to_path, sizeof(to_path) - 1, &db, &trigger, TRN_EXT, - key_file_fileparser); + key_file_fileparser, 0); switch (ddl_log_entry->phase) { case DDL_CREATE_TRIGGER_PHASE_DELETE_COPY: { @@ -2233,7 +2344,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, if (is_renamed) { // rename_triggers will rename from: from_db.from_name -> db.extra_name - rename_triggers(thd, ddl_log_entry, 1); + rename_triggers(thd, ddl_log_entry, 1, 0); (void) update_phase(entry_pos, DDL_ALTER_TABLE_PHASE_UPDATE_STATS); } } @@ -2348,7 +2459,12 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, end: delete file; - /* We are only interested in errors that where not ignored */ + /* + We are only interested in errors that where not ignored + The old value of error is only needed for debugging and can be + ignored. + no_such_table_handler has recorded all relevant errors + */ if ((error= (no_such_table_handler.unhandled_errors > 0))) my_errno= no_such_table_handler.first_error; thd->pop_internal_handler(); @@ -2451,8 +2567,16 @@ static bool ddl_log_execute_entry_no_lock(THD *thd, uint first_entry) DDL_LOG_ENTRY ddl_log_entry; uint read_entry= first_entry; MEM_ROOT mem_root; + partition_info *save_part_info; DBUG_ENTER("ddl_log_execute_entry_no_lock"); + /* + We have to reset partition_info from the CREATE TABLE as + open_table() uses it to check how the table is partitioned. + */ + save_part_info= thd->lex->part_info; + thd->lex->part_info= 0; + mysql_mutex_assert_owner(&LOCK_gdl); init_sql_alloc(key_memory_gdl, &mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC)); @@ -2483,6 +2607,7 @@ static bool ddl_log_execute_entry_no_lock(THD *thd, uint first_entry) } while (read_entry); free_root(&mem_root, MYF(0)); + thd->lex->part_info= save_part_info; DBUG_RETURN(FALSE); } @@ -2525,6 +2650,10 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry, set_global_from_ddl_log_entry(ddl_log_entry); if (ddl_log_get_free_entry(active_entry)) DBUG_RETURN(TRUE); +#ifndef DBUG_OFF + /* Easier debugging of action entries */ + (*active_entry)->action_type= ddl_log_entry->action_type; +#endif error= FALSE; DBUG_PRINT("ddl_log", @@ -2568,7 +2697,8 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry, @param first_entry First entry in linked list of entries to execute. - @param cond_entry Check and don't execute if cond_entry is active + @param cond_entry Check and don't execute if cond_entry is + active or not active based on flags @param[in,out] active_entry Entry to execute, 0 = NULL if the entry is written first time and needs to be returned. In this case the entry written @@ -2596,7 +2726,8 @@ bool ddl_log_write_execute_entry(uint first_entry, file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= (uchar)DDL_LOG_EXECUTE_CODE; int4store(file_entry_buf + DDL_LOG_NEXT_ENTRY_POS, first_entry); - int8store(file_entry_buf + DDL_LOG_ID_POS, ((ulonglong)cond_entry << DDL_LOG_RETRY_BITS)); + int8store(file_entry_buf + DDL_LOG_ID_POS, + ((ulonglong)cond_entry << DDL_LOG_RETRY_BITS)); if (!(*active_entry)) { @@ -2736,12 +2867,14 @@ bool ddl_log_close_binlogged_events(HASH *xids) { if (read_ddl_log_entry(i, &ddl_log_entry)) break; // Read error. Stop reading + DBUG_PRINT("xid",("xid: %llu", ddl_log_entry.xid)); if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE && ddl_log_entry.xid != 0 && my_hash_search(xids, (uchar*) &ddl_log_entry.xid, sizeof(ddl_log_entry.xid))) { + /* Entry found in binary log, disable it */ if (disable_execute_entry(i)) { mysql_mutex_unlock(&LOCK_gdl); @@ -2794,10 +2927,7 @@ int ddl_log_execute_recovery() default_charset_info); thd->log_all_errors= (global_system_variables.log_warnings >= 3); - recovery_state.drop_table.free(); - recovery_state.drop_view.free(); - recovery_state.query.free(); - recovery_state.db.free(); + recovery_state.free(); thd->set_query(recover_query_string, strlen(recover_query_string)); @@ -2812,7 +2942,7 @@ int ddl_log_execute_recovery() if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE) { /* - Remeber information about executive ddl log entry, + Remember information about executive ddl log entry, used for binary logging during recovery */ recovery_state.execute_entry_pos= i; @@ -2852,10 +2982,7 @@ int ddl_log_execute_recovery() count++; } } - recovery_state.drop_table.free(); - recovery_state.drop_view.free(); - recovery_state.query.free(); - recovery_state.db.free(); + recovery_state.free(); close_ddl_log(); mysql_mutex_unlock(&LOCK_gdl); thd->reset_query(); @@ -2915,6 +3042,7 @@ void ddl_log_release() my_free(global_ddl_log.file_entry_buf); global_ddl_log.file_entry_buf= 0; + recovery_state.free(); close_ddl_log(); create_ddl_log_file_name(file_name, 0); @@ -3007,6 +3135,20 @@ bool ddl_log_revert(THD *thd, DDL_LOG_STATE *state) DBUG_RETURN(res); } +/** + Disable a ddl entry. The entry will not be executed. +*/ + +void ddl_log_disable(DDL_LOG_STATE *state) +{ + if (likely(state->execute_entry)) + { + mysql_mutex_lock(&LOCK_gdl); // Required by next call + ddl_log_disable_execute_entry(&state->execute_entry); + mysql_mutex_unlock(&LOCK_gdl); + } +} + /* Update phase of main ddl log entry (usually the last one created, @@ -3098,7 +3240,8 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, mysql_mutex_lock(&LOCK_gdl); error= ((ddl_log_write_entry(ddl_log_entry, &log_entry)) || - ddl_log_write_execute_entry(log_entry->entry_pos, 0, + ddl_log_write_execute_entry(log_entry->entry_pos, + ddl_state->master_chain_pos, &ddl_state->execute_entry)); DBUG_EXECUTE_IF("ddl_log_write_fail", error= true;); if (error) @@ -3116,7 +3259,10 @@ static bool ddl_log_write(DDL_LOG_STATE *ddl_state, /** - Logging of rename table + Logging of rename + + @param phase Starting phase (usually DDL_RENAME_PHASE_TABLE) + @param flags Rename flags (FN_FROM_IS_TMP, FN_TO_IS_TMP) */ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, @@ -3124,10 +3270,12 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_alias) + const LEX_CSTRING *new_alias, + enum_ddl_log_rename_table_phase phase, + uint16 flags) { DDL_LOG_ENTRY ddl_log_entry; - DBUG_ENTER("ddl_log_rename_file"); + DBUG_ENTER("ddl_log_rename_table"); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); @@ -3139,7 +3287,8 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(new_alias); ddl_log_entry.from_db= *const_cast(org_db); ddl_log_entry.from_name= *const_cast(org_alias); - ddl_log_entry.phase= DDL_RENAME_PHASE_TABLE; + ddl_log_entry.phase= (uchar) phase; + ddl_log_entry.flags= flags; DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry)); } @@ -3185,7 +3334,7 @@ static bool ddl_log_drop_init(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *comment) { DDL_LOG_ENTRY ddl_log_entry; - DBUG_ENTER("ddl_log_drop_file"); + DBUG_ENTER("ddl_log_drop_init"); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); @@ -3220,6 +3369,16 @@ bool ddl_log_drop_view_init(DDL_LOG_STATE *ddl_state, be stored in call order instead of reverse order, which is the normal case for all other events. See also comment before ddl_log_drop_init(). + + @param ddl_state DDL log chain + @param action_code DDL_LOG_DROP_TABLE_ACTION or DDL_LOG_DROP_VIEW_ACTION + @param phase Starting phase (for table DDL_DROP_PHASE_TABLE) + @param hton Handlerton + @param path Table filepath without extension + @param db DB name + @param table Table name + @param orig_table Original table name (in case of create or replace) + @param flags DDL_LOG_FLAG_FROM_IS_TMP or DDL_LOG_FLAG_TO_IS_TMP */ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, @@ -3228,13 +3387,17 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table) + const LEX_CSTRING *table, + const LEX_CSTRING *orig_table, + uint16 flags) { DDL_LOG_ENTRY ddl_log_entry; DDL_LOG_MEMORY_ENTRY *log_entry; DBUG_ENTER("ddl_log_drop"); DBUG_ASSERT(ddl_state->list); + DBUG_ASSERT(action_code == DDL_LOG_DROP_TABLE_ACTION || + action_code == DDL_LOG_DROP_VIEW_ACTION); bzero(&ddl_log_entry, sizeof(ddl_log_entry)); ddl_log_entry.action_type= action_code; @@ -3244,7 +3407,10 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, ddl_log_entry.db= *const_cast(db); ddl_log_entry.name= *const_cast(table); ddl_log_entry.tmp_name= *const_cast(path); + if (orig_table) + ddl_log_entry.extra_name= *const_cast(orig_table); ddl_log_entry.phase= (uchar) phase; + ddl_log_entry.flags= flags; mysql_mutex_lock(&LOCK_gdl); if (ddl_log_write_entry(&ddl_log_entry, &log_entry)) @@ -3268,19 +3434,38 @@ static bool ddl_log_drop(DDL_LOG_STATE *ddl_state, } +/** + @param ddl_state DDL log chain + @param hton Handlerton + @param path Table filepath without extension + @param db DB name + @param table Table name + @param orig_table Original table name (in case of create or replace) + @param flags DDL_LOG_FLAG_FROM_IS_TMP or DDL_LOG_FLAG_TO_IS_TMP +*/ + bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table) + const LEX_CSTRING *table, + const LEX_CSTRING *orig_table, + uint16 flags) { DBUG_ENTER("ddl_log_drop_table"); DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_TABLE_ACTION, DDL_DROP_PHASE_TABLE, - hton, path, db, table)); + hton, path, db, table, orig_table, flags)); } +/** + @param ddl_state DDL log chain + @param path Table filepath without extension + @param db DB name + @param table Table name +*/ + bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -3289,7 +3474,8 @@ bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, DBUG_ENTER("ddl_log_drop_view"); DBUG_RETURN(ddl_log_drop(ddl_state, DDL_LOG_DROP_VIEW_ACTION, 0, - (handlerton*) 0, path, db, table)); + (handlerton*) 0, path, db, table, (LEX_CSTRING*) 0, + 0)); } @@ -3383,6 +3569,7 @@ bool ddl_log_create_table(DDL_LOG_STATE *ddl_state, ddl_log_entry.name= *const_cast(table); ddl_log_entry.tmp_name= *const_cast(path); ddl_log_entry.flags= only_frm ? DDL_LOG_FLAG_ONLY_FRM : 0; + ddl_log_entry.next_entry= ddl_state->list ? ddl_state->list->entry_pos : 0; DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry)); } @@ -3635,3 +3822,17 @@ bool ddl_log_delete_frm(DDL_LOG_STATE *ddl_state, const char *to_path) ddl_log_add_entry(ddl_state, log_entry); DBUG_RETURN(0); } + +/* + Link the ddl_log_state to another (master) chain. If the master + chain is active during DDL recovery, this event will not be executed. + + This is used for DROP TABLE of the backup table when + CREATE OR REPLACE ... is used. +*/ + +void ddl_log_link_chains(DDL_LOG_STATE *state, DDL_LOG_STATE *master_state) +{ + DBUG_ASSERT(master_state->execute_entry); + state->master_chain_pos= master_state->execute_entry->entry_pos; +} diff --git a/sql/ddl_log.h b/sql/ddl_log.h index 87b7af57102ee..3dadb1370d26d 100644 --- a/sql/ddl_log.h +++ b/sql/ddl_log.h @@ -21,6 +21,8 @@ #ifndef DDL_LOG_INCLUDED #define DDL_LOG_INCLUDED +#include + enum ddl_log_entry_code { /* @@ -173,6 +175,20 @@ enum enum_ddl_log_alter_table_phase { engine is not changed */ #define DDL_LOG_FLAG_ALTER_PARTITION (1 << 4) +#define DDL_LOG_FLAG_FROM_IS_TMP (1 << 5) +#define DDL_LOG_FLAG_TO_IS_TMP (1 << 6) + + +/* Convert tmp table flags from sql_layer to ddl_log */ +inline uint16 rename_flags_to_ddl_flags(uint flags) +{ + uint16 ddl_flags=0; + if (flags & FN_FROM_IS_TMP) + ddl_flags|= DDL_LOG_FLAG_FROM_IS_TMP; + if (flags & FN_TO_IS_TMP) + ddl_flags|= DDL_LOG_FLAG_TO_IS_TMP; + return ddl_flags; +} /* Setting ddl_log_entry.phase to this has the same effect as setting @@ -219,6 +235,9 @@ typedef struct st_ddl_log_entry typedef struct st_ddl_log_memory_entry { uint entry_pos; +#ifndef DBUG_OFF + enum ddl_log_action_code action_type; +#endif struct st_ddl_log_memory_entry *next_log_entry; struct st_ddl_log_memory_entry *prev_log_entry; struct st_ddl_log_memory_entry *next_active_log_entry; @@ -248,6 +267,7 @@ typedef struct st_ddl_log_state */ DDL_LOG_MEMORY_ENTRY *main_entry; uint16 flags; /* Cache for flags */ + uint master_chain_pos; bool is_active() { return list != 0; } } DDL_LOG_STATE; @@ -268,6 +288,7 @@ bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry); void ddl_log_complete(DDL_LOG_STATE *ddl_log_state); bool ddl_log_revert(THD *thd, DDL_LOG_STATE *ddl_log_state); +void ddl_log_disable(DDL_LOG_STATE *ddl_log_state); bool ddl_log_update_phase(DDL_LOG_STATE *entry, uchar phase); bool ddl_log_add_flag(DDL_LOG_STATE *entry, uint16 flag); @@ -286,7 +307,9 @@ bool ddl_log_rename_table(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_alias); + const LEX_CSTRING *new_alias, + enum_ddl_log_rename_table_phase phase, + uint16 flags); bool ddl_log_rename_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *org_db, const LEX_CSTRING *org_alias, @@ -301,7 +324,9 @@ bool ddl_log_drop_table(DDL_LOG_STATE *ddl_state, handlerton *hton, const LEX_CSTRING *path, const LEX_CSTRING *db, - const LEX_CSTRING *table); + const LEX_CSTRING *table, + const LEX_CSTRING *orig_table, + uint16 flags); bool ddl_log_drop_view(DDL_LOG_STATE *ddl_state, const LEX_CSTRING *path, const LEX_CSTRING *db, @@ -348,5 +373,6 @@ bool ddl_log_alter_table(DDL_LOG_STATE *ddl_state, bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_log_state, const char *query, size_t length); bool ddl_log_delete_frm(DDL_LOG_STATE *ddl_state, const char *to_path); +void ddl_log_link_chains(DDL_LOG_STATE *state, DDL_LOG_STATE *master_state); extern mysql_mutex_t LOCK_gdl; #endif /* DDL_LOG_INCLUDED */ diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 30b52ad0426a5..66b51a3a91d68 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -8400,6 +8400,20 @@ void ha_partition::return_record_by_parent() DBUG_ASSERT(0); } +bool ha_partition::vers_can_native(THD *thd) +{ + /* Ensure that all partitions can handle native partition */ + for (uint i= 0; i < m_tot_parts; i++) + if (!m_file[i]->vers_can_native(thd)) + return 0; + + if (thd->lex->part_info) + { + /* PARTITION BY SYSTEM_TIME is not supported for now */ + return thd->lex->part_info->part_type != VERSIONING_PARTITION; + } + return 1; +} /** Add index_next/prev from partitions without exact match. diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 9922822ea3b03..943f5e4279c09 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -522,13 +522,7 @@ class ha_partition final :public handler void return_record_by_parent() override; - bool vers_can_native(THD *thd) override - { - bool can= true; - for (uint i= 0; i < m_tot_parts && can; i++) - can= can && m_file[i]->vers_can_native(thd); - return can; - } + bool vers_can_native(THD *thd) override; /* ------------------------------------------------------------------------- diff --git a/sql/handler.cc b/sql/handler.cc index 6057e0da158c9..fa159b993e928 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5789,6 +5789,11 @@ int handler::ha_end_bulk_insert() DBUG_ENTER("handler::ha_end_bulk_insert"); DBUG_EXECUTE_IF("crash_end_bulk_insert", { extra(HA_EXTRA_FLUSH) ; DBUG_SUICIDE();}); + if (DBUG_IF("ha_end_bulk_insert_fail")) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } estimation_rows_to_insert= 0; DBUG_RETURN(end_bulk_insert()); } @@ -7242,6 +7247,67 @@ bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton, } +/** + Check if an existing table can be renamed as part of create or replace + when replacing an existing table. + + @retval + 0 ok + -1 error why create/replace could not be done. Warning is given to user + 1 Fatal error from open_table. Error given to user + + @notes + The known cases are: + - The to-be renamed table is of type InnoDB and has a named foreign key +*/ + +static const char *create_err_msg= + "Engine does not support atomic create or replace " + "for table '%-.192s' (Error: %d). Original table will be deleted"; + +static int ha_can_be_renamed_to_backup(THD *thd, TABLE *table) +{ + int res; + if ((res= table->file->can_be_renamed_to_backup())) + { + bool save_abort_on_warning= thd->abort_on_warning; + thd->abort_on_warning= false; + my_printf_error(HA_ERR_INTERNAL_ERROR, create_err_msg, + MYF(ME_WARNING), + table->s->table_name.str, res); + thd->abort_on_warning= save_abort_on_warning; + return -1; + } + return 0; +} + + +int ha_check_if_table_can_be_renamed_to_backup(THD *thd, handlerton *hton, + TABLE_LIST *create_table) +{ + int res= 0; + Open_table_context ot_ctx(thd, (MYSQL_OPEN_IGNORE_FLUSH | + MYSQL_OPEN_HAS_MDL_LOCK | + MYSQL_LOCK_IGNORE_TIMEOUT)); + if (!(hton->flags & HTON_CHECK_NEEDED_FOR_CREATE_OR_REPLACE)) + return 0; + + if (create_table->table) // Table is locked + return ha_can_be_renamed_to_backup(thd, create_table->table); + + create_table->open_strategy= TABLE_LIST::OPEN_NORMAL; + if (open_table(thd, create_table, &ot_ctx)) + return 1; // Table should exists! + res= ha_can_be_renamed_to_backup(thd, create_table->table); + + /* New opened tables are always first in the open list */ + DBUG_ASSERT(create_table->table == thd->open_tables); + close_thread_table(thd, &thd->open_tables); + create_table->table= 0; + return res; +} + + /** Discover all table names in a given database */ @@ -7308,9 +7374,10 @@ bool Discovered_table_list::add_table(const char *tname, size_t tlen) bool Discovered_table_list::add_file(const char *fname) { - bool is_temp= strncmp(fname, STRING_WITH_LEN(tmp_file_prefix)) == 0; + bool is_temp= is_tmp_table(fname); - if ((is_temp && !with_temps) || !strncmp(fname,STRING_WITH_LEN(ROCKSDB_DIRECTORY_NAME))) + if ((is_temp && !with_temps) || + !strncmp(fname,STRING_WITH_LEN(ROCKSDB_DIRECTORY_NAME))) return 0; char tname[SAFE_NAME_LEN + 1]; @@ -7947,7 +8014,8 @@ static int binlog_log_row_to_binlog(TABLE* table, { bool error= 0; THD *const thd= table->in_use; - + binlog_cache_mngr *cache_mngr; + binlog_cache_data *cache; DBUG_ENTER("binlog_log_row_to_binlog"); if (!thd->binlog_table_maps && @@ -7958,20 +8026,18 @@ static int binlog_log_row_to_binlog(TABLE* table, DBUG_ASSERT((WSREP_NNULL(thd) && wsrep_emulate_bin_log) || mysql_bin_log.is_open()); - auto *cache_mngr= thd->binlog_setup_trx_data(); - if (cache_mngr == NULL) + if (!(cache_mngr= thd->binlog_setup_trx_data())) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* Ensure that all events in a GTID group are in the same cache */ if (thd->variables.option_bits & OPTION_GTID_BEGIN) has_trans= 1; - auto *cache= binlog_get_cache_data(cache_mngr, - use_trans_cache(thd, has_trans)); + cache= binlog_get_cache_data(cache_mngr, use_trans_cache(thd, has_trans)); - error= (*log_func)(thd, table, mysql_bin_log.as_event_log(), cache, - has_trans, thd->variables.binlog_row_image, - before_record, after_record); + error= (*log_func)(thd, table, mysql_bin_log.as_event_log(), cache, + has_trans, thd->variables.binlog_row_image, + before_record, after_record); DBUG_RETURN(error ? HA_ERR_RBR_LOGGING_FAILED : 0); } diff --git a/sql/handler.h b/sql/handler.h index b9fe11632dfd8..73cb69023a087 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -31,6 +31,7 @@ #include "structs.h" /* SHOW_COMP_OPTION */ #include "sql_array.h" /* Dynamic_array<> */ #include "mdl.h" +#include "backup.h" #include "ha_handler_stats.h" #include "optimizer_costs.h" #include "handler_binlog_reader.h" @@ -61,6 +62,7 @@ struct slave_connection_state; struct rpl_binlog_state_base; struct handler_binlog_event_group_info; struct handler_binlog_purge_info; +typedef struct st_ddl_log_state DDL_LOG_STATE; // the following is for checking tables @@ -2001,6 +2003,18 @@ handlerton *ha_default_tmp_handlerton(THD *thd); hton->notify_tabledef_changed() before commit (S3) or after (InnoDB). */ #define HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT (1 << 20) +/* + Indicates that rename table is expensive operation. + When set atomic CREATE OR REPLACE TABLE is not used. +*/ +#define HTON_EXPENSIVE_RENAME (1 << 21) +/* + Engine may not support rename of a table to a backup, as used by + CREATE OR REPLACE. If this flag is set, then MariaDB will call + handler->can_rename_to_backup() to check if atomic CREATE OR REPLACE + code can be used. +*/ +#define HTON_CHECK_NEEDED_FOR_CREATE_OR_REPLACE (1 << 22) class Ha_trx_info; @@ -2458,13 +2472,17 @@ struct Table_scope_and_contents_source_pod_st // For trivial members TABLE_LIST *pos_in_locked_tables; TABLE_LIST *merge_list; MDL_ticket *mdl_ticket; - bool table_was_deleted; sequence_definition *seq_create_info; void init() { bzero(this, sizeof(*this)); } + /* + NOTE: share->tmp_table (tmp_table_type) is superset of this + HA_LEX_CREATE_TMP_TABLE which means TEMPORARY keyword in + CREATE TEMPORARY TABLE statement. + */ bool tmp_table() const { return options & HA_LEX_CREATE_TMP_TABLE; } void use_default_db_type(THD *thd) { @@ -2515,6 +2533,7 @@ struct Table_scope_and_contents_source_st: It does not include the "OR REPLACE" and "IF NOT EXISTS" parts, as these parts are handled on the SQL level and are not needed on the handler level. */ + struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, public Schema_specification_st { @@ -2522,12 +2541,25 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, Alter_info *alter_info; bool repair; + /* Used for Atomic CREATE or REPLACE */ + LEX_CSTRING tmp_name; + LEX_CSTRING backup_name; + DDL_LOG_STATE *ddl_log_state_create; + DDL_LOG_STATE *ddl_log_state_rm; + handlerton *org_hton; + backup_log_info drop_entry; + bool table_was_deleted, table_was_renamed, table_was_created; + void init() { Table_scope_and_contents_source_st::init(); Schema_specification_st::init(); alter_info= NULL; + tmp_name.length= 0; + ddl_log_state_rm= ddl_log_state_create= 0; + org_hton= 0; repair= 0; + table_was_deleted= table_was_renamed= table_was_created= 0; } ulong table_options_with_row_type() { @@ -2541,6 +2573,10 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, const Lex_table_charset_collation_attrs_st &convert_cscl, const Charset_collation_context &ctx); bool check_if_valid_log_table(); + bool is_atomic_replace() const + { + return table_was_renamed; + } }; @@ -2630,6 +2666,12 @@ struct Table_specification_st: public HA_CREATE_INFO, convert_charset_collation, ctx); } + bool finalize_create_table(THD *thd, TABLE_LIST *orig_table, + const char *query, size_t query_length, + bool is_trans); + void end_create_table(THD *thd, TABLE_LIST *orig_table, bool rollback); + bool revert_create_table(THD *thd, TABLE_LIST *orig_table); + bool finalize_locked_tables(THD *thd, bool operation_failed); }; @@ -5733,6 +5775,12 @@ class handler :public Sql_alloc bool log_not_redoable_operation(const char *operation); + /* Can the table be renamed to a backup name as part of create or_replace */ + virtual int can_be_renamed_to_backup() const + { + return 0; /* Yes */ + } + protected: Handler_share *get_ha_share_ptr(); void set_ha_share_ptr(Handler_share *arg_ha_share); @@ -6014,6 +6062,8 @@ bool non_existing_table_error(int error); uint ha_count_rw_2pc(THD *thd, bool all); uint ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list, bool all, bool *no_rollback); +int ha_check_if_table_can_be_renamed_to_backup(THD *thd, handlerton *hton, + TABLE_LIST *create_table); inline void Cost_estimate::reset(handler *file) { reset(); diff --git a/sql/log.cc b/sql/log.cc index 387795e30fce7..258650cb4480d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -704,6 +704,28 @@ class binlog_cache_mngr { binlog_cache_mngr(const binlog_cache_mngr& info); }; + +/* + Remove all row event from all binlog caches and clear all caches. + This is only called from CREATE .. SELECT, in which case it safe to delete + also events from the statement cache. +*/ + +void THD::binlog_remove_rows_events() +{ + binlog_cache_mngr *cache_mngr= binlog_get_cache_mngr(); + DBUG_ENTER("THD::binlog_remove_rows_events"); + + if (!cache_mngr || + (!WSREP_EMULATE_BINLOG_NNULL(this) && !mysql_bin_log.is_open())) + DBUG_VOID_RETURN; + + MYSQL_BIN_LOG::remove_pending_rows_event(this, &cache_mngr->stmt_cache); + MYSQL_BIN_LOG::remove_pending_rows_event(this, &cache_mngr->trx_cache); + cache_mngr->reset(1,1); + DBUG_VOID_RETURN; +} + /** The function handles the first phase of two-phase binlogged ALTER. On master binlogs START ALTER when that is configured to do so. @@ -806,7 +828,7 @@ bool write_bin_log_start_alter(THD *thd, bool& partial_alter, deferred for the second logging phase. */ thd->set_binlog_flags_for_alter(Gtid_log_event::FL_START_ALTER_E1); - if(write_bin_log_with_if_exists(thd, false, false, if_exists, false)) + if (write_bin_log_with_if_exists(thd, false, false, if_exists, false) > 0) { DBUG_ASSERT(thd->is_error()); @@ -2022,7 +2044,7 @@ int binlog_init(void *p) binlog_tp.start_consistent_snapshot= binlog_start_consistent_snapshot; } binlog_tp.flags= HTON_NO_ROLLBACK; - auto plugin= (st_plugin_int*)p; + st_plugin_int *plugin= (st_plugin_int*)p; plugin->data= &binlog_tp; return setup_transaction_participant(plugin); } @@ -2836,6 +2858,8 @@ int binlog_commit(THD *thd, bool all, bool ro_1pc) thd->backup_stage(&org_stage); THD_STAGE_INFO(thd, stage_binlog_write); + + thd->in_binlog_commit= 1; if (!cache_mngr->stmt_cache.empty()) { #ifdef WITH_WSREP @@ -2877,6 +2901,7 @@ int binlog_commit(THD *thd, bool all, bool ro_1pc) */ cache_mngr->reset(false, true); THD_STAGE_INFO(thd, org_stage); + thd->in_binlog_commit= 0; DBUG_RETURN(error); } @@ -2915,6 +2940,7 @@ int binlog_commit(THD *thd, bool all, bool ro_1pc) cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF); THD_STAGE_INFO(thd, org_stage); + thd->in_binlog_commit= 0; DBUG_RETURN(error); } @@ -5206,11 +5232,12 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO *linfo, const char *log_name, error= LOG_INFO_EOF; goto end; } - } + log_name_len= (uint) strlen(full_log_name); - log_name_len= log_name ? (uint) strlen(full_log_name) : 0; - DBUG_PRINT("enter", ("log_name: %s, full_log_name: %s", - log_name ? log_name : "NULL", full_log_name)); + DBUG_PRINT("enter", ("log_name: %s, full_log_name: %s", + log_name, full_log_name)); + + } /* As the file is flushed, we can't get an error here */ error= reinit_io_cache(&index_file, READ_CACHE, (my_off_t) 0, 0, 0); @@ -7270,7 +7297,7 @@ bool use_trans_cache(const THD* thd, bool is_transactional) { if (is_transactional) return 1; - auto *const cache_mngr= thd->binlog_get_cache_mngr(); + const binlog_cache_mngr *cache_mngr= thd->binlog_get_cache_mngr(); return ((thd->is_current_stmt_binlog_format_row() || thd->variables.binlog_direct_non_trans_update) ? 0 : @@ -8059,7 +8086,7 @@ int binlog_flush_pending_rows_event(THD *thd, bool stmt_end, binlog_cache_data *cache_data) { int error= 0; - auto *pending= cache_data->pending(); + Rows_log_event *pending= cache_data->pending(); if (pending) { /* @@ -14285,10 +14312,10 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, case XID_EVENT: if (do_xa) { - xid_recovery_member *member= - (xid_recovery_member*) - my_hash_search(&xids, (uchar*) &static_cast(ev)->xid, - sizeof(my_xid)); + Xid_log_event *xid_ev= (Xid_log_event*) ev; + + xid_recovery_member *member= (xid_recovery_member *) + my_hash_search(&xids, (uchar*) &xid_ev->xid, sizeof(my_xid)); #ifndef HAVE_REPLICATION { if (member) @@ -14298,6 +14325,12 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, if (ctx.decide_or_assess(member, round, fdle, linfo, end_pos)) goto err2; #endif + DBUG_PRINT("xid", ("Xid_event xid: %llu", xid_ev->xid)); + uchar *x= (uchar *) memdup_root(&mem_root, + (uchar*) &xid_ev->xid, + sizeof(xid_ev->xid)); + if (!x || my_hash_insert(&ddl_log_ids, x)) + goto err2; } break; case QUERY_EVENT: @@ -14305,7 +14338,7 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, Query_log_event *query_ev= (Query_log_event*) ev; if (query_ev->xid) { - DBUG_PRINT("QQ", ("xid: %llu xid", query_ev->xid)); + DBUG_PRINT("xid", ("Query_log_event xid: %llu", query_ev->xid)); DBUG_ASSERT(sizeof(query_ev->xid) == sizeof(my_xid)); uchar *x= (uchar *) memdup_root(&mem_root, (uchar*) &query_ev->xid, @@ -14859,7 +14892,7 @@ TC_LOG_BINLOG::set_status_variables(THD *thd) if (thd && opt_bin_log) { mysql_mutex_lock(&thd->LOCK_thd_data); - auto cache_mngr= thd->binlog_get_cache_mngr(); + binlog_cache_mngr *cache_mngr= thd->binlog_get_cache_mngr(); if (cache_mngr) { if (opt_binlog_engine_hton) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2f6d1da7b1cf7..b7841aed82a5b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3884,17 +3884,17 @@ static int temp_file_size_cb_func(struct tmp_file_tracking *track, /* Cache to avoid reading global_tmp_space_used too many times */ ulonglong cached_space= global_tmp_space_used; - if (cached_space > global_max_tmp_space_usage && !no_error && - global_max_tmp_space_usage) + if (global_max_tmp_space_usage && cached_space > global_max_tmp_space_usage && + !no_error && !thd->in_binlog_commit) { global_tmp_space_used-= size_change; error= EE_GLOBAL_TMP_SPACE_FULL; my_errno= ENOSPC; goto exit; } - if (thd->status_var.tmp_space_used + size_change > - thd->variables.max_tmp_space_usage && !no_error && - thd->variables.max_tmp_space_usage) + if (thd->variables.max_tmp_space_usage && + thd->status_var.tmp_space_used + size_change > + thd->variables.max_tmp_space_usage && !no_error && !thd->in_binlog_commit) { global_tmp_space_used-= size_change; error= EE_LOCAL_TMP_SPACE_FULL; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 01e4bc44c89e4..15540abb5af40 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1526,7 +1526,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (is_table_modified && is_cmd_replicated && !thd->lex->no_write_to_binlog) { thd->get_stmt_da()->set_overwrite_status(true); - auto res= write_bin_log(thd, true, thd->query(), thd->query_length()); + bool res= write_bin_log(thd, true, thd->query(), thd->query_length()); thd->get_stmt_da()->set_overwrite_status(false); if (res) goto err; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3455c553bb358..d063af4fe3477 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -942,7 +942,6 @@ int close_thread_tables(THD *thd) noexcept if (thd->locked_tables_mode) { - /* Ensure we are calling ha_reset() for all used tables */ mark_used_tables_as_free_for_reuse(thd, thd->open_tables); @@ -3049,21 +3048,46 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) DBUG_RETURN(FALSE); } -/** - Add back a locked table to the locked list that we just removed from it. - This is needed in CREATE OR REPLACE TABLE where we are dropping, creating - and re-opening a locked table. - @return 0 0k - @return 1 error +/** + Re-attach a re-created table to the LOCK TABLES state. + + Used by CREATE OR REPLACE TABLE under LOCK TABLES. The original table + was locked when LOCK TABLES was issued; CREATE OR REPLACE then either + dropped it (and created a new one) or renamed it to a backup name and + created a new one in its place. In both cases a fresh TABLE has been + opened and a temporary lock taken for it, and we now have to make that + TABLE part of the existing LOCK TABLES set again. + + The new table's lock is merged into thd->lock, the locked-tables list + entry is re-pointed at the new TABLE, its recorded lock type is + refreshed and the MDL lock is downgraded to match. + + @param thd Thread handle + @param dst_table_list Locked-tables list entry to re-point at the new + table (the table's original pos_in_locked_tables) + @param table The newly created/re-opened table to attach + @param lock Temporary lock taken for the new table; merged + into thd->lock on success (the caller then clears + its own reference so it is not unlocked twice) + @param relink_lock Whether to re-link dst_table_list into the + locked-tables list. TRUE when the original entry + was unlinked (the table was dropped); FALSE in the + atomic-rename path where the entry was never + removed and must not be added a second time. + + @return 0 Ok + @return 1 Error (out of memory while merging the lock) */ bool Locked_tables_list::restore_lock(THD *thd, TABLE_LIST *dst_table_list, - TABLE *table, MYSQL_LOCK *lock) + TABLE *table, MYSQL_LOCK *lock, + bool relink_lock) { MYSQL_LOCK *merged_lock; DBUG_ENTER("restore_lock"); - DBUG_ASSERT(!strcmp(dst_table_list->table_name.str, table->s->table_name.str)); + DBUG_ASSERT(!strcmp(dst_table_list->table_name.str, + table->s->table_name.str)); /* Ensure we have the memory to add the table back */ if (!(merged_lock= mysql_lock_merge(thd->lock, lock))) @@ -3079,7 +3103,8 @@ bool Locked_tables_list::restore_lock(THD *thd, TABLE_LIST *dst_table_list, dst_table_list->lock_type= table->reginfo.lock_type; table->pos_in_locked_tables= dst_table_list; - add_back_last_deleted_lock(dst_table_list); + if (relink_lock) + add_back_last_deleted_lock(dst_table_list); table->mdl_ticket->downgrade_lock(table->reginfo.lock_type >= TL_FIRST_WRITE ? @@ -3089,6 +3114,7 @@ bool Locked_tables_list::restore_lock(THD *thd, TABLE_LIST *dst_table_list, DBUG_RETURN(0); } + /* Add back the last deleted lock structure. This should be followed by a call to reopen_tables() to @@ -3299,7 +3325,7 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags) static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry) { if (Table_triggers_list::check_n_load(thd, &share->db, - &share->table_name, entry, 0)) + &share->table_name, entry, false, 0)) return TRUE; /* @@ -3574,8 +3600,17 @@ Open_table_context::recover_from_failed_open() case OT_ADD_HISTORY_PARTITION: DEBUG_SYNC(m_thd, "add_history_partition"); if (!m_thd->locked_tables_mode) + { + /* + Change sql_command temporary to ensure that we can repair tables in + CREATE...SELECT. + */ + enum_sql_command save_sql_command= m_thd->lex->sql_command; + m_thd->lex->sql_command= SQLCOM_REPAIR; result= lock_table_names(m_thd, m_thd->lex->create_info, m_failed_table, NULL, get_timeout(), 0); + m_thd->lex->sql_command= save_sql_command; + } else { DBUG_ASSERT(!result); @@ -3715,8 +3750,8 @@ Open_table_context::recover_from_failed_open() } /* Rollback to start of the current statement to release exclusive lock - on table which was discovered but preserve locks from previous statements - in current transaction. + on table which was discovered but preserve locks from previous + statements in current transaction. */ if (!result) m_thd->mdl_context.rollback_to_savepoint(start_of_statement_svp()); @@ -6050,7 +6085,14 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, uint flags) TABLE **start,**ptr; bool found_first_not_own= 0; - if (!(ptr= start= thd->alloc(count))) + if (unlikely(thd->lock)) + { + my_error(ER_INTERNAL_ERROR, MYF(0), + "Trying to lock tables when there is already locked tables"); + DBUG_RETURN(TRUE); + } + + if (unlikely(!(ptr= start= thd->alloc(count)))) DBUG_RETURN(TRUE); /* @@ -9747,7 +9789,7 @@ my_bool mysql_rm_tmp_tables(void) { file=dirp->dir_entry+idx; - if (!strncmp(file->name, tmp_file_prefix, tmp_file_prefix_length)) + if (is_tmp_table(file->name)) { char *ext= fn_ext(file->name); size_t ext_len= strlen(ext); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index cbd7b940fdd4d..58b715457d0ef 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -917,6 +917,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) system_thread= NON_SYSTEM_THREAD; killed_for_exceeding_limit_rows_warning_given= 0; shared_thd= 0; + tmp_table_binlog_handled= 0; + in_binlog_commit= 0; cleanup_done= free_connection_done= abort_on_warning= got_warning= 0; peer_port= 0; // For SHOW PROCESSLIST transaction= &default_transaction; @@ -8371,7 +8373,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, reset_binlog_for_next_statement(); /* Temp tables changes are logged as a statement */ - tmp_table_binlog_handled= 1; + tmp_table_binlog_handled= !error; DBUG_RETURN(error >= 0 ? error : 1); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 25ffcf49d3bab..59c26dc03f86e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -908,7 +908,7 @@ typedef struct system_variables my_bool low_priority_updates; my_bool query_cache_wlock_invalidate; my_bool keep_files_on_create; - + my_bool drop_before_create_or_replace; my_bool old_passwords; my_bool only_standard_compliant_cte; my_bool query_cache_strip_comments; @@ -2821,7 +2821,7 @@ class Locked_tables_list size_t reopen_count); bool reopen_tables(THD *thd, bool need_reopen); bool restore_lock(THD *thd, TABLE_LIST *dst_table_list, TABLE *table, - MYSQL_LOCK *lock); + MYSQL_LOCK *lock, bool restore_lock); void add_back_last_deleted_lock(TABLE_LIST *dst_table_list); void mark_table_for_reopen(TABLE *table); }; @@ -3559,6 +3559,7 @@ class THD: public THD_count, /* this must be first */ properly logged. */ bool tmp_table_binlog_handled; + bool in_binlog_commit; /* Disable tmp file size check during commit */ ulonglong client_capabilities; /* What the client supports */ ulong max_client_packet_length; @@ -3697,6 +3698,7 @@ class THD: public THD_count, /* this must be first */ bool binlog_write_annotated_row(bool use_trans_cache); void binlog_prepare_for_row_logging(); bool binlog_write_table_maps(); + uint count_tables_without_rollback(); void set_server_id(uint32 sid) { variables.server_id = sid; } @@ -3710,6 +3712,7 @@ class THD: public THD_count, /* this must be first */ binlog_flush_pending_rows_event(stmt_end, TRUE)); } int binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional); + void binlog_remove_rows_events(); uint has_pending_row_events(); bool binlog_need_stmt_format(bool is_transactional) const { @@ -6842,6 +6845,7 @@ class select_insert :public select_result_interceptor { Write_record *write; ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not COPY_INFO info; + Table_specification_st *create_info; bool insert_into_view; select_insert(THD *thd_arg, TABLE_LIST *table_list_par, TABLE *table_par, List *fields_par, List *update_fields, @@ -6853,7 +6857,7 @@ class select_insert :public select_result_interceptor { int send_data(List &items) override; virtual bool store_values(List &values, bool *trg_skip_row); virtual bool can_rollback_data() { return 0; } - bool prepare_eof(bool using_create); + bool prepare_eof(); bool send_ok_packet(); bool send_eof() override; void abort_result_set() override; @@ -6863,7 +6867,6 @@ class select_insert :public select_result_interceptor { class select_create: public select_insert { - Table_specification_st *create_info; TABLE_LIST *select_tables; Alter_info *alter_info; Field **field; @@ -6880,19 +6883,7 @@ class select_create: public select_insert { Table_specification_st *create_info_par, Alter_info *alter_info_arg, List &select_fields,enum_duplicates duplic, bool ignore, - TABLE_LIST *select_tables_arg, Write_record *write): - select_insert(thd_arg, table_arg, NULL, &select_fields, 0, 0, duplic, - ignore, NULL, write), - create_info(create_info_par), - select_tables(select_tables_arg), - alter_info(alter_info_arg), - m_plock(NULL), exit_done(0), - saved_tmp_table_share(0) - { - DBUG_ASSERT(create_info->default_table_charset); - bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); - bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); - } + TABLE_LIST *select_tables_arg, Write_record *write); int prepare(List &list, SELECT_LEX_UNIT *u) override; bool store_values(List &values, bool *trg_skip_row) override; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index b0e69dee4b357..c72eee7dbe71e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4245,6 +4245,7 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par, table_list(table_list_par), table(table_par), fields(fields_par), write(write), autoinc_value_of_last_inserted_row(0), + create_info(0), insert_into_view(table_list_par && table_list_par->view != 0) { bzero((char*) &info,sizeof(info)); @@ -4257,6 +4258,29 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par, } +select_create::select_create(THD *thd_arg, TABLE_LIST *table_arg, + Table_specification_st *create_info_par, + Alter_info *alter_info_arg, + List &select_fields,enum_duplicates duplic, + bool ignore, + TABLE_LIST *select_tables_arg, + Write_record *write): + select_insert(thd_arg, table_arg, NULL, &select_fields, 0, 0, duplic, + ignore, NULL, write), + select_tables(select_tables_arg), + alter_info(alter_info_arg), + m_plock(NULL), exit_done(0), + saved_tmp_table_share(0) +{ + create_info= create_info_par; + DBUG_ASSERT(create_info->default_table_charset); + bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); + bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + create_info->ddl_log_state_rm= &ddl_log_state_rm; + create_info->ddl_log_state_create= &ddl_log_state_create; +} + + int select_insert::prepare(List &values, SELECT_LEX_UNIT *u) { @@ -4591,7 +4615,7 @@ bool select_insert::store_values(List &values, bool *trg_skip_row) DBUG_RETURN(error); } -bool select_insert::prepare_eof(bool in_create_table) +bool select_insert::prepare_eof() { int error; // make sure any ROW format pending event is logged in the same binlog cache @@ -4657,22 +4681,20 @@ bool select_insert::prepare_eof(bool in_create_table) thd->transaction->stmt.modified_non_trans_table); /* - Write to binlog before committing transaction. No statement will - be written by the binlog_query() below in RBR mode. All the - events are in the transaction cache and will be written when - ha_autocommit_or_rollback() is issued below. + Write to binlog before committing transaction in case of inserts. + No statement will be written by the binlog_query() below in RBR + mode. All the events are in the transaction cache and will be + written when ha_autocommit_or_rollback() is issued below. - Temporary tables will be logged only on CREATE in STMT format - or on INSERT if all changes to the table is in the binlog. + Note that CREATE TEMPORARY TABLE ... SELECT is binlogged here. + In this case create_info is <> 0 and table->s->tmp_table is set. */ - if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) && - (table->s->using_binlog() || - ((in_create_table && - (!table->s->tmp_table || thd->binlog_create_tmp_table())))) && - (likely(!error) || - (!in_create_table && - (thd->transaction->stmt.modified_non_trans_table || - thd->log_current_statement())))) + if ((!create_info || + (table->s->tmp_table && thd->binlog_create_tmp_table())) && + (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) && + (create_info || table->s->using_binlog()) && + (likely(!error) || thd->transaction->stmt.modified_non_trans_table || + thd->log_current_statement())) { int errcode= 0; int res; @@ -4749,7 +4771,7 @@ bool select_insert::send_eof() { bool res; DBUG_ENTER("select_insert::send_eof"); - res= (prepare_eof(0) || (!suppress_my_ok && send_ok_packet())); + res= (prepare_eof() || (!suppress_my_ok && send_ok_packet())); DBUG_RETURN(res); } @@ -4811,8 +4833,9 @@ void select_insert::abort_result_set() query_cache_invalidate3(thd, table, 1); } transactional_table= table->file->has_transactions_and_rollback(); - if (thd->transaction->stmt.modified_non_trans_table || - thd->log_current_statement()) + if (!create_info && + (thd->transaction->stmt.modified_non_trans_table || + thd->log_current_statement())) { if (!can_rollback_data()) thd->transaction->all.modified_non_trans_table= TRUE; @@ -4838,9 +4861,9 @@ void select_insert::abort_result_set() else thd->tmp_table_binlog_handled= 1; // tmp table not changed } - DBUG_ASSERT(transactional_table || !changed || - (thd->transaction->stmt.modified_non_trans_table || - thd->transaction->all.modified_non_trans_table)); + DBUG_ASSERT(transactional_table || !changed || create_info || + thd->transaction->stmt.modified_non_trans_table || + thd->transaction->all.modified_non_trans_table); table->file->ha_release_auto_increment(); } @@ -4923,6 +4946,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, while ((item=it++)) { + Create_field *cr_field; Field *tmp_field= item->create_field_for_create_select(thd->mem_root, &tmp_table); @@ -4947,8 +4971,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, table_field= NULL; } - Create_field *cr_field= new (thd->mem_root) - Create_field(thd, tmp_field, table_field); + if (!(cr_field= (new (thd->mem_root) + Create_field(thd, tmp_field, table_field)))) + DBUG_RETURN(NULL); /* rather inconsistently we copy constant defaults and compression from the original field, but not default expression or check constraint @@ -4958,9 +4983,6 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, cr_field->default_value= 0; cr_field->check_constraint= 0; - if (!cr_field) - DBUG_RETURN(NULL); - if (item->maybe_null()) cr_field->flags &= ~NOT_NULL_FLAG; alter_info->create_list.push_back(cr_field, thd->mem_root); @@ -5029,6 +5051,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, { Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); TABLE_LIST::enum_open_strategy save_open_strategy; + bool error; /* Force the newly created table to be opened */ save_open_strategy= table_list->open_strategy; @@ -5037,14 +5060,16 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, Here we open the destination table, on which we already have an exclusive metadata lock. */ - if (open_table(thd, table_list, &ot_ctx)) + error= open_table(thd, table_list, &ot_ctx); + table_list->open_strategy= save_open_strategy; + + if (error) { - quick_rm_table(thd, create_info->db_type, &table_list->db, - table_case_name(create_info, &table_list->table_name), - QRMT_DEFAULT); + /* Newly created table will be deleted in abort_result_set() */ + DBUG_ASSERT(thd->is_error() && table_list->table == 0); + DBUG_RETURN(0); } /* Restore */ - table_list->open_strategy= save_open_strategy; } else { @@ -5072,8 +5097,6 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, { if (likely(!thd->is_error())) // CREATE ... IF NOT EXISTS my_ok(thd); // succeed, but did nothing - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); DBUG_RETURN(NULL); } @@ -5113,8 +5136,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, table->s->table_creation_was_logged= save_table_creation_was_logged; drop_open_table(thd, table, &table_list->db, &table_list->table_name); - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + /* Table is deleted. We don't have to delete it again */ + ddl_log_update_phase(&ddl_log_state_create, DDL_LOG_FINAL_PHASE); + DBUG_RETURN(NULL); /* purecov: end */ } @@ -5167,9 +5191,7 @@ int select_create::postlock(THD *thd, TABLE **tables) if (unlikely(error)) return error; - TABLE const *const table = *tables; - if (thd->is_current_stmt_binlog_format_row() && - !table->s->tmp_table) + if (thd->is_current_stmt_binlog_format_row() && !create_info->tmp_table()) return binlog_show_create_table(thd, *tables, create_info); return 0; } @@ -5197,20 +5219,7 @@ select_create::prepare(List &_values, SELECT_LEX_UNIT *u) } if (!(table= create_table_from_items(thd, &values, &extra_lock))) - { - if (create_info->or_replace()) - { - /* Original table was deleted. We have to log it */ - log_drop_table(thd, &table_list->db, &table_list->table_name, - &create_info->org_storage_engine_name, - create_info->db_type == partition_hton, - &create_info->org_tabledef_version, - thd->lex->tmp_table()); - } - - /* abort() deletes table */ DBUG_RETURN(-1); - } if (create_info->tmp_table()) { @@ -5320,6 +5329,10 @@ static int binlog_show_create_table(THD *thd, TABLE *table, create_info, WITH_DB_NAME); DBUG_ASSERT(result == 0); /* show_create_table() always return 0 */ + /* + We have to log the query if the normal binlog is open or if we are using + Galera, which has it's own binlog if the normal binlog is not used. + */ if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { int errcode= query_error_code(thd, thd->killed == NOT_KILLED); @@ -5455,7 +5468,8 @@ bool select_create::send_eof() the CREATE TABLE will already be logged if we are not using row based replication. */ - if (!thd->is_current_stmt_binlog_format_row()) + if (!thd->is_current_stmt_binlog_format_row() && + create_info->table_was_deleted) { if (ddl_log_state_create.is_active()) // Not temporary table ddl_log_update_phase(&ddl_log_state_create, DDL_CREATE_TABLE_PHASE_LOG); @@ -5466,7 +5480,8 @@ bool select_create::send_eof() ddl_log_complete(&ddl_log_state_rm); } - if (prepare_eof(1)) + debug_crash_here("ddl_log_create_before_prepare_eof"); + if (prepare_eof()) { abort_result_set(); DBUG_RETURN(true); @@ -5501,6 +5516,7 @@ bool select_create::send_eof() */ if (!table->s->tmp_table) { + bool trans_table; #ifdef WITH_WSREP if (WSREP(thd) && table->file->ht->db_type == DB_TYPE_INNODB) @@ -5534,19 +5550,26 @@ bool select_create::send_eof() thd->get_stmt_da()->set_overwrite_status(true); } #endif /* WITH_WSREP */ - thd->binlog_xid= thd->query_id; - /* Remember xid's for the case of row based logging */ - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - if (trans_commit_stmt(thd) || - (!(thd->variables.option_bits & OPTION_GTID_BEGIN) && - trans_commit_implicit(thd))) + + /* + If are using statement based replication the table will be deleted here + in case of a crash as we can't use xid to check if the query was logged + */ + + /* + As this is a CREATE ... SELECT, we have to use the transaction cache + when using row logging. See handler::prepare_for_row_logging(). + */ + trans_table= (table->file->row_logging ? 1 : + table->file->has_transactions_and_rollback()); + + if (create_info->finalize_create_table(thd, table_list, NullS, 0, + trans_table)) { - abort_result_set(); - DBUG_RETURN(true); + abort_result_set(); + DBUG_RETURN(true); } - - thd->binlog_xid= 0; + create_info->end_create_table(thd, table_list, 0); #ifdef WITH_WSREP if (WSREP(thd)) @@ -5581,15 +5604,6 @@ bool select_create::send_eof() ddl_log.org_table_id= create_info->tabledef_version; backup_log_ddl(&ddl_log); } - /* - If are using statement based replication the table will be deleted here - in case of a crash as we can't use xid to check if the query was logged - (as the query was logged before commit!) - */ - debug_crash_here("ddl_log_create_after_binlog"); - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); - debug_crash_here("ddl_log_create_log_complete"); /* exit_done must only be set after last potential call to @@ -5599,18 +5613,23 @@ bool select_create::send_eof() send_ok_packet(); + /* m_plock is the lock for the newly created table */ + + DBUG_ASSERT(m_plock && *m_plock); if (m_plock) { MYSQL_LOCK *lock= *m_plock; *m_plock= NULL; m_plock= NULL; - if (create_info->pos_in_locked_tables) + if (create_info->pos_in_locked_tables) // Under lock tables { + DBUG_ASSERT(create_info->pos_in_locked_tables->table == 0); + /* - If we are under lock tables, we have created a table that was - originally locked. We should add back the lock to ensure that - all tables in the thd->open_list are locked! + We have created a table that was originally locked and then deleted. + We should add back the lock to ensure that all tables in the + thd->open_list are locked! */ table->mdl_ticket= create_info->mdl_ticket; @@ -5618,22 +5637,62 @@ bool select_create::send_eof() if (!thd->locked_tables_list.restore_lock(thd, create_info-> pos_in_locked_tables, - table, lock)) - DBUG_RETURN(false); // ok - /* Fail. Continue without locking the table */ + table, lock, + create_info->table_was_deleted)) + lock= 0; // Lock merged + } + if (lock) + { + /* Remove the temporary lock that was added for the new table */ + mysql_unlock_tables(thd, lock); } - mysql_unlock_tables(thd, lock); } DBUG_RETURN(false); } +/* + Count number of tables without rollback used by the statement + This code loops over the same tables as THD::binlog_write_table_maps(). +*/ + +uint THD::count_tables_without_rollback() +{ + MYSQL_LOCK *locks[2], **locks_end= locks; + uint found= 0; + DBUG_ENTER("THD::count_tables_without_rollback"); + + if ((*locks_end= extra_lock)) + locks_end++; + if ((*locks_end= lock)) + locks_end++; + + for (MYSQL_LOCK **cur_lock= locks ; cur_lock < locks_end ; cur_lock++) + { + TABLE **const end_ptr= (*cur_lock)->table + (*cur_lock)->table_count; + for (TABLE **table_ptr= (*cur_lock)->table; + table_ptr != end_ptr ; + ++table_ptr) + { + TABLE *table= *table_ptr; + if (table->reginfo.lock_type >= TL_FIRST_WRITE && + !table->file->has_transactions_and_rollback()) + found++; + } + } + DBUG_RETURN(found); +} + + void select_create::abort_result_set() { ulonglong save_option_bits; DBUG_ENTER("select_create::abort_result_set"); - /* Avoid double calls, could happen in case of out of memory on cleanup */ + /* + Avoid double calls, could happen in case of out of memory on cleanup + or if binary logging fails. + */ if (exit_done) DBUG_VOID_RETURN; exit_done= 1; @@ -5669,13 +5728,22 @@ void select_create::abort_result_set() */ binlog_clear_incident(thd); - bool drop_table_was_logged= false; if (table) { bool tmp_table= table->s->tmp_table; - bool table_creation_was_logged= (!tmp_table || - table->s->table_creation_was_logged || - create_info->table_was_deleted); + bool non_transactional_table_updated; + /* + CREATE SELECT failed. Remove all row events and clear caches if + there is no other non-transactional tables than the current one or + if all tables are transactional. + If there are non transactional tables used in triggers, we have + to write the create table + drop table together with all the other + table changes to the binlog. + */ + if (!(non_transactional_table_updated= + thd->count_tables_without_rollback() != + MY_TEST(!table->file->has_transactions_and_rollback()))) + thd->binlog_remove_rows_events(); if (tmp_table) { @@ -5690,37 +5758,28 @@ void select_create::abort_result_set() if (m_plock) { + /* Unlock the original table */ mysql_unlock_tables(thd, *m_plock); *m_plock= NULL; m_plock= NULL; } + debug_crash_here("ddl_log_create_before_open_table"); drop_open_table(thd, table, &table_list->db, &table_list->table_name); + + /* Table is deleted. We don't have to delete it again */ + ddl_log_update_phase(&ddl_log_state_create, DDL_LOG_FINAL_PHASE); + table=0; // Safety if (thd->log_current_statement()) { if (mysql_bin_log.is_open()) { /* Remove logging of drop, create + insert rows */ - binlog_reset_cache(thd); - /* Original table was deleted. We have to log it */ - if (table_creation_was_logged) - { - thd->binlog_xid= thd->query_id; - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); - log_drop_table(thd, &table_list->db, &table_list->table_name, - &create_info->org_storage_engine_name, - create_info->db_type == partition_hton, - &create_info->tabledef_version, - tmp_table); - drop_table_was_logged= true; - debug_crash_here("ddl_log_create_after_binlog"); - thd->binlog_xid= 0; - } + if (!non_transactional_table_updated) + binlog_reset_cache(thd); } - else if (!tmp_table) + else if (!tmp_table && create_info->table_was_deleted) { backup_log_info ddl_log; bzero(&ddl_log, sizeof(ddl_log)); @@ -5733,30 +5792,26 @@ void select_create::abort_result_set() backup_log_ddl(&ddl_log); } } + else if (mysql_bin_log.is_open() && non_transactional_table_updated && + !thd->is_current_stmt_binlog_format_row()) + { + /* Binlog failed create .. select with side effects */ + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); + (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), + thd->query_length(), + 0, FALSE, FALSE, errcode); + } } - - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + create_info->revert_create_table(thd, table_list); if (create_info->table_was_deleted) { - if (drop_table_was_logged) - { - /* for DROP binlogging the error status has to be canceled first */ - Diagnostics_area new_stmt_da(thd->query_id, false, true); - Diagnostics_area *old_stmt_da= thd->get_stmt_da(); - - thd->set_stmt_da(&new_stmt_da); - (void) trans_rollback_stmt(thd); - thd->set_stmt_da(old_stmt_da); - } - else - { - /* Unlock locked table that was dropped by CREATE. */ - (void) trans_rollback_stmt(thd); - } + /* Unlock locked table that was dropped by CREATE. */ + (void) trans_rollback_stmt(thd); thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket); } + else if (create_info->pos_in_locked_tables) + create_info->finalize_locked_tables(thd, true /* failed */); DBUG_VOID_RETURN; } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 09c033f8b3229..7a406ba368581 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -7197,6 +7197,12 @@ static void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, DBUG_ENTER("handle_alter_part_error"); DBUG_ASSERT(table->needs_reopen()); + /* + TABLE is going to be released, we should not access old part_info + anymore + */ + lpt->part_info= part_info; + /* All instances of this table needs to be closed. Better to do that here, than leave the cleaning up to others. diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index aeb3279afe48c..a63b383f43c94 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -51,7 +51,7 @@ bool Sql_cmd_partition_unsupported::execute(THD *) static bool return_with_logging(THD *thd) { if (thd->slave_thread && - write_bin_log_with_if_exists(thd, true, false, true)) + write_bin_log_with_if_exists(thd, true, false, true) > 0) return(true); my_ok(thd); return(false); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index bf32df929a743..e5110dd0b8c28 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -35,6 +35,7 @@ #include "wsrep_mysqld.h" #include "debug.h" + /* used to hold table entries for as part of list of renamed temporary tables */ struct TABLE_PAIR { @@ -223,7 +224,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent, else { /* Revert the renames of normal tables with the help of the ddl log */ - ddl_log_revert(thd, &ddl_log_state); + error|= ddl_log_revert(thd, &ddl_log_state); postponed_handler.emit_errors(); } @@ -252,18 +253,6 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table) } -/** - Parameters for do_rename -*/ - -struct rename_param -{ - Lex_ident_table old_alias, new_alias; - LEX_CUSTRING old_version; - handlerton *from_table_hton; -}; - - /** check_rename() @@ -293,7 +282,6 @@ check_rename(THD *thd, rename_param *param, DBUG_ENTER("check_rename"); DBUG_PRINT("enter", ("if_exists: %d", (int) if_exists)); - if (lower_case_table_names == 2) { param->old_alias= ren_table->alias; @@ -327,7 +315,8 @@ check_rename(THD *thd, rename_param *param, DBUG_RETURN(-1); } - if (ha_table_exists(thd, &new_db, ¶m->new_alias, NULL, NULL, NULL, 0)) + if (ha_table_exists(thd, &new_db, ¶m->new_alias, NULL, NULL, NULL, + (param->rename_flags & FN_TO_IS_TMP))) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str); DBUG_RETURN(1); // This can't be skipped @@ -342,6 +331,8 @@ check_rename(THD *thd, rename_param *param, SYNPOSIS do_rename() thd Thread handle + param rename parameters + ddl_log_state Parameter for ddl logging from check_rename ren_table A table/view to be renamed new_db The database to which the table to be moved to skip_error Skip error, but only if the table didn't exists @@ -352,12 +343,17 @@ check_rename(THD *thd, rename_param *param, Rename a single table or a view. In case of failure, all changes will be reverted + Even if mysql_rename_tables() cannot be used with LOCK TABLES, + the table can still be locked if we come here from CREATE ... REPLACE. + + If ddl_log_state is NULL then we will not log the rename to the ddl log. + RETURN false Ok true rename failed */ -static bool +bool do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, TABLE_LIST *ren_table, const Lex_ident_db *new_db, bool skip_error, bool *force_if_exists) @@ -371,8 +367,7 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, const Lex_ident_table * const old_alias= ¶m->old_alias; const Lex_ident_table * const new_alias= ¶m->new_alias; hton= param->from_table_hton; - - DBUG_ASSERT(!thd->locked_tables_mode); + rename_param.rename_flags= param->rename_flags; #ifdef WITH_WSREP if (WSREP(thd) && hton && hton != view_pseudo_hton && @@ -389,7 +384,8 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, error_if_mysql50_prefix(new_alias->str, ER_WRONG_TABLE_NAME)) DBUG_RETURN(1); - tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str); + if (!(param->rename_flags & FN_FROM_IS_TMP)) + tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str); if (hton != view_pseudo_hton) { @@ -397,7 +393,8 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, *force_if_exists= 1; /* Check if we can rename triggers */ - if (Table_triggers_list::prepare_for_rename(thd, &rename_param, + if (!(param->rename_flags & FN_IS_TMP) && + Table_triggers_list::prepare_for_rename(thd, &rename_param, ren_table->db, *old_alias, ren_table->table_name, @@ -407,52 +404,85 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, thd->replication_flags= 0; - if (ddl_log_rename_table(ddl_log_state, hton, - &ren_table->db, old_alias, new_db, new_alias)) + if (ddl_log_state && + ddl_log_rename_table(ddl_log_state, hton, + &ren_table->db, old_alias, new_db, new_alias, + DDL_RENAME_PHASE_TABLE, + rename_flags_to_ddl_flags(param->rename_flags))) DBUG_RETURN(1); 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, - QRMT_DEFAULT))) + param->rename_flags | QRMT_DEFAULT))) { /* Table rename succeded. It's safe to start recovery at rename trigger phase */ debug_crash_here("ddl_log_rename_before_phase_trigger"); - ddl_log_update_phase(ddl_log_state, DDL_RENAME_PHASE_TRIGGER); + if (ddl_log_state) + ddl_log_update_phase(ddl_log_state, DDL_RENAME_PHASE_TRIGGER); debug_crash_here("ddl_log_rename_before_rename_trigger"); - if (!(rc= Table_triggers_list::change_table_name(thd, - &rename_param, - &ren_table->db, - old_alias, - &ren_table->table_name, - new_db, - new_alias))) + rc= 0; + if (!(param->rename_flags & FN_IS_TMP)) { - debug_crash_here("ddl_log_rename_before_stat_tables"); - (void) rename_table_in_stat_tables(thd, &ren_table->db, - &ren_table->table_name, - new_db, new_alias); - debug_crash_here("ddl_log_rename_after_stat_tables"); + if (!(rc= Table_triggers_list::change_table_name(thd, + &rename_param, + &ren_table->db, + old_alias, + &ren_table->table_name, + new_db, + new_alias))) + { + debug_crash_here("ddl_log_rename_before_stat_tables"); + (void) rename_table_in_stat_tables(thd, &ren_table->db, + &ren_table->table_name, + new_db, new_alias); + debug_crash_here("ddl_log_rename_after_stat_tables"); + } + else + { + /* + We've succeeded in renaming table's .frm and in updating + corresponding handler data, but have failed to update table's + triggers appropriately. So let us revert operations on .frm + and handler's data and report about failure to rename table. + */ + debug_crash_here("ddl_log_rename_after_failed_rename_trigger"); + (void) mysql_rename_table(hton, new_db, new_alias, + &ren_table->db, old_alias, + ¶m->old_version, + QRMT_DEFAULT | NO_FK_CHECKS); + debug_crash_here("ddl_log_rename_after_revert_rename_table"); + if (ddl_log_state) + ddl_log_disable_entry(ddl_log_state); + debug_crash_here("ddl_log_rename_after_disable_entry"); + } } else { /* - We've succeeded in renaming table's .frm and in updating - corresponding handler data, but have failed to update table's - triggers appropriately. So let us revert operations on .frm - and handler's data and report about failure to rename table. + We come here in case of CREATE OR REPLACE when renaming the + trigger file TO/FROM a temporary table name */ - debug_crash_here("ddl_log_rename_after_failed_rename_trigger"); - (void) mysql_rename_table(hton, new_db, new_alias, - &ren_table->db, old_alias, ¶m->old_version, - QRMT_DEFAULT | NO_FK_CHECKS); - debug_crash_here("ddl_log_rename_after_revert_rename_table"); - ddl_log_disable_entry(ddl_log_state); - debug_crash_here("ddl_log_rename_after_disable_entry"); + DBUG_EXECUTE_IF("rename_trigger_fail", + { + my_error(ER_ERROR_ON_RENAME, MYF(0), + ren_table->table_name.str, + "hidden-name", ENOENT); + rc= 1; + DBUG_RETURN(1); + }); + + rc= Table_triggers_list::rename_trigger_file(thd, + &ren_table->db, + &ren_table->table_name, + new_db, new_alias, + param->rename_flags); + skip_error= 0; // If this fails it cannot be skipped + debug_crash_here("ddl_log_rename_after_rename_trigger_file"); } } if (thd->replication_flags & OPTION_IF_EXISTS) @@ -472,6 +502,7 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, DBUG_RETURN(1); } + DBUG_ASSERT(ddl_log_state); ddl_log_rename_view(ddl_log_state, &ren_table->db, &ren_table->table_name, new_db, new_alias); debug_crash_here("ddl_log_rename_before_rename_view"); @@ -483,7 +514,8 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, /* On error mysql_rename_view() will leave things as such. */ - ddl_log_disable_entry(ddl_log_state); + if (ddl_log_state) + ddl_log_disable_entry(ddl_log_state); debug_crash_here("ddl_log_rename_after_disable_entry"); } } diff --git a/sql/sql_rename.h b/sql/sql_rename.h index 1f5f94b0f5c4f..4cb4f80bf11a9 100644 --- a/sql/sql_rename.h +++ b/sql/sql_rename.h @@ -19,7 +19,25 @@ class THD; struct TABLE_LIST; +/** + Parameters for do_rename +*/ + +struct rename_param +{ + Lex_ident_table old_alias, new_alias; + LEX_CUSTRING old_version; + handlerton *from_table_hton; + int rename_flags; /* FN_FROM_IS_TMP, FN_TO_IS_TMP */ + rename_param(): + from_table_hton(NULL), + rename_flags(0) {} +}; + bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent, bool if_exists); +bool do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state, + TABLE_LIST *ren_table, const Lex_ident_db *new_db, + bool skip_error, bool *force_if_exists); #endif /* SQL_RENAME_INCLUDED */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8e78bc9f994cf..ce31dca22e0d1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -52,6 +52,7 @@ #include "sql_window.h" #include "tztime.h" +#include "debug.h" // debug_crash_here #include "debug_sync.h" // DEBUG_SYNC #include #include @@ -26054,6 +26055,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) { if (join->procedure && join->procedure->end_of_records()) DBUG_RETURN(NESTED_LOOP_ERROR); + debug_crash_here("ddl_log_create_after_send_data"); DBUG_RETURN(NESTED_LOOP_OK); } diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 7958b95aecc23..721b6b559a1b7 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -541,7 +541,10 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *org_table_list) seq->is_unsigned= (*table->s->field)->is_unsigned(); /* We set reserved_until when creating a new sequence. */ if (seq->check_and_adjust(thd, true)) - DBUG_RETURN(TRUE); + { + error= 1; + goto error; + } } error= seq->write_initial_sequence(table); @@ -556,8 +559,11 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *org_table_list) if (trans_commit_implicit(thd)) error= 1; +error: if (!temporary_table) { + if (error) + table->s->tdc->flushed= 1; // Remove from table def cache close_thread_tables(thd); lex->restore_backup_query_tables_list(&query_tables_list_backup); thd->restore_backup_open_tables_state(&open_tables_backup); @@ -689,7 +695,20 @@ int SEQUENCE::read_initial_values(TABLE *table) */ if (!has_active_transaction && !thd->transaction->stmt.is_empty() && !thd->in_sub_stmt) - trans_commit_stmt(thd); + { + /* + We have to preserve the rollback flag marking this statement as + a DDL because Gtid_log_event::Gtid_log_event may be called later + as part of CREATE OR REPLACE and it needs to know if the statement + was a DDL. + */ + uint save_unsafe_rollback_flags= + thd->transaction->stmt.m_unsafe_rollback_flags; + if (trans_commit_stmt(thd)) + error= HA_ERR_COMMIT_ERROR; + thd->transaction->stmt.m_unsafe_rollback_flags= + save_unsafe_rollback_flags; + } } write_unlock(table); DBUG_RETURN(error); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 94d256a7fb00b..a9af518410e1a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2227,6 +2227,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, RETURN 0 OK + 1 Error (out of memory) */ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, const char *force_db, @@ -5298,7 +5299,7 @@ static int fill_schema_table_from_frm(THD *thd, MEM_ROOT *mem_root, init_sql_alloc(key_memory_table_triggers_list, &tbl.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0)); if (!Table_triggers_list::check_n_load(thd, db_name, - table_name, &tbl, 1)) + table_name, &tbl, true, 0)) { table_list.table= &tbl; res= schema_table->process_table(thd, &table_list, table, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 39f172984519a..968b65322d4b1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -64,6 +64,7 @@ #include "rpl_rli.h" #include "log.h" #include "vector_mhnsw.h" +#include "sql_rename.h" // do_rename() #ifdef WITH_WSREP #include "wsrep_mysqld.h" @@ -294,6 +295,7 @@ uint explain_filename(THD* thd, const char *tmp_p; DBUG_ENTER("explain_filename"); DBUG_PRINT("enter", ("from '%s'", from)); + tmp_p= from; table_name= from; /* @@ -456,6 +458,12 @@ uint filename_to_tablename(const char *from, char *to, size_t to_length, DBUG_ENTER("filename_to_tablename"); DBUG_PRINT("enter", ("from '%s'", from)); + if (is_tmp_table(from)) + { + res= (size_t) (strnmov(to, from, to_length) - to); + DBUG_RETURN(res); + } + res= strconvert(&my_charset_filename, from, FN_REFLEN, system_charset_info, to, to_length, &errors); if (unlikely(errors)) // Old 5.0 name @@ -522,7 +530,10 @@ uint check_n_cut_mysql50_prefix(const char *from, char *to, size_t to_length) static bool check_if_frm_exists(char *path, const char *db, const char *table) { - fn_format(path, table, db, reg_ext, MYF(0)); + char *end= strmov(path, mysql_data_home); + if (end[-1] != FN_LIBCHAR) + *end++= FN_LIBCHAR; + fn_format(end, table, db, reg_ext, MYF(0)); return !access(path, F_OK); } @@ -540,10 +551,11 @@ static bool check_if_frm_exists(char *path, const char *db, const char *table) File name length. */ -uint tablename_to_filename(const char *from, char *to, size_t to_length) +uint tablename_to_filename_internal(const char *from, char *to, + size_t to_length) { uint errors, length; - DBUG_ENTER("tablename_to_filename"); + DBUG_ENTER("tablename_to_filename_internal"); DBUG_PRINT("enter", ("from '%s'", from)); if ((length= check_n_cut_mysql50_prefix(from, to, to_length))) @@ -574,6 +586,22 @@ uint tablename_to_filename(const char *from, char *to, size_t to_length) DBUG_RETURN(length); } +/* + Same as tablename_to_filename_internal() except that if the name is a + an internal temporary file name then return it as such +*/ + +uint tablename_to_filename(const char *from, char *to, size_t to_length) +{ + DBUG_ENTER("tablename_to_filename"); + if (is_tmp_table(from)) + { + uint length= (uint) (strnmov(to, from, to_length) - to); + DBUG_RETURN(length); + } + + DBUG_RETURN(tablename_to_filename_internal(from, to, to_length)); +} /* Creates path to a file: mysql_data_dir/db/table.ext @@ -618,7 +646,7 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db, db, table_name, ext, flags)); DBUG_ASSERT(*db); - if (!tablename_to_filename(db, dbbuff, sizeof(dbbuff))) + if (!tablename_to_filename_internal(db, dbbuff, sizeof(dbbuff))) DBUG_RETURN(*buff= 0); /* @@ -626,7 +654,7 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db, file exists. */ if (!(flags & FN_IS_TMP) && - is_prefix(table_name, tmp_file_prefix) && + is_tmp_table(table_name) && strlen(table_name) < NAME_CHAR_LEN && check_if_frm_exists(tbbuff, dbbuff, table_name)) flags|= FN_IS_TMP; @@ -635,7 +663,7 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db, strmake(tbbuff, table_name, sizeof(tbbuff)-1); else if (!*table_name) *tbbuff= 0; // table_name="" hack is used very often - else if (!tablename_to_filename(table_name, tbbuff, sizeof(tbbuff))) + else if (!tablename_to_filename_internal(table_name, tbbuff, sizeof(tbbuff))) DBUG_RETURN(*buff= 0); char *end = buff + bufflen; @@ -1075,7 +1103,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) /* SYNOPSIS - write_bin_log() + write_bin_log_with_stat() thd Thread object clear_error is clear_error to be called query Query to log @@ -1084,17 +1112,22 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) a trans or non-trans engine. RETURN VALUES - NONE + @retval -1 query was not logged (binlog not open / filtered out) + @retval 0 Success (query written to binary log + @retval > 0 If there is a failure when writing the query (e.g., + write failure), then the error code is returned. DESCRIPTION Write the binlog if open, routine used in multiple places in this file */ -int write_bin_log(THD *thd, bool clear_error, - char const *query, ulong query_length, bool is_trans) +int write_bin_log_with_stat(THD *thd, bool clear_error, + char const *query, ulong query_length, + bool is_trans) + { - int error= 0; // No logging of query + int error= -1; // No logging of query if (mysql_bin_log.is_open()) { int errcode= 0; @@ -1115,6 +1148,8 @@ int write_bin_log(THD *thd, bool clear_error, error= thd->binlog_query(THD::STMT_QUERY_TYPE, query, query_length, is_trans, FALSE, FALSE, errcode) > 0; + if (!error) + thd->tmp_table_binlog_handled= 1; thd_proc_info(thd, 0); } return error; @@ -1133,8 +1168,10 @@ int write_bin_log(THD *thd, bool clear_error, @param commit_alter Whether the query should be binlogged as Commit Alter. - @return false on Success - @return true otherwise + @retval -1 query was not logged (binlog not open / filtered out) + @retval 0 Success (query written to binary log + @retval > 0 If there is a failure when writing the query (e.g., + write failure), then the error code is returned. */ int write_bin_log_with_if_exists(THD *thd, bool clear_error, @@ -1148,8 +1185,9 @@ int write_bin_log_with_if_exists(THD *thd, bool clear_error, if (commit_alter) thd->set_binlog_flags_for_alter(Gtid_log_event::FL_COMMIT_ALTER_E1); - result= write_bin_log(thd, clear_error, thd->query(), thd->query_length(), - is_trans); + result= write_bin_log_with_stat(thd, clear_error, + thd->query(), thd->query_length(), + is_trans); if (commit_alter) { thd->set_binlog_flags_for_alter(0); @@ -1339,6 +1377,46 @@ static uint32 get_comment(THD *thd, uint32 comment_pos, } +/* + Log to the ddl_log the drop of a single table + Used by create_or_replace(). +*/ + +static int ddl_log_drop_tmp_table(THD *thd, DDL_LOG_STATE *ddl_log_state, + TABLE_LIST *table, + Table_specification_st *create_info) +{ + bool res= 0; + LEX_CSTRING comment= {"",0}; + LEX_CSTRING *db= &table->db; + LEX_CSTRING cpath; + char path[FN_REFLEN + 1], *path_end; + size_t path_length; + + path_length= build_table_filename(path, sizeof(path) - 1, db->str, + create_info->tmp_name.str, reg_ext, + FN_IS_TMP); + path_end= path + path_length - reg_ext_length; + cpath= { path, (size_t)(path_end - path) }; + + if (ddl_log_drop_table_init(ddl_log_state, db, &comment)) + return 1; + if (create_info->org_hton == view_pseudo_hton) + { + DBUG_ASSERT(0); // Should never happen + res= ddl_log_drop_view(ddl_log_state, &cpath, db, &create_info->tmp_name); + } + else + res= ddl_log_drop_table(ddl_log_state, create_info->org_hton, + &cpath, db, &create_info->tmp_name, + (!create_info->tmp_table() ? + &create_info->alias /* original name */ : + (LEX_CSTRING*) 0), + DDL_LOG_FLAG_FROM_IS_TMP); + return res; +} + + /** Execute the drop of a sequence, view or table (normal or temporary). @@ -1473,7 +1551,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, const LEX_CSTRING db= table->db; const LEX_CSTRING table_name= table->table_name; LEX_CSTRING cpath= {0,0}; - LEX_CSTRING partition_engine_name= {NULL, 0}; + LEX_CSTRING partition_engine_name= null_clex_str; handlerton *hton= 0; Table_type table_type; size_t path_length= 0; @@ -1733,7 +1811,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, if (was_view) res= ddl_log_drop_view(ddl_log_state, &cpath, &db, &table_name); else - res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db, &table_name); + res= ddl_log_drop_table(ddl_log_state, hton, &cpath, &db, &table_name, + (LEX_CSTRING*) 0, 0); if (res) goto err; @@ -1821,7 +1900,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, int ferror= 0; DBUG_ASSERT(!was_view); - if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db, &table_name)) + if (ddl_log_drop_table(ddl_log_state, 0, &cpath, &db, &table_name, + (LEX_CSTRING *) 0, 0)) { error= -1; goto err; @@ -1867,7 +1947,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, if (likely(!error) || non_existing_table_error(error)) { - if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name, + if (Table_triggers_list::drop_all_triggers(thd, &db, &table_name, 0, MYF(MY_WME | MY_IGNORE_ENOENT))) error= error ? error : -1; } @@ -4645,41 +4725,290 @@ handler *mysql_create_frm_image(THD *thd, HA_CREATE_INFO *create_info, /** - Create a table - - @param thd Thread object - @param orig_db Database for error messages - @param orig_table_name Table name for error messages - (it's different from table_name for ALTER TABLE) - @param db Database - @param table_name Table name - @param path Path to table (i.e. to its .FRM file without - the extension). - @param create_info Create information (like MAX_ROWS) - @param alter_info Description of fields and keys for new table - @param create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE, - C_ASSISTED_DISCOVERY or C_ALTER_TABLE_FRM_ONLY. - or any positive number (for C_CREATE_SELECT). - If set to C_ALTER_TABLE_FRM_ONY then no frm or - table is created, only the frm image in memory. - @param[out] is_trans Identifies the type of engine where the table - was created: either trans or non-trans. - @param[out] key_info Array of KEY objects describing keys in table - which was created. - @param[out] key_count Number of keys in table which was created. - @param[out] frm The frm image. - - If one creates a temporary table, its is automatically opened and its - TABLE_SHARE is added to THD::all_temp_tables list. - - Note that this function assumes that caller already have taken - exclusive metadata lock on table being created or used some other - way to ensure that concurrent operations won't intervene. - mysql_create_table() is a wrapper that can be used for this. - - @retval 0 OK - @retval 1 error - @retval -1 table existed but IF NOT EXISTS was used + Finalize mysql_create_table() and mysql_create_like_table() + + @param thd thread handler + @param orig_table Table that we are creating/re-creating. + @param query Query to be logged. 0 if we should commit transaction + @param query_length Query_length of query. 0 if we should commit transaction + @param is_trans 1 if the table was transactional (for binary log) +*/ + +bool Table_specification_st:: +finalize_create_table(THD *thd, TABLE_LIST *orig_table, const char *query, + size_t query_length, bool is_trans) +{ + bool res= 0, wrote_to_binlog= 0; + + debug_crash_here("ddl_log_finalize_create"); + + thd->binlog_xid= thd->query_id; + if (tmp_table()) + thd->transaction->stmt.mark_created_temp_table(); + + if (table_was_renamed) + { + TABLE_LIST tmp_table; + tmp_table.db= orig_table->db; + tmp_table.table_name= Lex_ident_table(tmp_name); + tmp_table.alias= tmp_table.table_name; + + /* Ensure we only execute the drop if create is not rolled back */ + ddl_log_link_chains(ddl_log_state_rm, ddl_log_state_create); + + debug_crash_here("ddl_log_finalize_create_after_link"); + + ddl_log_drop_tmp_table(thd, ddl_log_state_rm, &tmp_table, this); + } + else if (table_was_deleted) + ddl_log_update_xid(ddl_log_state_rm, thd->binlog_xid); + + ddl_log_update_xid(ddl_log_state_create, thd->binlog_xid); + + debug_crash_here("ddl_log_create_before_binlog"); + + if (!query_length) + { + if (!orig_table->table->file->has_transactions()) + { + /* Tell non transactional engine to flush all data to disk */ + res= orig_table->table->file->extra(HA_EXTRA_FLUSH); + } + + if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) + { + int tmp; + thd->binlog_xid= thd->query_id; + /* Remember xid's for the case of row based logging */ + ddl_log_update_xid(ddl_log_state_create, thd->binlog_xid); + query= thd->query(); + query_length=thd->query_length(); + + tmp= thd->binlog_query(THD::ROW_QUERY_TYPE, + query, (ulong) query_length, + is_trans, FALSE, FALSE, 0); + wrote_to_binlog= tmp == 0; + res|= tmp > 0; + } + + /* This was a "CREATE OR REPLACE ... SELECT". Commit statement */ + if (res == 0) + { + res= trans_commit_stmt(thd); + if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) + res|= trans_commit_implicit(thd); + } + } + else if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) + { + int tmp; + tmp= write_bin_log_with_stat(thd, TRUE, + query, (ulong) query_length, + is_trans); + wrote_to_binlog= tmp == 0; + res|= tmp > 0; + } + else + { + /* + Mark that we have accepted the new table and do not need to + revert it in case of crashes. atomic_replace also ensures that + ddl_log_state_rm will run, as it would be run if binary logging + would be used. + */ + ddl_log_disable(ddl_log_state_create); + } + if (tmp_table() && wrote_to_binlog) + { + /* + Remember that temporary table creation was logged so that we know + that we should log a delete of it. + */ + table->s->table_creation_was_logged= 1; + } + + thd->binlog_xid= 0; + /* + The there was no problem with writing to the binlog, then + the new table is accepted and in case of the crash only the backup + table would be deleted if it exists. ddl_log_state_create will not + be used. + */ + + debug_crash_here("ddl_log_create_after_binlog"); + + return (res); +} + + +void Table_specification_st::end_create_table(THD *thd, + TABLE_LIST *orig_table, + bool rollback) +{ + if (unlikely(rollback)) + { + /* + Could not write to binlog. + Remove the new table and reinstate the old one if it was a real + table and delete it if it was a temporary table + */ + if (!tmp_table() || table_was_deleted) + { + revert_create_table(thd, orig_table); + /* revert_create_table() has cleanup up things */ + table_was_deleted= 0; + } + + if (tmp_table() && table_was_created) + { + DBUG_ASSERT(!table->s->table_creation_was_logged); + thd->drop_temporary_table(table, NULL, true); + table= 0; + } + return; + } + + debug_crash_here("ddl_log_create_after_binlog"); + + if (table_was_renamed) + { + /* remove backup table */ + ddl_log_revert(thd, ddl_log_state_rm); + debug_crash_here("ddl_log_create_after_revert"); + } + + ddl_log_complete(ddl_log_state_create); + debug_crash_here("ddl_log_create_middle_complete"); + ddl_log_complete(ddl_log_state_rm); + debug_crash_here("ddl_log_create_complete"); +} + + +/** + Finalize operation of LOCK TABLES mode for CREATE TABLE family of commands. + + @param operation_failed Notify if the callee CREATE fails the operation + @return true on error, false on success +*/ + +bool Table_specification_st::finalize_locked_tables(THD *thd, + bool operation_failed) +{ + TABLE *table= 0; + DBUG_ASSERT(thd->locked_tables_mode); + DBUG_ASSERT(pos_in_locked_tables); + + if (table_was_deleted && operation_failed) + { + /* + Locked table was dropped. We should remove meta data locks + associated with it and do UNLOCK_TABLES if no more locked tables. + */ + (void) thd->locked_tables_list.unlock_locked_table(thd, mdl_ticket); + return false; + } + + if (table_was_renamed) + { + /* The following is true if it was not a CREATE ... SELECT */ + if (!pos_in_locked_tables->table) + { + /* + Reopen the table. It can either be the newly created table or + the original table + + The lock was made exclusive in create_table_impl(). We have now + to bring it back to it's orginal state. + */ + if (thd->locked_tables_list.reopen_tables(thd, false)) + { + thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); + return true; + } + } + table= pos_in_locked_tables->table; + table->mdl_ticket= mdl_ticket; + mdl_ticket->downgrade_lock(table->reginfo.lock_type >= + TL_FIRST_WRITE ? + MDL_SHARED_NO_READ_WRITE : + MDL_SHARED_READ); + return operation_failed; + } + /* + In failed non-atomic we have nothing to downgrade: + original table was deleted and the lock was already removed. + */ + DBUG_ASSERT(operation_failed || !pos_in_locked_tables->table); + return false; +} + + +bool Table_specification_st::revert_create_table(THD *thd, + TABLE_LIST *orig_table) +{ + bool res= 0; + if (table_was_deleted) + { + /* + New table was not created. Original table was dropped. + We have to log the drop. + */ + thd->binlog_xid= thd->query_id; + debug_crash_here("ddl_log_create_before_binlog"); + + /* The following is true if the table was not a temporary table */ + if (ddl_log_state_rm->is_active()) + ddl_log_update_xid(ddl_log_state_rm, thd->binlog_xid); + res= log_drop_table(thd, &orig_table->db, &orig_table->table_name, + &org_storage_engine_name, + db_type == partition_hton, + &org_tabledef_version, + tmp_table()); + debug_crash_here("ddl_log_create_after_binlog"); + thd->binlog_xid= 0; + } + ddl_log_complete(ddl_log_state_rm); + ddl_log_revert(thd, ddl_log_state_create); + return res; +} + + +/** + Create a table + + @param thd Thread object + @param orig_db Database for error messages + @param orig_table_name Table name for error messages + (it's different from table_name for ALTER TABLE) + @param db Database + @param table_name Table name + @param path Path to table (i.e. to its .FRM file without + the extension). + @param create_info Create information (like MAX_ROWS) + @param alter_info Description of fields and keys for new table + @param create_table_mode C_ORDINARY_CREATE, C_ALTER_TABLE, + C_ASSISTED_DISCOVERY or C_ALTER_TABLE_FRM_ONLY. + or any positive number (for C_CREATE_SELECT). + If set to C_ALTER_TABLE_FRM_ONY then no frm or + table is created, only the frm image in memory. + @param[out] is_trans Identifies the type of engine where the table + was created: either trans or non-trans. + @param[out] key_info Array of KEY objects describing keys in table + which was created. + @param[out] key_count Number of keys in table which was created. + @param[out] frm The frm image. + + If one creates a temporary table, its is automatically opened and its + TABLE_SHARE is added to THD::all_temp_tables list. + + Note that this function assumes that caller already have taken + exclusive metadata lock on table being created or used some other + way to ensure that concurrent operations won't intervene. + mysql_create_table() is a wrapper that can be used for this. + + @retval 0 OK + @retval 1 error + @retval -1 table existed but IF NOT EXISTS was used */ static @@ -4699,6 +5028,7 @@ int create_table_impl(THD *thd, int error= 1; bool frm_only= create_table_mode == C_ALTER_TABLE_FRM_ONLY; bool internal_tmp_table= create_table_mode == C_ALTER_TABLE || frm_only; + TABLE_LIST tmp_table; DBUG_ENTER("create_table_impl"); DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d path: %s", db.str, table_name.str, internal_tmp_table, path.str)); @@ -4814,54 +5144,143 @@ int create_table_impl(THD *thd, error= 0; goto err; } - if (options.or_replace()) { - (void) delete_statistics_for_table(thd, &db, &table_name); - - table_list.table= create_info->table; + bool use_drop_table= (db_type == view_pseudo_hton || + (db_type->flags & HTON_EXPENSIVE_RENAME) || + thd->slave_thread || !ddl_log_state_create || + thd->variables.drop_before_create_or_replace); + int res= 0; + TABLE_LIST table_list; + TABLE *table= create_info->table; + table_list.init_one_table(&db, &table_name, 0, TL_WRITE_ALLOW_WRITE); + table_list.table= table; + + if (!use_drop_table && + (res= ha_check_if_table_can_be_renamed_to_backup(thd, db_type, + &table_list))) + { + if (res > 0) + goto err; // Error from open_table() + use_drop_table= 1; + } if (log_table && logger.is_log_table_enabled(log_table)) { my_error(ER_BAD_LOG_STATEMENT, MYF(0), "CREATE OR REPLACE"); goto err; } - - /* - Rollback the empty transaction started in mysql_create_table() - call to open_and_lock_tables() when we are using LOCK TABLES. - */ + + if (use_drop_table) { - uint save_unsafe_rollback_flags= - thd->transaction->stmt.m_unsafe_rollback_flags; - (void) trans_rollback_stmt(thd); - thd->transaction->stmt.m_unsafe_rollback_flags= - save_unsafe_rollback_flags; + /* + Rollback the empty transaction started in mysql_create_table() + call to open_and_lock_tables() when we are using LOCK TABLES. + */ + { + uint save_unsafe_rollback_flags= + thd->transaction->stmt.m_unsafe_rollback_flags; + (void) trans_rollback_stmt(thd); + thd->transaction->stmt.m_unsafe_rollback_flags= + save_unsafe_rollback_flags; + } + + (void) delete_statistics_for_table(thd, &db, &table_name); + + /* Remove normal table without logging. Keep tables locked */ + if (mysql_rm_table_no_locks(thd, &table_list, &thd->db, + ddl_log_state_rm, + 0, 0, 0, 0, 1, 1)) + goto err; + + debug_crash_here("ddl_log_create_after_drop"); + + /* + We have to log this query, even if it failed later to ensure the + drop is done. + */ + thd->variables.option_bits|= OPTION_BINLOG_THIS; + create_info->table_was_deleted= 1; + lex_string_set(&create_info->org_storage_engine_name, + ha_resolve_storage_engine_name(db_type)); + DBUG_EXECUTE_IF("send_kill_after_delete", + thd->set_killed(KILL_QUERY);); + /* + Restart statement transactions for the case of CREATE ... SELECT. + */ + if (thd->lex->first_select_lex()->item_list.elements && + restart_trans_for_tables(thd, thd->lex->query_tables)) + goto err; } - /* Remove normal table without logging. Keep tables locked */ - if (mysql_rm_table_no_locks(thd, &table_list, &thd->db, - ddl_log_state_rm, - 0, 0, 0, 0, 1, 1)) - goto err; + else + { + /* Rename the conflicting table to a temporary table name */ + bool force_if_exists= 0, tmp_error; + rename_param param; + MDL_request mdl_request; + partition_info *save_part_info; + + create_info->org_hton= db_type; + if (!(create_info->tmp_name.str= thd->alloc(64))) + goto err; - debug_crash_here("ddl_log_create_after_drop"); + create_info->tmp_name.length= 64; + make_tmp_table_name(thd, (LEX_STRING*) &create_info->tmp_name, + "create"); - /* - We have to log this query, even if it failed later to ensure the - drop is done. - */ - thd->variables.option_bits|= OPTION_BINLOG_THIS; - create_info->table_was_deleted= 1; - lex_string_set(&create_info->org_storage_engine_name, - ha_resolve_storage_engine_name(db_type)); - DBUG_EXECUTE_IF("send_kill_after_delete", - thd->set_killed(KILL_QUERY);); - /* - Restart statement transactions for the case of CREATE ... SELECT. - */ - if (thd->lex->first_select_lex()->item_list.elements && - restart_trans_for_tables(thd, thd->lex->query_tables)) - goto err; + param.new_alias= Lex_ident_table(create_info->tmp_name); + if (lower_case_table_names == 2) + param.old_alias= table_list.alias; + else + param.old_alias= table_list.table_name; + param.from_table_hton= db_type; + + param.rename_flags= FN_TO_IS_TMP; + + tmp_table.db= table_list.db; + tmp_table.table_name= param.old_alias; + + if (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + if (wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED)) + goto err; + + close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); + table= 0; + } + + /* Check we have an exclusive lock on the table to be dropped. */ + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db.str, + table_name.str, + MDL_EXCLUSIVE)); + /* + Create an exclusive lock on the temporary table name. + during the rename. As the name is unique this should + never fail. + */ + MDL_REQUEST_INIT(&mdl_request, MDL_key::TABLE, + db.str, create_info->tmp_name.str, + MDL_EXCLUSIVE, MDL_EXPLICIT); + thd->mdl_context.acquire_lock(&mdl_request, 0); + + /* + We have to reset partition_info from the CREATE TABLE as + open_table() uses it to check how the table is partitioned. + */ + save_part_info= thd->lex->part_info; + thd->lex->part_info= 0; + tmp_error= do_rename(thd, ¶m, ddl_log_state_create, &tmp_table, + &tmp_table.db, 0, &force_if_exists); + thd->lex->part_info= save_part_info; + if (mdl_request.ticket) + thd->mdl_context.release_lock(mdl_request.ticket); + if (tmp_error) + goto err; // error is already set + + create_info->table_was_renamed= 1; + thd->variables.option_bits|= OPTION_BINLOG_THIS; + } } else if (options.if_not_exists()) { @@ -4908,7 +5327,8 @@ int create_table_impl(THD *thd, goto err; } - init_tmp_table_share(thd, &share, db.str, 0, table_name.str, path.str, true); + init_tmp_table_share(thd, &share, db.str, 0, table_name.str, path.str, + true); /* prepare everything for discovery */ share.field= &no_fields; @@ -4985,6 +5405,8 @@ int create_table_impl(THD *thd, { file->ha_create_partitioning_metadata(path.str, NULL, CHF_DELETE_FLAG); deletefrm(path.str); + if (ddl_log_state_create) + ddl_log_add_flag(ddl_log_state_create, 1); // No drop table needed goto err; } debug_crash_here("ddl_log_create_after_create_table"); @@ -5014,11 +5436,19 @@ int create_table_impl(THD *thd, } error= 0; + create_info->table_was_created= 1; + err: - if (unlikely(error) && ddl_log_state_create) + if (unlikely(error)) { - /* Table was never created, so we can ignore the ddl log entry */ - ddl_log_complete(ddl_log_state_create); + if (ddl_log_state_create) + { + /* + Table was never created, so we can ignore the ddl log entry + Logging of an eventual drop is done by the caller + */ + ddl_log_revert(thd, ddl_log_state_create); + } } THD_STAGE_INFO(thd, stage_after_create); @@ -5036,14 +5466,14 @@ int create_table_impl(THD *thd, } /** - Simple wrapper around create_table_impl() to be used - in various version of CREATE TABLE statement. - - @result - 1 unspecified error - 2 error; Don't log create statement - 0 ok - -1 Table was used with IF NOT EXISTS and table existed (warning, not error) + Simple wrapper around create_table_impl() to be used + in various version of CREATE TABLE statement. + + @result + 1 unspecified error + 2 error; Don't log create statement + 0 ok + -1 Table was used with IF NOT EXISTS and table existed (warning, not error) */ int mysql_create_table_no_lock(THD *thd, DDL_LOG_STATE *ddl_log_state_create, @@ -5070,7 +5500,7 @@ int mysql_create_table_no_lock(THD *thd, DDL_LOG_STATE *ddl_log_state_create, const LEX_CSTRING *alias= table_case_name(create_info, table_name); path_length= build_table_filename(path, sizeof(path) - 1, db->str, alias->str, - "", 0); + "", 0); // Check if we hit FN_REFLEN bytes along with file extension. if (path_length+reg_ext_length > FN_REFLEN) { @@ -5097,117 +5527,100 @@ int mysql_create_table_no_lock(THD *thd, DDL_LOG_STATE *ddl_log_state_create, res= sequence_insert(thd, thd->lex, table_list); if (res) { + DBUG_ASSERT(thd->is_error()); - /* - Drop the new table, we were not completely done. - Temporarily modify table_list to avoid dropping source sequence - in CREATE TABLE LIKE . - */ - TABLE_LIST *tail= table_list->next_local; - table_list->next_local= NULL; - /* Drop the table as it wasn't completely done */ - if (!mysql_rm_table_no_locks(thd, table_list, &thd->db, - (DDL_LOG_STATE*) 0, - 1, - create_info->tmp_table(), - false, true /* Sequence*/, - true /* Don't log_query */, - true /* Don't free locks */ )) - { - /* - From the user point of view, the table creation failed - We return 2 to indicate that this statement doesn't have - to be logged. - */ - res= 2; - } - table_list->next_local= tail; + /* Drop the new table and rename back old renamed table if used */ + ddl_log_revert(thd, ddl_log_state_create); + create_info->table_was_created= 0; } } - return res; } + #ifdef WITH_WSREP -/** Additional sequence checks for Galera cluster. +/** + Additional sequence checks for Galera cluster. -@param thd thread handle -@param seq sequence definition -@param used_engine create used ENGINE= -@retval false success -@retval true failure + @param thd thread handle + @param seq sequence definition + @param used_engine create used ENGINE= + @retval false success + @retval true failure */ + bool wsrep_check_sequence(THD* thd, const sequence_definition *seq, const bool used_engine) { - enum legacy_db_type db_type; - const LEX_CSTRING *engine_name; + enum legacy_db_type db_type; + const LEX_CSTRING *engine_name; - DBUG_ASSERT(WSREP(thd)); + DBUG_ASSERT(WSREP(thd)); - if (used_engine) - { - db_type= thd->lex->create_info.db_type->db_type; - // Currently any dynamic storage engine is not possible to identify - // using DB_TYPE_XXXX and ENGINE=SEQUENCE is one of them. - // Therefore, we get storage engine name from lex. - engine_name= - thd->lex->m_sql_cmd->option_storage_engine_name()->name(); - } - else - { - const handlerton *hton= ha_default_handlerton(thd); - db_type= hton->db_type; - engine_name= hton_name(hton); - } - - // In Galera cluster we support only InnoDB sequences - if (db_type != DB_TYPE_INNODB) - { - // (1) CREATE TABLE ... ENGINE=SEQUENCE OR - // (2) ALTER TABLE ... ENGINE= OR - // Note in ALTER TABLE table->s->sequence != nullptr - // (3) CREATE SEQUENCE ... ENGINE= - if ((thd->lex->sql_command == SQLCOM_CREATE_TABLE && - lex_string_eq(engine_name, STRING_WITH_LEN("SEQUENCE"))) || - (thd->lex->sql_command == SQLCOM_ALTER_TABLE) || - (thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE)) - { - my_error(ER_NOT_SUPPORTED_YET, MYF(0), - "non-InnoDB sequences in Galera cluster"); - push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, - ER_NOT_SUPPORTED_YET, - "ENGINE=%s not supported by Galera", - engine_name->str); - return(true); - } - } + if (used_engine) + { + db_type= thd->lex->create_info.db_type->db_type; + // Currently any dynamic storage engine is not possible to identify + // using DB_TYPE_XXXX and ENGINE=SEQUENCE is one of them. + // Therefore, we get storage engine name from lex. + engine_name= + thd->lex->m_sql_cmd->option_storage_engine_name()->name(); + } + else + { + const handlerton *hton= ha_default_handlerton(thd); + db_type= hton->db_type; + engine_name= hton_name(hton); + } - // In Galera cluster it is best to use INCREMENT BY 0 with CACHE - // or NOCACHE - if (seq && - seq->increment && - seq->cache) + // In Galera cluster we support only InnoDB sequences + if (db_type != DB_TYPE_INNODB) + { + // (1) CREATE TABLE ... ENGINE=SEQUENCE OR + // (2) ALTER TABLE ... ENGINE= OR + // Note in ALTER TABLE table->s->sequence != nullptr + // (3) CREATE SEQUENCE ... ENGINE= + if ((thd->lex->sql_command == SQLCOM_CREATE_TABLE && + lex_string_eq(engine_name, STRING_WITH_LEN("SEQUENCE"))) || + (thd->lex->sql_command == SQLCOM_ALTER_TABLE) || + (thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE)) { my_error(ER_NOT_SUPPORTED_YET, MYF(0), - "CACHE without INCREMENT BY 0 in Galera cluster"); + "non-InnoDB sequences in Galera cluster"); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_NOT_SUPPORTED_YET, + "ENGINE=%s not supported by Galera", + engine_name->str); return(true); } + } + + // In Galera cluster it is best to use INCREMENT BY 0 with CACHE + // or NOCACHE + if (seq && + seq->increment && + seq->cache) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "CACHE without INCREMENT BY 0 in Galera cluster"); + return(true); + } - return (false); + return (false); } + /** Additional CREATE TABLE/SEQUENCE checks for Galera cluster. -@param thd thread handle -@param wsrep_ctas CREATE TABLE AS SELECT ? -@param used_engine CREATE TABLE ... ENGINE = ? -@param create_info Create information + @param thd thread handle + @param wsrep_ctas CREATE TABLE AS SELECT ? + @param used_engine CREATE TABLE ... ENGINE = ? + @param create_info Create information -@retval false Galera cluster does support used clause -@retval true Galera cluster does not support used clause + @retval false Galera cluster does support used clause + @retval true Galera cluster does not support used clause */ static bool wsrep_check_support(THD* thd, @@ -5241,8 +5654,8 @@ bool wsrep_check_support(THD* thd, only InnoDB-sequences. */ if (((used_engine && create_info->db_type && - (create_info->db_type->db_type == DB_TYPE_SEQUENCE || - create_info->db_type->db_type >= DB_TYPE_FIRST_DYNAMIC)) || + (create_info->db_type->db_type == DB_TYPE_SEQUENCE || + create_info->db_type->db_type >= DB_TYPE_FIRST_DYNAMIC)) || thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE) && wsrep_check_sequence(thd, create_info->seq_create_info, used_engine)) return true; @@ -5252,13 +5665,13 @@ bool wsrep_check_support(THD* thd, #endif /* WITH_WSREP */ /** - Implementation of SQLCOM_CREATE_TABLE. + Implementation of SQLCOM_CREATE_TABLE. - Take the metadata locks (including a shared lock on the affected - schema) and create the table. Is written to be called from - mysql_execute_command(), to which it delegates the common parts - with other commands (i.e. implicit commit before and after, - close of thread tables. + Take the metadata locks (including a shared lock on the affected + schema) and create the table. Is written to be called from + mysql_execute_command(), to which it delegates the common parts + with other commands (i.e. implicit commit before and after, + close of thread tables. */ @@ -5267,13 +5680,11 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, Table_specification_st *create_info, Alter_info *alter_info) { - TABLE_LIST *pos_in_locked_tables= 0; - MDL_ticket *mdl_ticket= 0; DDL_LOG_STATE ddl_log_state_create, ddl_log_state_rm; int create_table_mode; uint save_thd_create_info_options; bool is_trans= FALSE; - bool result; + int result; DBUG_ENTER("mysql_create_table"); DBUG_ASSERT(create_info->default_table_charset); @@ -5282,12 +5693,17 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + create_info->ddl_log_state_create= &ddl_log_state_create; + create_info->ddl_log_state_rm= &ddl_log_state_rm; /* Copy temporarily the statement flags to thd for lock_table_names() */ save_thd_create_info_options= thd->lex->create_info.options; thd->lex->create_info.options|= create_info->options; - /* Open or obtain an exclusive metadata lock on table being created */ + /* + Obtain an exclusive metadata lock on table being created. + Table is not opened. + */ create_table->db_type= 0; result= open_and_lock_tables(thd, *create_info, create_table, FALSE, 0); @@ -5309,8 +5725,9 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, /* The following is needed only in case of lock tables */ if ((create_info->table= create_table->table)) { - pos_in_locked_tables= create_info->table->pos_in_locked_tables; - mdl_ticket= create_table->table->mdl_ticket; + create_info->pos_in_locked_tables= + create_info->table->pos_in_locked_tables; + create_info->mdl_ticket= create_table->table->mdl_ticket; } /* Got lock. */ @@ -5327,89 +5744,31 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, /* We can abort create table for any table type */ thd->abort_on_warning= thd->is_strict_mode(); - if (mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm, - create_info, alter_info, &is_trans, - create_table_mode, create_table) > 0) - { - result= 1; - goto err; - } - - /* - Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES - on a non temporary table - */ - if (thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) - { - DBUG_ASSERT(thd->variables.option_bits & OPTION_TABLE_LOCK); - /* - Add back the deleted table and re-created table as a locked table - This should always work as we have a meta lock on the table. - */ - thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - if (thd->locked_tables_list.reopen_tables(thd, false)) - { - thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); - result= 1; - goto err; - } - else - { - TABLE *table= pos_in_locked_tables->table; - table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); - } - } - -err: + result= mysql_create_table_no_lock(thd, &ddl_log_state_create, + &ddl_log_state_rm, + create_info, alter_info, &is_trans, + create_table_mode, create_table); thd->abort_on_warning= 0; +err: /* In RBR or readonly server we don't need to log CREATE TEMPORARY TABLE */ if (!result && create_info->tmp_table() && !thd->binlog_create_tmp_table()) { /* - Note that mark_created_temp_table was not called and thus - table->s->table_creation_was_logged is not set! + The newly created temporary table is not logged. + Note that table->s->table_creation_was_logged is not set! */ - DBUG_RETURN(result); + goto end; } - if (create_info->tmp_table()) - thd->transaction->stmt.mark_created_temp_table(); - - /* Write log if no error or if we already deleted a table */ - if (!result || thd->log_current_statement()) + if (!result) + result= create_info->finalize_create_table(thd, create_table, + thd->query(), + thd->query_length(), + is_trans); + create_info->end_create_table(thd, create_table, result); + if (!result) { - if (unlikely(result) && create_info->table_was_deleted && - pos_in_locked_tables) - { - /* - Possible locked table was dropped. We should remove meta data locks - associated with it and do UNLOCK_TABLES if no more locked tables. - */ - (void) thd->locked_tables_list.unlock_locked_table(thd, mdl_ticket); - } - else if (likely(!result) && create_info->table) - { - /* - Remember that table creation was logged so that we know if - we should log a delete of it. - If create_info->table was not set, it's a normal table and - table_creation_was_logged will be set when the share is created. - */ - create_info->table->s->table_creation_was_logged= 1; - } - thd->binlog_xid= thd->query_id; - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active()) - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); - if (unlikely(write_bin_log(thd, result ? FALSE : TRUE, thd->query(), - thd->query_length(), is_trans))) - result= 1; - debug_crash_here("ddl_log_create_after_binlog"); - thd->binlog_xid= 0; - if (!create_info->tmp_table()) { backup_log_info ddl_log; @@ -5423,9 +5782,13 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, backup_log_ddl(&ddl_log); } } - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); - DBUG_RETURN(result); + +end: + /* result is < 0 if table existed and was not replaced */ + if (create_info->pos_in_locked_tables && result >= 0) + result|= create_info->finalize_locked_tables(thd, result); + + DBUG_RETURN(result > 0); } @@ -5550,7 +5913,8 @@ bool operator!=(const MYSQL_TIME &lhs, const MYSQL_TIME &rhs) bool mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, const LEX_CSTRING *old_name, const LEX_CSTRING *new_db, - const LEX_CSTRING *new_name, const LEX_CUSTRING *id, uint flags) + const LEX_CSTRING *new_name, const LEX_CUSTRING *id, + uint flags) { THD *thd= current_thd; char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN]; @@ -5727,21 +6091,24 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, Table_specification_st *create_info) { Table_specification_st local_create_info; - TABLE_LIST *pos_in_locked_tables= 0; Alter_info local_alter_info; Alter_table_ctx local_alter_ctx; // Not used DDL_LOG_STATE ddl_log_state_create, ddl_log_state_rm; + char buf[2048]; + String query(buf, sizeof(buf), system_charset_info); + int res= 1; bool is_trans= FALSE; bool do_logging= FALSE; bool force_generated_create= false; - bool src_table_exists= FALSE; + bool table_was_created= false; uint not_used; int create_res; DBUG_ENTER("mysql_create_like_table"); bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); + query.length(0); // Have to zero it since constructor doesn't #ifdef WITH_WSREP if (WSREP(thd) && !thd->wsrep_applier && @@ -5770,8 +6137,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, { /* is_error() may be 0 if table existed and we generated a warning */ res= thd->is_error(); - src_table_exists= !res; - goto err; + DBUG_RETURN(res); } /* Ensure we don't try to create something from which we select from */ if (create_info->or_replace() && !create_info->tmp_table()) @@ -5780,8 +6146,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if ((duplicate= unique_table(thd, table, src_table, 0))) { update_non_unique_table_error(src_table, "CREATE", duplicate); - res= 1; - goto err; + DBUG_RETURN(1); } } @@ -5790,7 +6155,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, DEBUG_SYNC(thd, "create_table_like_after_open"); /* - Fill Table_specification_st and Alter_info with the source table description. + Fill Table_specification_st and Alter_info with the source table + description. Set OR REPLACE and IF NOT EXISTS option as in the CREATE TABLE LIKE statement. */ @@ -5798,6 +6164,9 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, local_create_info.db_type= src_table->table->s->db_type(); local_create_info.row_type= src_table->table->s->row_type; local_create_info.alter_info= &local_alter_info; + local_create_info.ddl_log_state_create= &ddl_log_state_create; + local_create_info.ddl_log_state_rm= &ddl_log_state_rm; + /* This statement: CREATE TABLE t1 LIKE t2 @@ -5806,8 +6175,9 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ DBUG_ASSERT(create_info->default_charset_collation.is_empty()); DBUG_ASSERT(create_info->convert_charset_collation.is_empty()); - if (mysql_prepare_alter_table(thd, src_table->table, &local_create_info, - &local_alter_info, &local_alter_ctx)) + if ((res= mysql_prepare_alter_table(thd, src_table->table, + &local_create_info, + &local_alter_info, &local_alter_ctx))) goto err; #ifdef WITH_PARTITION_STORAGE_ENGINE /* Partition info is not handled by mysql_prepare_alter_table() call. */ @@ -5843,15 +6213,21 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, local_create_info.data_file_name= local_create_info.index_file_name= NULL; if (src_table->table->versioned() && - local_create_info.vers_info.fix_create_like(local_alter_info, local_create_info, + local_create_info.vers_info.fix_create_like(local_alter_info, + local_create_info, *src_table, *table)) { + res= 1; goto err; } /* The following is needed only in case of lock tables */ if ((local_create_info.table= thd->lex->query_tables->table)) - pos_in_locked_tables= local_create_info.table->pos_in_locked_tables; + { + local_create_info.pos_in_locked_tables= + local_create_info.table->pos_in_locked_tables; + local_create_info.mdl_ticket= local_create_info.table->mdl_ticket; + } res= ((create_res= mysql_create_table_no_lock(thd, @@ -5861,37 +6237,18 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, table)) > 0); /* Remember to log if we deleted something */ do_logging= thd->log_current_statement(); - if (res) + if (create_res) goto err; + table_was_created= 1; + if (!create_info->tmp_table()) + table->table= 0; // Original table is closed. /* Check if we are doing CREATE OR REPLACE TABLE under LOCK TABLES on a non temporary table */ - if (thd->locked_tables_mode && pos_in_locked_tables && - create_info->or_replace()) - { - /* - Add back the deleted table and re-created table as a locked table - This should always work as we have a meta lock on the table. - */ - thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - if (thd->locked_tables_list.reopen_tables(thd, false)) - { - thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); - res= 1; // We got an error - } - else - { - /* - Get pointer to the newly opened table. We need this to ensure we - don't reopen the table when doing statement logging below. - */ - table->table= pos_in_locked_tables->table; - table->table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE); - } - } - else + if (!(thd->locked_tables_mode && local_create_info.pos_in_locked_tables && + create_info->or_replace())) { /* Ensure that we have an exclusive lock on target table if we are creating @@ -5902,7 +6259,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str, table->table_name.str, MDL_EXCLUSIVE) || - (thd->locked_tables_mode && pos_in_locked_tables && + (thd->locked_tables_mode && + local_create_info.pos_in_locked_tables && create_info->if_not_exists())); } @@ -5930,8 +6288,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, #endif /* - If src table was a temporary table that was not replicated we have to write the - full table definition to the binary log. + If src table was a temporary table that was not replicated we have + to write the full table definition to the binary log. */ force_generated_create|= !src_table->table->s->table_creation_was_logged; @@ -5960,9 +6318,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, // Case 2 & 5 if (src_table->table->s->tmp_table || force_generated_create) { - char buf[2048]; - String query(buf, sizeof(buf), system_charset_info); - query.length(0); // Have to zero it since constructor doesn't Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN | MYSQL_OPEN_IGNORE_KILLED); bool new_table= FALSE; // Whether newly created table is open. @@ -5976,13 +6331,23 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, do_logging= 0; goto err; } + + /* In case of locked tables */ + if (local_create_info.pos_in_locked_tables) + { + res= local_create_info.finalize_locked_tables(thd, 0); + local_create_info.pos_in_locked_tables= 0; + if (res) + goto err; + } + if (!table->table) { if (local_create_info.table) { /* - The table was a temporary table or a generated table. Use the src as - the table definition. + The table was a temporary table or a generated table. Use the + src as the table definition. */ table->table= local_create_info.table; } @@ -6025,7 +6390,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, statement generation by the binary log. Note that placeholders don't have the handler open. */ - if (table->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST)) + if ((res= table->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST))) goto err; /* @@ -6034,18 +6399,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ create_info->used_fields|= HA_CREATE_USED_ENGINE; - int result __attribute__((unused))= - show_create_table(thd, table, &query, create_info, WITH_DB_NAME); - - DBUG_ASSERT(result == 0); // show_create_table() always return 0 - do_logging= FALSE; - if (write_bin_log(thd, TRUE, query.ptr(), query.length())) - { - res= 1; + res= show_create_table(thd, table, &query, create_info, + WITH_DB_NAME); + if (res) goto err; - } - if (local_create_info.table && thd->tmp_table_binlog_handled) - local_create_info.table->s->table_creation_was_logged= 1; + do_logging= TRUE; if (new_table) { @@ -6074,13 +6432,13 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if (create_info->tmp_table()) { thd->transaction->stmt.mark_created_temp_table(); + if (!res && local_create_info.table && thd->binlog_create_tmp_table()) { /* Remember that tmp table creation was logged so that we know if we should log a delete of it. */ - local_create_info.table->s->table_creation_was_logged= 1; do_logging= TRUE; } } @@ -6091,35 +6449,25 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, err: if (do_logging) { - thd->binlog_xid= thd->query_id; - ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); - if (ddl_log_state_rm.is_active()) - ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - debug_crash_here("ddl_log_create_before_binlog"); - if (res && create_info->table_was_deleted) - { - /* - Table was not deleted. Original table was deleted. - We have to log it. - */ - DBUG_ASSERT(ddl_log_state_rm.is_active()); - log_drop_table(thd, &table->db, &table->table_name, - &create_info->org_storage_engine_name, - create_info->db_type == partition_hton, - &create_info->org_tabledef_version, - create_info->tmp_table()); - } - else if (res != 2) // Table was not dropped + if (!res) { - if (write_bin_log(thd, res ? FALSE : TRUE, thd->query(), - thd->query_length(), is_trans)) - res= 1; + LEX_CSTRING bin_query; + if (!query.length()) + bin_query= { thd->query(), thd->query_length() }; + else + bin_query= { query.ptr(), query.length() }; + + res= local_create_info.finalize_create_table(thd, table, + bin_query.str, + bin_query.length, + is_trans); } - debug_crash_here("ddl_log_create_after_binlog"); - thd->binlog_xid= 0; + local_create_info.end_create_table(thd, table, res); } + ddl_log_complete(&ddl_log_state_create); + ddl_log_complete(&ddl_log_state_rm); - if (!res && !src_table_exists && !create_info->tmp_table()) + if (!res && table_was_created && !create_info->tmp_table()) { backup_log_info ddl_log; bzero(&ddl_log, sizeof(ddl_log)); @@ -6131,8 +6479,10 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, backup_log_ddl(&ddl_log); } - ddl_log_complete(&ddl_log_state_rm); - ddl_log_complete(&ddl_log_state_create); + if (local_create_info.pos_in_locked_tables && + local_create_info.or_replace()) + res|= (int) local_create_info.finalize_locked_tables(thd, res); + DBUG_RETURN(res != 0); } @@ -6146,6 +6496,7 @@ int mysql_discard_or_import_tablespace(THD *thd, int error; TABLE *table; enum_mdl_type mdl_downgrade= MDL_NOT_INITIALIZED; + bool binlog_error= 0; DBUG_ENTER("mysql_discard_or_import_tablespace"); mysql_audit_alter_table(thd, table_list); @@ -6230,10 +6581,16 @@ int mysql_discard_or_import_tablespace(THD *thd, if (unlikely(trans_commit_implicit(thd))) error=1; if (likely(!error)) + { error= write_bin_log(thd, FALSE, thd->query(), thd->query_length()); + if (error) + binlog_error= 1; + } err: thd->tablespace_op=FALSE; + thd->tmp_table_binlog_handled= !binlog_error; + if (mdl_downgrade > MDL_NOT_INITIALIZED) table->mdl_ticket->downgrade_lock(mdl_downgrade); @@ -6245,7 +6602,6 @@ int mysql_discard_or_import_tablespace(THD *thd, } table->file->print_error(error, MYF(0)); - DBUG_RETURN(-1); } @@ -7962,10 +8318,12 @@ static bool notify_tabledef_changed(TABLE_LIST *table_list) tmp_db.str= db_buff; tmp_table.str= table_buff; - tmp_db.length= tablename_to_filename(table_list->db.str, - db_buff, sizeof(db_buff)); - tmp_table.length= tablename_to_filename(table_list->table_name.str, - table_buff, sizeof(table_buff)); + tmp_db.length= + tablename_to_filename_internal(table_list->db.str, db_buff, + sizeof(db_buff)); + tmp_table.length= + tablename_to_filename_internal(table_list->table_name.str, table_buff, + sizeof(table_buff)); if ((hton->notify_tabledef_changed)(hton, &tmp_db, &tmp_table, table->s->frm_image, &table->s->tabledef_version, @@ -8051,7 +8409,7 @@ write_bin_log_start_alter_rollback(THD *thd, uint64 &start_alter_id, { // Send the rollback message Write_log_with_flags wlwf(thd, Gtid_log_event::FL_ROLLBACK_ALTER_E1); - if(write_bin_log_with_if_exists(thd, false, false, if_exists, false)) + if(write_bin_log_with_if_exists(thd, false, false, if_exists, false) > 0) return true; partial_alter= false; } @@ -10201,7 +10559,7 @@ simple_tmp_rename_or_index_change(THD *thd, TABLE_LIST *table_list, binary log. */ if (table->s->table_creation_was_logged) - error= write_bin_log(thd, true, thd->query(), thd->query_length()) != 0; + error= write_bin_log(thd, true, thd->query(), thd->query_length()); if (likely(!error)) my_ok(thd); } @@ -10310,7 +10668,8 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list, (void) ddl_log_rename_table(&ddl_log_state, old_db_type, &alter_ctx->db, &alter_ctx->table_name, - &alter_ctx->new_db, &alter_ctx->new_alias); + &alter_ctx->new_db, &alter_ctx->new_alias, + DDL_RENAME_PHASE_TABLE, 0); if (mysql_rename_table(old_db_type, &alter_ctx->db, &alter_ctx->table_name, &alter_ctx->new_db, &alter_ctx->new_alias, &table_version, QRMT_DEFAULT)) @@ -11319,7 +11678,7 @@ do_continue:; /* We don't replicate alter table statement on temporary tables */ if (table_creation_was_logged) { - if (write_bin_log_with_if_exists(thd, true, false, log_if_exists)) + if (write_bin_log_with_if_exists(thd, true, false, log_if_exists) > 0) DBUG_RETURN(true); } @@ -12093,9 +12452,9 @@ do_continue:; ddl_log_update_xid(&ddl_log_state, thd->binlog_xid); tmp_error= write_bin_log_with_if_exists(thd, true, false, log_if_exists); thd->binlog_xid= 0; - if (tmp_error) + if (tmp_error > 0) goto err_cleanup; - new_table->s->table_creation_was_logged= 1; + new_table->s->table_creation_was_logged= tmp_error == 0; } goto end_temporary; } @@ -12348,7 +12707,7 @@ do_continue:; tmp_error= write_bin_log_with_if_exists(thd, true, false, log_if_exists, partial_alter); thd->binlog_xid= 0; - if (tmp_error) + if (tmp_error > 0) goto err_cleanup; } diff --git a/sql/sql_table.h b/sql/sql_table.h index 3a27204f2c45b..a6d703049dd58 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -206,12 +206,24 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db, const char *table_path=0); void close_cached_table(THD *thd, TABLE *table); bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags); -int write_bin_log(THD *thd, bool clear_error, - char const *query, ulong query_length, - bool is_trans= FALSE); + +int write_bin_log_with_stat(THD *thd, bool clear_error, + char const *query, ulong query_length, + bool is_trans= FALSE); int write_bin_log_with_if_exists(THD *thd, bool clear_error, bool is_trans, bool add_if_exists, bool commit_alter= false); +/* + Write to binlog, but return true only if write failed +*/ +inline bool write_bin_log(THD *thd, bool clear_error, + char const *query, ulong query_length, + bool is_trans= FALSE) +{ + int res= write_bin_log_with_stat(thd, clear_error, query, query_length, + is_trans); + return res <= 0 ? false : true; +} void promote_first_timestamp_column(List *column_definitions); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index d0a96ba5a7501..e95b79bccf02b 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1297,9 +1297,11 @@ bool Trigger::match_updatable_columns(List &fields) */ static bool rm_trigger_file(char *path, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, myf MyFlags) + const LEX_CSTRING *table_name, uint flags, + myf MyFlags) { - 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); } @@ -1341,7 +1343,8 @@ bool rm_trigname_file(char *path, const LEX_CSTRING *db, */ bool Table_triggers_list::save_trigger_file(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name) + const LEX_CSTRING *table_name, + uint flags) { char file_buff[FN_REFLEN]; LEX_CSTRING file; @@ -1351,7 +1354,7 @@ bool Table_triggers_list::save_trigger_file(THD *thd, const LEX_CSTRING *db, DBUG_RETURN(true); file.length= build_table_filename(file_buff, FN_REFLEN - 1, db->str, table_name->str, - TRG_EXT, 0); + TRG_EXT, flags); file.str= file_buff; DBUG_RETURN(sql_create_definition_file(NULL, &file, &triggers_file_type, (uchar*) this, @@ -1483,12 +1486,12 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables, drop or create ddl_log recovery will ensure that all related trigger files are deleted or the original ones are restored. */ - if (rm_trigger_file(path, &tables->db, &tables->table_name, MYF(MY_WME))) + if (rm_trigger_file(path, &tables->db, &tables->table_name, 0, MYF(MY_WME))) goto err; } else { - if (save_trigger_file(thd, &tables->db, &tables->table_name)) + if (save_trigger_file(thd, &tables->db, &tables->table_name, 0)) goto err; } @@ -1721,7 +1724,7 @@ copy_on_update_columns_list(MEM_ROOT *table_mem_root, 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; @@ -1730,7 +1733,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 ? @@ -2002,8 +2005,10 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, DBUG_ASSERT((lex.query_tables->db.streq(*db) || (check_n_cut_mysql50_prefix(db->str, fname, sizeof(fname)) && lex.query_tables->db.streq(Lex_cstring_strlen(fname))))); - DBUG_ASSERT((lex.query_tables->table_name.streq(*table_name) || - (check_n_cut_mysql50_prefix(table_name->str, fname, sizeof(fname)) && + DBUG_ASSERT((flags & FN_IS_TMP) || + (lex.query_tables->table_name.streq(*table_name) || + (check_n_cut_mysql50_prefix(table_name->str, fname, + sizeof(fname)) && lex.query_tables->table_name. streq(Lex_cstring_strlen(fname))))); #endif @@ -2280,7 +2285,7 @@ bool add_table_for_trigger(THD *thd, bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *name, - myf MyFlags) + uint flags, myf MyFlags) { TABLE table; char path[FN_REFLEN]; @@ -2291,11 +2296,11 @@ 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)) + if (Table_triggers_list::check_n_load(thd, db, name, &table, true, 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, flags, MyFlags); goto end; } if (table.triggers) @@ -2329,7 +2334,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, flags, MyFlags)) result= 1; delete table.triggers; } @@ -2387,12 +2392,12 @@ change_table_name_in_triggers(THD *thd, if (unlikely(thd->is_fatal_error)) return TRUE; /* OOM */ - if (save_trigger_file(thd, new_db_name, new_table_name)) + if (save_trigger_file(thd, new_db_name, new_table_name, 0)) return TRUE; - if (rm_trigger_file(path_buff, old_db_name, old_table_name, MYF(MY_WME))) + if (rm_trigger_file(path_buff, old_db_name, old_table_name, 0, MYF(MY_WME))) { - (void) rm_trigger_file(path_buff, new_db_name, new_table_name, + (void) rm_trigger_file(path_buff, new_db_name, new_table_name, 0, MYF(MY_WME)); return TRUE; } @@ -2535,6 +2540,7 @@ Table_triggers_list::prepare_for_rename(THD *thd, TABLE *table= ¶m->table; bool result= 0; DBUG_ENTER("Table_triggers_lists::prepare_change_table_name"); + DBUG_ASSERT(!param->rename_flags); init_sql_alloc(key_memory_Table_trigger_dispatcher, &table->mem_root, 8192, 0, MYF(0)); @@ -2542,7 +2548,8 @@ Table_triggers_list::prepare_for_rename(THD *thd, DBUG_ASSERT(!db.streq(new_db) || !old_alias.streq(new_table)); - if (Table_triggers_list::check_n_load(thd, &db, &old_table, table, TRUE)) + if (Table_triggers_list::check_n_load(thd, &db, &old_table, table, TRUE, + param->rename_flags)) { result= 1; goto end; @@ -2668,6 +2675,37 @@ bool Table_triggers_list::change_table_name(THD *thd, } + +/* + Rename the trigger file (.TRG) if it exists + + This is used to mainly to backup and restore a trigger file + as part of CREATE OR REPLACE +*/ + +bool Table_triggers_list::rename_trigger_file(THD *thd, + const LEX_CSTRING *old_db, + const LEX_CSTRING *old_tab, + const LEX_CSTRING *new_db, + const LEX_CSTRING *new_tab, + uint flags) +{ + char old_file[FN_REFLEN], new_file[FN_REFLEN]; + + build_table_filename(old_file, sizeof(old_file)-1, + old_db->str, old_tab->str, TRG_EXT, + flags & FN_FROM_IS_TMP); + + if (access(old_file, F_OK)) + return 0; // .TRG file did not exists + + build_table_filename(new_file, sizeof(new_file)-1, + new_db->str, new_tab->str, TRG_EXT, + flags & FN_TO_IS_TMP); + return my_rename(old_file, new_file, MYF(MY_WME)); +} + + /** Check that a BEFORE trigger has raised the signal to inform that a current row being processed must be skipped. diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index f9adfaa32a2b2..1b017c43192de 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -125,10 +125,12 @@ class TRIGGER_RENAME_PARAM TABLE table; bool upgrading50to51; bool got_error; + int rename_flags; TRIGGER_RENAME_PARAM() { upgrading50to51= got_error= 0; + rename_flags= 0; table.reset(); } ~TRIGGER_RENAME_PARAM() @@ -320,12 +322,15 @@ class Table_triggers_list: public Sql_alloc List *fields_in_update_stmt= nullptr); void empty_lists(); bool create_lists_needed_for_files(MEM_ROOT *root); - bool save_trigger_file(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name); + bool save_trigger_file(THD *thd, const LEX_CSTRING *db, + const LEX_CSTRING *table_name, uint flags); - static bool check_n_load(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, - TABLE *table, bool names_only); + static bool check_n_load(THD *thd, const LEX_CSTRING *db, + const LEX_CSTRING *table_name, + TABLE *table, bool names_only, uint flags); static bool drop_all_triggers(THD *thd, const LEX_CSTRING *db, - const LEX_CSTRING *table_name, myf MyFlags); + const LEX_CSTRING *table_name, uint flags, + myf MyFlags); static bool prepare_for_rename(THD *thd, TRIGGER_RENAME_PARAM *param, const Lex_ident_db &db, const Lex_ident_table &old_alias, @@ -343,11 +348,17 @@ class Table_triggers_list: public Sql_alloc trigger_order_type ordering_clause, const Lex_ident_trigger &anchor_trigger_name, Trigger *trigger); - void add_trigger(trg_event_type event_type, + void add_trigger(trg_event_type event_type, trg_action_time_type action_time, trigger_order_type ordering_clause, const Lex_ident_trigger &anchor_trigger_name, Trigger *trigger); + static bool rename_trigger_file(THD *thd, + const LEX_CSTRING *old_db, + const LEX_CSTRING *old_tab, + const LEX_CSTRING *new_db, + const LEX_CSTRING *new_tab, + uint flags); Trigger *get_trigger(trg_event_type event_type, trg_action_time_type action_time) { diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 0a773ba3cda7e..31271110aacba 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -569,7 +569,8 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) /* DDL is logged in statement format, regardless of binlog format. */ if (binlog_stmt) - error|= write_bin_log(thd, !error, thd->query(), thd->query_length()); + error|= MY_TEST(write_bin_log(thd, !error, thd->query(), + thd->query_length())); /* A locked table ticket was upgraded to a exclusive lock. After the diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7e321359b1c7e..fcf8da7fcdaf1 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4257,6 +4257,16 @@ static Sys_var_set Sys_new_behavior( NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_new_mode_var_value), 0, 0, new_mode_hidden_names); +static Sys_var_mybool Sys_drop_before_create_replace( + "drop_before_create_or_replace", + + "CREATE OR REPLACE should drop old tables before creating new ones. " + "If not set then old table will be temporarly renamed until create " + "table succeeeds. If create does not succeed the old table will be " + "renamed back", + SESSION_VAR(drop_before_create_or_replace), CMD_LINE(OPT_ARG), + DEFAULT(FALSE)); + #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #define SSL_OPT(X) CMD_LINE(REQUIRED_ARG,X) #else diff --git a/sql/table.h b/sql/table.h index 339ea2d968889..79b379003f03b 100644 --- a/sql/table.h +++ b/sql/table.h @@ -103,6 +103,12 @@ typedef ulonglong nested_join_map; #define TMP_TABLE_KEY_EXTRA 8 #define ROCKSDB_DIRECTORY_NAME "#rocksdb" +static inline bool is_tmp_table(const char *filename) +{ + return (filename[0] == '#' && + !strncmp(filename+1, tmp_file_prefix+1, tmp_file_prefix_length-1)); +} + #define HLINDEX_TEMPLATE "#i#%02u" #define HLINDEX_BUF_LEN 16 /* with extension .ibd/.MYI/etc and safety margin */ @@ -844,7 +850,7 @@ struct TABLE_SHARE enum Table_type table_type; enum tmp_table_type tmp_table; - /** Transactional or not. */ + /** Created transactional or not. */ enum ha_choice transactional; /** Per-page checksums or not. */ enum ha_choice page_checksum; diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index b8bf2c398fe68..a78d72c45a9c6 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -913,7 +913,8 @@ bool wsrep_trx_fragment_size_check (sys_var *self, THD* thd, set_var* var) return true; } - if (!ha_table_exists(thd, &WSREP_LEX_SCHEMA, &WSREP_LEX_STREAMING)) + if (!ha_table_exists(thd, &WSREP_LEX_SCHEMA, &WSREP_LEX_STREAMING, 0, + 0, 0, 0)) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WRONG_VALUE_FOR_VAR, @@ -965,7 +966,8 @@ bool wsrep_trx_fragment_unit_check (sys_var *self, THD* thd, set_var* var) return true; } - if (!ha_table_exists(thd, &WSREP_LEX_SCHEMA, &WSREP_LEX_STREAMING)) + if (!ha_table_exists(thd, &WSREP_LEX_SCHEMA, &WSREP_LEX_STREAMING, + 0, 0, 0, 0)) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WRONG_VALUE_FOR_VAR, diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6dc945b907eee..ce8b4590f8222 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4335,7 +4335,8 @@ static int innodb_init(void* p) HTON_WSREP_REPLICATION | HTON_REQUIRES_CLOSE_AFTER_TRUNCATE | HTON_TRUNCATE_REQUIRES_EXCLUSIVE_USE | - HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT; + HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT | + HTON_CHECK_NEEDED_FOR_CREATE_OR_REPLACE; #ifdef WITH_WSREP innobase_hton->abort_transaction=wsrep_abort_transaction; @@ -13844,7 +13845,7 @@ int ha_innobase::delete_table(const char *name) DBUG_RETURN(0); } - if (parent_trx->check_foreigns && + if (parent_trx->check_foreigns && ! table->name.is_create_or_replace() && delete_table_check_foreigns(*table, sqlcom)) { dict_sys.unlock(); @@ -14026,7 +14027,8 @@ int ha_innobase::delete_table(const char *name) if (!table->no_rollback()) { - if (trx->check_foreigns && delete_table_check_foreigns(*table, sqlcom)) + if (trx->check_foreigns && ! table->name.is_create_or_replace() && + delete_table_check_foreigns(*table, sqlcom)) { err= DB_CANNOT_DROP_CONSTRAINT; goto err_exit; diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 39149e970bb14..4eb15b9fc9ad1 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -453,6 +453,7 @@ class ha_innobase final : public handler @param ib_table InnoDB table definition @retval true if not errors were found */ bool check_index_consistency(const dict_table_t* ib_table) noexcept; + protected: bool can_convert_string(const Field_string* field, diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 5c830d850c088..b4285aa9c22e8 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10192,7 +10192,7 @@ innobase_update_foreign_cache( ib::error() << "Failed to load table " << table_name_t(const_cast(f)) - << " which has a foreign key constraint with" + << " which has a foreign key constraint with " << user_table->name; break; } diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index ed9cc8062189f..3f672783769ab 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -2189,14 +2189,26 @@ struct dict_table_t { } /** Check if a table name contains the string "/#sql" - which denotes temporary or intermediate tables in MariaDB. */ - static bool is_temporary_name(const char* name) + which denotes temporary or intermediate tables in MariaDB. + Table names starting with '#sql-create-', which are used + as backup during create and replace, are not threated as + temporary tables as they may contain foreign key references + that needs to be renamed as part of table renames */ + static bool is_temporary_name(const char* name) noexcept { - return strstr(name, "/#sql"); + const char *str= strstr(name, "/#sql"); + return (str && strncmp(str+5, "-create-",8)); + } + + /** Check if a table name contains the string "/#sql-create-" + which denotes a backup file as part of create or replace */ + static bool is_create_or_replace_name(const char* name) noexcept + { + return strstr(name, "/#sql-create-"); } /** @return whether instant ALTER TABLE is in effect */ - bool is_instant() const + bool is_instant() const noexcept { return(UT_LIST_GET_FIRST(indexes)->is_instant()); } @@ -2806,11 +2818,16 @@ inline void dict_index_t::set_modified(mtr_t& mtr) const mtr.set_named_space(table->space); } -inline bool table_name_t::is_temporary() const +inline bool table_name_t::is_temporary() const noexcept { return dict_table_t::is_temporary_name(m_name); } +inline bool table_name_t::is_create_or_replace() const noexcept +{ + return dict_table_t::is_create_or_replace_name(m_name); +} + inline bool dict_index_t::is_readable() const { return table->is_readable(); } inline bool dict_index_t::is_instant() const diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index 4814924ad2a19..22975fc0e4778 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -145,8 +145,9 @@ struct table_name_t @retval NULL if the table is not partitioned */ const char* part() const { return dict_is_partition(basename()); } /** @return whether this is a temporary or intermediate table name */ - inline bool is_temporary() const; -}; + inline bool is_temporary() const noexcept; + inline bool is_create_or_replace() const noexcept; + }; /** Shift for spatial status */ #define SPATIAL_STATUS_SHIFT 12 diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 8f5e47daea728..93e36f9c51069 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -901,18 +901,20 @@ void _ma_check_print_warning(HA_CHECK *param, const char *fmt, ...) DBUG_VOID_RETURN; } + /* Create a transaction object SYNOPSIS info Maria handler + all If we should register a full transaction (1) or stmt(0) RETURN 0 ok # Error number (HA_ERR_OUT_OF_MEM) */ -static int maria_create_trn_for_mysql(MARIA_HA *info) +static int maria_create_trn_for_mysql(MARIA_HA *info, my_bool all) { THD *thd= ((TABLE*) info->external_ref)->in_use; TRN *trn= THD_TRN; @@ -929,10 +931,17 @@ static int maria_create_trn_for_mysql(MARIA_HA *info) } _ma_set_trn_for_table(info, trn); if (!trnman_increment_locked_tables(trn)) - { - trans_register_ha(thd, FALSE, maria_hton, trn->trid); trnman_new_statement(trn); - } + + /* + Ensure that the transaction is registered. + We have to do that even if we had previous locked tables as the + statement could be 'create or replace locked_table SELECT ..' + in which case we do not yet have a transaction registered. + */ + if (!all) + trans_register_ha(thd, FALSE, maria_hton, trn->trid); + #ifdef EXTRA_DEBUG if (info->lock_type == F_WRLCK && ! (trnman_get_flags(trn) & TRN_STATE_INFO_LOGGED)) @@ -3220,7 +3229,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) if (handler->s->lock_key_trees) { /* _ma_set_trn_for_table() will be called indirectly */ - if (_ma_setup_live_state(handler)) + if (_ma_setup_live_state(handler, 1)) error= HA_ERR_OUT_OF_MEM; } else @@ -3631,15 +3640,19 @@ static int maria_commit(THD *thd, bool all) MARIA_HA *used_instances; DBUG_ENTER("maria_commit"); - /* No commit inside lock_tables() */ - if ((!trn || - thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) + /* No commit inside lock_tables() except for create table */ + if (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + if (trn && thd->lex->sql_command == SQLCOM_CREATE_TABLE) + DBUG_RETURN(ha_maria::implicit_commit(thd, 1)); DBUG_RETURN(0); + } /* statement or transaction ? */ - if ((thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && - !all) + if (!trn || + ((thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && + !all)) DBUG_RETURN(0); // end of statement used_instances= (MARIA_HA*) trn->used_instances; diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc index b49293e5bbe70..fd9251df1ef39 100644 --- a/storage/maria/ha_s3.cc +++ b/storage/maria/ha_s3.cc @@ -1078,7 +1078,8 @@ static int ha_s3_init(void *p) s3_hton->show_status= 0; s3_hton->prepare_for_backup= 0; s3_hton->end_backup= 0; - s3_hton->flags= ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) | + s3_hton->flags= HTON_EXPENSIVE_RENAME | + ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) | (s3_replicate_alter_as_create_select ? HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE : 0)); /* Copy global arguments to s3_access_key and s3_secret_key */ diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c index 4f952b6527b16..23eb482b3d243 100644 --- a/storage/maria/ma_init.c +++ b/storage/maria/ma_init.c @@ -41,7 +41,8 @@ void history_state_free(void *closed_history_) } -static int dummy_maria_create_trn_hook(MARIA_HA *info __attribute__((unused))) +static int dummy_maria_create_trn_hook(MARIA_HA *info __attribute__((unused)), + my_bool all __attribute__((unused))) { return 0; } diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 16a01ed77bd2d..3f40880003c7b 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -38,6 +38,7 @@ @fn _ma_setup_live_state @param info Maria handler + @param all @notes This function ensures that trn->used_tables contains a list of @@ -52,7 +53,7 @@ @retval 1 error (out of memory) */ -my_bool _ma_setup_live_state(MARIA_HA *info) +my_bool _ma_setup_live_state(MARIA_HA *info, my_bool all) { TRN *trn; MARIA_SHARE *share= info->s; @@ -63,7 +64,7 @@ my_bool _ma_setup_live_state(MARIA_HA *info) DBUG_ASSERT(share->lock_key_trees); - if (maria_create_trn_hook(info)) + if (maria_create_trn_hook(info, all)) DBUG_RETURN(1); trn= info->trn; @@ -662,7 +663,7 @@ my_bool _ma_block_start_trans(void* param) out of memory conditions) TODO: Fix this by having one extra state pre-allocated */ - DBUG_RETURN(_ma_setup_live_state(info)); + DBUG_RETURN(_ma_setup_live_state(info, 0)); } else { @@ -691,7 +692,7 @@ my_bool _ma_block_start_trans(void* param) Assume for now that this doesn't fail (It can only fail in out of memory conditions) */ - DBUG_RETURN(maria_create_trn_hook(info) != 0); + DBUG_RETURN(maria_create_trn_hook(info, 0) != 0); } DBUG_RETURN(0); } @@ -737,7 +738,7 @@ my_bool _ma_block_start_trans_no_versioning(void* param) Assume for now that this doesn't fail (It can only fail in out of memory conditions) */ - DBUG_RETURN(maria_create_trn_hook(info)); + DBUG_RETURN(maria_create_trn_hook(info, 0)); } DBUG_RETURN(0); } diff --git a/storage/maria/ma_state.h b/storage/maria/ma_state.h index d7b67acca2587..699a230bb3430 100644 --- a/storage/maria/ma_state.h +++ b/storage/maria/ma_state.h @@ -59,7 +59,7 @@ typedef struct st_state_history_closed { } MARIA_STATE_HISTORY_CLOSED; -my_bool _ma_setup_live_state(MARIA_HA *info); +my_bool _ma_setup_live_state(MARIA_HA *info, my_bool all); MARIA_STATE_HISTORY *_ma_remove_not_visible_states(MARIA_STATE_HISTORY *org_history, my_bool all, diff --git a/storage/maria/ma_static.c b/storage/maria/ma_static.c index d45ac8cbfff87..18445773424b7 100644 --- a/storage/maria/ma_static.c +++ b/storage/maria/ma_static.c @@ -63,7 +63,7 @@ PAGECACHE *maria_log_pagecache= &maria_log_pagecache_var; MY_TMPDIR *maria_tmpdir; /* Tempdir for redo */ const char *maria_data_root; HASH maria_stored_state; -int (*maria_create_trn_hook)(MARIA_HA *); +int (*maria_create_trn_hook)(MARIA_HA *, my_bool); void dummy_crash(const char *keyword __attribute__((unused))) {} void (*ma_debug_crash_here)(const char *keyword)= dummy_crash; diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 9d3661efeac3e..13bf868751ccf 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -1276,7 +1276,7 @@ extern my_bool maria_recovery_verbose, maria_checkpoint_disabled; extern my_bool maria_assert_if_crashed_table, aria_readonly; extern uint maria_checkpoint_min_log_activity; extern HASH maria_stored_state; -extern int (*maria_create_trn_hook)(MARIA_HA *); +extern int (*maria_create_trn_hook)(MARIA_HA *, my_bool all); extern my_bool (*ma_killed)(MARIA_HA *); extern void (*ma_debug_crash_here)(const char *keyword); diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 7904b7193ae00..df6c80ccebfbb 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -2610,7 +2610,7 @@ static int myisam_init(void *p) hton->drop_table= myisam_drop_table; hton->panic= myisam_panic; hton->update_optimizer_costs= myisam_update_optimizer_costs; - hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES; + hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES | HTON_NO_ROLLBACK; hton->tablefile_extensions= ha_myisam_exts; mi_killed= mi_killed_in_mariadb; diff --git a/storage/videx/ha_videx.cc b/storage/videx/ha_videx.cc index 7b21073ad604a..55f476cd10c20 100644 --- a/storage/videx/ha_videx.cc +++ b/storage/videx/ha_videx.cc @@ -422,7 +422,7 @@ ha_videx::ha_videx(handlerton *hton, TABLE_SHARE *table_arg) HA_PRIMARY_KEY_REQUIRED_FOR_POSITION | HA_PRIMARY_KEY_IN_READ_INDEX | HA_BINLOG_ROW_CAPABLE | HA_CAN_GEOMETRY | HA_PARTIAL_COLUMN_READ | HA_TABLE_SCAN_ON_INDEX | HA_CAN_EXPORT | HA_ONLINE_ANALYZE | - HA_CAN_RTREEKEYS | HA_CAN_TABLES_WITHOUT_ROLLBACK | + HA_CAN_RTREEKEYS | HA_CAN_ONLINE_BACKUPS | HA_CONCURRENT_OPTIMIZE | HA_CAN_SKIP_LOCKED), m_start_of_scan() { diff --git a/storage/videx/mysql-test/videx/create-table-and-index.result b/storage/videx/mysql-test/videx/create-table-and-index.result index e6ca10646f910..56c6f35c9a5e6 100644 --- a/storage/videx/mysql-test/videx/create-table-and-index.result +++ b/storage/videx/mysql-test/videx/create-table-and-index.result @@ -45,3 +45,14 @@ orders CREATE TABLE `orders` ( KEY `idx_orders_status_date` (`O_ORDERSTATUS`,`O_ORDERDATE`) ) ENGINE=VIDEX DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci DROP TABLE orders; +create sequence s1 engine=videx; +ERROR HY000: Table storage engine 'VIDEX' does not support the create option 'SEQUENCE' +# +# MDEV-38479 Crash in CREATE OR REPLACE SEQUENCE when new sequence +# cannot be created +# +create sequence s1; +create or replace sequence s1 engine=videx; +ERROR HY000: Table storage engine 'VIDEX' does not support the create option 'SEQUENCE' +drop sequence s1; +SET SESSION videx_server_ip=DEFAULT; diff --git a/storage/videx/mysql-test/videx/create-table-and-index.test b/storage/videx/mysql-test/videx/create-table-and-index.test index 094e2e91b41ee..74e71cc532e18 100644 --- a/storage/videx/mysql-test/videx/create-table-and-index.test +++ b/storage/videx/mysql-test/videx/create-table-and-index.test @@ -23,3 +23,18 @@ CREATE INDEX idx_orders_status_date ON orders (O_ORDERSTATUS, O_ORDERDATE); SHOW CREATE TABLE orders; DROP TABLE orders; + +--error ER_ILLEGAL_HA_CREATE_OPTION +create sequence s1 engine=videx; + +--echo # +--echo # MDEV-38479 Crash in CREATE OR REPLACE SEQUENCE when new sequence +--echo # cannot be created +--echo # + +create sequence s1; +--error ER_ILLEGAL_HA_CREATE_OPTION +create or replace sequence s1 engine=videx; +drop sequence s1; + +SET SESSION videx_server_ip=DEFAULT; diff --git a/strings/is_prefix.c b/strings/is_prefix.c index dfb61612e7938..5042341b937e4 100644 --- a/strings/is_prefix.c +++ b/strings/is_prefix.c @@ -40,5 +40,5 @@ int is_prefix(register const char *s, register const char *t) { while (*t) if (*s++ != *t++) return 0; - return 1; /* WRONG */ + return 1; /* t was a prefix of s */ } From 470b5866ce3356ee6b8bb82172922147c9be262a Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 17 Aug 2026 16:24:32 +0530 Subject: [PATCH 2/2] MDEV-40776 Atomic CREATE OR REPLACE silently breaks the foreign key Problem: ======== Atomic CREATE OR REPLACE renames the original table to a #sql-create- backup copy, and because such a name is not treated as a temporary name, InnoDB renamed every constraint of that table, including SYS_FOREIGN.REF_NAME of the constraints that belong to other tables. Those constraints ended up referencing the backup copy, which is dropped at the end of the statement, so the child tables were left with a dangling reference that survived a restart. Solution: ============ row_rename_table_for_mysql(): Fix this by splitting the two halves of the constraint renaming. Identifiers that the renamed table owns (SYS_FOREIGN.ID, FOR_NAME, SYS_FOREIGN_COLS.ID, and REF_NAME of a self-referencing constraint) keep following the table, so that they cannot conflict with the constraints of the table that is created under the original name, while REF_NAME of the constraints of other tables is left pointing to the original name, so that the newly created table inherits them and is rejected if it is not compatible with them. dict_table_rename_in_cache(): Does the same in the data dictionary cache by detaching the referencing constraints from the backup copy instead of renaming them, so that dict_load_foreigns() attaches them to the new table. As the newly created table can now be a parent table, the tables that CREATE OR REPLACE drops in order to restore the previous state must be dropped without foreign key checks, both in drop_open_table() and in the DDL log recovery (execute_drop_table()). --- mysql-test/suite/atomic/create_fk.result | 131 +++++++++++++++++++++++ mysql-test/suite/atomic/create_fk.test | 78 ++++++++++++++ sql/ddl_log.cc | 4 + sql/sql_base.cc | 8 ++ storage/innobase/dict/dict0dict.cc | 34 ++++++ storage/innobase/row/row0mysql.cc | 45 +++++++- 6 files changed, 296 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/atomic/create_fk.result b/mysql-test/suite/atomic/create_fk.result index b3111de818a5d..1d2dd69543f8b 100644 --- a/mysql-test/suite/atomic/create_fk.result +++ b/mysql-test/suite/atomic/create_fk.result @@ -49,3 +49,134 @@ select * from t1; a b c 1 1 1 drop table t1; +# +# CREATE OR REPLACE of a table that is referenced by another table +# +create table t1 (f1 int primary key, f2 int) engine=InnoDB; +create table t2 (f1 int primary key, f2 int, +constraint fk1 foreign key (f2) references t1 (f1)) engine=InnoDB; +insert into t1 values (1,10),(2,20); +insert into t2 values (1,1),(2,2); +create or replace table t1 (f1 int primary key, f2 int) engine=InnoDB; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`), + KEY `fk1` (`f2`), + CONSTRAINT `fk1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +fk1 test/t2 test/t1 +insert into t2 values (5,99); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)) +# The dictionary cache and SYS_FOREIGN must agree about this +# restart +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`), + KEY `fk1` (`f2`), + CONSTRAINT `fk1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +fk1 test/t2 test/t1 +insert into t2 values (5,99); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)) +# +# A replacement that does not fit the inherited constraint is rejected +# +create or replace table t1 (f3 int) engine=InnoDB; +ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed") +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select * from t1; +f1 f2 +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +fk1 test/t2 test/t1 +# +# Revert of a failed CREATE OR REPLACE of a referenced table +# +create or replace table t1 (f1 int primary key, f2 int) engine=InnoDB +select 1 as f1, 1 as f2 union all select 1,2; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select * from t1; +f1 f2 +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +fk1 test/t2 test/t1 +alter table t2 drop foreign key fk1; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +drop table t2, t1; +# +# A self-referencing constraint follows the #sql-create- backup copy +# +create table t1 (f1 int primary key, f2 int, +constraint d foreign key (f2) references t1 (f1)) engine=InnoDB; +insert into t1 values (1,1); +create or replace table t1 (f1 varchar(10) primary key, f2 varchar(10), +constraint d foreign key (f2) references t1 (f1)) engine=InnoDB; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(10) NOT NULL, + `f2` varchar(10) DEFAULT NULL, + PRIMARY KEY (`f1`), + KEY `d` (`f2`), + CONSTRAINT `d` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +d test/t1 test/t1 +insert into t1 values ('x','y'); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `d` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)) +drop table t1; +# +# Unnamed constraint identifiers are restored when CREATE OR REPLACE fails +# +create table t1 (f1 int primary key) engine=InnoDB; +create table t2 (f1 int primary key, f2 int, +foreign key (f2) references t1 (f1)) engine=InnoDB; +insert into t1 values (1); +insert into t2 values (1,1); +create or replace table t2 (f1 int primary key, f2 int, +foreign key (f2) references t1 (f1)) engine=InnoDB +select 1 as f1, 1 as f2 union all select 1,1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`), + KEY `f2` (`f2`), + CONSTRAINT `1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +select * from t2; +f1 f2 +1 1 +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +id for_name ref_name +1 test/t2 test/t1 +insert into t2 values (2,7); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)) +drop table t2, t1; diff --git a/mysql-test/suite/atomic/create_fk.test b/mysql-test/suite/atomic/create_fk.test index 83fbd4e3352c2..3adc05743aa1e 100644 --- a/mysql-test/suite/atomic/create_fk.test +++ b/mysql-test/suite/atomic/create_fk.test @@ -52,3 +52,81 @@ insert into t1 values (1,1,1); create or replace table t1 (a int primary key, b int, c int, g int, constraint d foreign key e (b) references t1 (a)) engine=innodb select 1 as a ,2 as b,3 as c; select * from t1; drop table t1; + +--echo # +--echo # CREATE OR REPLACE of a table that is referenced by another table +--echo # + +create table t1 (f1 int primary key, f2 int) engine=InnoDB; +create table t2 (f1 int primary key, f2 int, + constraint fk1 foreign key (f2) references t1 (f1)) engine=InnoDB; +insert into t1 values (1,10),(2,20); +insert into t2 values (1,1),(2,2); + +create or replace table t1 (f1 int primary key, f2 int) engine=InnoDB; +show create table t2; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +--error ER_NO_REFERENCED_ROW_2 +insert into t2 values (5,99); + +--echo # The dictionary cache and SYS_FOREIGN must agree about this +--source include/restart_mysqld.inc +show create table t2; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +--error ER_NO_REFERENCED_ROW_2 +insert into t2 values (5,99); + +--echo # +--echo # A replacement that does not fit the inherited constraint is rejected +--echo # +--error ER_CANT_CREATE_TABLE +create or replace table t1 (f3 int) engine=InnoDB; +show create table t1; +select * from t1; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; + +--echo # +--echo # Revert of a failed CREATE OR REPLACE of a referenced table +--echo # +--error ER_DUP_ENTRY +create or replace table t1 (f1 int primary key, f2 int) engine=InnoDB + select 1 as f1, 1 as f2 union all select 1,2; +show create table t1; +select * from t1; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +alter table t2 drop foreign key fk1; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +drop table t2, t1; + +--echo # +--echo # A self-referencing constraint follows the #sql-create- backup copy +--echo # +create table t1 (f1 int primary key, f2 int, + constraint d foreign key (f2) references t1 (f1)) engine=InnoDB; +insert into t1 values (1,1); +create or replace table t1 (f1 varchar(10) primary key, f2 varchar(10), + constraint d foreign key (f2) references t1 (f1)) engine=InnoDB; +show create table t1; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +--error ER_NO_REFERENCED_ROW_2 +insert into t1 values ('x','y'); +drop table t1; + +--echo # +--echo # Unnamed constraint identifiers are restored when CREATE OR REPLACE fails +--echo # +create table t1 (f1 int primary key) engine=InnoDB; +create table t2 (f1 int primary key, f2 int, + foreign key (f2) references t1 (f1)) engine=InnoDB; +insert into t1 values (1); +insert into t2 values (1,1); +--error ER_DUP_ENTRY +create or replace table t2 (f1 int primary key, f2 int, + foreign key (f2) references t1 (f1)) engine=InnoDB + select 1 as f1, 1 as f2 union all select 1,1; +show create table t2; +select * from t2; +select id, for_name, ref_name from information_schema.innodb_sys_foreign; +--error ER_NO_REFERENCED_ROW_2 +insert into t2 values (2,7); +drop table t2, t1; diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 59f0453d2eee5..acb1ec90fd92a 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -1200,8 +1200,11 @@ static int execute_drop_table(THD *thd, handlerton *hton, const LEX_CSTRING *db, uint keys, total_keys; int error, first_error= 0; MDL_request mdl_request; + ulonglong save_bits= thd->variables.option_bits; DBUG_ENTER("execute_drop_table"); + thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS; + /* Under an unexpected error conditions, like server shutdown, there may still be an open table definition for the table when we come here. @@ -1233,6 +1236,7 @@ static int execute_drop_table(THD *thd, handlerton *hton, const LEX_CSTRING *db, } if (mdl_request.ticket) thd->mdl_context.release_lock(mdl_request.ticket); + thd->variables.option_bits= save_bits; DBUG_ASSERT(!tdc_share_is_cached(thd, db->str, table->str)); DBUG_RETURN(first_error); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d063af4fe3477..dcf315a9ae8d2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1522,11 +1522,19 @@ void drop_open_table(THD *thd, TABLE *table, const LEX_CSTRING *db_name, DBUG_ASSERT(table == thd->open_tables); handlerton *table_type= table->s->db_type(); + ulonglong save_bits= thd->variables.option_bits; table->file->extra(HA_EXTRA_PREPARE_FOR_DROP); table->s->tdc->flush(thd, true); close_thread_table(thd, &thd->open_tables); + /* + Atomic CREATE OR REPLACE the table has inherited the constraints + that were referencing the original table, which is restored + from the backup copy after this. + */ + thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS; /* Remove the table from the storage engine and rm the .frm. */ quick_rm_table(thd, table_type, db_name, table_name, QRMT_DEFAULT); + thd->variables.option_bits= save_bits; } DBUG_VOID_RETURN; } diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index acece337575e3..599bc4af2043b 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1646,6 +1646,40 @@ dict_table_rename_in_cache( ut_a(table->foreign_set.empty()); table->foreign_set.swap(fk_set); + if (table->name.is_create_or_replace()) { + /* CREATE OR REPLACE TABLE renamed the table to the + #sql-create- backup name and is going to create the new + table under the original name. The constraints of other + tables that are referencing this table were intentionally + not renamed in SYS_FOREIGN (see row_rename_table_for_mysql()) + because they will be inherited by the newly created table. + Detach them from the backup table; they will be attached + again by dict_load_foreigns() when the new table is created, + or when this table is renamed back in case the CREATE OR + REPLACE fails. Self-referencing constraints belong to this + table and follow the new name. */ + for (dict_foreign_set::iterator it + = table->referenced_set.begin(); + it != table->referenced_set.end(); ) { + foreign = *it; + + if (foreign->foreign_table == table) { + foreign->referenced_table_name = + mem_heap_strdup(foreign->heap, + table->name.m_name); + foreign->referenced_table_name_lookup_set(); + ++it; + continue; + } + + foreign->referenced_table = NULL; + foreign->referenced_index = NULL; + it = table->referenced_set.erase(it); + } + + return DB_SUCCESS; + } + for (dict_foreign_set::iterator it = table->referenced_set.begin(); it != table->referenced_set.end(); ++it) { diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 25b50d33da333..f9a0072f62ed7 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2677,7 +2677,13 @@ row_rename_table_for_mysql( // Assume the caller guarantees destination name doesn't exist. ut_ad(err != DB_DUPLICATE_KEY); } else if (/* fk == RENAME_IGNORE_FK || */ !new_is_tmp) { - /* Rename all constraints. */ + /* Rename the constraints that are owned by this table + (SYS_FOREIGN.ID, SYS_FOREIGN.FOR_NAME and + SYS_FOREIGN_COLS.ID). This must be done also when the + table is being renamed to the CREATE OR REPLACE backup + name, so that the constraint identifiers of the table + that is being created under the original name will not + conflict with the ones of the backup table. */ info = pars_info_create(); pars_info_add_str_literal(info, "new_name", new_name); @@ -2703,17 +2709,48 @@ row_rename_table_for_mysql( " SUBSTR(old,p,LENGTH(old)-1));\n" " UPDATE SYS_FOREIGN\n" " SET ID=new, FOR_NAME=:new_name WHERE ID=old;\n" + " UPDATE SYS_FOREIGN SET REF_NAME=:new_name\n" + " WHERE ID=new AND REF_NAME=:old_name\n" + " AND TO_BINARY(REF_NAME)=TO_BINARY(:old_name);\n" " UPDATE SYS_FOREIGN_COLS\n" " SET ID=new WHERE ID=old;\n" " END IF;\n" "END LOOP;\n" - "UPDATE SYS_FOREIGN SET REF_NAME = :new_name\n" - "WHERE REF_NAME = :old_name\n" - "AND TO_BINARY(REF_NAME)=TO_BINARY(:old_name);\n" "END;\n", trx); if (err == DB_DUPLICATE_KEY) { err = DB_FOREIGN_DUPLICATE_KEY; } + + /* Rename the constraints of other tables that are + referencing this table. Self-referencing constraints were + already updated above, together with their FOR_NAME. + + CREATE OR REPLACE TABLE is renaming the original table to + a #sql-create- backup name and creating the new table under + the original name. The constraints of the child tables must + keep referencing the original name, so that they will be + inherited by the newly created table (and rejected if the + new definition is not compatible with them), instead of + following the backup table that is going to be dropped. */ + if (err == DB_SUCCESS + && !dict_table_t::is_create_or_replace_name(new_name)) { + info = pars_info_create(); + + pars_info_add_str_literal(info, "new_name", new_name); + pars_info_add_str_literal(info, "old_name", old_name); + + err = que_eval_sql( + info, + "PROCEDURE RENAME_REF_NAMES () IS\n" + "BEGIN\n" + "UPDATE SYS_FOREIGN SET REF_NAME = :new_name\n" + "WHERE REF_NAME = :old_name\n" + "AND TO_BINARY(REF_NAME)=TO_BINARY(:old_name);\n" + "END;\n", trx); + if (err == DB_DUPLICATE_KEY) { + err = DB_FOREIGN_DUPLICATE_KEY; + } + } } else if (n_constraints_to_drop > 0) { /* Drop some constraints of tmp tables. */ for (auto i = n_constraints_to_drop; i--; ) {