mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-21 09:00:59 +03:00
Allow the rowid at the end of an index to be used in a constraint on that index.
FossilOrigin-Name: 9bf0524df7ca2e7fcd92b2878a8457264b3c7f6e
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Improvements\sto\sORDER\sBY\shandling\sin\sthe\sNGQP.\s\sFix\san\s"exit"\smistakenly\nleft\sin\sa\stest\sscript\sduring\sthe\sprevious\scheck-in.
|
C Allow\sthe\srowid\sat\sthe\send\sof\san\sindex\sto\sbe\sused\sin\sa\sconstraint\son\sthat\sindex.
|
||||||
D 2013-05-22T02:06:59.780
|
D 2013-05-22T17:01:17.424
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in f6b58b7bdf6535f0f0620c486dd59aa4662c0b4f
|
F Makefile.in f6b58b7bdf6535f0f0620c486dd59aa4662c0b4f
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -265,7 +265,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83
|
|||||||
F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d
|
F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d
|
||||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||||
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
|
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
|
||||||
F src/where.c b695db3fe80456a57461c43f1fa1596a38fb4652
|
F src/where.c 3ca12d203c0cca5bc36f0cd408a97ed5a9357047
|
||||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
|
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
|
||||||
@@ -1065,7 +1065,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||||
P 04dfb85a2a7025d4b5056b73fa8477691323919f
|
P 12c709b4369c7d94d7fb743d0d0da7a9350a3d16
|
||||||
R b7bf12d6215811537a2285f41fc9e19a
|
R 7322735243734361422a3e6e35778930
|
||||||
U drh
|
U drh
|
||||||
Z 6465b78fdb5633463ec5d8b46a4226e0
|
Z fd0ab2669226a74d38406e095d929629
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
12c709b4369c7d94d7fb743d0d0da7a9350a3d16
|
9bf0524df7ca2e7fcd92b2878a8457264b3c7f6e
|
||||||
22
src/where.c
22
src/where.c
@@ -5104,7 +5104,7 @@ static void whereLoopPrint(WhereLoop *p, SrcList *pTabList){
|
|||||||
sqlite3DebugPrintf(" %-15s", z);
|
sqlite3DebugPrintf(" %-15s", z);
|
||||||
sqlite3_free(z);
|
sqlite3_free(z);
|
||||||
}
|
}
|
||||||
sqlite3DebugPrintf(" fg %08x N %2d", p->wsFlags, p->nTerm);
|
sqlite3DebugPrintf(" fg %08x N %d", p->wsFlags, p->nTerm);
|
||||||
sqlite3DebugPrintf(" cost %.2g,%.2g,%.2g\n",
|
sqlite3DebugPrintf(" cost %.2g,%.2g,%.2g\n",
|
||||||
p->prereq, p->rSetup, p->rRun, p->nOut);
|
p->prereq, p->rSetup, p->rRun, p->nOut);
|
||||||
}
|
}
|
||||||
@@ -5293,6 +5293,7 @@ static int whereLoopAddBtreeIndex(
|
|||||||
WhereLoop savedLoop; /* Saved original content of pNew[] */
|
WhereLoop savedLoop; /* Saved original content of pNew[] */
|
||||||
int iCol; /* Index of the column in the table */
|
int iCol; /* Index of the column in the table */
|
||||||
int rc = SQLITE_OK; /* Return code */
|
int rc = SQLITE_OK; /* Return code */
|
||||||
|
tRowcnt iRowEst; /* Estimated index selectivity */
|
||||||
double rLogSize; /* Logarithm of table size */
|
double rLogSize; /* Logarithm of table size */
|
||||||
|
|
||||||
db = pBuilder->db;
|
db = pBuilder->db;
|
||||||
@@ -5300,7 +5301,7 @@ static int whereLoopAddBtreeIndex(
|
|||||||
if( db->mallocFailed ) return SQLITE_NOMEM;
|
if( db->mallocFailed ) return SQLITE_NOMEM;
|
||||||
|
|
||||||
assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
|
assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
|
||||||
assert( pNew->u.btree.nEq<pProbe->nColumn );
|
assert( pNew->u.btree.nEq<=pProbe->nColumn );
|
||||||
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
|
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
|
||||||
if( pNew->wsFlags & WHERE_BTM_LIMIT ){
|
if( pNew->wsFlags & WHERE_BTM_LIMIT ){
|
||||||
opMask = WO_LT|WO_LE;
|
opMask = WO_LT|WO_LE;
|
||||||
@@ -5310,9 +5311,15 @@ static int whereLoopAddBtreeIndex(
|
|||||||
opMask = WO_EQ|WO_IN|WO_ISNULL|WO_GT|WO_GE|WO_LT|WO_LE;
|
opMask = WO_EQ|WO_IN|WO_ISNULL|WO_GT|WO_GE|WO_LT|WO_LE;
|
||||||
}
|
}
|
||||||
|
|
||||||
iCol = pProbe->aiColumn[pNew->u.btree.nEq];
|
if( pNew->u.btree.nEq < pProbe->nColumn ){
|
||||||
|
iCol = pProbe->aiColumn[pNew->u.btree.nEq];
|
||||||
|
iRowEst = pProbe->aiRowEst[pNew->u.btree.nEq+1];
|
||||||
|
}else{
|
||||||
|
iCol = -1;
|
||||||
|
iRowEst = 1;
|
||||||
|
}
|
||||||
pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
|
pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
|
||||||
opMask, iCol>=0 ? pProbe : 0);
|
opMask, pProbe);
|
||||||
savedLoop = *pNew;
|
savedLoop = *pNew;
|
||||||
pNew->rSetup = (double)0;
|
pNew->rSetup = (double)0;
|
||||||
rLogSize = estLog(pProbe->aiRowEst[0]);
|
rLogSize = estLog(pProbe->aiRowEst[0]);
|
||||||
@@ -5334,11 +5341,11 @@ static int whereLoopAddBtreeIndex(
|
|||||||
nIn = pExpr->x.pList->nExpr;
|
nIn = pExpr->x.pList->nExpr;
|
||||||
}
|
}
|
||||||
pNew->u.btree.nEq++;
|
pNew->u.btree.nEq++;
|
||||||
pNew->nOut = (double)pProbe->aiRowEst[pNew->u.btree.nEq] * nInMul * nIn;
|
pNew->nOut = (double)iRowEst * nInMul * nIn;
|
||||||
}else if( pTerm->eOperator & (WO_EQ|WO_ISNULL) ){
|
}else if( pTerm->eOperator & (WO_EQ|WO_ISNULL) ){
|
||||||
pNew->wsFlags |= WHERE_COLUMN_EQ;
|
pNew->wsFlags |= WHERE_COLUMN_EQ;
|
||||||
pNew->u.btree.nEq++;
|
pNew->u.btree.nEq++;
|
||||||
pNew->nOut = (double)pProbe->aiRowEst[pNew->u.btree.nEq] * nInMul;
|
pNew->nOut = (double)iRowEst * nInMul;
|
||||||
}else if( pTerm->eOperator & (WO_GT|WO_GE) ){
|
}else if( pTerm->eOperator & (WO_GT|WO_GE) ){
|
||||||
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
|
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
|
||||||
pNew->nOut = savedLoop.nOut/3;
|
pNew->nOut = savedLoop.nOut/3;
|
||||||
@@ -5358,7 +5365,8 @@ static int whereLoopAddBtreeIndex(
|
|||||||
/* TBD: Adjust nOut for additional constraints */
|
/* TBD: Adjust nOut for additional constraints */
|
||||||
rc = whereLoopInsert(pBuilder, pNew);
|
rc = whereLoopInsert(pBuilder, pNew);
|
||||||
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
|
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
|
||||||
&& pNew->u.btree.nEq<pProbe->nColumn
|
&& pNew->u.btree.nEq<=pProbe->nColumn
|
||||||
|
&& pProbe->zName!=0
|
||||||
){
|
){
|
||||||
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul*nIn);
|
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul*nIn);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user