From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id F1B5426612 for ; Wed, 7 Aug 2019 11:13:21 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nC4zrVbnc7aE for ; Wed, 7 Aug 2019 11:13:21 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A361C26615 for ; Wed, 7 Aug 2019 11:13:21 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 3/3] sql: use struct txn_savepoint as anonymous savepoint Date: Wed, 7 Aug 2019 18:13:14 +0300 Message-Id: <9aec988b070358c684eb2ce9d4f853174184f08c.1565190104.git.korablev@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik 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