From: drh Date: Mon, 26 May 2014 22:01:00 +0000 (+0000) Subject: Minor enhancements to comments and clarification of the code. X-Git-Tag: version-3.8.5~26^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5609baf35e668ca24f0c80430f0923ca6448a3e6;p=thirdparty%2Fsqlite.git Minor enhancements to comments and clarification of the code. FossilOrigin-Name: cbec30d0c49a3f618c3df3ae0ca3d651b48841c2 --- diff --git a/manifest b/manifest index 4c806d5a59..fb7eecbb03 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\sVdbeCoverage()\smacro\son\san\sOP_Found\sopcode\sadded\sin\sthe\sprevious\ncheck-in. -D 2014-05-26T20:25:34.589 +C Minor\senhancements\sto\scomments\sand\sclarification\sof\sthe\scode. +D 2014-05-26T22:01:00.008 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in dd2b1aba364ff9b05de41086f74407f285c57670 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -294,7 +294,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c d46d73c76f48ede86e0e5bb112b2bcc91947bfaa +F src/where.c b5719b11c414874826c676cf8c8455cb2939a30c F src/whereInt.h 6804c2e5010378568c2bb1350477537755296a46 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1173,7 +1173,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2c7e277bbebd5c93dec53d381d9737909d40d846 -R 3707fb894adfd77b824ab9f7bdc17e79 +P b4980a07e287480beddb2c6633c733520e05d074 +R 8f53ac145522e21d9a1c5059c77f2db7 U drh -Z 370b7f2e785b22f24333c303cca00bc0 +Z ad528aef359e7c77cf0a017e9208591c diff --git a/manifest.uuid b/manifest.uuid index e04960c2e5..2940deda79 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b4980a07e287480beddb2c6633c733520e05d074 \ No newline at end of file +cbec30d0c49a3f618c3df3ae0ca3d651b48841c2 \ No newline at end of file diff --git a/src/where.c b/src/where.c index bf81ed8ffd..b74f44987d 100644 --- a/src/where.c +++ b/src/where.c @@ -3293,6 +3293,10 @@ static Bitmask codeOneLoopStart( ** ** B: ** + ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then + ** use an ephermeral index instead of a RowSet to record the primary + ** keys of the rows we have already seen. + ** */ WhereClause *pOrWc; /* The OR-clause broken out into subterms */ SrcList *pOrTab; /* Shortened table list or OR-clause generation */ @@ -3340,7 +3344,8 @@ static Bitmask codeOneLoopStart( } /* Initialize the rowset register to contain NULL. An SQL NULL is - ** equivalent to an empty rowset. + ** equivalent to an empty rowset. Or, create an ephermeral index + ** capable of holding primary keys in the case of a WITHOUT ROWID. ** ** Also initialize regReturn to contain the address of the instruction ** immediately following the OP_Return at the bottom of the loop. This @@ -3401,6 +3406,7 @@ static Bitmask codeOneLoopStart( if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ WhereInfo *pSubWInfo; /* Info for single OR-term scan */ Expr *pOrExpr = pOrTerm->pExpr; + int j1 = 0; /* Address of jump operation */ if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){ pAndExpr->pLeft = pOrExpr; pOrExpr = pAndExpr; @@ -3417,12 +3423,10 @@ static Bitmask codeOneLoopStart( ); if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){ int r; - int addr; /* Address just past Gosub coded below */ int iSet = ((ii==pOrWc->nTerm-1)?-1:ii); if( HasRowid(pTab) ){ r = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, regRowid, 0); - addr = sqlite3VdbeCurrentAddr(v)+2; - sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, addr, r, iSet); + j1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0, r,iSet); VdbeCoverage(v); }else{ Index *pPk = sqlite3PrimaryKeyIndex(pTab); @@ -3448,8 +3452,7 @@ static Bitmask codeOneLoopStart( ** need to insert the key into the temp table, as it will never ** be tested for. */ if( iSet ){ - addr = sqlite3VdbeCurrentAddr(v) + 2 + ((iSet>0) ? 2 : 0); - sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, addr, r, nPk); + j1 = sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, 0, r, nPk); VdbeCoverage(v); } if( iSet>=0 ){ @@ -3461,10 +3464,9 @@ static Bitmask codeOneLoopStart( /* Release the array of temp registers */ sqlite3ReleaseTempRange(pParse, r, nPk); } - assert( db->mallocFailed - || iSet==0 || addr==(sqlite3VdbeCurrentAddr(v)+1) ); } sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody); + if( j1 ) sqlite3VdbeJumpHere(v, j1); /* The pSubWInfo->untestedTerms flag means that this OR term ** contained one or more AND term from a notReady table. The