mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
For the OR-optimization, avoid generating OP_OpenRead opcodes that reopen
exactly the same index. FossilOrigin-Name: b67a6e33f23ce5f5d9a545fa9d6700a7ed636901
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Limit\sthe\smaximum\sSQLITE_MAX_ATTACHED\sto\s127,\ssince\sa\ssigned\scharacter\nis\ssometimes\sused\sto\sstore\sthe\sdatabase\sindex.
|
C For\sthe\sOR-optimization,\savoid\sgenerating\sOP_OpenRead\sopcodes\sthat\sreopen\nexactly\sthe\ssame\sindex.
|
||||||
D 2014-07-21T20:07:17.299
|
D 2014-07-22T00:40:45.480
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
|
F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -227,7 +227,7 @@ F src/shell.c 566aee8213372a2e81ba0eb34e9759f7b2574009
|
|||||||
F src/sqlite.h.in fd8e3a36b0aded082dc93a4b89c1e85324b4cf75
|
F src/sqlite.h.in fd8e3a36b0aded082dc93a4b89c1e85324b4cf75
|
||||||
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
|
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
|
||||||
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
||||||
F src/sqliteInt.h 5dbcdcf81cb15e77df16f88699a15f7af491c580
|
F src/sqliteInt.h 0991b31a98c6ce072d255954af617baf50735eb1
|
||||||
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
|
||||||
@@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
|
|||||||
F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a
|
F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a
|
||||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||||
F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45
|
F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45
|
||||||
F src/where.c 3a451b00516b59f414c59f817508edce51c732f1
|
F src/where.c 4f8dce8f4e50b3b3675e8af7811e48526d6b4be2
|
||||||
F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6
|
F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6
|
||||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
@@ -1182,7 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 1a817ae2f35fa0396148dda2782cd4f919bf5c6f
|
P f1c76c7c4c7d16855db60d16e23ecdf8d7ca862a
|
||||||
R 848516fae6f90d131f9449e42d77b0c0
|
R ff4e333e5c258e291fb4ff256a0eb1e1
|
||||||
U drh
|
U drh
|
||||||
Z 0a273a2cc8050e8888f6349db4185a5f
|
Z 9049ac2491ab8361811966ab022cf8d0
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
f1c76c7c4c7d16855db60d16e23ecdf8d7ca862a
|
b67a6e33f23ce5f5d9a545fa9d6700a7ed636901
|
||||||
@@ -2136,6 +2136,7 @@ struct SrcList {
|
|||||||
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
|
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
|
||||||
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
|
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
|
||||||
#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
|
#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
|
||||||
|
#define WHERE_OR_INDEX_OPEN 0x1000 /* OP_OpenRead for the OR index exists */
|
||||||
|
|
||||||
/* Allowed return values from sqlite3WhereIsDistinct()
|
/* Allowed return values from sqlite3WhereIsDistinct()
|
||||||
*/
|
*/
|
||||||
|
|||||||
19
src/where.c
19
src/where.c
@@ -3422,6 +3422,7 @@ static Bitmask codeOneLoopStart(
|
|||||||
int iRetInit; /* Address of regReturn init */
|
int iRetInit; /* Address of regReturn init */
|
||||||
int untestedTerms = 0; /* Some terms not completely tested */
|
int untestedTerms = 0; /* Some terms not completely tested */
|
||||||
int ii; /* Loop counter */
|
int ii; /* Loop counter */
|
||||||
|
int subWctrlFlags; /* wctrlFlags for sub-queries */
|
||||||
Expr *pAndExpr = 0; /* An ".. AND (...)" expression */
|
Expr *pAndExpr = 0; /* An ".. AND (...)" expression */
|
||||||
Table *pTab = pTabItem->pTab;
|
Table *pTab = pTabItem->pTab;
|
||||||
|
|
||||||
@@ -3517,6 +3518,8 @@ static Bitmask codeOneLoopStart(
|
|||||||
** eliminating duplicates from other WHERE clauses, the action for each
|
** eliminating duplicates from other WHERE clauses, the action for each
|
||||||
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
|
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
|
||||||
*/
|
*/
|
||||||
|
subWctrlFlags = WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
|
||||||
|
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY;
|
||||||
for(ii=0; ii<pOrWc->nTerm; ii++){
|
for(ii=0; ii<pOrWc->nTerm; ii++){
|
||||||
WhereTerm *pOrTerm = &pOrWc->a[ii];
|
WhereTerm *pOrTerm = &pOrWc->a[ii];
|
||||||
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
|
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
|
||||||
@@ -3529,8 +3532,7 @@ static Bitmask codeOneLoopStart(
|
|||||||
}
|
}
|
||||||
/* Loop through table entries that match term pOrTerm. */
|
/* Loop through table entries that match term pOrTerm. */
|
||||||
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
|
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
|
||||||
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
|
subWctrlFlags, iCovCur);
|
||||||
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
|
|
||||||
assert( pSubWInfo || pParse->nErr || db->mallocFailed );
|
assert( pSubWInfo || pParse->nErr || db->mallocFailed );
|
||||||
if( pSubWInfo ){
|
if( pSubWInfo ){
|
||||||
WhereLoop *pSubLoop;
|
WhereLoop *pSubLoop;
|
||||||
@@ -3621,6 +3623,7 @@ static Bitmask codeOneLoopStart(
|
|||||||
){
|
){
|
||||||
assert( pSubWInfo->a[0].iIdxCur==iCovCur );
|
assert( pSubWInfo->a[0].iIdxCur==iCovCur );
|
||||||
pCov = pSubLoop->u.btree.pIndex;
|
pCov = pSubLoop->u.btree.pIndex;
|
||||||
|
subWctrlFlags |= WHERE_OR_INDEX_OPEN;
|
||||||
}else{
|
}else{
|
||||||
pCov = 0;
|
pCov = 0;
|
||||||
}
|
}
|
||||||
@@ -6212,6 +6215,18 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
pWInfo->aiCurOnePass[1] = iIndexCur;
|
pWInfo->aiCurOnePass[1] = iIndexCur;
|
||||||
}else if( iIdxCur && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){
|
}else if( iIdxCur && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){
|
||||||
iIndexCur = iIdxCur;
|
iIndexCur = iIdxCur;
|
||||||
|
if( (wctrlFlags & WHERE_OR_INDEX_OPEN)!=0 ){
|
||||||
|
/* For 2nd and subsequent subqueries for processing OR terms,
|
||||||
|
** try to reuse the previous OP_OpenRead, if there is one. The
|
||||||
|
** WHERE_OR_INDEX_OPEN bit will only be set if there is a prior
|
||||||
|
** OP_OpenRead opcode on cursor iIndexCur, so the while() loop
|
||||||
|
** below is guaranteed to terminate.
|
||||||
|
*/
|
||||||
|
VdbeOp *pOp = sqlite3VdbeGetOp(v, -1);
|
||||||
|
while( pOp->opcode!=OP_OpenRead || pOp->p1!=iIndexCur ) pOp--;
|
||||||
|
assert( pOp->p3==iDb );
|
||||||
|
if( pOp->p2==pIx->tnum ) op = 0;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
iIndexCur = pParse->nTab++;
|
iIndexCur = pParse->nTab++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user