-C Still\smore\srefinements\sto\sthe\shasHotJournal()\sfix\sof\sticket\s#3883.\s(CVS\s6689)
-D 2009-05-29T11:57:38
+C Refinements\sin\sexpression\shandling\slogic\sthat\shave\sresulted\sfrom\srecent\nstructural\stesting.\s(CVS\s6690)
+D 2009-05-29T14:39:08
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/complete.c 5ad5c6cd4548211867c204c41a126d73a9fbcea0
F src/date.c ab5f7137656652a48434d64f96bdcdc823bb23b3
F src/delete.c cb791855c7948cecc96def9d97989879ca26f257
-F src/expr.c 9d25d7229719334dc87909f8094b10d033b994f1
+F src/expr.c ba5ba6a6332ec07d81cda97585dabf6c88bffbab
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
F src/func.c 9d7b47729c337c5e4b78d795922ed34eec4aef67
F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c
F src/prepare.c f46d1a029760edee5447e27164fb3ae10e2a6839
F src/printf.c 3f4dca207a88258d37af5a7a03e800a825fe6456
F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
-F src/resolve.c fc6fdd01305518fd1462e1621213e63bd011a115
+F src/resolve.c 42065c05d4dd56894d1ae232974668674435e468
F src/rowset.c c64dafba1f9fd876836c8db8682966b9d197eb1f
F src/select.c fd1737a667bab296f50049a841b3aba5ec89418e
F src/shell.c 7eacd0bdaa887931f5ff205c9defc3e8df95a2dd
F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
F test/async4.test bdb997924394a2034ff3df1d839ff95b2e602ed4
-F test/attach.test e710d543769305942e9354cee5aba8cfcbe89577
+F test/attach.test 1d1be27b9e4c654f9bb14d011a4a87753c0b197a
F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
F test/attach3.test 7b92dc8e40c1ebca9732ca6f2d3fefbd46f196df
F test/attachmalloc.test cf8cf17d183de357b1147a9baacbdfc85b940b61
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P a2ba61d927a06c390a9a818a013328092b802222
-R df5faf03661654bce8e5953dac271838
+P 726b425e43e5d864e7e83853bdf134debc1ffb59
+R 7782c740d0e684d85e0d73fa4ed3175a
U drh
-Z c67a8bef852bbf3b9d8397d68afe4414
+Z 3b276276ba95400e6569bffb7e01828d
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.439 2009/05/28 21:04:38 drh Exp $
+** $Id: expr.c,v 1.440 2009/05/29 14:39:08 drh Exp $
*/
#include "sqliteInt.h"
** ephemeral table.
*/
p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
- if( pParse->nErr==0 && isCandidateForInOpt(p) ){
+ if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){
sqlite3 *db = pParse->db; /* Database connection */
Expr *pExpr = p->pEList->a[0].pExpr; /* Expression <column> */
int iCol = pExpr->iColumn; /* Index of column <column> */
** to some integer key column of a table B-Tree. In this case, use an
** intkey B-Tree to store the set of IN(...) values instead of the usual
** (slower) variable length keys B-Tree.
+**
+** If rMayHaveNull is non-zero, that means that the operation is an IN
+** (not a SELECT or EXISTS) and that the RHS might contains NULLs.
+** Furthermore, the IN is in a WHERE clause and that we really want
+** to iterate over the RHS of the IN operator in order to quickly locate
+** all corresponding LHS elements. All this routine does is initialize
+** the register given by rMayHaveNull to NULL. Calling routines will take
+** care of changing this register value to non-NULL if the RHS is NULL-free.
+**
+** If rMayHaveNull is zero, that means that the subquery is being used
+** for membership testing only. There is no need to initialize any
+** registers to indicate the presense or absence of NULLs on the RHS.
*/
#ifndef SQLITE_OMIT_SUBQUERY
void sqlite3CodeSubselect(
- Parse *pParse,
- Expr *pExpr,
- int rMayHaveNull,
- int isRowid
+ Parse *pParse, /* Parsing context */
+ Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
+ int rMayHaveNull, /* Register that records whether NULLs exist in RHS */
+ int isRowid /* If true, LHS of IN operator is a rowid */
){
int testAddr = 0; /* One-time test address */
Vdbe *v = sqlite3GetVdbe(pParse);
- if( v==0 ) return;
+ if( NEVER(v==0) ) return;
sqlite3ExprCachePush(pParse);
/* This code must be run in its entirety every time it is encountered
return;
}
pEList = pExpr->x.pSelect->pEList;
- if( pEList && pEList->nExpr>0 ){
+ if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
pEList->a[0].pExpr);
}
- }else if( pExpr->x.pList ){
+ }else if( pExpr->x.pList!=0 ){
/* Case 2: expr IN (exprlist)
**
** For each expression, build an index key from the evaluation and
}
case TK_EXISTS:
- case TK_SELECT: {
- /* This has to be a scalar SELECT. Generate code to put the
+ case TK_SELECT:
+ default: {
+ testcase( pExpr->op==TK_EXISTS );
+ testcase( pExpr->op==TK_SELECT );
+ assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
+ /* If this has to be a scalar SELECT. Generate code to put the
** value of this select in a memory cell and record the number
- ** of the memory cell in iColumn.
+ ** of the memory cell in iColumn. If this is an EXISTS, write
+ ** an integer 0 (not exists) or 1 (exists) into a memory cell
+ ** and record that memory cell in iColumn.
*/
- static const Token one = { "1", 1 };
- Select *pSel;
- SelectDest dest;
+ static const Token one = { "1", 1 }; /* Token for literal value 1 */
+ Select *pSel; /* SELECT statement to encode */
+ SelectDest dest; /* How to deal with SELECt result */
assert( ExprHasProperty(pExpr, EP_xIsSelect) );
pSel = pExpr->x.pSelect;
** like the continuation of the number.
*/
static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
- assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
- if( z ){
+ if( ALWAYS(z!=0) ){
double value;
char *zV;
sqlite3AtoF(z, &value);
** like the continuation of the number.
*/
static void codeInteger(Vdbe *v, Expr *pExpr, int negFlag, int iMem){
- const char *z;
if( pExpr->flags & EP_IntValue ){
int i = pExpr->u.iValue;
if( negFlag ) i = -i;
sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
- }else if( (z = pExpr->u.zToken)!=0 ){
- int i;
- int n = sqlite3Strlen30(pExpr->u.zToken);
- assert( !sqlite3Isdigit(z[n]) );
- if( sqlite3GetInt32(z, &i) ){
- if( negFlag ) i = -i;
- sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
- }else if( sqlite3FitsIn64Bits(z, negFlag) ){
+ }else{
+ const char *z = pExpr->u.zToken;
+ assert( z!=0 );
+ if( sqlite3FitsIn64Bits(z, negFlag) ){
i64 value;
char *zV;
sqlite3Atoi64(z, &value);