[MDEV-544] Galera: CREATE TABLE .. AS SELECT is not written into the binary log Created: 2012-09-23  Updated: 2012-10-23  Resolved: 2012-10-23

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.28a-galera
Fix Version/s: 5.5.28a-galera

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Seppo Jaakola
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates

 Description   

It is a regression in revno 3352 (works on revno 3351, doesn't work on 3352).

If a table is created as CREATE TABLE ... AS SELECT ..., normally it should trigger two events in the row binary log: one for CREATE DDL (statement format), and another one for Write_rows. It was so in revno 3351, but not anymore:

revno 3352 (wrong):

create table t1 as select 1;
Query OK, 1 row affected (0.31 sec)
Records: 1  Duplicates: 0  Warnings: 0
 
show binlog events;
+-------------------+-----+-------------+-----------+-------------+-----------------------------------------------------+
| Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                                |
+-------------------+-----+-------------+-----------+-------------+-----------------------------------------------------+
| master-bin.000001 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.27-MariaDB-debug-log, Binlog ver: 4 |
| master-bin.000001 | 245 | Query       |         1 |         318 | BEGIN                                               |
| master-bin.000001 | 318 | Table_map   |         1 |         359 | table_id: 33 (test.t1)                              |
| master-bin.000001 | 359 | Write_rows  |         1 |         393 | table_id: 33 flags: STMT_END_F                      |
| master-bin.000001 | 393 | Xid         |         1 |         420 | COMMIT /* xid=2 */                                  |
+-------------------+-----+-------------+-----------+-------------+-----------------------------------------------------+
5 rows in set (0.01 sec)

revno 3351 (OK):

create table t1 as select 1;
Query OK, 1 row affected (0.34 sec)
Records: 1  Duplicates: 0  Warnings: 0
 
show binlog events;
+-------------------+-----+-------------+-----------+-------------+---------------------------------------------------------------------+
| Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                                                |
+-------------------+-----+-------------+-----------+-------------+---------------------------------------------------------------------+
| master-bin.000001 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.27-MariaDB-debug-log, Binlog ver: 4                 |
| master-bin.000001 | 245 | Query       |         1 |         318 | BEGIN                                                               |
| master-bin.000001 | 318 | Query       |         1 |         441 | use `test`; CREATE TABLE `t1` (
  `1` int(1) NOT NULL DEFAULT '0'
) |
| master-bin.000001 | 441 | Table_map   |         1 |         482 | table_id: 33 (test.t1)                                              |
| master-bin.000001 | 482 | Write_rows  |         1 |         516 | table_id: 33 flags: STMT_END_F                                      |
| master-bin.000001 | 516 | Xid         |         1 |         543 | COMMIT /* xid=1 */                                                  |
+-------------------+-----+-------------+-----------+-------------+---------------------------------------------------------------------+
6 rows in set (0.00 sec)

It means that if the binlog is used to replicate (or recreate) the data, the process will fail immediately on the Write_rows event, because the table won't exist.
The problem is reproducible even if wsrep provider is not set.



 Comments   
Comment by Seppo Jaakola [ 2012-10-23 ]

CTAS processing was refactored in upstream based on tracker: https://bugs.launchpad.net/codership-mysql/+bug/1052002

Comment by Seppo Jaakola [ 2012-10-23 ]

Fix was merged as part of revision: http://bazaar.launchpad.net/~maria-captains/maria/maria-5.5-galera/revision/3355

Generated at Thu Feb 08 06:29:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.