summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-01-17 16:06:43 +0200
committerMonty <monty@mariadb.org>2021-02-16 16:12:38 +0200
commit8c54ecbefbe95ac798558107060e8f21178d0316 (patch)
treed640f45b6e655126e245681e434ee53433908581
parent7d530f2154e5b4cd78e49232c0818c4fa63b99be (diff)
downloadmariadb-git-8c54ecbefbe95ac798558107060e8f21178d0316.tar.gz
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;
-rw-r--r--mysql-test/main/mysqlbinlog_row_compressed.result174
-rw-r--r--mysql-test/main/mysqlbinlog_row_minimal.result174
-rw-r--r--mysql-test/main/mysqlbinlog_stmt_compressed.result110
-rw-r--r--mysql-test/main/mysqldump-max.test2
-rw-r--r--mysql-test/suite/atomic/create_table.result447
-rw-r--r--mysql-test/suite/atomic/create_table.test126
-rw-r--r--mysql-test/suite/binlog/t/binlog_mysqlbinlog2.test18
-rw-r--r--mysql-test/suite/galera_sr/r/MDEV-18585.result40
-rw-r--r--mysql-test/suite/galera_sr/t/MDEV-18585.test5
-rw-r--r--mysql-test/suite/innodb/t/binlog_consistent.test8
-rw-r--r--mysql-test/suite/innodb/t/group_commit_binlog_pos.test2
-rw-r--r--mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test2
-rw-r--r--mysql-test/suite/multi_source/reset_slave.test7
-rw-r--r--mysql-test/suite/s3/partition.result2
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_fatal_semaphore_wait_threshold.result4
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test3
-rw-r--r--sql/ddl_log.cc85
-rw-r--r--sql/ddl_log.h14
-rw-r--r--sql/sql_alter.h6
-rw-r--r--sql/sql_class.h9
-rw-r--r--sql/sql_insert.cc56
-rw-r--r--sql/sql_table.cc144
-rw-r--r--sql/sql_table.h5
23 files changed, 1128 insertions, 315 deletions
diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result
index 95a81c7305c..b76d6af6d42 100644
--- a/mysql-test/main/mysqlbinlog_row_compressed.result
+++ b/mysql-test/main/mysqlbinlog_row_compressed.result
@@ -29,7 +29,7 @@ ROLLBACK/*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
# at 371
-#<date> server id 1 end_log_pos 533 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+#<date> server id 1 end_log_pos 542 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
@@ -42,26 +42,26 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 533
-#<date> server id 1 end_log_pos 575 CRC32 XXX GTID 0-1-2 ddl
+# at 542
+#<date> server id 1 end_log_pos 584 CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
-# at 575
-#<date> server id 1 end_log_pos 727 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 584
+#<date> server id 1 end_log_pos 745 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 727
-#<date> server id 1 end_log_pos 769 CRC32 XXX GTID 0-1-3
+# at 745
+#<date> server id 1 end_log_pos 787 CRC32 XXX GTID 0-1-3
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
START TRANSACTION
/*!*/;
-# at 769
-# at 843
-#<date> server id 1 end_log_pos 843 CRC32 XXX Annotate_rows:
+# at 787
+# at 861
+#<date> server id 1 end_log_pos 861 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
-#<date> server id 1 end_log_pos 899 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 899
-#<date> server id 1 end_log_pos 967 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 917 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 917
+#<date> server id 1 end_log_pos 985 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -74,23 +74,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 967
-#<date> server id 1 end_log_pos 1040 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 985
+#<date> server id 1 end_log_pos 1058 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1040
-#<date> server id 1 end_log_pos 1082 CRC32 XXX GTID 0-1-4
+# at 1058
+#<date> server id 1 end_log_pos 1100 CRC32 XXX GTID 0-1-4
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
START TRANSACTION
/*!*/;
-# at 1082
-# at 1158
-#<date> server id 1 end_log_pos 1158 CRC32 XXX Annotate_rows:
+# at 1100
+# at 1176
+#<date> server id 1 end_log_pos 1176 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
-#<date> server id 1 end_log_pos 1214 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1214
-#<date> server id 1 end_log_pos 1281 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1232 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 1232
+#<date> server id 1 end_log_pos 1299 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=11 /* INT meta=0 nullable=0 is_null=0 */
@@ -103,23 +103,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9=NULL /* STRING(1) meta=65025 nullable=1 is_null=1 */
# Number of rows: 1
-# at 1281
-#<date> server id 1 end_log_pos 1354 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1299
+#<date> server id 1 end_log_pos 1372 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1354
-#<date> server id 1 end_log_pos 1396 CRC32 XXX GTID 0-1-5
+# at 1372
+#<date> server id 1 end_log_pos 1414 CRC32 XXX GTID 0-1-5
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
START TRANSACTION
/*!*/;
-# at 1396
-# at 1474
-#<date> server id 1 end_log_pos 1474 CRC32 XXX Annotate_rows:
+# at 1414
+# at 1492
+#<date> server id 1 end_log_pos 1492 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
-#<date> server id 1 end_log_pos 1530 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1530
-#<date> server id 1 end_log_pos 1596 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1548 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 1548
+#<date> server id 1 end_log_pos 1614 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=12 /* INT meta=0 nullable=0 is_null=0 */
@@ -132,23 +132,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1596
-#<date> server id 1 end_log_pos 1669 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1614
+#<date> server id 1 end_log_pos 1687 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1669
-#<date> server id 1 end_log_pos 1711 CRC32 XXX GTID 0-1-6
+# at 1687
+#<date> server id 1 end_log_pos 1729 CRC32 XXX GTID 0-1-6
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
START TRANSACTION
/*!*/;
-# at 1711
-# at 1786
-#<date> server id 1 end_log_pos 1786 CRC32 XXX Annotate_rows:
+# at 1729
+# at 1804
+#<date> server id 1 end_log_pos 1804 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
-#<date> server id 1 end_log_pos 1842 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1842
-#<date> server id 1 end_log_pos 1909 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1860 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 1860
+#<date> server id 1 end_log_pos 1927 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
@@ -161,23 +161,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1909
-#<date> server id 1 end_log_pos 1982 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1927
+#<date> server id 1 end_log_pos 2000 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1982
-#<date> server id 1 end_log_pos 2024 CRC32 XXX GTID 0-1-7
+# at 2000
+#<date> server id 1 end_log_pos 2042 CRC32 XXX GTID 0-1-7
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
START TRANSACTION
/*!*/;
-# at 2024
-# at 2078
-#<date> server id 1 end_log_pos 2078 CRC32 XXX Annotate_rows:
+# at 2042
+# at 2096
+#<date> server id 1 end_log_pos 2096 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t2 SELECT * FROM t1
-#<date> server id 1 end_log_pos 2134 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 2134
-#<date> server id 1 end_log_pos 2225 CRC32 XXX Write_compressed_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2152 CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at 2152
+#<date> server id 1 end_log_pos 2243 CRC32 XXX Write_compressed_rows: table id 33 flags: STMT_END_F
### INSERT INTO `test`.`t2`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -223,23 +223,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 2225
-#<date> server id 1 end_log_pos 2298 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2243
+#<date> server id 1 end_log_pos 2316 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2298
-#<date> server id 1 end_log_pos 2340 CRC32 XXX GTID 0-1-8
+# at 2316
+#<date> server id 1 end_log_pos 2358 CRC32 XXX GTID 0-1-8
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
START TRANSACTION
/*!*/;
-# at 2340
-# at 2406
-#<date> server id 1 end_log_pos 2406 CRC32 XXX Annotate_rows:
+# at 2358
+# at 2424
+#<date> server id 1 end_log_pos 2424 CRC32 XXX Annotate_rows:
#Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
-#<date> server id 1 end_log_pos 2462 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 2462
-#<date> server id 1 end_log_pos 2561 CRC32 XXX Update_compressed_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2480 CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at 2480
+#<date> server id 1 end_log_pos 2579 CRC32 XXX Update_compressed_rows: table id 33 flags: STMT_END_F
### UPDATE `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -304,23 +304,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 3
-# at 2561
-#<date> server id 1 end_log_pos 2634 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2579
+#<date> server id 1 end_log_pos 2652 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2634
-#<date> server id 1 end_log_pos 2676 CRC32 XXX GTID 0-1-9
+# at 2652
+#<date> server id 1 end_log_pos 2694 CRC32 XXX GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
START TRANSACTION
/*!*/;
-# at 2676
-# at 2713
-#<date> server id 1 end_log_pos 2713 CRC32 XXX Annotate_rows:
+# at 2694
+# at 2731
+#<date> server id 1 end_log_pos 2731 CRC32 XXX Annotate_rows:
#Q> DELETE FROM t1
-#<date> server id 1 end_log_pos 2769 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 2769
-#<date> server id 1 end_log_pos 2861 CRC32 XXX Delete_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2787 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 2787
+#<date> server id 1 end_log_pos 2879 CRC32 XXX Delete_compressed_rows: table id 32 flags: STMT_END_F
### DELETE FROM `test`.`t1`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -366,23 +366,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 2861
-#<date> server id 1 end_log_pos 2934 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2879
+#<date> server id 1 end_log_pos 2952 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2934
-#<date> server id 1 end_log_pos 2976 CRC32 XXX GTID 0-1-10
+# at 2952
+#<date> server id 1 end_log_pos 2994 CRC32 XXX GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
START TRANSACTION
/*!*/;
-# at 2976
-# at 3013
-#<date> server id 1 end_log_pos 3013 CRC32 XXX Annotate_rows:
+# at 2994
+# at 3031
+#<date> server id 1 end_log_pos 3031 CRC32 XXX Annotate_rows:
#Q> DELETE FROM t2
-#<date> server id 1 end_log_pos 3069 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 3069
-#<date> server id 1 end_log_pos 3154 CRC32 XXX Delete_compressed_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos 3087 CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at 3087
+#<date> server id 1 end_log_pos 3172 CRC32 XXX Delete_compressed_rows: table id 33 flags: STMT_END_F
### DELETE FROM `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -428,13 +428,13 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 3154
-#<date> server id 1 end_log_pos 3227 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 3172
+#<date> server id 1 end_log_pos 3245 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 3227
-#<date> server id 1 end_log_pos 3275 CRC32 XXX Rotate to master-bin.000002 pos: 4
+# at 3245
+#<date> server id 1 end_log_pos 3293 CRC32 XXX Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result
index 659228a57e2..a83c1b97237 100644
--- a/mysql-test/main/mysqlbinlog_row_minimal.result
+++ b/mysql-test/main/mysqlbinlog_row_minimal.result
@@ -27,7 +27,7 @@ ROLLBACK/*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
# at 371
-#<date> server id 1 end_log_pos 555 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+#<date> server id 1 end_log_pos 564 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
@@ -40,26 +40,26 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 555
-#<date> server id 1 end_log_pos 597 CRC32 XXX GTID 0-1-2 ddl
+# at 564
+#<date> server id 1 end_log_pos 606 CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
-# at 597
-#<date> server id 1 end_log_pos 774 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 606
+#<date> server id 1 end_log_pos 792 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 774
-#<date> server id 1 end_log_pos 816 CRC32 XXX GTID 0-1-3
+# at 792
+#<date> server id 1 end_log_pos 834 CRC32 XXX GTID 0-1-3
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
START TRANSACTION
/*!*/;
-# at 816
-# at 890
-#<date> server id 1 end_log_pos 890 CRC32 XXX Annotate_rows:
+# at 834
+# at 908
+#<date> server id 1 end_log_pos 908 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
-#<date> server id 1 end_log_pos 946 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 946
-#<date> server id 1 end_log_pos 1015 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 964 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 964
+#<date> server id 1 end_log_pos 1033 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -72,23 +72,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1015
-#<date> server id 1 end_log_pos 1088 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1033
+#<date> server id 1 end_log_pos 1106 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1088
-#<date> server id 1 end_log_pos 1130 CRC32 XXX GTID 0-1-4
+# at 1106
+#<date> server id 1 end_log_pos 1148 CRC32 XXX GTID 0-1-4
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
START TRANSACTION
/*!*/;
-# at 1130
-# at 1206
-#<date> server id 1 end_log_pos 1206 CRC32 XXX Annotate_rows:
+# at 1148
+# at 1224
+#<date> server id 1 end_log_pos 1224 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
-#<date> server id 1 end_log_pos 1262 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1262
-#<date> server id 1 end_log_pos 1330 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1280 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 1280
+#<date> server id 1 end_log_pos 1348 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=11 /* INT meta=0 nullable=0 is_null=0 */
@@ -101,23 +101,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9=NULL /* STRING(1) meta=65025 nullable=1 is_null=1 */
# Number of rows: 1
-# at 1330
-#<date> server id 1 end_log_pos 1403 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1348
+#<date> server id 1 end_log_pos 1421 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1403
-#<date> server id 1 end_log_pos 1445 CRC32 XXX GTID 0-1-5
+# at 1421
+#<date> server id 1 end_log_pos 1463 CRC32 XXX GTID 0-1-5
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
START TRANSACTION
/*!*/;
-# at 1445
-# at 1523
-#<date> server id 1 end_log_pos 1523 CRC32 XXX Annotate_rows:
+# at 1463
+# at 1541
+#<date> server id 1 end_log_pos 1541 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
-#<date> server id 1 end_log_pos 1579 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1579
-#<date> server id 1 end_log_pos 1646 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1597 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 1597
+#<date> server id 1 end_log_pos 1664 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=12 /* INT meta=0 nullable=0 is_null=0 */
@@ -130,23 +130,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1646
-#<date> server id 1 end_log_pos 1719 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1664
+#<date> server id 1 end_log_pos 1737 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1719
-#<date> server id 1 end_log_pos 1761 CRC32 XXX GTID 0-1-6
+# at 1737
+#<date> server id 1 end_log_pos 1779 CRC32 XXX GTID 0-1-6
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
START TRANSACTION
/*!*/;
-# at 1761
-# at 1836
-#<date> server id 1 end_log_pos 1836 CRC32 XXX Annotate_rows:
+# at 1779
+# at 1854
+#<date> server id 1 end_log_pos 1854 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
-#<date> server id 1 end_log_pos 1892 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1892
-#<date> server id 1 end_log_pos 1962 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1910 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 1910
+#<date> server id 1 end_log_pos 1980 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
@@ -159,23 +159,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1962
-#<date> server id 1 end_log_pos 2035 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1980
+#<date> server id 1 end_log_pos 2053 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2035
-#<date> server id 1 end_log_pos 2077 CRC32 XXX GTID 0-1-7
+# at 2053
+#<date> server id 1 end_log_pos 2095 CRC32 XXX GTID 0-1-7
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
START TRANSACTION
/*!*/;
-# at 2077
-# at 2131
-#<date> server id 1 end_log_pos 2131 CRC32 XXX Annotate_rows:
+# at 2095
+# at 2149
+#<date> server id 1 end_log_pos 2149 CRC32 XXX Annotate_rows:
#Q> INSERT INTO t2 SELECT * FROM t1
-#<date> server id 1 end_log_pos 2187 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 2187
-#<date> server id 1 end_log_pos 2354 CRC32 XXX Write_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2205 CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at 2205
+#<date> server id 1 end_log_pos 2372 CRC32 XXX Write_rows: table id 33 flags: STMT_END_F
### INSERT INTO `test`.`t2`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -221,23 +221,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 2354
-#<date> server id 1 end_log_pos 2427 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2372
+#<date> server id 1 end_log_pos 2445 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2427
-#<date> server id 1 end_log_pos 2469 CRC32 XXX GTID 0-1-8
+# at 2445
+#<date> server id 1 end_log_pos 2487 CRC32 XXX GTID 0-1-8
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
START TRANSACTION
/*!*/;
-# at 2469
-# at 2535
-#<date> server id 1 end_log_pos 2535 CRC32 XXX Annotate_rows:
+# at 2487
+# at 2553
+#<date> server id 1 end_log_pos 2553 CRC32 XXX Annotate_rows:
#Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
-#<date> server id 1 end_log_pos 2591 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 2591
-#<date> server id 1 end_log_pos 2657 CRC32 XXX Update_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2609 CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at 2609
+#<date> server id 1 end_log_pos 2675 CRC32 XXX Update_rows: table id 33 flags: STMT_END_F
### UPDATE `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -254,23 +254,23 @@ START TRANSACTION
### SET
### @5=5 /* INT meta=0 nullable=1 is_null=0 */
# Number of rows: 3
-# at 2657
-#<date> server id 1 end_log_pos 2730 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2675
+#<date> server id 1 end_log_pos 2748 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2730
-#<date> server id 1 end_log_pos 2772 CRC32 XXX GTID 0-1-9
+# at 2748
+#<date> server id 1 end_log_pos 2790 CRC32 XXX GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
START TRANSACTION
/*!*/;
-# at 2772
-# at 2809
-#<date> server id 1 end_log_pos 2809 CRC32 XXX Annotate_rows:
+# at 2790
+# at 2827
+#<date> server id 1 end_log_pos 2827 CRC32 XXX Annotate_rows:
#Q> DELETE FROM t1
-#<date> server id 1 end_log_pos 2865 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 2865
-#<date> server id 1 end_log_pos 2919 CRC32 XXX Delete_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2883 CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at 2883
+#<date> server id 1 end_log_pos 2937 CRC32 XXX Delete_rows: table id 32 flags: STMT_END_F
### DELETE FROM `test`.`t1`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -284,23 +284,23 @@ START TRANSACTION
### WHERE
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
# Number of rows: 4
-# at 2919
-#<date> server id 1 end_log_pos 2992 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2937
+#<date> server id 1 end_log_pos 3010 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2992
-#<date> server id 1 end_log_pos 3034 CRC32 XXX GTID 0-1-10
+# at 3010
+#<date> server id 1 end_log_pos 3052 CRC32 XXX GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
START TRANSACTION
/*!*/;
-# at 3034
-# at 3071
-#<date> server id 1 end_log_pos 3071 CRC32 XXX Annotate_rows:
+# at 3052
+# at 3089
+#<date> server id 1 end_log_pos 3089 CRC32 XXX Annotate_rows:
#Q> DELETE FROM t2
-#<date> server id 1 end_log_pos 3127 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 3127
-#<date> server id 1 end_log_pos 3181 CRC32 XXX Delete_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos 3145 CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at 3145
+#<date> server id 1 end_log_pos 3199 CRC32 XXX Delete_rows: table id 33 flags: STMT_END_F
### DELETE FROM `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -314,13 +314,13 @@ START TRANSACTION
### WHERE
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
# Number of rows: 4
-# at 3181
-#<date> server id 1 end_log_pos 3254 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 3199
+#<date> server id 1 end_log_pos 3272 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 3254
-#<date> server id 1 end_log_pos 3302 CRC32 XXX Rotate to master-bin.000002 pos: 4
+# at 3272
+#<date> server id 1 end_log_pos 3320 CRC32 XXX Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result
index 078e6a746ff..4cd1ddda2e3 100644
--- a/mysql-test/main/mysqlbinlog_stmt_compressed.result
+++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result
@@ -29,7 +29,7 @@ ROLLBACK/*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
# at 371
-#<date> server id 1 end_log_pos 533 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+#<date> server id 1 end_log_pos 542 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
@@ -42,136 +42,136 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 533
-#<date> server id 1 end_log_pos 575 CRC32 XXX GTID 0-1-2 ddl
+# at 542
+#<date> server id 1 end_log_pos 584 CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
-# at 575
-#<date> server id 1 end_log_pos 727 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 584
+#<date> server id 1 end_log_pos 745 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 727
-#<date> server id 1 end_log_pos 769 CRC32 XXX GTID 0-1-3
+# at 745
+#<date> server id 1 end_log_pos 787 CRC32 XXX GTID 0-1-3
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
START TRANSACTION
/*!*/;
-# at 769
-#<date> server id 1 end_log_pos 897 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 787
+#<date> server id 1 end_log_pos 915 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
/*!*/;
-# at 897
-#<date> server id 1 end_log_pos 970 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 915
+#<date> server id 1 end_log_pos 988 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 970
-#<date> server id 1 end_log_pos 1012 CRC32 XXX GTID 0-1-4
+# at 988
+#<date> server id 1 end_log_pos 1030 CRC32 XXX GTID 0-1-4
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
START TRANSACTION
/*!*/;
-# at 1012
-#<date> server id 1 end_log_pos 1140 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 1030
+#<date> server id 1 end_log_pos 1158 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
/*!*/;
-# at 1140
-#<date> server id 1 end_log_pos 1213 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1158
+#<date> server id 1 end_log_pos 1231 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1213
-#<date> server id 1 end_log_pos 1255 CRC32 XXX GTID 0-1-5
+# at 1231
+#<date> server id 1 end_log_pos 1273 CRC32 XXX GTID 0-1-5
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
START TRANSACTION
/*!*/;
-# at 1255
-#<date> server id 1 end_log_pos 1385 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 1273
+#<date> server id 1 end_log_pos 1403 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
/*!*/;
-# at 1385
-#<date> server id 1 end_log_pos 1458 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1403
+#<date> server id 1 end_log_pos 1476 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1458
-#<date> server id 1 end_log_pos 1500 CRC32 XXX GTID 0-1-6
+# at 1476
+#<date> server id 1 end_log_pos 1518 CRC32 XXX GTID 0-1-6
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
START TRANSACTION
/*!*/;
-# at 1500
-#<date> server id 1 end_log_pos 1627 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 1518
+#<date> server id 1 end_log_pos 1645 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
/*!*/;
-# at 1627
-#<date> server id 1 end_log_pos 1700 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1645
+#<date> server id 1 end_log_pos 1718 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1700
-#<date> server id 1 end_log_pos 1742 CRC32 XXX GTID 0-1-7
+# at 1718
+#<date> server id 1 end_log_pos 1760 CRC32 XXX GTID 0-1-7
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
START TRANSACTION
/*!*/;
-# at 1742
-#<date> server id 1 end_log_pos 1850 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 1760
+#<date> server id 1 end_log_pos 1868 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t2 SELECT * FROM t1
/*!*/;
-# at 1850
-#<date> server id 1 end_log_pos 1923 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 1868
+#<date> server id 1 end_log_pos 1941 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1923
-#<date> server id 1 end_log_pos 1965 CRC32 XXX GTID 0-1-8
+# at 1941
+#<date> server id 1 end_log_pos 1983 CRC32 XXX GTID 0-1-8
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
START TRANSACTION
/*!*/;
-# at 1965
-#<date> server id 1 end_log_pos 2082 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 1983
+#<date> server id 1 end_log_pos 2100 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
/*!*/;
-# at 2082
-#<date> server id 1 end_log_pos 2155 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2100
+#<date> server id 1 end_log_pos 2173 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2155
-#<date> server id 1 end_log_pos 2197 CRC32 XXX GTID 0-1-9
+# at 2173
+#<date> server id 1 end_log_pos 2215 CRC32 XXX GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
START TRANSACTION
/*!*/;
-# at 2197
-#<date> server id 1 end_log_pos 2288 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 2215
+#<date> server id 1 end_log_pos 2306 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
DELETE FROM t1
/*!*/;
-# at 2288
-#<date> server id 1 end_log_pos 2361 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2306
+#<date> server id 1 end_log_pos 2379 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2361
-#<date> server id 1 end_log_pos 2403 CRC32 XXX GTID 0-1-10
+# at 2379
+#<date> server id 1 end_log_pos 2421 CRC32 XXX GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
START TRANSACTION
/*!*/;
-# at 2403
-#<date> server id 1 end_log_pos 2494 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
+# at 2421
+#<date> server id 1 end_log_pos 2512 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
DELETE FROM t2
/*!*/;
-# at 2494
-#<date> server id 1 end_log_pos 2567 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
+# at 2512
+#<date> server id 1 end_log_pos 2585 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2567
-#<date> server id 1 end_log_pos 2615 CRC32 XXX Rotate to master-bin.000002 pos: 4
+# at 2585
+#<date> server id 1 end_log_pos 2633 CRC32 XXX Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
diff --git a/mysql-test/main/mysqldump-max.test b/mysql-test/main/mysqldump-max.test
index 49e54d542b8..e85490b7352 100644
--- a/mysql-test/main/mysqldump-max.test
+++ b/mysql-test/main/mysqldump-max.test
@@ -1194,7 +1194,7 @@ source include/binlog_start_pos.inc;
let _BINLOG_START_POS= $binlog_start_pos;
--perl
my $f= "$ENV{MYSQLTEST_VARDIR}/tmp/mwl136.sql";
-my $pos=$ENV{_BINLOG_START_POS} + 739;
+my $pos=$ENV{_BINLOG_START_POS} + 757;
open F, '<', $f or die "Failed to open $f: $!\n";
while (<F>) {
s/$pos/<pos>/;
diff --git a/mysql-test/suite/atomic/create_table.result b/mysql-test/suite/atomic/create_table.result
new file mode 100644
index 00000000000..ceec345d400
--- /dev/null
+++ b/mysql-test/suite/atomic/create_table.result
@@ -0,0 +1,447 @@
+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: 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 log */
+crash point: ddl_log_create_before_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_drop
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_before_binlog
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+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: 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 log */
+crash point: ddl_log_create_before_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_drop
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_before_binlog
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+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: 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 log */
+crash point: ddl_log_create_before_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_drop
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_before_binlog
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_prepare_eof
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+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: 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 log */
+crash point: ddl_log_create_before_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_drop
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_before_binlog
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+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: 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 log */
+crash point: ddl_log_create_before_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_drop
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_before_binlog
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+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: 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 log */
+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 log */
+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 log */
+crash point: ddl_log_create_before_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_create_table
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_after_drop
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+crash point: ddl_log_create_before_binlog
+master-bin.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t2` /* generated by ddl log */
+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 log */
+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 log */
+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'
diff --git a/mysql-test/suite/atomic/create_table.test b/mysql-test/suite/atomic/create_table.test
new file mode 100644
index 00000000000..a3c41de36ab
--- /dev/null
+++ b/mysql-test/suite/atomic/create_table.test
@@ -0,0 +1,126 @@
+--source include/have_debug.inc
+--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
+#
+
+--disable_query_log
+call mtr.add_suppression("InnoDB: .* does not exist in the InnoDB internal");
+--enable_query_log
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+let $engine_count=2;
+let $engines='myisam','innodb';
+
+let $crash_count=8;
+let $crash_points='ddl_log_create_before_create_frm', '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=6;
+let $statements='CREATE TABLE t1 (a int)',
+ 'CREATE OR REPLACE TABLE t2 (a int)',
+ '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
+ }
+ 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!";
+ }
+ # Check which tables still exists
+ --list_files $MYSQLD_DATADIR/test t*
+
+ --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
+ }
+ # 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;
+
+--enable_query_log
diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog2.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog2.test
index f5b7e2c01d6..d064a0aad23 100644
--- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog2.test
+++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog2.test
@@ -58,20 +58,20 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
-let $start_pos= `select @binlog_start_pos + 696`;
+let $start_pos= `select @binlog_start_pos + 705`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
-let $stop_pos= `select @binlog_start_pos + 696`;
+let $stop_pos= `select @binlog_start_pos + 705`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
select "--- start and stop positions ---" as "";
--enable_query_log
-let $start_pos= `select @binlog_start_pos + 696`;
-let $stop_pos= `select @binlog_start_pos + 857`;
+let $start_pos= `select @binlog_start_pos + 705`;
+let $stop_pos= `select @binlog_start_pos + 866`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
@@ -103,7 +103,7 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
-let $start_pos= `select @binlog_start_pos + 696`;
+let $start_pos= `select @binlog_start_pos + 705`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
--disable_query_log
@@ -138,19 +138,19 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
-let $start_pos= `select @binlog_start_pos + 696`;
+let $start_pos= `select @binlog_start_pos + 705`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
-let $stop_pos= `select @binlog_start_pos + 696`;
+let $stop_pos= `select @binlog_start_pos + 705`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- start and stop positions ---" as "";
--enable_query_log
-let $start_pos= `select @binlog_start_pos + 696`;
+let $start_pos= `select @binlog_start_pos + 705`;
let $stop_pos= `select @binlog_start_pos + 812`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
@@ -180,7 +180,7 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
-let $start_pos= `select @binlog_start_pos + 696`;
+let $start_pos= `select @binlog_start_pos + 705`;
--replace_regex /collation_server=[0-9]+/collation_server=X/ /character_set_client=[0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log
diff --git a/mysql-test/suite/galera_sr/r/MDEV-18585.result b/mysql-test/suite/galera_sr/r/MDEV-18585.result
index d30def1ea63..44c3637506b 100644
--- a/mysql-test/suite/galera_sr/r/MDEV-18585.result
+++ b/mysql-test/suite/galera_sr/r/MDEV-18585.result
@@ -12,25 +12,25 @@ SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (5), (6);
SET SESSION wsrep_trx_fragment_unit=default;
SET SESSION wsrep_trx_fragment_size=default;
-SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM 518;
+SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM 527;
Log_name Pos Event_type Server_id End_log_pos Info
-mysqld-bin.000002 518 Gtid 1 560 BEGIN GTID 0-1-2
-mysqld-bin.000002 560 Annotate_rows 1 613 INSERT INTO t1 VALUES (1), (2)
-mysqld-bin.000002 613 Table_map 1 658 table_id: # (test.t1)
-mysqld-bin.000002 658 Write_rows_v1 1 696 table_id: # flags: STMT_END_F
-mysqld-bin.000002 696 Table_map 1 741 table_id: # (test.t1)
-mysqld-bin.000002 741 Write_rows_v1 1 779 table_id: # flags: STMT_END_F
-mysqld-bin.000002 779 Xid 1 810 COMMIT /* xid=# */
-mysqld-bin.000002 810 Gtid 1 852 BEGIN GTID 0-1-3
-mysqld-bin.000002 852 Annotate_rows 1 905 INSERT INTO t1 VALUES (3), (4)
-mysqld-bin.000002 905 Table_map 1 950 table_id: # (test.t1)
-mysqld-bin.000002 950 Write_rows_v1 1 988 table_id: # flags: STMT_END_F
-mysqld-bin.000002 988 Table_map 1 1033 table_id: # (test.t1)
-mysqld-bin.000002 1033 Write_rows_v1 1 1071 table_id: # flags: STMT_END_F
-mysqld-bin.000002 1071 Xid 1 1102 COMMIT /* xid=# */
-mysqld-bin.000002 1102 Gtid 1 1144 BEGIN GTID 0-1-4
-mysqld-bin.000002 1144 Annotate_rows 1 1197 INSERT INTO t1 VALUES (5), (6)
-mysqld-bin.000002 1197 Table_map 1 1242 table_id: # (test.t1)
-mysqld-bin.000002 1242 Write_rows_v1 1 1285 table_id: # flags: STMT_END_F
-mysqld-bin.000002 1285 Xid 1 1316 COMMIT /* xid=# */
+mysqld-bin.000002 # Gtid 1 # BEGIN GTID 0-1-2
+mysqld-bin.000002 # Annotate_rows 1 # INSERT INTO t1 VALUES (1), (2)
+mysqld-bin.000002 # Table_map 1 # table_id: # (test.t1)
+mysqld-bin.000002 # Write_rows_v1 1 # table_id: # flags: STMT_END_F
+mysqld-bin.000002 # Table_map 1 # table_id: # (test.t1)
+mysqld-bin.000002 # Write_rows_v1 1 # table_id: # flags: STMT_END_F
+mysqld-bin.000002 # Xid 1 # COMMIT /* xid=# */
+mysqld-bin.000002 # Gtid 1 # BEGIN GTID 0-1-3
+mysqld-bin.000002 # Annotate_rows 1 # INSERT INTO t1 VALUES (3), (4)
+mysqld-bin.000002 # Table_map 1 # table_id: # (test.t1)
+mysqld-bin.000002 # Write_rows_v1 1 # table_id: # flags: STMT_END_F
+mysqld-bin.000002 # Table_map 1 # table_id: # (test.t1)
+mysqld-bin.000002 # Write_rows_v1 1 # table_id: # flags: STMT_END_F
+mysqld-bin.000002 # Xid 1 # COMMIT /* xid=# */
+mysqld-bin.000002 # Gtid 1 # BEGIN GTID 0-1-4
+mysqld-bin.000002 # Annotate_rows 1 # INSERT INTO t1 VALUES (5), (6)
+mysqld-bin.000002 # Table_map 1 # table_id: # (test.t1)
+mysqld-bin.000002 # Write_rows_v1 1 # table_id: # flags: STMT_END_F
+mysqld-bin.000002 # Xid 1 # COMMIT /* xid=# */
DROP TABLE t1;
diff --git a/mysql-test/suite/galera_sr/t/MDEV-18585.test b/mysql-test/suite/galera_sr/t/MDEV-18585.test
index 18bbbe8f7e0..7535b524a6d 100644
--- a/mysql-test/suite/galera_sr/t/MDEV-18585.test
+++ b/mysql-test/suite/galera_sr/t/MDEV-18585.test
@@ -12,6 +12,8 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY);
SET SESSION wsrep_trx_fragment_unit='ROWS';
SET SESSION wsrep_trx_fragment_size=1;
+--let $start_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
+
INSERT INTO t1 VALUES (1), (2);
#
@@ -37,6 +39,7 @@ SET SESSION wsrep_trx_fragment_unit=default;
SET SESSION wsrep_trx_fragment_size=default;
--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/
-SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM 518;
+--replace_column 2 # 5 #
+--eval SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM $start_pos
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/binlog_consistent.test b/mysql-test/suite/innodb/t/binlog_consistent.test
index 2a735a30a0e..ad0410ae451 100644
--- a/mysql-test/suite/innodb/t/binlog_consistent.test
+++ b/mysql-test/suite/innodb/t/binlog_consistent.test
@@ -16,7 +16,7 @@ connect(con4,localhost,root,,);
connection default;
CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb;
-let pos=`select $binlog_start_pos + 254`;
+let pos=`select $binlog_start_pos + 263`;
--replace_result $pos <pos>
SHOW MASTER STATUS;
--replace_result $pos <pos>
@@ -53,10 +53,10 @@ COMMIT;
connection default;
SELECT * FROM t1 ORDER BY a,b;
-let pos=`select $binlog_start_pos + 788`;
+let pos=`select $binlog_start_pos + 806`;
--replace_result $pos <pos>
SHOW STATUS LIKE 'binlog_snapshot_%';
-let pos=`select $binlog_start_pos + 1164`;
+let pos=`select $binlog_start_pos + 1182`;
--replace_result $pos <pos>
SHOW MASTER STATUS;
SELECT * FROM t2 ORDER BY a;
@@ -74,7 +74,7 @@ FLUSH LOGS;
connection default;
SELECT * FROM t1 ORDER BY a,b;
-let pos=`select $binlog_start_pos + 788`;
+let pos=`select $binlog_start_pos + 806`;
--replace_result $pos <pos>
SHOW STATUS LIKE 'binlog_snapshot_%';
let pos=`select $binlog_start_pos + 131`;
diff --git a/mysql-test/suite/innodb/t/group_commit_binlog_pos.test b/mysql-test/suite/innodb/t/group_commit_binlog_pos.test
index 801895e825d..c2e38d5412d 100644
--- a/mysql-test/suite/innodb/t/group_commit_binlog_pos.test
+++ b/mysql-test/suite/innodb/t/group_commit_binlog_pos.test
@@ -97,7 +97,7 @@ SELECT * FROM t1 ORDER BY a;
# for the end of the second transaction (as can be checked with
# mysqlbinlog).
let $MYSQLD_DATADIR= `SELECT @@datadir`;
-let pos=`select $binlog_start_pos + 730`;
+let pos=`select $binlog_start_pos + 739`;
--replace_result $pos <pos>
--exec sed -ne 's/.*\(InnoDB: Last binlog file .* position.*\)/\1/p' $MYSQLD_DATADIR/../../log/mysqld.1.err | tail -1
diff --git a/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test b/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test
index 116bc54441e..250f0beeab6 100644
--- a/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test
+++ b/mysql-test/suite/innodb/t/group_commit_binlog_pos_no_optimize_thread.test
@@ -98,7 +98,7 @@ SELECT * FROM t1 ORDER BY a;
# for the end of the second transaction (as can be checked with
# mysqlbinlog).
let $MYSQLD_DATADIR= `SELECT @@datadir`;
-let pos=`select $binlog_start_pos + 730`;
+let pos=`select $binlog_start_pos + 739`;
--replace_result $pos <pos>
--exec sed -ne 's/.*\(InnoDB: Last binlog file .* position.*\)/\1/p' $MYSQLD_DATADIR/../../log/mysqld.1.err | tail -1
SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/suite/multi_source/reset_slave.test b/mysql-test/suite/multi_source/reset_slave.test
index d267ecb0cbf..34b42ae6d6d 100644
--- a/mysql-test/suite/multi_source/reset_slave.test
+++ b/mysql-test/suite/multi_source/reset_slave.test
@@ -39,9 +39,10 @@ stop slave 'master1';
--let $datadir = `SELECT @@datadir`
-let read_master_log_pos=`select $binlog_start_pos + 599`;
-let relay_log_pos=`select 2*$binlog_start_pos + 643`;
-let relay_log_space=`select 3*$binlog_start_pos + 705`;
+let read_master_log_pos=`select $binlog_start_pos + 608`;
+let relay_log_pos=`select 2*$binlog_start_pos + 652`;
+let relay_log_space=`select 3*$binlog_start_pos + 714`;
+
--replace_result $SERVER_MYPORT_1 MYPORT_1 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space <relay_log_space>
show slave 'master1' status;
--list_files $datadir mysqld*
diff --git a/mysql-test/suite/s3/partition.result b/mysql-test/suite/s3/partition.result
index ee837611d50..3cfa33e99eb 100644
--- a/mysql-test/suite/s3/partition.result
+++ b/mysql-test/suite/s3/partition.result
@@ -18,8 +18,6 @@ ERROR 42000: Table 't1' uses an extension that doesn't exist in this MariaDB ver
SHOW WARNINGS;
Level Code Message
Error 1112 Table 't1' uses an extension that doesn't exist in this MariaDB version
-Error 6 Error on delete of './s3/t1#P#p0#TMP#.MAI' (Errcode: 2 "No such file or directory")
-Error 6 Error on delete of './s3/t1#P#p0#TMP#.MAD' (Errcode: 2 "No such file or directory")
ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
SELECT count(*) FROM t1;
count(*)
diff --git a/mysql-test/suite/sys_vars/r/innodb_fatal_semaphore_wait_threshold.result b/mysql-test/suite/sys_vars/r/innodb_fatal_semaphore_wait_threshold.result
index 50fbc1bd83b..674934af13e 100644
--- a/mysql-test/suite/sys_vars/r/innodb_fatal_semaphore_wait_threshold.result
+++ b/mysql-test/suite/sys_vars/r/innodb_fatal_semaphore_wait_threshold.result
@@ -9,6 +9,4 @@ SELECT * FROM t1;
connection default;
# Waiting for mariadbd to crash
# Crash was detected
-DROP TABLE t1, t2;
-Warnings:
-Warning 1932 Table 'test.t2' doesn't exist in engine
+DROP TABLE t1;
diff --git a/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test b/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test
index dc28498675d..124b0c8563a 100644
--- a/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test
+++ b/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test
@@ -65,4 +65,5 @@ connection default;
# Call script that will poll the server waiting for it to be back online again
source include/wait_until_connected_again.inc;
-DROP TABLE t1, t2;
+# We only have to do drop t1, as t2 as been automatically deleted by ddl recovery
+DROP TABLE t1;
diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc
index 24168e5a7e1..56e40128132 100644
--- a/sql/ddl_log.cc
+++ b/sql/ddl_log.cc
@@ -87,7 +87,7 @@ const char *ddl_log_action_name[DDL_LOG_LAST_ACTION]=
"partitioning replace", "partitioning exchange",
"rename table", "rename view",
"initialize drop table", "drop table",
- "drop view", "drop trigger", "drop db",
+ "drop view", "drop trigger", "drop db", "create table",
};
/* Number of phases per entry */
@@ -96,7 +96,7 @@ const uchar ddl_log_entry_phases[DDL_LOG_LAST_ACTION]=
0, 1, 1, 2,
(uchar) EXCH_PHASE_END, (uchar) DDL_RENAME_PHASE_END, 1, 1,
(uchar) DDL_DROP_PHASE_END, 1, 1,
- (uchar) DDL_DROP_DB_PHASE_END
+ (uchar) DDL_DROP_DB_PHASE_END, (uchar) DDL_CREATE_TABLE_PHASE_END
};
@@ -1464,6 +1464,56 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root,
}
break;
}
+ case DDL_LOG_CREATE_TABLE_ACTION:
+ {
+ LEX_CSTRING db, table, path;
+ db= ddl_log_entry->db;
+ table= ddl_log_entry->name;
+ path= ddl_log_entry->tmp_name;
+
+ /* Don't delete the table if we didn't create it */
+ if (ddl_log_entry->unique_id == 0)
+ {
+ if (hton)
+ {
+ if ((error= hton->drop_table(hton, path.str)))
+ {
+ if (!non_existing_table_error(error))
+ break;
+ error= -1;
+ }
+ }
+ else
+ error= ha_delete_table_force(thd, path.str, &db, &table);
+ }
+ strxnmov(to_path, sizeof(to_path)-1, path.str, reg_ext, NullS);
+ mysql_file_delete(key_file_frm, to_path, MYF(MY_WME|MY_IGNORE_ENOENT));
+ if (ddl_log_entry->phase == DDL_CREATE_TABLE_PHASE_LOG)
+ {
+ /*
+ The server logged CREATE TABLE ... SELECT into binary log
+ before crashing. As the commit failed and we have delete the
+ table above, we have now to log the DROP of the created table.
+ */
+
+ String *query= &recovery_state.drop_table;
+ query->length(0);
+ query->append(STRING_WITH_LEN("DROP TABLE IF EXISTS "));
+ append_identifier(thd, query, &db);
+ query->append('.');
+ append_identifier(thd, query, &table);
+ query->append(&end_comment);
+
+ mysql_mutex_unlock(&LOCK_gdl);
+ (void) thd->binlog_query(THD::STMT_QUERY_TYPE,
+ query->ptr(), query->length(),
+ TRUE, FALSE, FALSE, 0);
+ mysql_mutex_lock(&LOCK_gdl);
+ }
+ (void) update_phase(entry_pos, DDL_LOG_FINAL_PHASE);
+ break;
+ }
+ break;
default:
DBUG_ASSERT(0);
break;
@@ -2358,3 +2408,34 @@ bool ddl_log_drop_db(THD *thd, DDL_LOG_STATE *ddl_state,
ddl_log_entry.tmp_name= *const_cast<LEX_CSTRING*>(path);
DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry));
}
+
+
+/**
+ Log CREATE TABLE
+
+ @param only_frm On recovery, only drop the .frm. This is needed for
+ example when deleting a table that was discovered.
+*/
+
+bool ddl_log_create_table(THD *thd, DDL_LOG_STATE *ddl_state,
+ handlerton *hton,
+ const LEX_CSTRING *path,
+ const LEX_CSTRING *db,
+ const LEX_CSTRING *table,
+ bool only_frm)
+{
+ DDL_LOG_ENTRY ddl_log_entry;
+ DBUG_ENTER("ddl_log_create_table");
+
+ bzero(&ddl_log_entry, sizeof(ddl_log_entry));
+ ddl_log_entry.action_type= DDL_LOG_CREATE_TABLE_ACTION;
+ if (hton)
+ lex_string_set(&ddl_log_entry.handler_name,
+ ha_resolve_storage_engine_name(hton));
+ ddl_log_entry.db= *const_cast<LEX_CSTRING*>(db);
+ ddl_log_entry.name= *const_cast<LEX_CSTRING*>(table);
+ ddl_log_entry.tmp_name= *const_cast<LEX_CSTRING*>(path);
+ ddl_log_entry.unique_id= only_frm;
+
+ DBUG_RETURN(ddl_log_write(ddl_state, &ddl_log_entry));
+}
diff --git a/sql/ddl_log.h b/sql/ddl_log.h
index b8e2c3fc91d..a0b2e103617 100644
--- a/sql/ddl_log.h
+++ b/sql/ddl_log.h
@@ -83,6 +83,7 @@ enum ddl_log_action_code
DDL_LOG_DROP_VIEW_ACTION= 9,
DDL_LOG_DROP_TRIGGER_ACTION= 10,
DDL_LOG_DROP_DB_ACTION=11,
+ DDL_LOG_CREATE_TABLE_ACTION=12,
DDL_LOG_LAST_ACTION /* End marker */
};
@@ -119,6 +120,12 @@ enum enum_ddl_log_drop_db_phase {
DDL_DROP_DB_PHASE_END
};
+enum enum_ddl_log_create_table_phase {
+ DDL_CREATE_TABLE_PHASE_INIT=0,
+ DDL_CREATE_TABLE_PHASE_LOG,
+ DDL_CREATE_TABLE_PHASE_END
+};
+
/*
Setting ddl_log_entry.phase to this has the same effect as setting
action_type to DDL_IGNORE_LOG_ENTRY_CODE
@@ -166,6 +173,7 @@ typedef struct st_ddl_log_state
DDL_LOG_MEMORY_ENTRY *list;
/* One execute entry per list */
DDL_LOG_MEMORY_ENTRY *execute_entry;
+ bool is_active() { return list != 0; }
} DDL_LOG_STATE;
@@ -233,5 +241,11 @@ bool ddl_log_drop_view(THD *thd, DDL_LOG_STATE *ddl_state,
const LEX_CSTRING *db);
bool ddl_log_drop_db(THD *thd, DDL_LOG_STATE *ddl_state,
const LEX_CSTRING *db, const LEX_CSTRING *path);
+bool ddl_log_create_table(THD *thd, DDL_LOG_STATE *ddl_state,
+ handlerton *hton,
+ const LEX_CSTRING *path,
+ const LEX_CSTRING *db,
+ const LEX_CSTRING *table,
+ bool only_frm);
extern mysql_mutex_t LOCK_gdl;
#endif /* DDL_LOG_INCLUDED */
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 89eb4ebb3e9..250801838b3 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -290,6 +290,12 @@ public:
const char *get_tmp_path() const
{ return tmp_path; }
+ const LEX_CSTRING get_tmp_cstring_path() const
+ {
+ LEX_CSTRING tmp= { tmp_path, strlen(tmp_path) };
+ return tmp;
+ };
+
/**
Mark ALTER TABLE as needing to produce foreign key error if
it deletes a row from the table being changed.
diff --git a/sql/sql_class.h b/sql/sql_class.h
index b96e3e5a5fd..2e7772b3c37 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -39,7 +39,7 @@
#include "thr_lock.h" /* thr_lock_type, THR_LOCK_DATA, THR_LOCK_INFO */
#include "thr_timer.h"
#include "thr_malloc.h"
-#include "log_slow.h" /* LOG_SLOW_DISABLE_... */
+#include "log_slow.h" /* LOG_SLOW_DISABLE_... */
#include <my_tree.h>
#include "sql_digest_stream.h" // sql_digest_state
#include <mysql/psi/mysql_stage.h>
@@ -50,6 +50,7 @@
#include "session_tracker.h"
#include "backup.h"
#include "xa.h"
+#include "ddl_log.h" /* DDL_LOG_STATE */
extern "C"
void set_thd_stage_info(void *thd,
@@ -5824,6 +5825,7 @@ class select_create: public select_insert {
MYSQL_LOCK **m_plock;
bool exit_done;
TMP_TABLE_SHARE *saved_tmp_table_share;
+ DDL_LOG_STATE ddl_log_state_create, ddl_log_state_rm;
public:
select_create(THD *thd_arg, TABLE_LIST *table_arg,
@@ -5839,7 +5841,10 @@ public:
alter_info(alter_info_arg),
m_plock(NULL), exit_done(0),
saved_tmp_table_share(0)
- {}
+ {
+ bzero(&ddl_log_state_create, sizeof(ddl_log_state_create));
+ bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm));
+ }
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
void store_values(List<Item> &values);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e7363ab7709..c1806df2a75 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4391,7 +4391,8 @@ Field *Item::create_field_for_create_select(MEM_ROOT *root, TABLE *table)
*/
TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
- MYSQL_LOCK **lock, TABLEOP_HOOKS *hooks)
+ MYSQL_LOCK **lock,
+ TABLEOP_HOOKS *hooks)
{
TABLE tmp_table; // Used during 'Create_field()'
TABLE_SHARE share;
@@ -4489,7 +4490,8 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
open_table().
*/
- if (!mysql_create_table_no_lock(thd, &create_table->db,
+ if (!mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm,
+ &create_table->db,
&create_table->table_name,
create_info, alter_info, NULL,
select_field_count, create_table))
@@ -4548,6 +4550,8 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *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);
}
@@ -4586,7 +4590,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
*lock= 0;
}
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
- DBUG_RETURN(0);
+ ddl_log_complete(&ddl_log_state_rm);
+ ddl_log_complete(&ddl_log_state_create);
+ DBUG_RETURN(NULL);
/* purecov: end */
}
table->s->table_creation_was_logged= save_table_creation_was_logged;
@@ -4924,11 +4930,30 @@ bool select_create::send_eof()
if (thd->slave_thread)
thd->variables.binlog_annotate_row_events= 0;
+ debug_crash_here("ddl_log_create_before_binlog");
+
+ /*
+ In case of crash, we have to add DROP TABLE to the binary log as
+ the CREATE TABLE will already be logged if we are not using row based
+ replication.
+ */
+ if (!thd->is_current_stmt_binlog_format_row())
+ {
+ if (ddl_log_state_create.is_active()) // Not temporary table
+ ddl_log_update_phase(&ddl_log_state_create, DDL_CREATE_TABLE_PHASE_LOG);
+ /*
+ We can ignore if we replaced an old table as ddl_log_state_create will
+ now handle the logging of the drop if needed.
+ */
+ ddl_log_complete(&ddl_log_state_rm);
+ }
+
if (prepare_eof())
{
abort_result_set();
DBUG_RETURN(true);
}
+ debug_crash_here("ddl_log_create_after_prepare_eof");
if (table->s->tmp_table)
{
@@ -4994,9 +5019,15 @@ 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);
trans_commit_stmt(thd);
if (!(thd->variables.option_bits & OPTION_GTID_BEGIN))
trans_commit_implicit(thd);
+ thd->binlog_xid= 0;
+
#ifdef WITH_WSREP
if (WSREP(thd))
{
@@ -5015,6 +5046,15 @@ bool select_create::send_eof()
}
#endif /* WITH_WSREP */
}
+ /*
+ 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
@@ -5131,10 +5171,20 @@ void select_create::abort_result_set()
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, &create_table->db, &create_table->table_name,
tmp_table);
+ debug_crash_here("ddl_log_create_after_binlog");
+ thd->binlog_xid= 0;
+ }
}
}
+ ddl_log_complete(&ddl_log_state_rm);
+ ddl_log_complete(&ddl_log_state_create);
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f201e62a4a9..42486a1e6f5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1076,6 +1076,7 @@ static uint32 comment_length(THD *thd, uint32 comment_pos,
const uchar *query_end= (uchar*) query + thd->query_length();
const uchar *const state_map= thd->charset()->state_map;
+ *comment_start= ""; // Ensure it points to something
for (; query < query_end; query++)
{
if (state_map[static_cast<uchar>(*query)] == MY_LEX_SKIP)
@@ -4114,10 +4115,13 @@ err:
*/
static
-int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
+int create_table_impl(THD *thd,
+ DDL_LOG_STATE *ddl_log_state_create,
+ DDL_LOG_STATE *ddl_log_state_rm,
+ const LEX_CSTRING &orig_db,
const LEX_CSTRING &orig_table_name,
const LEX_CSTRING &db, const LEX_CSTRING &table_name,
- const char *path, const DDL_options_st options,
+ const LEX_CSTRING &path, const DDL_options_st options,
HA_CREATE_INFO *create_info, Alter_info *alter_info,
int create_table_mode, bool *is_trans, KEY **key_info,
uint *key_count, LEX_CUSTRING *frm)
@@ -4128,9 +4132,16 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
bool frm_only= create_table_mode == C_ALTER_TABLE_FRM_ONLY;
bool internal_tmp_table= create_table_mode == C_ALTER_TABLE || frm_only;
handlerton *exists_hton;
- DBUG_ENTER("mysql_create_table_no_lock");
+ 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));
+ db.str, table_name.str, internal_tmp_table, path.str));
+
+ /* Easy check for ddl logging if we are creating a temporary table */
+ if (create_info->tmp_table())
+ {
+ ddl_log_state_create= 0;
+ ddl_log_state_rm= 0;
+ }
if (fix_constraints_names(thd, &alter_info->check_constraint_list,
create_info))
@@ -4244,10 +4255,12 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
(void) trans_rollback_stmt(thd);
/* Remove normal table without logging. Keep tables locked */
if (mysql_rm_table_no_locks(thd, &table_list, &thd->db,
- (DDL_LOG_STATE*) 0,
+ 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.
@@ -4310,7 +4323,7 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
goto err;
}
- init_tmp_table_share(thd, &share, db.str, 0, table_name.str, path);
+ init_tmp_table_share(thd, &share, db.str, 0, table_name.str, path.str);
/* prepare everything for discovery */
share.field= &no_fields;
@@ -4321,6 +4334,14 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
if (parse_engine_table_options(thd, hton, &share))
goto err;
+ /*
+ Log that we are going to do discovery. If things fails, any generated
+ .frm files are deleted
+ */
+ if (ddl_log_state_create)
+ ddl_log_create_table(thd, ddl_log_state_create, (handlerton*) 0, &path,
+ &db, &table_name, 1);
+
ha_err= hton->discover_table_structure(hton, thd, &share, create_info);
/*
@@ -4342,44 +4363,56 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
}
else
{
+ if (ddl_log_state_create)
+ ddl_log_create_table(thd, ddl_log_state_create, create_info->db_type,
+ &path, &db, &table_name, frm_only);
+ debug_crash_here("ddl_log_create_before_create_frm");
+
file= mysql_create_frm_image(thd, orig_db, orig_table_name, create_info,
alter_info, create_table_mode, key_info,
key_count, frm);
/*
- TODO: remove this check of thd->is_error() (now it intercept
- errors in some val_*() methoids and bring some single place to
- such error interception).
+ TODO: remove this check of thd->is_error() (now it intercept
+ errors in some val_*() methods and bring some single place to
+ such error interception).
*/
if (!file || thd->is_error())
+ {
+ if (!file)
+ deletefrm(path.str);
goto err;
+ }
if (thd->variables.keep_files_on_create)
create_info->options|= HA_CREATE_KEEP_FILES;
- if (file->ha_create_partitioning_metadata(path, NULL, CHF_CREATE_FLAG))
+ if (file->ha_create_partitioning_metadata(path.str, NULL, CHF_CREATE_FLAG))
goto err;
if (!frm_only)
{
- if (ha_create_table(thd, path, db.str, table_name.str, create_info, frm))
+ debug_crash_here("ddl_log_create_before_create_table");
+ if (ha_create_table(thd, path.str, db.str, table_name.str, create_info,
+ frm))
{
- file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG);
- deletefrm(path);
+ file->ha_create_partitioning_metadata(path.str, NULL, CHF_DELETE_FLAG);
+ deletefrm(path.str);
goto err;
}
+ debug_crash_here("ddl_log_create_after_create_table");
}
}
create_info->table= 0;
if (!frm_only && create_info->tmp_table())
{
- TABLE *table= thd->create_and_open_tmp_table(frm, path, db.str,
+ TABLE *table= thd->create_and_open_tmp_table(frm, path.str, db.str,
table_name.str,
false);
if (!table)
{
- (void) thd->rm_temporary_table(create_info->db_type, path);
+ (void) thd->rm_temporary_table(create_info->db_type, path.str);
goto err;
}
@@ -4392,6 +4425,12 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
error= 0;
err:
+ if (unlikely(error) && ddl_log_state_create)
+ {
+ /* Table was never created, so we can ignore the ddl log entry */
+ ddl_log_complete(ddl_log_state_create);
+ }
+
THD_STAGE_INFO(thd, stage_after_create);
delete file;
DBUG_PRINT("exit", ("return: %d", error));
@@ -4417,7 +4456,10 @@ warn:
-1 Table was used with IF NOT EXISTS and table existed (warning, not error)
*/
-int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *db,
+int mysql_create_table_no_lock(THD *thd,
+ DDL_LOG_STATE *ddl_log_state_create,
+ DDL_LOG_STATE *ddl_log_state_rm,
+ const LEX_CSTRING *db,
const LEX_CSTRING *table_name,
Table_specification_st *create_info,
Alter_info *alter_info, bool *is_trans,
@@ -4426,26 +4468,31 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *db,
KEY *not_used_1;
uint not_used_2;
int res;
+ uint path_length;
char path[FN_REFLEN + 1];
+ LEX_CSTRING cpath;
LEX_CUSTRING frm= {0,0};
if (create_info->tmp_table())
- build_tmptable_filename(thd, path, sizeof(path));
+ path_length= build_tmptable_filename(thd, path, sizeof(path));
else
{
- int length;
const LEX_CSTRING *alias= table_case_name(create_info, table_name);
- length= build_table_filename(path, sizeof(path) - 1, db->str, alias->str, "", 0);
+ path_length= build_table_filename(path, sizeof(path) - 1, db->str,
+ alias->str,
+ "", 0);
// Check if we hit FN_REFLEN bytes along with file extension.
- if (length+reg_ext_length > FN_REFLEN)
+ if (path_length+reg_ext_length > FN_REFLEN)
{
my_error(ER_IDENT_CAUSES_TOO_LONG_PATH, MYF(0), (int) sizeof(path)-1,
path);
return true;
}
}
+ lex_string_set3(&cpath, path, path_length);
- res= create_table_impl(thd, *db, *table_name, *db, *table_name, path,
+ res= create_table_impl(thd, ddl_log_state_create, ddl_log_state_rm,
+ *db, *table_name, *db, *table_name, cpath,
*create_info, create_info,
alter_info, create_table_mode,
is_trans, &not_used_1, &not_used_2, &frm);
@@ -4498,17 +4545,22 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
Table_specification_st *create_info,
Alter_info *alter_info)
{
- bool is_trans= FALSE;
- bool result;
- int create_table_mode;
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;
DBUG_ENTER("mysql_create_table");
DBUG_ASSERT(create_table == thd->lex->query_tables);
+ bzero(&ddl_log_state_create, sizeof(ddl_log_state_create));
+ bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm));
+
/* Copy temporarily the statement flags to thd for lock_table_names() */
- uint save_thd_create_info_options= thd->lex->create_info.options;
+ 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 */
@@ -4548,7 +4600,8 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
if (!opt_explicit_defaults_for_timestamp)
promote_first_timestamp_column(&alter_info->create_list);
- if (mysql_create_table_no_lock(thd, &create_table->db,
+ if (mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm,
+ &create_table->db,
&create_table->table_name, create_info,
alter_info,
&is_trans, create_table_mode,
@@ -4618,10 +4671,19 @@ err:
*/
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;
}
+ ddl_log_complete(&ddl_log_state_rm);
+ ddl_log_complete(&ddl_log_state_create);
DBUG_RETURN(result);
}
@@ -4898,7 +4960,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
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
+ Alter_table_ctx local_alter_ctx; // Not used
+ DDL_LOG_STATE ddl_log_state_create, ddl_log_state_rm;
int res= 1;
bool is_trans= FALSE;
bool do_logging= FALSE;
@@ -4907,6 +4970,9 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
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));
+
#ifdef WITH_WSREP
if (WSREP(thd) && !thd->wsrep_applier &&
wsrep_create_like_table(thd, table, src_table, create_info))
@@ -5000,7 +5066,9 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
pos_in_locked_tables= local_create_info.table->pos_in_locked_tables;
res= ((create_res=
- mysql_create_table_no_lock(thd, &table->db, &table->table_name,
+ mysql_create_table_no_lock(thd,
+ &ddl_log_state_create, &ddl_log_state_rm,
+ &table->db, &table->table_name,
&local_create_info, &local_alter_info,
&is_trans, C_ORDINARY_CREATE,
table)) > 0);
@@ -5210,22 +5278,33 @@ 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.
*/
- log_drop_table(thd, &table->db, &table->table_name, create_info->tmp_table());
+ DBUG_ASSERT(ddl_log_state_rm.is_active());
+ log_drop_table(thd, &table->db, &table->table_name,
+ create_info->tmp_table());
}
else if (res != 2) // Table was not dropped
{
if (write_bin_log(thd, res ? FALSE : TRUE, thd->query(),
thd->query_length(), is_trans))
- res= 1;
+ res= 1;
}
+ debug_crash_here("ddl_log_create_after_binlog");
+ thd->binlog_xid= 0;
}
+ ddl_log_complete(&ddl_log_state_rm);
+ ddl_log_complete(&ddl_log_state_create);
DBUG_RETURN(res != 0);
}
@@ -9517,9 +9596,10 @@ do_continue:;
tmp_disable_binlog(thd);
create_info->options|=HA_CREATE_TMP_ALTER;
create_info->alias= alter_ctx.table_name;
- error= create_table_impl(thd, alter_ctx.db, alter_ctx.table_name,
+ error= create_table_impl(thd, (DDL_LOG_STATE*) 0, (DDL_LOG_STATE*) 0,
+ alter_ctx.db, alter_ctx.table_name,
alter_ctx.new_db, alter_ctx.tmp_name,
- alter_ctx.get_tmp_path(),
+ alter_ctx.get_tmp_cstring_path(),
thd->lex->create_info, create_info, alter_info,
C_ALTER_TABLE_FRM_ONLY, NULL,
&key_info, &key_count, &frm);
diff --git a/sql/sql_table.h b/sql/sql_table.h
index 7ac5cc90f04..7b0ae21847d 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -125,7 +125,10 @@ bool add_keyword_to_query(THD *thd, String *result, const LEX_CSTRING *keyword,
#define C_ALTER_TABLE_FRM_ONLY -2
#define C_ASSISTED_DISCOVERY -3
-int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *db,
+int mysql_create_table_no_lock(THD *thd,
+ DDL_LOG_STATE *ddl_log_state,
+ DDL_LOG_STATE *ddl_log_state_rm,
+ const LEX_CSTRING *db,
const LEX_CSTRING *table_name,
Table_specification_st *create_info,
Alter_info *alter_info, bool *is_trans,