summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorVenkatesh Duggirala <venkatesh.duggirala@oracle.com>2016-02-26 09:01:49 +0530
committerVenkatesh Duggirala <venkatesh.duggirala@oracle.com>2016-02-26 09:01:49 +0530
commit29cc2c28832ae4733804ac6b29d650238ee0559c (patch)
tree0f670362f99fc159df0b14cccc6ea667bb3af76e /sql
parent4ed09d54f53771383b943ee6610dae5faa068cff (diff)
downloadmariadb-git-29cc2c28832ae4733804ac6b29d650238ee0559c.tar.gz
BUG#20574550 MAIN.MERGE TEST CASE FAILS IF BINLOG_FORMAT=ROW
The main.merge test case was failing when tested using row based binlog format. While analyzing the issue it was found the following issues: a) The server is calling binlog related code even when a statement will not be binlogged; b) The child table list was not present into table structure by the time to generate the create table statement; c) The tables in the child table list will not be opened yet when generating table create info using row based replication; d) CREATE TABLE LIKE TEMP_TABLE does not preserve original table storage engine when using row based replication; This patch addressed all above issues. @ sql/sql_class.h Added a function to determine if the binary log is disabled to the current session. This is related with issue (a) above. @ sql/sql_table.cc Added code to skip binary logging related code if the statement will not be binlogged. This is related with issue (a) above. Added code to add the children to the query list of the table that will have its CREATE TABLE generated. This is related with issue (b) above. Added code to force the storage engine to be generated into the CREATE TABLE. This is related with issue (d) above. @ storage/myisammrg/ha_myisammrg.cc Added a test to skip a table getting info about a child table if the child table is not opened. This is related to issue (c) above.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_class.h14
-rw-r--r--sql/sql_table.cc20
2 files changed, 31 insertions, 3 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index c9900231615..0df8c70e184 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1662,6 +1662,18 @@ public:
current_stmt_binlog_format == BINLOG_FORMAT_ROW);
return current_stmt_binlog_format == BINLOG_FORMAT_ROW;
}
+ /**
+ Determine if binlogging is disabled for this session
+ @retval 0 if the current statement binlogging is disabled
+ (could be because of binlog closed/binlog option
+ is set to false).
+ @retval 1 if the current statement will be binlogged
+ */
+ inline bool is_current_stmt_binlog_disabled() const
+ {
+ return (!(variables.option_bits & OPTION_BIN_LOG) ||
+ !mysql_bin_log.is_open());
+ }
private:
/**
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7b4d08613cf..49f05c6116e 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -4709,7 +4709,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
/*
We have to write the query before we unlock the tables.
*/
- if (thd->is_current_stmt_binlog_format_row())
+ if (!thd->is_current_stmt_binlog_disabled() &&
+ thd->is_current_stmt_binlog_format_row())
{
/*
Since temporary tables are not replicated under row-based
@@ -4751,6 +4752,21 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
if (open_table(thd, table, thd->mem_root, &ot_ctx))
goto err;
+ /*
+ After opening a MERGE table add the children to the query list of
+ tables, so that children tables info can be used on "CREATE TABLE"
+ statement generation by the binary log.
+ Note that placeholders don't have the handler open.
+ */
+ if (table->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST))
+ goto err;
+
+ /*
+ As the reference table is temporary and may not exist on slave, we must
+ force the ENGINE to be present into CREATE TABLE.
+ */
+ create_info->used_fields|= HA_CREATE_USED_ENGINE;
+
int result __attribute__((unused))=
store_create_info(thd, table, &query,
create_info, TRUE /* show_database */);