Commit 362ad94b authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: don't copy-paste, don't current_thd

parent 747893a8
...@@ -5875,6 +5875,26 @@ int handler::ha_reset() ...@@ -5875,6 +5875,26 @@ int handler::ha_reset()
} }
static int check_wsrep_max_ws_rows()
{
#ifdef WITH_WSREP
if (wsrep_max_ws_rows)
{
THD *thd= current_thd;
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 handler::ha_write_row(uchar *buf)
{ {
int error; int error;
...@@ -5897,20 +5917,9 @@ int handler::ha_write_row(uchar *buf) ...@@ -5897,20 +5917,9 @@ int handler::ha_write_row(uchar *buf)
rows_changed++; rows_changed++;
if (unlikely(error= binlog_log_row(table, 0, buf, log_func))) if (unlikely(error= binlog_log_row(table, 0, buf, log_func)))
DBUG_RETURN(error); /* purecov: inspected */ DBUG_RETURN(error); /* purecov: inspected */
#ifdef WITH_WSREP
current_thd->wsrep_affected_rows++;
if (wsrep_max_ws_rows &&
current_thd->wsrep_exec_mode != REPL_RECV &&
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
{
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
DBUG_RETURN(ER_ERROR_DURING_COMMIT);
}
#endif /* WITH_WSREP */
DEBUG_SYNC_C("ha_write_row_end"); DEBUG_SYNC_C("ha_write_row_end");
DBUG_RETURN(0); DBUG_RETURN(check_wsrep_max_ws_rows());
} }
...@@ -5941,18 +5950,7 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data) ...@@ -5941,18 +5950,7 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
rows_changed++; rows_changed++;
if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func))) if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func)))
return error; return error;
#ifdef WITH_WSREP return check_wsrep_max_ws_rows();
current_thd->wsrep_affected_rows++;
if (wsrep_max_ws_rows &&
current_thd->wsrep_exec_mode != REPL_RECV &&
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
{
trans_rollback_stmt(current_thd) || trans_rollback(current_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_delete_row(const uchar *buf) int handler::ha_delete_row(const uchar *buf)
...@@ -5979,18 +5977,7 @@ int handler::ha_delete_row(const uchar *buf) ...@@ -5979,18 +5977,7 @@ int handler::ha_delete_row(const uchar *buf)
rows_changed++; rows_changed++;
if (unlikely(error= binlog_log_row(table, buf, 0, log_func))) if (unlikely(error= binlog_log_row(table, buf, 0, log_func)))
return error; return error;
#ifdef WITH_WSREP return check_wsrep_max_ws_rows();
current_thd->wsrep_affected_rows++;
if (wsrep_max_ws_rows &&
current_thd->wsrep_exec_mode != REPL_RECV &&
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
{
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
return ER_ERROR_DURING_COMMIT;
}
#endif /* WITH_WSREP */
return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment