mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Increase the number of bits available in Expr.flags. Other tweaks aimed at
making expression processing more robust. FossilOrigin-Name: 579a512538528cf4bb4381ba393c5d9e7310086b
This commit is contained in:
29
manifest
29
manifest
@@ -1,5 +1,5 @@
|
|||||||
C For\serror\slog\smessages\sgenerated\sby\sthe\sWin32\snative\sallocator,\smake\ssure\sthe\scorrect\sformat\sspecifier\sis\sused\sfor\sthe\svalue\sreturned\sby\sGetLastError().
|
C Increase\sthe\snumber\sof\sbits\savailable\sin\sExpr.flags.\s\sOther\stweaks\saimed\sat\nmaking\sexpression\sprocessing\smore\srobust.
|
||||||
D 2013-09-12T02:09:05.258
|
D 2013-09-12T16:50:49.178
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -158,7 +158,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
|
|||||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||||
F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083
|
F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083
|
||||||
F src/analyze.c d322972af09e3f8debb45f420dfe3ded142b108b
|
F src/analyze.c d322972af09e3f8debb45f420dfe3ded142b108b
|
||||||
F src/attach.c eeb8d9d2c791caa0a54a835170ea898e96c2802d
|
F src/attach.c 4a2b6a6d9b5f9fd55a8b59488ff7929fef73a195
|
||||||
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
||||||
F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3
|
F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3
|
||||||
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
||||||
@@ -172,7 +172,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
|
|||||||
F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c
|
F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c
|
||||||
F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
|
F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
|
||||||
F src/delete.c 2dc64ca360b7d7da481183ea920a813a0c203c97
|
F src/delete.c 2dc64ca360b7d7da481183ea920a813a0c203c97
|
||||||
F src/expr.c 33ae44812d25799000dbcfd54bb2142b30cdd049
|
F src/expr.c 7f93e51fd7ca0d3ea1be2715a29c86a69e7b1e93
|
||||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||||
F src/fkey.c be866cd8c4fa6cae98ba33109578fd1a3311ee5b
|
F src/fkey.c be866cd8c4fa6cae98ba33109578fd1a3311ee5b
|
||||||
F src/func.c 7650d35651bb0ca903d24f4e5e944bfdaac9f152
|
F src/func.c 7650d35651bb0ca903d24f4e5e944bfdaac9f152
|
||||||
@@ -206,7 +206,7 @@ F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6
|
|||||||
F src/os_win.c 0e73f891dd806b82a76d4e19179c532f02236b86
|
F src/os_win.c 0e73f891dd806b82a76d4e19179c532f02236b86
|
||||||
F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8
|
F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8
|
||||||
F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c
|
F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c
|
||||||
F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f
|
F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da
|
||||||
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
|
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
|
||||||
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
|
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
|
||||||
F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63
|
F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63
|
||||||
@@ -214,14 +214,14 @@ F src/pragma.c 3aa3d8c8623b7b71c5b1bfb72dcc31fb0c25665f
|
|||||||
F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f
|
F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f
|
||||||
F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
|
F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
|
||||||
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
|
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
|
||||||
F src/resolve.c 9d53899cc6e1f4ec0b4632d07e97d57827bf63b9
|
F src/resolve.c d336be12493bb376c6756c214379c727cd8c01a8
|
||||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
||||||
F src/select.c 9239586282bd146ec5843a2cde7d54cd7816cf78
|
F src/select.c d96bcdbc2e7de89cb72febeccd232746f67839fd
|
||||||
F src/shell.c d920a891ca09b8bd262cced7fb0ab9d723f7a747
|
F src/shell.c d920a891ca09b8bd262cced7fb0ab9d723f7a747
|
||||||
F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5
|
F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5
|
||||||
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
|
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
|
||||||
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
||||||
F src/sqliteInt.h 600a1da8ca71c919a1a270146b052a66a128533a
|
F src/sqliteInt.h e4cb0c8700ca77889570bf30cf75a5c56f297615
|
||||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||||
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
||||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||||
@@ -289,7 +289,7 @@ F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc
|
|||||||
F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d
|
F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d
|
||||||
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
|
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
|
||||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||||
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
|
F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74
|
||||||
F src/where.c b5d59b899b85aa03800905ecdc0a17565d51a6ab
|
F src/where.c b5d59b899b85aa03800905ecdc0a17565d51a6ab
|
||||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
@@ -1112,7 +1112,10 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
|||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
|
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
|
||||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||||
P 59708674f66e06c9c31c1a24f2f1c51f0bf4fa3e
|
P 75a8a8c1b39725d36db627536d0c69401f8e0815
|
||||||
R 1ed3fe4d70c0b22924a418f004301c6c
|
R 14e40117cf5ed4a868935b4adf8b8b0d
|
||||||
U mistachkin
|
T *branch * expr-tuning
|
||||||
Z 0449c470c02ad9774090312d2090be91
|
T *sym-expr-tuning *
|
||||||
|
T -sym-trunk *
|
||||||
|
U drh
|
||||||
|
Z e578fc31598c846285e1a40bbc280fc4
|
||||||
|
@@ -1 +1 @@
|
|||||||
75a8a8c1b39725d36db627536d0c69401f8e0815
|
579a512538528cf4bb4381ba393c5d9e7310086b
|
@@ -509,7 +509,7 @@ int sqlite3FixExpr(
|
|||||||
Expr *pExpr /* The expression to be fixed to one database */
|
Expr *pExpr /* The expression to be fixed to one database */
|
||||||
){
|
){
|
||||||
while( pExpr ){
|
while( pExpr ){
|
||||||
if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ) break;
|
if( ExprHasProperty(pExpr, EP_TokenOnly) ) break;
|
||||||
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
||||||
if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
|
if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
|
||||||
}else{
|
}else{
|
||||||
|
54
src/expr.c
54
src/expr.c
@@ -596,7 +596,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
|
|||||||
const char *z;
|
const char *z;
|
||||||
|
|
||||||
if( pExpr==0 ) return;
|
if( pExpr==0 ) return;
|
||||||
assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
|
assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
|
||||||
z = pExpr->u.zToken;
|
z = pExpr->u.zToken;
|
||||||
assert( z!=0 );
|
assert( z!=0 );
|
||||||
assert( z[0]!=0 );
|
assert( z[0]!=0 );
|
||||||
@@ -666,12 +666,12 @@ void sqlite3ExprDelete(sqlite3 *db, Expr *p){
|
|||||||
if( p==0 ) return;
|
if( p==0 ) return;
|
||||||
/* Sanity check: Assert that the IntValue is non-negative if it exists */
|
/* Sanity check: Assert that the IntValue is non-negative if it exists */
|
||||||
assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
|
assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
|
||||||
if( !ExprHasAnyProperty(p, EP_TokenOnly) ){
|
if( !ExprHasProperty(p, EP_TokenOnly) ){
|
||||||
|
/* The Expr.x union is never used at the same time as Expr.pRight */
|
||||||
|
assert( p->x.pList==0 || p->pRight==0 );
|
||||||
sqlite3ExprDelete(db, p->pLeft);
|
sqlite3ExprDelete(db, p->pLeft);
|
||||||
sqlite3ExprDelete(db, p->pRight);
|
sqlite3ExprDelete(db, p->pRight);
|
||||||
if( !ExprHasProperty(p, EP_Reduced) && (p->flags2 & EP2_MallocedToken)!=0 ){
|
if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
|
||||||
sqlite3DbFree(db, p->u.zToken);
|
|
||||||
}
|
|
||||||
if( ExprHasProperty(p, EP_xIsSelect) ){
|
if( ExprHasProperty(p, EP_xIsSelect) ){
|
||||||
sqlite3SelectDelete(db, p->x.pSelect);
|
sqlite3SelectDelete(db, p->x.pSelect);
|
||||||
}else{
|
}else{
|
||||||
@@ -734,10 +734,10 @@ static int dupedExprStructSize(Expr *p, int flags){
|
|||||||
if( 0==(flags&EXPRDUP_REDUCE) ){
|
if( 0==(flags&EXPRDUP_REDUCE) ){
|
||||||
nSize = EXPR_FULLSIZE;
|
nSize = EXPR_FULLSIZE;
|
||||||
}else{
|
}else{
|
||||||
assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
|
||||||
assert( !ExprHasProperty(p, EP_FromJoin) );
|
assert( !ExprHasProperty(p, EP_FromJoin) );
|
||||||
assert( (p->flags2 & EP2_MallocedToken)==0 );
|
assert( !ExprHasProperty(p, EP_MemToken) );
|
||||||
assert( (p->flags2 & EP2_Irreducible)==0 );
|
assert( !ExprHasProperty(p, EP_Irreduce) );
|
||||||
if( p->pLeft || p->pRight || p->x.pList ){
|
if( p->pLeft || p->pRight || p->x.pList ){
|
||||||
nSize = EXPR_REDUCEDSIZE | EP_Reduced;
|
nSize = EXPR_REDUCEDSIZE | EP_Reduced;
|
||||||
}else{
|
}else{
|
||||||
@@ -834,7 +834,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
|
/* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
|
||||||
pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static);
|
pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken);
|
||||||
pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);
|
pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);
|
||||||
pNew->flags |= staticFlag;
|
pNew->flags |= staticFlag;
|
||||||
|
|
||||||
@@ -854,7 +854,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in pNew->pLeft and pNew->pRight. */
|
/* Fill in pNew->pLeft and pNew->pRight. */
|
||||||
if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly) ){
|
if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
|
||||||
zAlloc += dupedExprNodeSize(p, flags);
|
zAlloc += dupedExprNodeSize(p, flags);
|
||||||
if( ExprHasProperty(pNew, EP_Reduced) ){
|
if( ExprHasProperty(pNew, EP_Reduced) ){
|
||||||
pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
|
pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
|
||||||
@@ -864,8 +864,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
|
|||||||
*pzBuffer = zAlloc;
|
*pzBuffer = zAlloc;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
pNew->flags2 = 0;
|
if( !ExprHasProperty(p, EP_TokenOnly) ){
|
||||||
if( !ExprHasAnyProperty(p, EP_TokenOnly) ){
|
|
||||||
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
|
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
|
||||||
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
|
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
|
||||||
}
|
}
|
||||||
@@ -1175,7 +1174,7 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
|
|||||||
/* If pWalker->u.i is 3 then any term of the expression that comes from
|
/* If pWalker->u.i is 3 then any term of the expression that comes from
|
||||||
** the ON or USING clauses of a join disqualifies the expression
|
** the ON or USING clauses of a join disqualifies the expression
|
||||||
** from being considered constant. */
|
** from being considered constant. */
|
||||||
if( pWalker->u.i==3 && ExprHasAnyProperty(pExpr, EP_FromJoin) ){
|
if( pWalker->u.i==3 && ExprHasProperty(pExpr, EP_FromJoin) ){
|
||||||
pWalker->u.i = 0;
|
pWalker->u.i = 0;
|
||||||
return WRC_Abort;
|
return WRC_Abort;
|
||||||
}
|
}
|
||||||
@@ -1606,7 +1605,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
|
|||||||
}else{
|
}else{
|
||||||
testcase( pParse->nQueryLoop>0 );
|
testcase( pParse->nQueryLoop>0 );
|
||||||
pParse->nQueryLoop = 0;
|
pParse->nQueryLoop = 0;
|
||||||
if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){
|
if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){
|
||||||
eType = IN_INDEX_ROWID;
|
eType = IN_INDEX_ROWID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1675,7 +1674,7 @@ int sqlite3CodeSubselect(
|
|||||||
** If all of the above are false, then we can run this code just once
|
** If all of the above are false, then we can run this code just once
|
||||||
** save the results, and reuse the same result on subsequent invocations.
|
** save the results, and reuse the same result on subsequent invocations.
|
||||||
*/
|
*/
|
||||||
if( !ExprHasAnyProperty(pExpr, EP_VarSelect) ){
|
if( !ExprHasProperty(pExpr, EP_VarSelect) ){
|
||||||
testAddr = sqlite3CodeOnce(pParse);
|
testAddr = sqlite3CodeOnce(pParse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2615,7 +2614,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
|||||||
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
|
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
|
||||||
testcase( op==TK_CONST_FUNC );
|
testcase( op==TK_CONST_FUNC );
|
||||||
testcase( op==TK_FUNCTION );
|
testcase( op==TK_FUNCTION );
|
||||||
if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
|
if( ExprHasProperty(pExpr, EP_TokenOnly) ){
|
||||||
pFarg = 0;
|
pFarg = 0;
|
||||||
}else{
|
}else{
|
||||||
pFarg = pExpr->x.pList;
|
pFarg = pExpr->x.pList;
|
||||||
@@ -2846,9 +2845,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
|||||||
** WHEN x=eN THEN rN ELSE y END
|
** WHEN x=eN THEN rN ELSE y END
|
||||||
**
|
**
|
||||||
** X (if it exists) is in pExpr->pLeft.
|
** X (if it exists) is in pExpr->pLeft.
|
||||||
** Y is in pExpr->pRight. The Y is also optional. If there is no
|
** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is
|
||||||
** ELSE clause and no other term matches, then the result of the
|
** odd. The Y is also optional. If the number of elements in x.pList
|
||||||
** exprssion is NULL.
|
** is even, then Y is omitted and the "otherwise" result is NULL.
|
||||||
** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
|
** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
|
||||||
**
|
**
|
||||||
** The result of the expression is the Ri for the first matching Ei,
|
** The result of the expression is the Ri for the first matching Ei,
|
||||||
@@ -2869,7 +2868,6 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
|||||||
VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )
|
VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )
|
||||||
|
|
||||||
assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
|
assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
|
||||||
assert((pExpr->x.pList->nExpr % 2) == 0);
|
|
||||||
assert(pExpr->x.pList->nExpr > 0);
|
assert(pExpr->x.pList->nExpr > 0);
|
||||||
pEList = pExpr->x.pList;
|
pEList = pExpr->x.pList;
|
||||||
aListelem = pEList->a;
|
aListelem = pEList->a;
|
||||||
@@ -2891,7 +2889,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
|||||||
** purposes and possibly overwritten. */
|
** purposes and possibly overwritten. */
|
||||||
regFree1 = 0;
|
regFree1 = 0;
|
||||||
}
|
}
|
||||||
for(i=0; i<nExpr; i=i+2){
|
for(i=0; i<nExpr-1; i=i+2){
|
||||||
sqlite3ExprCachePush(pParse);
|
sqlite3ExprCachePush(pParse);
|
||||||
if( pX ){
|
if( pX ){
|
||||||
assert( pTest!=0 );
|
assert( pTest!=0 );
|
||||||
@@ -2909,9 +2907,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
|||||||
sqlite3ExprCachePop(pParse, 1);
|
sqlite3ExprCachePop(pParse, 1);
|
||||||
sqlite3VdbeResolveLabel(v, nextCase);
|
sqlite3VdbeResolveLabel(v, nextCase);
|
||||||
}
|
}
|
||||||
if( pExpr->pRight ){
|
if( (nExpr&1)!=0 ){
|
||||||
sqlite3ExprCachePush(pParse);
|
sqlite3ExprCachePush(pParse);
|
||||||
sqlite3ExprCode(pParse, pExpr->pRight, target);
|
sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
|
||||||
sqlite3ExprCachePop(pParse, 1);
|
sqlite3ExprCachePop(pParse, 1);
|
||||||
}else{
|
}else{
|
||||||
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
|
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
|
||||||
@@ -3155,7 +3153,7 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
|
|||||||
case TK_CONST_FUNC:
|
case TK_CONST_FUNC:
|
||||||
case TK_FUNCTION: {
|
case TK_FUNCTION: {
|
||||||
ExprList *pFarg; /* List of function arguments */
|
ExprList *pFarg; /* List of function arguments */
|
||||||
if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
|
if( ExprHasProperty(pExpr, EP_TokenOnly) ){
|
||||||
pFarg = 0;
|
pFarg = 0;
|
||||||
}else{
|
}else{
|
||||||
pFarg = pExpr->x.pList;
|
pFarg = pExpr->x.pList;
|
||||||
@@ -3821,8 +3819,8 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
|
|||||||
if( pA==0||pB==0 ){
|
if( pA==0||pB==0 ){
|
||||||
return pB==pA ? 0 : 2;
|
return pB==pA ? 0 : 2;
|
||||||
}
|
}
|
||||||
assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(pA, EP_TokenOnly|EP_Reduced) );
|
||||||
assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(pB, EP_TokenOnly|EP_Reduced) );
|
||||||
if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
|
if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@@ -4036,7 +4034,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
|
|||||||
struct SrcList_item *pItem = pSrcList->a;
|
struct SrcList_item *pItem = pSrcList->a;
|
||||||
for(i=0; i<pSrcList->nSrc; i++, pItem++){
|
for(i=0; i<pSrcList->nSrc; i++, pItem++){
|
||||||
struct AggInfo_col *pCol;
|
struct AggInfo_col *pCol;
|
||||||
assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
|
||||||
if( pExpr->iTable==pItem->iCursor ){
|
if( pExpr->iTable==pItem->iCursor ){
|
||||||
/* If we reach this point, it means that pExpr refers to a table
|
/* If we reach this point, it means that pExpr refers to a table
|
||||||
** that is in the FROM clause of the aggregate query.
|
** that is in the FROM clause of the aggregate query.
|
||||||
@@ -4131,7 +4129,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
|
|||||||
}
|
}
|
||||||
/* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
|
/* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
|
||||||
*/
|
*/
|
||||||
assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
|
||||||
ExprSetIrreducible(pExpr);
|
ExprSetIrreducible(pExpr);
|
||||||
pExpr->iAgg = (i16)i;
|
pExpr->iAgg = (i16)i;
|
||||||
pExpr->pAggInfo = pAggInfo;
|
pExpr->pAggInfo = pAggInfo;
|
||||||
|
@@ -1081,12 +1081,13 @@ expr(A) ::= expr(W) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
|
|||||||
|
|
||||||
/* CASE expressions */
|
/* CASE expressions */
|
||||||
expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
|
expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
|
||||||
A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, Z, 0);
|
A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, 0, 0);
|
||||||
if( A.pExpr ){
|
if( A.pExpr ){
|
||||||
A.pExpr->x.pList = Y;
|
A.pExpr->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y;
|
||||||
sqlite3ExprSetHeight(pParse, A.pExpr);
|
sqlite3ExprSetHeight(pParse, A.pExpr);
|
||||||
}else{
|
}else{
|
||||||
sqlite3ExprListDelete(pParse->db, Y);
|
sqlite3ExprListDelete(pParse->db, Y);
|
||||||
|
sqlite3ExprDelete(pParse->db, Z);
|
||||||
}
|
}
|
||||||
A.zStart = C.z;
|
A.zStart = C.z;
|
||||||
A.zEnd = &E.z[E.n];
|
A.zEnd = &E.z[E.n];
|
||||||
|
@@ -129,7 +129,7 @@ static void resolveAlias(
|
|||||||
if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
|
if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
|
||||||
assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
|
assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
|
||||||
pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
|
pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
|
||||||
pExpr->flags2 |= EP2_MallocedToken;
|
pExpr->flags |= EP_MemToken;
|
||||||
}
|
}
|
||||||
sqlite3DbFree(db, pDup);
|
sqlite3DbFree(db, pDup);
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ static int lookupName(
|
|||||||
|
|
||||||
assert( pNC ); /* the name context cannot be NULL. */
|
assert( pNC ); /* the name context cannot be NULL. */
|
||||||
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
|
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
|
||||||
assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
|
||||||
|
|
||||||
/* Initialize the node to no-match */
|
/* Initialize the node to no-match */
|
||||||
pExpr->iTable = -1;
|
pExpr->iTable = -1;
|
||||||
@@ -591,7 +591,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
|
|||||||
pParse = pNC->pParse;
|
pParse = pNC->pParse;
|
||||||
assert( pParse==pWalker->pParse );
|
assert( pParse==pWalker->pParse );
|
||||||
|
|
||||||
if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;
|
if( ExprHasProperty(pExpr, EP_Resolved) ) return WRC_Prune;
|
||||||
ExprSetProperty(pExpr, EP_Resolved);
|
ExprSetProperty(pExpr, EP_Resolved);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){
|
if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){
|
||||||
|
@@ -264,7 +264,7 @@ static void addWhereTerm(
|
|||||||
pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
|
pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
|
||||||
if( pEq && isOuterJoin ){
|
if( pEq && isOuterJoin ){
|
||||||
ExprSetProperty(pEq, EP_FromJoin);
|
ExprSetProperty(pEq, EP_FromJoin);
|
||||||
assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );
|
||||||
ExprSetIrreducible(pEq);
|
ExprSetIrreducible(pEq);
|
||||||
pEq->iRightJoinTable = (i16)pE2->iTable;
|
pEq->iRightJoinTable = (i16)pE2->iTable;
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ static void addWhereTerm(
|
|||||||
static void setJoinExpr(Expr *p, int iTable){
|
static void setJoinExpr(Expr *p, int iTable){
|
||||||
while( p ){
|
while( p ){
|
||||||
ExprSetProperty(p, EP_FromJoin);
|
ExprSetProperty(p, EP_FromJoin);
|
||||||
assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) );
|
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
|
||||||
ExprSetIrreducible(p);
|
ExprSetIrreducible(p);
|
||||||
p->iRightJoinTable = (i16)iTable;
|
p->iRightJoinTable = (i16)iTable;
|
||||||
setJoinExpr(p->pLeft, iTable);
|
setJoinExpr(p->pLeft, iTable);
|
||||||
|
@@ -1722,7 +1722,7 @@ typedef int ynVar;
|
|||||||
struct Expr {
|
struct Expr {
|
||||||
u8 op; /* Operation performed by this node */
|
u8 op; /* Operation performed by this node */
|
||||||
char affinity; /* The affinity of the column or 0 if not a column */
|
char affinity; /* The affinity of the column or 0 if not a column */
|
||||||
u16 flags; /* Various flags. EP_* See below */
|
u32 flags; /* Various flags. EP_* See below */
|
||||||
union {
|
union {
|
||||||
char *zToken; /* Token value. Zero terminated and dequoted */
|
char *zToken; /* Token value. Zero terminated and dequoted */
|
||||||
int iValue; /* Non-negative integer value if EP_IntValue */
|
int iValue; /* Non-negative integer value if EP_IntValue */
|
||||||
@@ -1736,8 +1736,8 @@ struct Expr {
|
|||||||
Expr *pLeft; /* Left subnode */
|
Expr *pLeft; /* Left subnode */
|
||||||
Expr *pRight; /* Right subnode */
|
Expr *pRight; /* Right subnode */
|
||||||
union {
|
union {
|
||||||
ExprList *pList; /* Function arguments or in "<expr> IN (<expr-list)" */
|
ExprList *pList; /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */
|
||||||
Select *pSelect; /* Used for sub-selects and "<expr> IN (<select>)" */
|
Select *pSelect; /* EP_xIsSelect and op = IN, EXISTS, SELECT */
|
||||||
} x;
|
} x;
|
||||||
|
|
||||||
/* If the EP_Reduced flag is set in the Expr.flags mask, then no
|
/* If the EP_Reduced flag is set in the Expr.flags mask, then no
|
||||||
@@ -1755,7 +1755,6 @@ struct Expr {
|
|||||||
** TK_VARIABLE: variable number (always >= 1). */
|
** TK_VARIABLE: variable number (always >= 1). */
|
||||||
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
|
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
|
||||||
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
|
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
|
||||||
u8 flags2; /* Second set of flags. EP2_... */
|
|
||||||
u8 op2; /* TK_REGISTER: original value of Expr.op
|
u8 op2; /* TK_REGISTER: original value of Expr.op
|
||||||
** TK_COLUMN: the value of p5 for OP_Column
|
** TK_COLUMN: the value of p5 for OP_Column
|
||||||
** TK_AGG_FUNCTION: nesting depth */
|
** TK_AGG_FUNCTION: nesting depth */
|
||||||
@@ -1766,28 +1765,24 @@ struct Expr {
|
|||||||
/*
|
/*
|
||||||
** The following are the meanings of bits in the Expr.flags field.
|
** The following are the meanings of bits in the Expr.flags field.
|
||||||
*/
|
*/
|
||||||
#define EP_FromJoin 0x0001 /* Originated in ON or USING clause of a join */
|
#define EP_FromJoin 0x000001 /* Originated in ON or USING clause of a join */
|
||||||
#define EP_Agg 0x0002 /* Contains one or more aggregate functions */
|
#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
|
||||||
#define EP_Resolved 0x0004 /* IDs have been resolved to COLUMNs */
|
#define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
|
||||||
#define EP_Error 0x0008 /* Expression contains one or more errors */
|
#define EP_Error 0x000008 /* Expression contains one or more errors */
|
||||||
#define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */
|
#define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
|
||||||
#define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */
|
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
|
||||||
#define EP_DblQuoted 0x0040 /* token.z was originally in "..." */
|
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
|
||||||
#define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
|
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
|
||||||
#define EP_Collate 0x0100 /* Tree contains a TK_COLLATE opeartor */
|
#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE opeartor */
|
||||||
#define EP_FixedDest 0x0200 /* Result needed in a specific register */
|
#define EP_FixedDest 0x000200 /* Result needed in a specific register */
|
||||||
#define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
|
#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
|
||||||
#define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
|
#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
|
||||||
#define EP_Hint 0x1000 /* Not used */
|
#define EP_Hint 0x001000 /* Not used */
|
||||||
#define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
|
#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
|
||||||
#define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
|
#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
|
||||||
#define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
|
#define EP_Static 0x008000 /* Held in memory not obtained from malloc() */
|
||||||
|
#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
|
||||||
/*
|
#define EP_Irreduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
|
||||||
** The following are the meanings of bits in the Expr.flags2 field.
|
|
||||||
*/
|
|
||||||
#define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */
|
|
||||||
#define EP2_Irreducible 0x0002 /* Cannot EXPRDUP_REDUCE this Expr */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The pseudo-routine sqlite3ExprSetIrreducible sets the EP2_Irreducible
|
** The pseudo-routine sqlite3ExprSetIrreducible sets the EP2_Irreducible
|
||||||
@@ -1796,7 +1791,7 @@ struct Expr {
|
|||||||
** so as not to burden production code.
|
** so as not to burden production code.
|
||||||
*/
|
*/
|
||||||
#ifdef SQLITE_DEBUG
|
#ifdef SQLITE_DEBUG
|
||||||
# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible
|
# define ExprSetIrreducible(X) (X)->flags |= EP_Irreduce
|
||||||
#else
|
#else
|
||||||
# define ExprSetIrreducible(X)
|
# define ExprSetIrreducible(X)
|
||||||
#endif
|
#endif
|
||||||
@@ -1805,8 +1800,8 @@ struct Expr {
|
|||||||
** These macros can be used to test, set, or clear bits in the
|
** These macros can be used to test, set, or clear bits in the
|
||||||
** Expr.flags field.
|
** Expr.flags field.
|
||||||
*/
|
*/
|
||||||
#define ExprHasProperty(E,P) (((E)->flags&(P))==(P))
|
#define ExprHasProperty(E,P) (((E)->flags&(P))!=0)
|
||||||
#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0)
|
#define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P))
|
||||||
#define ExprSetProperty(E,P) (E)->flags|=(P)
|
#define ExprSetProperty(E,P) (E)->flags|=(P)
|
||||||
#define ExprClearProperty(E,P) (E)->flags&=~(P)
|
#define ExprClearProperty(E,P) (E)->flags&=~(P)
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
|
|||||||
testcase( ExprHasProperty(pExpr, EP_Reduced) );
|
testcase( ExprHasProperty(pExpr, EP_Reduced) );
|
||||||
rc = pWalker->xExprCallback(pWalker, pExpr);
|
rc = pWalker->xExprCallback(pWalker, pExpr);
|
||||||
if( rc==WRC_Continue
|
if( rc==WRC_Continue
|
||||||
&& !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){
|
&& !ExprHasProperty(pExpr,EP_TokenOnly) ){
|
||||||
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
|
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
|
||||||
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
|
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
|
||||||
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
|
||||||
|
Reference in New Issue
Block a user