diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 18 | ||||
-rw-r--r-- | src/resolve.c | 6 | ||||
-rw-r--r-- | src/sqliteInt.h | 23 | ||||
-rw-r--r-- | src/vdbeInt.h | 6 | ||||
-rw-r--r-- | src/vdbeaux.c | 2 |
5 files changed, 23 insertions, 32 deletions
diff --git a/src/expr.c b/src/expr.c index ff75f5f70..0cc309361 100644 --- a/src/expr.c +++ b/src/expr.c @@ -571,20 +571,12 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ if( z[1]==0 ){ /* Wildcard of the form "?". Assign the next variable number */ assert( z[0]=='?' ); -#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - pExpr->iColumn = (i16)(++pParse->nVar); -#else - pExpr->iColumn = ++pParse->nVar; -#endif + pExpr->iColumn = (ynVar)(++pParse->nVar); }else if( z[0]=='?' ){ /* Wildcard of the form "?nnn". Convert "nnn" to an integer and ** use it as the variable number */ int i = atoi((char*)&z[1]); -#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - pExpr->iColumn = (i16)i; -#else - pExpr->iColumn = i; -#endif + pExpr->iColumn = (ynVar)i; testcase( i==0 ); testcase( i==1 ); testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); @@ -613,11 +605,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ } } if( i>=pParse->nVarExpr ){ -#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - pExpr->iColumn = (i16)(++pParse->nVar); -#else - pExpr->iColumn = ++pParse->nVar; -#endif + pExpr->iColumn = (ynVar)(++pParse->nVar); if( pParse->nVarExpr>=pParse->nVarExprAlloc-1 ){ pParse->nVarExprAlloc += pParse->nVarExprAlloc + 10; pParse->apVarExpr = diff --git a/src/resolve.c b/src/resolve.c index 09f547c94..ed1d6ab5d 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -407,11 +407,7 @@ Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){ if( p->pTab->iPKey==iCol ){ p->iColumn = -1; }else{ -#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - p->iColumn = (i16)iCol; -#else - p->iColumn = iCol; -#endif + p->iColumn = (ynVar)iCol; pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol); } ExprSetProperty(p, EP_Resolved); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 158005265..b1b04725a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1498,6 +1498,22 @@ struct AggInfo { }; /* +** The datatype ynVar is a signed integer, either 16-bit or 32-bit. +** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater +** than 32767 we have to make it 32-bit. 16-bit is preferred because +** it uses less memory in the Expr object, which is a big memory user +** in systems with lots of prepared statements. And few applications +** need more than about 10 or 20 variables. But some extreme users want +** to have prepared statements with over 32767 variables, and for them +** the option is available (at compile-time). +*/ +#if SQLITE_MAX_VARIABLE_NUMBER<=32767 +typedef i64 ynVar; +#else +typedef int ynVar; +#endif + +/* ** Each node of an expression in the parse tree is an instance ** of this structure. ** @@ -1590,13 +1606,8 @@ struct Expr { int iTable; /* TK_COLUMN: cursor number of table holding column ** TK_REGISTER: register number ** TK_TRIGGER: 1 -> new, 0 -> old */ -#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - i16 iColumn; /* TK_COLUMN: column index. -1 for rowid. + ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. ** TK_VARIABLE: variable number (always >= 1). */ -#else - int iColumn; /* Some users want a lot of variables and are willing - ** to bear the memory and performance costs. */ -#endif i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ u8 flags2; /* Second set of flags. EP2_... */ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 3294498e4..964d55fca 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -290,11 +290,7 @@ struct Vdbe { VdbeCursor **apCsr; /* One element of this array for each open cursor */ u8 errorAction; /* Recovery action to do in case of an error */ u8 okVar; /* True if azVar[] has been initialized */ -#if SQLITE_MAX_VARIABLE_NUMBER<=32767 - u16 nVar; /* Number of entries in aVar[] */ -#else - int nVar; /* Some users want many variables. */ -#endif + ynVar nVar; /* Number of entries in aVar[] */ Mem *aVar; /* Values for the OP_Variable opcode. */ char **azVar; /* Name of variables */ u32 magic; /* Magic number for sanity checking */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 37f8b1431..b28ba96f2 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1359,7 +1359,7 @@ void sqlite3VdbeMakeReady( p->nCursor = (u16)nCursor; if( p->aVar ){ - p->nVar = (u16)nVar; + p->nVar = (ynVar)nVar; for(n=0; n<nVar; n++){ p->aVar[n].flags = MEM_Null; p->aVar[n].db = db; |