Commit 69052ed0 authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-10320: NO-OP ALTER TABLE on temporary tables getting

.. logged under row binlog format

In the early stages of ALTER TABLE execution, the implementation
checks whether its a NOOP (alter_info->flags == 0), and if so,
it returns after logging the command to binary log. The logging,
however, was done unconditionally.

Fixed by skipping the logging for temporary tables when under row
based replication.
parent df9b4554
...@@ -230,5 +230,16 @@ UNLOCK TABLES; ...@@ -230,5 +230,16 @@ UNLOCK TABLES;
ALTER TABLE t1 RENAME t2, LOCK SHARED; ALTER TABLE t1 RENAME t2, LOCK SHARED;
ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE; ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE;
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-10320: NO-OP ALTER TABLE on temporary tables getting logged
# under row binlog format
#
connection master;
CREATE TEMPORARY TABLE t1(i INT PRIMARY KEY) ENGINE=MYISAM;
ALTER TABLE t1;
ALTER TABLE t1 ADD COLUMN IF NOT EXISTS I INT;
Warnings:
Note 1060 Duplicate column name 'I'
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
include/rpl_end.inc include/rpl_end.inc
...@@ -401,6 +401,16 @@ ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE; ...@@ -401,6 +401,16 @@ ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-10320: NO-OP ALTER TABLE on temporary tables getting logged
--echo # under row binlog format
--echo #
connection master;
CREATE TEMPORARY TABLE t1(i INT PRIMARY KEY) ENGINE=MYISAM;
ALTER TABLE t1;
ALTER TABLE t1 ADD COLUMN IF NOT EXISTS I INT;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
--let $rpl_only_running_threads= 1 --let $rpl_only_running_threads= 1
--source include/rpl_end.inc --source include/rpl_end.inc
...@@ -8735,8 +8735,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -8735,8 +8735,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
thd->get_stmt_da()->current_statement_warn_count()); thd->get_stmt_da()->current_statement_warn_count());
my_ok(thd, 0L, 0L, alter_ctx.tmp_name); my_ok(thd, 0L, 0L, alter_ctx.tmp_name);
if (write_bin_log(thd, true, thd->query(), thd->query_length())) /* We don't replicate alter table statement on temporary tables */
DBUG_RETURN(true); if (table->s->tmp_table == NO_TMP_TABLE ||
!thd->is_current_stmt_binlog_format_row())
{
if (write_bin_log(thd, true, thd->query(), thd->query_length()))
DBUG_RETURN(true);
}
DBUG_RETURN(false); 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