[Commits] a189c40: cleanup: don't copy-paste, don't current_thd

serg at mariadb.org serg at mariadb.org
Mon Sep 5 09:56:45 EEST 2016


revision-id: a189c409b6d6524d281b5a7e284e52a936fbb754 (mariadb-10.1.17-6-ga189c40)
parent(s): 747893a854515e96891dcfafed8adcc721e8011f
author: Sergei Golubchik
committer: Sergei Golubchik
timestamp: 2016-09-05 08:56:11 +0200
message:

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

---
 sql/handler.cc | 58 ++++++++++++++++++++++------------------------------------
 1 file changed, 22 insertions(+), 36 deletions(-)

diff --git a/sql/handler.cc b/sql/handler.cc
index de456f7..807faae 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5875,6 +5875,25 @@ 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 +5916,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 +5949,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 +5976,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();
 }
 
 


More information about the commits mailing list