[tarantool-patches] [PATCH v1 2/2] sql: remove usless sqlite3NestedParse function

Kirill Shcherbatov kshcherbatov at tarantool.org
Wed Jul 4 20:17:55 MSK 2018


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





More information about the Tarantool-patches mailing list