summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2019-10-21 17:17:09 +0300
committerMichael Widenius <monty@mariadb.org>2019-10-21 17:17:09 +0300
commit06d2e1d828140d887adb68b05c85d5107baf816c (patch)
treefa3cbcadb16c80c0163d44bfdd6ef418aa8004f8 /sql
parent7def2877e3d7bd5335a0a53c20c01948407ab775 (diff)
downloadmariadb-git-06d2e1d828140d887adb68b05c85d5107baf816c.tar.gz
read-only slave using statement replication should replicate tmp tables
Relates to MDEV-17863 DROP TEMPORARY TABLE creates a transaction in binary log on read only server Other things: - Fixed that insert into normal_table select from tmp_table is replicated as row events if tmp_table doesn't exists on slave.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_admin.cc6
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_table.cc2
3 files changed, 6 insertions, 4 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 297733a00a7..dde194053b9 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -1314,7 +1314,7 @@ bool Sql_cmd_analyze_table::execute(THD *thd)
"analyze", lock_type, 1, 0, 0, 0,
&handler::ha_analyze, 0);
/* ! we write after unlocking the table */
- if (!res && !m_lex->no_write_to_binlog && !opt_readonly)
+ if (!res && !m_lex->no_write_to_binlog && (!opt_readonly || thd->slave_thread))
{
/*
Presumably, ANALYZE and binlog writing doesn't require synchronization
@@ -1372,7 +1372,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
"optimize", TL_WRITE, 1, 0, 0, 0,
&handler::ha_optimize, 0);
/* ! we write after unlocking the table */
- if (!res && !m_lex->no_write_to_binlog && !opt_readonly)
+ if (!res && !m_lex->no_write_to_binlog && (!opt_readonly || thd->slave_thread))
{
/*
Presumably, OPTIMIZE and binlog writing doesn't require synchronization
@@ -1406,7 +1406,7 @@ bool Sql_cmd_repair_table::execute(THD *thd)
&handler::ha_repair, &view_repair);
/* ! we write after unlocking the table */
- if (!res && !m_lex->no_write_to_binlog && !opt_readonly)
+ if (!res && !m_lex->no_write_to_binlog && (!opt_readonly || thd->slave_thread))
{
/*
Presumably, REPAIR and binlog writing doesn't require synchronization
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f79d8828fcd..9875f0cd14a 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -6040,6 +6040,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
*/
DBUG_ASSERT(share->tmp_table);
flags&= ~HA_BINLOG_STMT_CAPABLE;
+ /* We can only use row logging */
+ set_current_stmt_binlog_format_row();
}
DBUG_PRINT("info", ("table: %s; ha_table_flags: 0x%llx",
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index ebf268fe8c8..8eb0b078bd1 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5217,7 +5217,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
err:
/* In RBR or readonly server we don't need to log CREATE TEMPORARY TABLE */
if (!result && create_info->tmp_table() &&
- (thd->is_current_stmt_binlog_format_row() || opt_readonly))
+ (thd->is_current_stmt_binlog_format_row() || (opt_readonly && !thd->slave_thread)))
{
/* Note that table->s->table_creation_was_logged is not set! */
DBUG_RETURN(result);