summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorunknown <mats@romeo.(none)>2006-08-16 15:59:41 +0200
committerunknown <mats@romeo.(none)>2006-08-16 15:59:41 +0200
commit84ba160cc90be3acbfcbc3b37d15430ef30314d3 (patch)
tree277e4e135a6a0c14be59c5cf806b70470770a0ea /sql/sql_class.cc
parent2457ca1cb572e900126df151cafda181cab649a5 (diff)
parentf6144fb75eaed8f0d7f25349cf9f8e0ae03dad4f (diff)
downloadmariadb-git-84ba160cc90be3acbfcbc3b37d15430ef30314d3.tar.gz
Merging with mysql-5.1-new-rpl tree
sql/log.cc: Auto merged sql/sql_class.cc: Auto merged mysql-test/r/rpl_switch_stm_row_mixed.result: Merge with mysql-5.1-new-rpl mysql-test/t/rpl_switch_stm_row_mixed.test: Merge with mysql-5.1-new-rpl
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc40
1 files changed, 21 insertions, 19 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index c1a3b76ce55..df87bf07269 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2652,7 +2652,12 @@ int THD::binlog_delete_row(TABLE* table, bool is_trans,
int THD::binlog_flush_pending_rows_event(bool stmt_end)
{
DBUG_ENTER("THD::binlog_flush_pending_rows_event");
- if (!current_stmt_binlog_row_based || !mysql_bin_log.is_open())
+ /*
+ We shall flush the pending event even if we are not in row-based
+ mode: it might be the case that we left row-based mode before
+ flushing anything (e.g., if we have explicitly locked tables).
+ */
+ if (!mysql_bin_log.is_open())
DBUG_RETURN(0);
/*
@@ -2718,6 +2723,21 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
DBUG_PRINT("enter", ("qtype=%d, query='%s'", qtype, query));
DBUG_ASSERT(query && mysql_bin_log.is_open());
+ /*
+ If we are not in prelocked mode, mysql_unlock_tables() will be
+ called after this binlog_query(), so we have to flush the pending
+ rows event with the STMT_END_F set to unlock all tables at the
+ slave side as well.
+
+ If we are in prelocked mode, the flushing will be done inside the
+ top-most close_thread_tables().
+ */
+#ifdef HAVE_ROW_BASED_REPLICATION
+ if (this->prelocked_mode == NON_PRELOCKED)
+ if (int error= binlog_flush_pending_rows_event(TRUE))
+ DBUG_RETURN(error);
+#endif /*HAVE_ROW_BASED_REPLICATION*/
+
switch (qtype) {
case THD::MYSQL_QUERY_TYPE:
/*
@@ -2731,25 +2751,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
case THD::ROW_QUERY_TYPE:
#ifdef HAVE_ROW_BASED_REPLICATION
if (current_stmt_binlog_row_based)
- {
- /*
- If thd->lock is set, then we are not inside a stored function.
- In that case, mysql_unlock_tables() will be called after this
- binlog_query(), so we have to flush the pending rows event
- with the STMT_END_F set to unlock all tables at the slave side
- as well.
-
- We will not flush the pending event, if thd->lock is NULL.
- This means that we are inside a stored function or trigger, so
- the flushing will be done inside the top-most
- close_thread_tables().
- */
-#ifdef HAVE_ROW_BASED_REPLICATION
- if (this->lock)
- DBUG_RETURN(binlog_flush_pending_rows_event(TRUE));
-#endif /*HAVE_ROW_BASED_REPLICATION*/
DBUG_RETURN(0);
- }
#endif
/* Otherwise, we fall through */
case THD::STMT_QUERY_TYPE: