summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc105
1 files changed, 39 insertions, 66 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 7662d68e51f..e5362c7cf9c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5899,29 +5899,6 @@ bool handler::check_table_binlog_row_based_internal(bool binlog_row)
{
THD *thd= table->in_use;
-#ifdef WITH_WSREP
- /* only InnoDB tables will be replicated through binlog emulation */
- if (binlog_row &&
- ((WSREP_EMULATE_BINLOG(thd) &&
- table->file->partition_ht()->db_type != DB_TYPE_INNODB) ||
- (thd->wsrep_ignore_table == true)))
- return 0;
-
- /* enforce wsrep_max_ws_rows */
- if (WSREP(thd) && table->s->tmp_table == NO_TMP_TABLE)
- {
- thd->wsrep_affected_rows++;
- if (wsrep_max_ws_rows &&
- thd->wsrep_exec_mode != REPL_RECV &&
- thd->wsrep_affected_rows > wsrep_max_ws_rows)
- {
- trans_rollback_stmt(thd) || trans_rollback(thd);
- my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
- return ER_ERROR_DURING_COMMIT;
- }
- }
-#endif
-
return (table->s->can_do_row_logging &&
thd->is_current_stmt_binlog_format_row() &&
/*
@@ -6030,12 +6007,10 @@ static int write_locked_table_maps(THD *thd)
}
-static int check_wsrep_max_ws_rows();
-
-int binlog_log_row(TABLE* table,
- const uchar *before_record,
- const uchar *after_record,
- Log_func *log_func)
+static int binlog_log_row_internal(TABLE* table,
+ const uchar *before_record,
+ const uchar *after_record,
+ Log_func *log_func)
{
bool error= 0;
THD *const thd= table->in_use;
@@ -6059,17 +6034,42 @@ int binlog_log_row(TABLE* table,
bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE ||
table->file->has_transactions();
error= (*log_func)(thd, table, has_trans, before_record, after_record);
-
- /*
- Now that the record has been logged, increment wsrep_affected_rows and
- also check whether its within the allowable limits (wsrep_max_ws_rows).
- */
- if (error == 0)
- error= check_wsrep_max_ws_rows();
}
return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
}
+int binlog_log_row(TABLE* table, const uchar *before_record,
+ const uchar *after_record, Log_func *log_func)
+{
+#ifdef WITH_WSREP
+ THD *const thd= table->in_use;
+
+ /* only InnoDB tables will be replicated through binlog emulation */
+ if ((WSREP_EMULATE_BINLOG(thd) &&
+ table->file->partition_ht()->db_type != DB_TYPE_INNODB) ||
+ (thd->wsrep_ignore_table == true))
+ return 0;
+
+ /* enforce wsrep_max_ws_rows */
+ if (WSREP(thd) && table->s->tmp_table == NO_TMP_TABLE)
+ {
+ thd->wsrep_affected_rows++;
+ if (wsrep_max_ws_rows &&
+ thd->wsrep_exec_mode != REPL_RECV &&
+ thd->wsrep_affected_rows > wsrep_max_ws_rows)
+ {
+ trans_rollback_stmt(thd) || trans_rollback(thd);
+ my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
+ return ER_ERROR_DURING_COMMIT;
+ }
+ }
+#endif
+
+ if (!table->file->check_table_binlog_row_based(1))
+ return 0;
+ return binlog_log_row_internal(table, before_record, after_record, log_func);
+}
+
int handler::ha_external_lock(THD *thd, int lock_type)
{
@@ -6175,30 +6175,6 @@ int handler::ha_reset()
}
-static int check_wsrep_max_ws_rows()
-{
-#ifdef WITH_WSREP
- if (wsrep_max_ws_rows)
- {
- THD *thd= current_thd;
-
- if (!WSREP(thd))
- return 0;
-
- thd->wsrep_affected_rows++;
- if (thd->wsrep_exec_mode != REPL_RECV &&
- thd->wsrep_affected_rows > wsrep_max_ws_rows)
- {
- trans_rollback_stmt(thd) || trans_rollback(thd);
- my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
- return ER_ERROR_DURING_COMMIT;
- }
- }
-#endif /* WITH_WSREP */
- return 0;
-}
-
-
int handler::ha_write_row(uchar *buf)
{
int error;
@@ -6219,8 +6195,7 @@ int handler::ha_write_row(uchar *buf)
if (likely(!error) && !row_already_logged)
{
rows_changed++;
- if (table->file->check_table_binlog_row_based(1))
- error= binlog_log_row(table, 0, buf, log_func);
+ error= binlog_log_row(table, 0, buf, log_func);
}
DEBUG_SYNC_C("ha_write_row_end");
DBUG_RETURN(error);
@@ -6252,8 +6227,7 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data)
if (likely(!error) && !row_already_logged)
{
rows_changed++;
- if (table->file->check_table_binlog_row_based(1))
- error= binlog_log_row(table, old_data, new_data, log_func);
+ error= binlog_log_row(table, old_data, new_data, log_func);
}
return error;
}
@@ -6308,8 +6282,7 @@ int handler::ha_delete_row(const uchar *buf)
if (likely(!error))
{
rows_changed++;
- if (table->file->check_table_binlog_row_based(1))
- error= binlog_log_row(table, buf, 0, log_func);
+ error= binlog_log_row(table, buf, 0, log_func);
}
return error;
}