From 83ae5aaf51efddc81a5168b339ae5d65851084e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= <marko.makela@mariadb.com>
Date: Fri, 15 Dec 2017 15:54:32 +0200
Subject: [PATCH 5/6] Make trx_mod_table_time_t a class

---
 storage/innobase/include/trx0trx.h | 26 ++++++++++++++++++++++++--
 storage/innobase/trx/trx0roll.cc   |  2 +-
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 81ef6093e2e..6e6ad11c265 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -779,8 +779,30 @@ struct trx_lock_t {
 	bool		start_stmt;
 };
 
-/** The first modification time of a table in a transaction */
-typedef undo_no_t trx_mod_table_time_t;
+/** Logical first modification time of a table in a transaction */
+class trx_mod_table_time_t
+{
+	/** First modification of the table */
+	undo_no_t	first;
+
+public:
+	/** Constructor
+	@param[in]	rows	number of modified rows so far */
+	trx_mod_table_time_t(undo_no_t rows)
+		: first(rows) {}
+
+	/** Invoked after partial rollback
+	@param[in]	limit	number of surviving modified rows
+	@return	whether this should be erased from trx_t::mod_tables */
+	bool rollback(undo_no_t limit)
+	{
+		if (first >= limit) {
+			return true;
+		}
+
+		return false;
+	}
+};
 
 /** Collection of persistent tables and their first modification
 in a transaction.
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index 82dd69b0d4d..eb8d461111d 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -125,7 +125,7 @@ trx_rollback_to_savepoint_low(
 		for (trx_mod_tables_t::iterator i = trx->mod_tables.begin();
 		     i != trx->mod_tables.end(); ) {
 			trx_mod_tables_t::iterator j = i++;
-			if (j->second >= limit) {
+			if (j->second.rollback(limit)) {
 				trx->mod_tables.erase(j);
 			}
 		}
-- 
2.15.1

