Commit 90f2c822 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-7817 ALTER TABLE {ADD|DROP} INDEX IF [NOT] EXISTS does not get written...

MDEV-7817 ALTER TABLE {ADD|DROP} INDEX IF [NOT] EXISTS does not get written into binlog if nothing to do.
Just log the ALTER statement even if there's nothing to do.
parent 3c47809b
......@@ -345,3 +345,48 @@ RESET MASTER;
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 <pos>
CREATE TABLE t1(a INT, b INT);
CREATE TABLE IF NOT EXISTS t1(a INT, b INT);
Warnings:
Note 1050 Table 't1' already exists
CREATE INDEX IF NOT EXISTS i1 ON t1(a);
CREATE INDEX IF NOT EXISTS i1 ON t1(a);
Warnings:
Note 1061 Duplicate key name 'i1'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `i1` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP INDEX IF EXISTS i1 ON t1;
DROP INDEX IF EXISTS i1 ON t1;
Warnings:
Note 1091 Can't DROP 'i1'; check that column/key exists
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 'test.t1'
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`; 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 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;
......@@ -175,3 +175,22 @@ SHOW MASTER STATUS;
RESET MASTER;
--replace_result $pos <pos>
SHOW MASTER STATUS;
#
# mdev-7817 ALTER TABLE {ADD|DROP} INDEX IF [NOT] EXISTS does not get written into binlog if nothing to do
#
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;
......@@ -8484,6 +8484,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
ER_THD(thd, ER_INSERT_INFO), 0L, 0L,
thd->get_stmt_da()->current_statement_warn_count());
my_ok(thd, 0L, 0L, alter_ctx.tmp_name);
if (write_bin_log(thd, true, thd->query(), thd->query_length()))
DBUG_RETURN(true);
DBUG_RETURN(false);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment