From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v2 07/11] sql: move sqlite3DeleteTrigger to sql.h Date: Sat, 9 Jun 2018 12:32:20 +0300 [thread overview] Message-ID: <8e81edd81ecfcb8b90330fde614c95488df15dfc.1528535873.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1528535873.git.kshcherbatov@tarantool.org> In-Reply-To: <cover.1528535873.git.kshcherbatov@tarantool.org> Part of #3273. --- src/box/sql.h | 9 +++++++++ src/box/sql/callback.c | 2 +- src/box/sql/sqliteInt.h | 3 +-- src/box/sql/status.c | 6 +++--- src/box/sql/tokenize.c | 2 +- src/box/sql/trigger.c | 25 +++++++++++-------------- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/box/sql.h b/src/box/sql.h index 3f6cf22..35aacc3 100644 --- a/src/box/sql.h +++ b/src/box/sql.h @@ -66,6 +66,7 @@ struct Expr; struct Parse; struct Select; struct Table; +struct Trigger; /** * Perform parsing of provided expression. This is done by @@ -83,6 +84,14 @@ struct Expr * sql_expr_compile(struct sqlite3 *db, const char *expr, int expr_len); /** + * Free AST pointed by trigger. + * @param db SQL handle. + * @param trigger AST object. + */ +void +sql_trigger_delete(struct sqlite3 *db, struct Trigger *trigger); + +/** * Store duplicate of a parsed expression into @a parser. * @param parser Parser context. * @param select Select to extract from. diff --git a/src/box/sql/callback.c b/src/box/sql/callback.c index 8289c05..e3f36e3 100644 --- a/src/box/sql/callback.c +++ b/src/box/sql/callback.c @@ -292,7 +292,7 @@ sqlite3SchemaClear(sqlite3 * db) sqlite3HashInit(&pSchema->trigHash); for (pElem = sqliteHashFirst(&temp2); pElem; pElem = sqliteHashNext(pElem)) { - sqlite3DeleteTrigger(0, (Trigger *) sqliteHashData(pElem)); + sql_trigger_delete(0, (Trigger *) sqliteHashData(pElem)); } sqlite3HashClear(&temp2); sqlite3HashInit(&pSchema->tblHash); diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index 01351a1..ecbd573 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -4027,7 +4027,6 @@ TriggerStep *sqlite3TriggerInsertStep(sqlite3 *, Token *, IdList *, TriggerStep *sqlite3TriggerUpdateStep(sqlite3 *, Token *, ExprList *, Expr *, u8); TriggerStep *sqlite3TriggerDeleteStep(sqlite3 *, Token *, Expr *); -void sqlite3DeleteTrigger(sqlite3 *, Trigger *); void sqlite3UnlinkAndDeleteTrigger(sqlite3 *, const char *); u32 sqlite3TriggerColmask(Parse *, Trigger *, ExprList *, int, int, Table *, int); @@ -4035,7 +4034,7 @@ u32 sqlite3TriggerColmask(Parse *, Trigger *, ExprList *, int, int, Table *, #define sqlite3IsToplevel(p) ((p)->pToplevel==0) #else #define sqlite3TriggersExist(C,D,E,F) 0 -#define sqlite3DeleteTrigger(A,B) +#define sql_trigger_delete(A,B) #define sqlite3DropTriggerPtr(A,B) #define sqlite3UnlinkAndDeleteTrigger(A,B,C) #define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) diff --git a/src/box/sql/status.c b/src/box/sql/status.c index 84f07cc..dda91c5 100644 --- a/src/box/sql/status.c +++ b/src/box/sql/status.c @@ -256,9 +256,9 @@ sqlite3_db_status(sqlite3 * db, /* The database connection whose status is desir for (p = sqliteHashFirst(&pSchema->trigHash); p; p = sqliteHashNext(p)) { - sqlite3DeleteTrigger(db, - (Trigger *) - sqliteHashData(p)); + sql_trigger_delete(db, + (Trigger *) + sqliteHashData(p)); } for (p = sqliteHashFirst(&pSchema->tblHash); p; p = sqliteHashNext(p)) { diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c index 5b7c97d..3f59fc8 100644 --- a/src/box/sql/tokenize.c +++ b/src/box/sql/tokenize.c @@ -534,7 +534,7 @@ sqlite3RunParser(Parse * pParse, const char *zSql, char **pzErrMsg) if (pParse->pWithToFree) sqlite3WithDelete(db, pParse->pWithToFree); - sqlite3DeleteTrigger(db, pParse->pNewTrigger); + sql_trigger_delete(db, pParse->pNewTrigger); sqlite3DbFree(db, pParse->pVList); while (pParse->pZombieTab) { Table *p = pParse->pZombieTab; diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index ea35211..053dadb 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -186,7 +186,7 @@ sqlite3BeginTrigger(Parse * pParse, /* The parse context of the CREATE TRIGGER s sqlite3IdListDelete(db, pColumns); sql_expr_delete(db, pWhen, false); if (!pParse->pNewTrigger) { - sqlite3DeleteTrigger(db, pTrigger); + sql_trigger_delete(db, pTrigger); } else { assert(pParse->pNewTrigger == pTrigger); } @@ -328,7 +328,7 @@ sqlite3FinishTrigger(Parse * pParse, /* Parser context */ /* No need to free zName sinceif we reach this point alloc for it either wasn't called at all or failed. */ } - sqlite3DeleteTrigger(db, pTrig); + sql_trigger_delete(db, pTrig); assert(!pParse->pNewTrigger); sqlite3DeleteTriggerStep(db, pStepList); } @@ -471,20 +471,17 @@ sqlite3TriggerDeleteStep(sqlite3 * db, /* Database connection */ return pTriggerStep; } -/* - * Recursively delete a Trigger structure - */ void -sqlite3DeleteTrigger(sqlite3 * db, Trigger * pTrigger) +sql_trigger_delete(struct sqlite3 *db, struct Trigger *trigger) { - if (pTrigger == 0) + if (trigger == NULL) return; - sqlite3DeleteTriggerStep(db, pTrigger->step_list); - sqlite3DbFree(db, pTrigger->zName); - sqlite3DbFree(db, pTrigger->table); - sql_expr_delete(db, pTrigger->pWhen, false); - sqlite3IdListDelete(db, pTrigger->pColumns); - sqlite3DbFree(db, pTrigger); + sqlite3DeleteTriggerStep(db, trigger->step_list); + sqlite3DbFree(db, trigger->zName); + sqlite3DbFree(db, trigger->table); + sql_expr_delete(db, trigger->pWhen, false); + sqlite3IdListDelete(db, trigger->pColumns); + sqlite3DbFree(db, trigger); } /* @@ -593,7 +590,7 @@ sqlite3UnlinkAndDeleteTrigger(sqlite3 * db, const char *zName) pp = &((*pp)->pNext)) ; *pp = (*pp)->pNext; } - sqlite3DeleteTrigger(db, pTrigger); + sql_trigger_delete(db, pTrigger); user_session->sql_flags |= SQLITE_InternChanges; } } -- 2.7.4
next prev parent reply other threads:[~2018-06-09 9:36 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-09 9:58 [tarantool-patches] [PATCH v2 00/11] sql: remove Triggers to server Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 10/11] sql: move " Kirill Shcherbatov 2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov 2018-06-28 7:18 ` Konstantin Osipov 2018-06-28 7:33 ` Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 11/11] sql: VDBE tests for trigger existence Kirill Shcherbatov 2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 02/11] box: move db->pShchema init to sql_init Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 04/11] sql: fix sql len in tarantoolSqlite3RenameTrigger Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 06/11] sql: refactor sql_expr_compile to return AST Kirill Shcherbatov 2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov 2018-06-09 9:32 ` Kirill Shcherbatov [this message] 2018-06-13 18:53 ` [tarantool-patches] Re: [PATCH v2 07/11] sql: move sqlite3DeleteTrigger to sql.h Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 08/11] box: sort error codes in misc.test Kirill Shcherbatov 2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 09/11] sql: new _trigger space format with space_id Kirill Shcherbatov 2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov 2018-06-09 9:58 ` [tarantool-patches] [PATCH v2 01/11] box: remove migration from alpha 1.8.2 and 1.8.4 Kirill Shcherbatov 2018-06-09 9:58 ` [tarantool-patches] [PATCH v2 03/11] sql: fix leak on CREATE TABLE and resolve self ref Kirill Shcherbatov 2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov 2018-06-09 9:58 ` [tarantool-patches] [PATCH v2 05/11] box: port schema_find_id to C Kirill Shcherbatov 2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy 2018-06-14 16:12 ` Kirill Shcherbatov
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=8e81edd81ecfcb8b90330fde614c95488df15dfc.1528535873.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v2 07/11] sql: move sqlite3DeleteTrigger to sql.h' \ /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