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 v1 2/2] sql: remove usless sqlite3NestedParse function Date: Wed, 4 Jul 2018 20:17:55 +0300 [thread overview] Message-ID: <444b91093cc6ea1648f0e8bdd9b0923694ca3f8a.1530724375.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1530724375.git.kshcherbatov@tarantool.org> In-Reply-To: <cover.1530724375.git.kshcherbatov@tarantool.org> As sqlite3NestedParse become totaly useless, let's remove unreacheble code and all mentioning. Resolves #3496. --- src/box/sql/build.c | 40 ---------------------------------------- src/box/sql/delete.c | 6 +----- src/box/sql/insert.c | 6 +----- src/box/sql/sqliteInt.h | 1 - src/box/sql/update.c | 6 +----- 5 files changed, 3 insertions(+), 56 deletions(-) diff --git a/src/box/sql/build.c b/src/box/sql/build.c index ac53906..573da9a 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -116,46 +116,6 @@ sql_finish_coding(struct Parse *parse_context) } } -/* - * Run the parser and code generator recursively in order to generate - * code for the SQL statement given onto the end of the pParse context - * currently under construction. When the parser is run recursively - * this way, the final OP_Halt is not appended and other initialization - * and finalization steps are omitted because those are handling by the - * outermost parser. - * - * Not everything is nestable. This facility is designed to perform - * basic DDL operations. Use care if you decide to try to use this routine - * for some other purposes. - */ -void -sqlite3NestedParse(Parse * pParse, const char *zFormat, ...) -{ - va_list ap; - char *zSql; - char *zErrMsg = 0; - sqlite3 *db = pParse->db; - char saveBuf[PARSE_TAIL_SZ]; - - if (pParse->nErr) - return; - assert(pParse->nested < 10); /* Nesting should only be of limited depth */ - va_start(ap, zFormat); - zSql = sqlite3VMPrintf(db, zFormat, ap); - va_end(ap); - if (zSql == 0) { - return; /* A malloc must have failed */ - } - pParse->nested++; - memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ); - memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); - sqlite3RunParser(pParse, zSql, &zErrMsg); - sqlite3DbFree(db, zErrMsg); - sqlite3DbFree(db, zSql); - memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ); - pParse->nested--; -} - /** * This is a function which should be called during execution * of sqlite3EndTable. It ensures that only PRIMARY KEY diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c index 5a79971..5f78062 100644 --- a/src/box/sql/delete.c +++ b/src/box/sql/delete.c @@ -403,11 +403,7 @@ sql_table_delete_from(struct Parse *parse, struct SrcList *tab_list, } } - /* Return the number of rows that were deleted. If this - * routine is generating code because of a call to - * sqlite3NestedParse(), do not invoke the callback - * function. - */ + /* Return the number of rows that were deleted. */ if ((user_session->sql_flags & SQLITE_CountRows) != 0 && parse->nested == 0 && parse->pTriggerTab != NULL) { sqlite3VdbeAddOp2(v, OP_ResultRow, reg_count, 1); diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c index c12043b..6ce5be7 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -904,11 +904,7 @@ sqlite3Insert(Parse * pParse, /* Parser context */ insert_end: - /* - * Return the number of rows inserted. If this routine is - * generating code because of a call to sqlite3NestedParse(), do not - * invoke the callback function. - */ + /* Return the number of rows inserted. */ if ((user_session->sql_flags & SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab) { sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index a0a874c..7a3a3d1 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -4449,7 +4449,6 @@ void sqlite3AlterRenameTable(Parse *, SrcList *, Token *); int sql_token(const char *z, int *type, bool *is_reserved); -void sqlite3NestedParse(Parse *, const char *, ...); void sqlite3ExpirePreparedStatements(sqlite3 *); int sqlite3CodeSubselect(Parse *, Expr *, int); void sqlite3SelectPrep(Parse *, Select *, NameContext *); diff --git a/src/box/sql/update.c b/src/box/sql/update.c index 212adbc..3a5c6f0 100644 --- a/src/box/sql/update.c +++ b/src/box/sql/update.c @@ -625,11 +625,7 @@ sqlite3Update(Parse * pParse, /* The parser context */ } sqlite3VdbeResolveLabel(v, labelBreak); - /* - * Return the number of rows that were changed. If this routine is - * generating code because of a call to sqlite3NestedParse(), do not - * invoke the callback function. - */ + /* Return the number of rows that were changed. */ if ((user_session->sql_flags & SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested) { sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); -- 2.7.4
next prev parent reply other threads:[~2018-07-04 17:18 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-04 17:17 [tarantool-patches] [PATCH v1 0/2] sql: get rid off sqlite3NestedParse Kirill Shcherbatov 2018-07-04 17:17 ` [tarantool-patches] [PATCH v1 1/2] sql: get rid off sqlite3NestedParse in clean stats Kirill Shcherbatov 2018-07-05 16:11 ` [tarantool-patches] " Vladislav Shpilevoy 2018-07-06 18:13 ` Kirill Shcherbatov 2018-07-09 10:20 ` Vladislav Shpilevoy 2018-07-04 17:17 ` Kirill Shcherbatov [this message] 2018-07-05 16:11 ` [tarantool-patches] Re: [PATCH v1 2/2] sql: remove usless sqlite3NestedParse function Vladislav Shpilevoy 2018-07-06 18:13 ` Kirill Shcherbatov 2018-07-09 10:20 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: get rid off sqlite3NestedParse Vladislav Shpilevoy
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=444b91093cc6ea1648f0e8bdd9b0923694ca3f8a.1530724375.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 2/2] sql: remove usless sqlite3NestedParse function' \ /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