[MDEV-7817] ALTER TABLE {ADD|DROP} INDEX IF [NOT] EXISTS does not get written into binlog if nothing to do Created: 2015-03-23  Updated: 2015-10-06  Resolved: 2015-10-06

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.0, 10.1
Fix Version/s: 10.1.8

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexey Botchkov
Resolution: Fixed Votes: 1
Labels: verified


 Description   

I add this code into an mtr test:

CREATE TABLE t1(a INT, b INT);
CREATE TABLE IF NOT EXISTS t1(a INT, b INT);
CREATE INDEX IF NOT EXISTS i1 ON t1(a);
CREATE INDEX IF NOT EXISTS i1 ON t1(a);
SHOW CREATE TABLE t1;
DROP INDEX IF EXISTS i1 ON t1;
DROP INDEX IF EXISTS i1 ON t1;
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
--replace_column 1 # 2 # 5 #
--replace_regex /xid=[0-9]+/xid=XX/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ /Server.ver.*/VER/
SHOW BINLOG EVENTS;
RESET MASTER;

and see this output:

+SHOW BINLOG EVENTS;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+#	#	Format_desc	1	#	VER
+#	#	Gtid_list	1	#	[]
+#	#	Binlog_checkpoint	1	#	master-bin.000001
+#	#	Gtid	1	#	GTID #-#-#
+#	#	Query	1	#	use `test`; CREATE TABLE t1(a INT, b INT)
+#	#	Gtid	1	#	GTID #-#-#
+#	#	Query	1	#	use `test`; CREATE TABLE IF NOT EXISTS t1(a INT, b INT)
+#	#	Gtid	1	#	GTID #-#-#
+#	#	Query	1	#	use `test`; CREATE INDEX IF NOT EXISTS i1 ON t1(a)
+#	#	Gtid	1	#	GTID #-#-#
+#	#	Query	1	#	use `test`; DROP INDEX IF EXISTS i1 ON t1
+#	#	Gtid	1	#	GTID #-#-#
+#	#	Query	1	#	use `test`; DROP TABLE `t1` /* generated by server */
+#	#	Gtid	1	#	GTID #-#-#
+#	#	Query	1	#	use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */
+RESET MASTER;

Notice, these queries do get logged even if nothing to do:

  • CREATE TABLE IF NOT EXISTS
  • DROP TABLE IF EXISTS

Unlike the above, these queries do not get logged if nothing todo:

  • CREATE INDEX IF NOT EXISTS i1 ON t1(a);
  • DROP INDEX IF EXISTS i1 ON t1;
    They should be get logged.


 Comments   
Comment by Daniel Black [ 2015-06-23 ]

this might have been introduced in MDEV-7390 accidentally. sorry if this was the case.

Comment by Alexey Botchkov [ 2015-10-05 ]

proposed patch: http://lists.askmonty.org/pipermail/commits/2015-October/008483.html

Comment by Alexander Barkov [ 2015-10-05 ]


The patch looks Ok to push.

Comment by Alexey Botchkov [ 2015-10-06 ]

I belive that can be fixed in 10.0 similarly.

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