diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-09-05 09:11:42 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-09-05 09:11:42 +0200 |
commit | 362ad94bb0068178c018e826db1fc6bfa56ea712 (patch) | |
tree | 3507634d0a8a97ce154dfb8d25740f66e5f80f38 /sql/handler.cc | |
parent | 747893a854515e96891dcfafed8adcc721e8011f (diff) | |
download | mariadb-git-362ad94bb0068178c018e826db1fc6bfa56ea712.tar.gz |
cleanup: don't copy-paste, don't current_thd
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index de456f703f1..4e4c8fa33f6 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -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 error; @@ -5897,20 +5917,9 @@ int handler::ha_write_row(uchar *buf) rows_changed++; if (unlikely(error= binlog_log_row(table, 0, buf, log_func))) 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"); - 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) rows_changed++; if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func))) return error; -#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)); - return ER_ERROR_DURING_COMMIT; - } -#endif /* WITH_WSREP */ - return 0; + return check_wsrep_max_ws_rows(); } int handler::ha_delete_row(const uchar *buf) @@ -5979,18 +5977,7 @@ int handler::ha_delete_row(const uchar *buf) rows_changed++; if (unlikely(error= binlog_log_row(table, buf, 0, log_func))) return error; -#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)); - return ER_ERROR_DURING_COMMIT; - } -#endif /* WITH_WSREP */ - return 0; + return check_wsrep_max_ws_rows(); } |