[tarantool-patches] [PATCH 1/1] sql: remove unused struct AutoinfInfo

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Apr 17 23:50:07 MSK 2018


---
Branch: https://github.com/tarantool/tarantool/tree/remove-autoincinfo

I was trying to remove iAutoIncPKey from struct Table, but it appeared, that
it can be not only 0. SQL allows to create autoincrement not only on a first
field. During researching I have removed struct AutoinfInfo, so there is the
patch.

 src/box/sql/build.c     |  2 --
 src/box/sql/sqliteInt.h | 16 ----------------
 src/box/sql/tokenize.c  |  5 -----
 src/box/sql/trigger.c   |  2 +-
 4 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index c6185e41a..4aff123ac 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -119,8 +119,6 @@ sqlite3FinishCoding(Parse * pParse)
 		/* A minimum of one cursor is required if autoincrement is used
 		 *  See ticket [a696379c1f08866]
 		 */
-		if (pParse->pAinc != 0 && pParse->nTab == 0)
-			pParse->nTab = 1;
 		sqlite3VdbeMakeReady(v, pParse);
 		pParse->rc = SQLITE_DONE;
 	} else {
diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
index 59662cf14..a49c636a2 100644
--- a/src/box/sql/sqliteInt.h
+++ b/src/box/sql/sqliteInt.h
@@ -1455,7 +1455,6 @@ void *sqlite3_wsd_find(void *K, int L);
  * Forward references to structures
  */
 typedef struct AggInfo AggInfo;
-typedef struct AutoincInfo AutoincInfo;
 typedef struct Bitvec Bitvec;
 typedef struct Column Column;
 typedef struct Schema Schema;
@@ -2854,20 +2853,6 @@ struct SelectDest {
 	ExprList *pOrderBy;	/* Key columns for SRT_Queue and SRT_DistQueue */
 };
 
-/*
- * During code generation of statements that do inserts into AUTOINCREMENT
- * tables, the following information is attached to the Table.u.autoInc.p
- * pointer of each autoincrement table to record some side information that
- * the code generator needs.  We have to keep per-table autoincrement
- * information in case inserts are done within triggers.  Triggers do not
- * normally coordinate their activities, but we do need to coordinate the
- * loading and saving of autoincrement information.
- */
-struct AutoincInfo {
-	AutoincInfo *pNext;	/* Next info block in a list of them all */
-	Table *pTab;		/* Table this info block refers to */
-};
-
 /*
  * Size of the column cache
  */
@@ -2947,7 +2932,6 @@ struct Parse {
 	int nSelect;		/* Number of SELECT statements seen */
 	int nSelectIndent;	/* How far to indent SELECTTRACE() output */
 #endif
-	AutoincInfo *pAinc;	/* Information about AUTOINCREMENT counters */
 	Parse *pToplevel;	/* Parse structure for main program (or NULL) */
 	Table *pTriggerTab;	/* Table triggers are being coded for */
 	u32 nQueryLoop;		/* Est number of iterations of a query (10*log2(N)) */
diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c
index 2894f8d7e..c77aa9bcf 100644
--- a/src/box/sql/tokenize.c
+++ b/src/box/sql/tokenize.c
@@ -639,11 +639,6 @@ sqlite3RunParser(Parse * pParse, const char *zSql, char **pzErrMsg)
 		sqlite3WithDelete(db, pParse->pWithToFree);
 	sqlite3DeleteTrigger(db, pParse->pNewTrigger);
 	sqlite3DbFree(db, pParse->pVList);
-	while (pParse->pAinc) {
-		AutoincInfo *p = pParse->pAinc;
-		pParse->pAinc = p->pNext;
-		sqlite3DbFree(db, p);
-	}
 	while (pParse->pZombieTab) {
 		Table *p = pParse->pZombieTab;
 		pParse->pZombieTab = p->pNextZombie;
diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c
index ed7b948ab..28c56db3a 100644
--- a/src/box/sql/trigger.c
+++ b/src/box/sql/trigger.c
@@ -932,7 +932,7 @@ codeRowTrigger(Parse * pParse,	/* Current parse context */
 		sqlite3VdbeDelete(v);
 	}
 
-	assert(!pSubParse->pAinc && !pSubParse->pZombieTab);
+	assert(!pSubParse->pZombieTab);
 	assert(!pSubParse->pTriggerPrg && !pSubParse->nMaxArg);
 	sqlite3ParserReset(pSubParse);
 	sqlite3StackFree(db, pSubParse);
-- 
2.15.1 (Apple Git-101)





More information about the Tarantool-patches mailing list