Skip to content

Commit

Permalink
MDEV-10320: NO-OP ALTER TABLE on temporary tables getting
Browse files Browse the repository at this point in the history
.. 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.
  • Loading branch information
Nirbhay Choubey committed Aug 8, 2016
1 parent df9b455 commit 69052ed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
11 changes: 11 additions & 0 deletions mysql-test/suite/rpl/r/rpl_temporary.result
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,16 @@ UNLOCK TABLES;
ALTER TABLE t1 RENAME t2, LOCK SHARED;
ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE;
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
include/rpl_end.inc
10 changes: 10 additions & 0 deletions mysql-test/suite/rpl/t/rpl_temporary.test
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,16 @@ ALTER TABLE t2 RENAME t1, LOCK EXCLUSIVE;

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
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc
9 changes: 7 additions & 2 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8735,8 +8735,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
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);
/* We don't replicate alter table statement on temporary tables */
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);
}
Expand Down

0 comments on commit 69052ed

Please sign in to comment.