mariadb/mysql-test/suite/atomic/create_table.result
Monty 6aa9a552c2 MDEV-24576 Atomic CREATE TABLE
There are a few different cases to consider

Logging of CREATE TABLE and CREATE TABLE ... LIKE
- If REPLACE is used and there was an existing table, DDL log the drop of
  the table.
- If discovery of table is to be done
    - DDL LOG create table
  else
    - DDL log create table (with engine type)
    - create the table
- If table was created
  - Log entry to binary log with xid
  - Mark DDL log completed

Crash recovery:
- If query was in binary log do nothing and exit
- If discoverted table
   - Delete the .frm file
-else
   - Drop created table and frm file
- If table was dropped, write a DROP TABLE statement in binary log

CREATE TABLE ... SELECT required a little more work as when one is using
statement logging the query is written to the binary log before commit is
done.
This was fixed by adding a DROP TABLE to the binary log during crash
recovery if the ddl log entry was not closed. In this case the binary log
will contain:
CREATE TABLE xxx ... SELECT ....
DROP TABLE xxx;

Other things:
- Added debug_crash_here() functionality to Aria to be able to test
  crash in create table between the creation of the .MAI and the .MAD files.
2021-05-19 22:54:13 +02:00

537 lines
16 KiB
Text

create table const_table (a int, b int) engine=myisam;
insert into const_table values (1,1),(2,2);
flush tables;
engine: myisam
query: CREATE TABLE t1 (a 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
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int)
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_create_after_drop
"No crash!"
t1.MYD
t1.MYI
t1.frm
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
t2.frm
crash point: ddl_log_create_after_prepare_eof
"No crash!"
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int)
crash point: ddl_log_create_after_binlog
t1.MYD
t1.MYI
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!"
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 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)
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
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table
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_create_after_drop
"No crash!"
t1.MYD
t1.MYI
t1.frm
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
t2.frm
crash point: ddl_log_create_after_prepare_eof
"No crash!"
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table
crash point: ddl_log_create_after_binlog
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table
crash point: ddl_log_create_log_complete
"No crash!"
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
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
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
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_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_create_after_drop
"No crash!"
t1.MYD
t1.MYI
t1.frm
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
t2.frm
crash point: ddl_log_create_after_prepare_eof
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
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_log_complete
t1.MYD
t1.MYI
t1.frm
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
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.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 */
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
master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl recovery */
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(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
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)
crash point: ddl_log_create_before_create_frm
t2.frm
t2.ibd
crash point: storage_engine_middle_of_create
"No crash!"
t1.frm
t1.ibd
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a 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
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
crash point: ddl_log_create_after_prepare_eof
"No crash!"
t1.frm
t1.ibd
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a 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!"
t1.frm
t1.ibd
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int)
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)
query: CREATE TABLE t1 LIKE const_table
crash point: ddl_log_create_before_create_frm
t2.frm
t2.ibd
crash point: storage_engine_middle_of_create
"No crash!"
t1.MYD
t1.MYI
t1.frm
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table
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.MYD
t1.MYI
t1.frm
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
crash point: ddl_log_create_after_prepare_eof
"No crash!"
t1.MYD
t1.MYI
t1.frm
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table
crash point: ddl_log_create_after_binlog
t1.MYD
t1.MYI
t1.frm
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 LIKE const_table
crash point: ddl_log_create_log_complete
"No crash!"
t1.MYD
t1.MYI
t1.frm
t2.frm
t2.ibd
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
crash point: ddl_log_create_before_create_frm
t2.frm
t2.ibd
crash point: storage_engine_middle_of_create
"No crash!"
t1.frm
t1.ibd
t2.frm
t2.ibd
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 SELECT * 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
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
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
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
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_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
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_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
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'