Compare commits

...

2 Commits

Author SHA1 Message Date
drh f6a163eb89 Remove an "exit" call in the where2.test script that accidentally left in the
code following a debugging session.

FossilOrigin-Name: a0c08d2689804958937662f2529f182812c4aaa6
2015-10-29 14:29:01 +00:00
drh 04903ebd64 Apply optimizations to simplify OR clauses that contain constant terms.
FossilOrigin-Name: d533e23f059621364bd5dac5fae794f5973b1349
2015-10-29 12:27:38 +00:00
3 changed files with 64 additions and 36 deletions
+7 -7
View File
@@ -1,5 +1,5 @@
C Enhance\scomments\sin\sthe\sMSVC\sbatch\sbuild\stool.
D 2015-10-29T01:11:39.776
C Remove\san\s"exit"\scall\sin\sthe\swhere2.test\sscript\sthat\saccidentally\sleft\sin\sthe\ncode\sfollowing\sa\sdebugging\ssession.
D 2015-10-29T14:29:01.051
F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4
@@ -292,7 +292,7 @@ F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a
F src/date.c fb1c99172017dcc8e237339132c91a21a0788584
F src/dbstat.c e637e7a7ff40ef32132a418c6fdf1cfb63aa27c7
F src/delete.c c4c6fb9da78b946fcba2a6aac5b24bc5c15e752a
F src/expr.c 0080c0f12806eca91e75a23a121a68918e9da357
F src/expr.c 16043ce1cae327c6d2741ce957d330dc886cc9bd
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0
F src/func.c ecdd69ec6a1e406f04cc73324be2ebbf6354197f
@@ -1395,7 +1395,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P b10ab59fb8a696d11a269f3904e799c687246aea
R cc38e20a3bed22c727ef2060f0363586
U mistachkin
Z f9c898158c1864e737c38818df859932
P d533e23f059621364bd5dac5fae794f5973b1349
R 681ae505ea158e27f07d4e5eaf4d61f9
U drh
Z 5c815017e5f9cb85ac94dd7802c21ff1
+1 -1
View File
@@ -1 +1 @@
2964ce25864e8aec86272af741caf49c23c86590
a0c08d2689804958937662f2529f182812c4aaa6
+56 -28
View File
@@ -533,34 +533,6 @@ void sqlite3ExprAttachSubtrees(
}
}
/*
** Allocate an Expr node which joins as many as two subtrees.
**
** One or both of the subtrees can be NULL. Return a pointer to the new
** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed,
** free the subtrees and return NULL.
*/
Expr *sqlite3PExpr(
Parse *pParse, /* Parsing context */
int op, /* Expression opcode */
Expr *pLeft, /* Left operand */
Expr *pRight, /* Right operand */
const Token *pToken /* Argument token */
){
Expr *p;
if( op==TK_AND && pParse->nErr==0 ){
/* Take advantage of short-circuit false optimization for AND */
p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
}else{
p = sqlite3ExprAlloc(pParse->db, op & TKFLG_MASK, pToken, 1);
sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
}
if( p ) {
sqlite3ExprCheckHeight(pParse, p->nHeight);
}
return p;
}
/*
** If the expression is always either TRUE or FALSE (respectively),
** then return 1. If one cannot determine the truth value of the
@@ -612,6 +584,62 @@ Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
}
}
/* Join expressions pLeft and pRight using OR. Apply constant-folding
** style optimizations. For example, "x OR 1" becomes just "1".
*/
static Expr *sqlite3ExprOr(sqlite3 *db, Expr *pLeft, Expr *pRight){
if( pLeft && exprAlwaysFalse(pLeft) ){
sqlite3ExprDelete(db, pLeft);
pLeft = 0;
}
if( pRight==0 || exprAlwaysFalse(pRight) ){
sqlite3ExprDelete(db, pRight);
if( pLeft ) return pLeft;
return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);
}
if( pLeft==0 ) return pRight;
if( exprAlwaysTrue(pLeft) || exprAlwaysTrue(pRight) ){
sqlite3ExprDelete(db, pLeft);
sqlite3ExprDelete(db, pRight);
return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0);
}else{
Expr *pNew = sqlite3ExprAlloc(db, TK_OR, 0, 0);
sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
return pNew;
}
}
/*
** Allocate an Expr node which joins as many as two subtrees.
**
** One or both of the subtrees can be NULL. Return a pointer to the new
** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed,
** free the subtrees and return NULL.
*/
Expr *sqlite3PExpr(
Parse *pParse, /* Parsing context */
int op, /* Expression opcode */
Expr *pLeft, /* Left operand */
Expr *pRight, /* Right operand */
const Token *pToken /* Argument token */
){
Expr *p;
if( pParse->nErr==0 && op==TK_AND ){
/* Take advantage of short-circuit false optimization for AND */
p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
}else if( pParse->nErr==0 && op==TK_OR ){
/* Take advantage of short-circuit false optimization for OR */
p = sqlite3ExprOr(pParse->db, pLeft, pRight);
}else{
p = sqlite3ExprAlloc(pParse->db, op & TKFLG_MASK, pToken, 1);
sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
}
if( p ) {
sqlite3ExprCheckHeight(pParse, p->nHeight);
}
return p;
}
/*
** Construct a new expression node for a function with multiple
** arguments.