Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-7817

ALTER TABLE {ADD|DROP} INDEX IF [NOT] EXISTS does not get written into binlog if nothing to do

    XMLWordPrintable

    Details

      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.

        Attachments

          Activity

            People

            Assignee:
            holyfoot Alexey Botchkov
            Reporter:
            bar Alexander Barkov
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration