[Tarantool-patches] [PATCH v3 05/13] txm: save txn in txn_stmt

Aleksandr Lyapunov alyapunov at tarantool.org
Wed Jul 15 16:55:28 MSK 2020


There is a lot of places in transaction engine (see futher commits)
where it's convenient to store just a pointer to tx statement while
having a way to get the transaction itself by this pointer.
Let's store a pointer to TX in TX statement for that purpose.

Part of #4897
---
 src/box/txn.c | 1 +
 src/box/txn.h | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/box/txn.c b/src/box/txn.c
index 287f352..62b91d6 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -109,6 +109,7 @@ txn_stmt_new(struct region *region)
 	}
 
 	/* Initialize members explicitly to save time on memset() */
+	stmt->txn = in_txn();
 	stmt->space = NULL;
 	stmt->old_tuple = NULL;
 	stmt->new_tuple = NULL;
diff --git a/src/box/txn.h b/src/box/txn.h
index c1f06db..36b1a03 100644
--- a/src/box/txn.h
+++ b/src/box/txn.h
@@ -129,6 +129,8 @@ struct txn_stmt {
 
 	/** A linked list of all statements. */
 	struct stailq_entry next;
+	/** Owner of that statement. */
+	struct txn *txn;
 	/** Undo info. */
 	struct space *space;
 	struct tuple *old_tuple;
-- 
2.7.4



More information about the Tarantool-patches mailing list