From: Vladimir Davydov <vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Subject: [PATCH v2 1/3] txn: move stmt list/savepoint manipulation out of txn_stmt_new Date: Tue, 30 Jul 2019 13:49:13 +0300 [thread overview] Message-ID: <37bedba5d2f3670547633d0c70169e47d6f6476b.1564483378.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1564483378.git.vdavydov.dev@gmail.com> txn_stmt_new is supposed to simply allocate an initialize a new txn_stmt struct. Adding the new statement to the txn's statement list and setting up a savepoint for rollback looks confusing. Move it to txn_begin_stmt. --- src/box/txn.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 05ec6f14..27ae43ac 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -84,10 +84,10 @@ txn_add_redo(struct txn *txn, struct txn_stmt *stmt, struct request *request) /** Initialize a new stmt object within txn. */ static struct txn_stmt * -txn_stmt_new(struct txn *txn) +txn_stmt_new(struct region *region) { struct txn_stmt *stmt; - stmt = region_alloc_object(&txn->region, struct txn_stmt); + stmt = region_alloc_object(region, struct txn_stmt); if (stmt == NULL) { diag_set(OutOfMemory, sizeof(*stmt), "region", "struct txn_stmt"); @@ -100,12 +100,6 @@ txn_stmt_new(struct txn *txn) stmt->new_tuple = NULL; stmt->engine_savepoint = NULL; stmt->row = NULL; - - /* Set the savepoint for statement rollback. */ - txn->sub_stmt_begin[txn->in_sub_stmt] = stailq_last(&txn->stmts); - txn->in_sub_stmt++; - - stailq_add_tail_entry(&txn->stmts, stmt, next); return stmt; } @@ -246,9 +240,15 @@ txn_begin_stmt(struct txn *txn, struct space *space) diag_set(ClientError, ER_SUB_STMT_MAX); return -1; } - struct txn_stmt *stmt = txn_stmt_new(txn); + struct txn_stmt *stmt = txn_stmt_new(&txn->region); if (stmt == NULL) return -1; + + /* Set the savepoint for statement rollback. */ + txn->sub_stmt_begin[txn->in_sub_stmt] = stailq_last(&txn->stmts); + txn->in_sub_stmt++; + stailq_add_tail_entry(&txn->stmts, stmt, next); + if (space == NULL) return 0; -- 2.20.1
next prev parent reply other threads:[~2019-07-30 10:49 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-30 10:49 [PATCH v2 0/3] Support savepoints in DDL transactions Vladimir Davydov 2019-07-30 10:49 ` Vladimir Davydov [this message] 2019-07-30 12:10 ` [tarantool-patches] Re: [PATCH v2 1/3] txn: move stmt list/savepoint manipulation out of txn_stmt_new Konstantin Osipov 2019-07-30 10:49 ` [PATCH v2 2/3] txn: kill txn_last_stmt helper Vladimir Davydov 2019-07-30 12:11 ` [tarantool-patches] " Konstantin Osipov 2019-07-30 10:49 ` [PATCH v2 3/3] txn: undo commit/rollback triggers when reverting to savepoint Vladimir Davydov 2019-07-30 12:13 ` [tarantool-patches] " Konstantin Osipov 2019-07-30 12:31 ` [PATCH v2 0/3] Support savepoints in DDL transactions Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=37bedba5d2f3670547633d0c70169e47d6f6476b.1564483378.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v2 1/3] txn: move stmt list/savepoint manipulation out of txn_stmt_new' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox