From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 3/3] sql: use struct txn_savepoint as anonymous savepoint Date: Wed, 7 Aug 2019 18:13:14 +0300 [thread overview] Message-ID: <9aec988b070358c684eb2ce9d4f853174184f08c.1565190104.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1565190104.git.korablev@tarantool.org> In-Reply-To: <cover.1565190104.git.korablev@tarantool.org> This allows us to completely remove SQL specific struct Savepoint and use instead original struct txn_savepoint. --- src/box/sql/sqlInt.h | 13 ------------- src/box/sql/vdbe.c | 2 +- src/box/sql/vdbeInt.h | 6 ++---- src/box/sql/vdbeaux.c | 30 ++---------------------------- 4 files changed, 5 insertions(+), 46 deletions(-) diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 87e5d22ee..c61605046 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -1050,7 +1050,6 @@ typedef struct NameContext NameContext; typedef struct Parse Parse; typedef struct PrintfArguments PrintfArguments; typedef struct RowSet RowSet; -typedef struct Savepoint Savepoint; typedef struct Select Select; typedef struct sqlThread sqlThread; typedef struct SelectDest SelectDest; @@ -1406,18 +1405,6 @@ enum trim_side_mask { {nArg, (nc*SQL_FUNC_NEEDCOLL)|extraFlags, \ SQL_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}, type} -/* - * All current savepoints are stored in a linked list starting at - * sql.pSavepoint. The first element in the list is the most recently - * opened savepoint. Savepoints are added to the list by the vdbe - * OP_Savepoint instruction. - */ -struct Savepoint { - box_txn_savepoint_t *tnt_savepoint; /* Tarantool's savepoint struct */ - char *zName; /* Savepoint name (nul-terminated) */ - Savepoint *pNext; /* Parent savepoint (if any) */ -}; - /* * The following are used as the second parameter to sqlSavepoint(), * and as the P1 argument to the OP_Savepoint instruction. diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 7d05ce11c..9165db6c3 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -2977,7 +2977,7 @@ case OP_TTransaction: { if (sql_txn_begin() != 0) goto abort_due_to_error; } else { - p->anonymous_savepoint = sql_savepoint(p, NULL); + p->anonymous_savepoint = txn_savepoint_new(in_txn(), NULL); if (p->anonymous_savepoint == NULL) goto abort_due_to_error; } diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 5582d9506..f3e05a180 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -425,7 +425,7 @@ struct Vdbe { /** Parser flags with which this object was built. */ uint32_t sql_flags; /* Anonymous savepoint for aborts only */ - Savepoint *anonymous_savepoint; + struct txn_savepoint *anonymous_savepoint; }; /* @@ -455,9 +455,7 @@ int sqlVdbeExec(Vdbe *); int sqlVdbeList(Vdbe *); int sql_txn_begin(); -Savepoint * -sql_savepoint(Vdbe *p, - const char *zName); + int sqlVdbeHalt(Vdbe *); int sqlVdbeMemTooBig(Mem *); int sqlVdbeMemCopy(Mem *, const Mem *); diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 3d256f86a..7e512dbea 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -1937,12 +1937,12 @@ int sqlVdbeCloseStatement(Vdbe * p, int eOp) { int rc = 0; - const Savepoint *savepoint = p->anonymous_savepoint; + struct txn_savepoint *savepoint = p->anonymous_savepoint; /* * If we have an anonymous transaction opened -> perform eOp. */ if (savepoint && eOp == SAVEPOINT_ROLLBACK) - rc = box_txn_rollback_to_savepoint(savepoint->tnt_savepoint); + rc = box_txn_rollback_to_savepoint(savepoint); p->anonymous_savepoint = NULL; return rc; } @@ -1984,32 +1984,6 @@ sql_txn_begin() return 0; } -Savepoint * -sql_savepoint(MAYBE_UNUSED Vdbe *p, const char *zName) -{ - assert(p); - size_t nName = zName ? strlen(zName) + 1 : 0; - size_t savepoint_sz = sizeof(Savepoint) + nName; - Savepoint *pNew; - - pNew = (Savepoint *)region_aligned_alloc(&fiber()->gc, - savepoint_sz, - alignof(Savepoint)); - if (pNew == NULL) { - diag_set(OutOfMemory, savepoint_sz, "region", - "savepoint"); - return NULL; - } - pNew->tnt_savepoint = box_txn_savepoint(); - if (!pNew->tnt_savepoint) - return NULL; - if (zName) { - pNew->zName = (char *)&pNew[1]; - memcpy(pNew->zName, zName, nName); - }; - return pNew; -} - /* * This routine is called the when a VDBE tries to halt. If the VDBE * has made changes and is in autocommit mode, then commit those -- 2.15.1
next prev parent reply other threads:[~2019-08-07 15:13 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-07 15:13 [tarantool-patches] [PATCH 0/3] Merge struct sql_txn into struct txn/savepoint Nikita Pettik 2019-08-07 15:13 ` [tarantool-patches] [PATCH 1/3] txn: move fk_deferred_count from psql_txn to txn Nikita Pettik 2019-08-09 20:59 ` [tarantool-patches] " Vladislav Shpilevoy 2019-08-15 11:03 ` n.pettik 2019-08-07 15:13 ` [tarantool-patches] [PATCH 2/3] txn: merge struct sql_txn into struct txn Nikita Pettik 2019-08-07 15:26 ` [tarantool-patches] " Konstantin Osipov 2019-08-09 21:02 ` Vladislav Shpilevoy 2019-08-12 21:55 ` Konstantin Osipov 2019-08-15 11:04 ` n.pettik 2019-08-15 22:03 ` Vladislav Shpilevoy 2019-08-16 18:52 ` n.pettik 2019-08-19 20:47 ` Vladislav Shpilevoy 2019-08-21 0:23 ` n.pettik 2019-08-21 20:45 ` Vladislav Shpilevoy 2019-08-07 15:13 ` Nikita Pettik [this message] 2019-08-07 15:26 ` [tarantool-patches] Re: [PATCH 0/3] Merge struct sql_txn into struct txn/savepoint Konstantin Osipov 2019-08-22 11:56 ` Kirill Yukhin
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=9aec988b070358c684eb2ce9d4f853174184f08c.1565190104.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 3/3] sql: use struct txn_savepoint as anonymous savepoint' \ /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