mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Performance improvement in resolving the INDEXED BY index name for the common
case where there is no INDEXED BY clause. FossilOrigin-Name: 554b286ac208168bde91c6c6034cc7087410def76fce650b519661b2ee2c61b7
This commit is contained in:
32
src/select.c
32
src/select.c
@@ -4711,23 +4711,25 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
|
||||
** pFrom->pIndex and return SQLITE_OK.
|
||||
*/
|
||||
int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){
|
||||
if( pFrom->pTab && pFrom->fg.isIndexedBy ){
|
||||
Table *pTab = pFrom->pTab;
|
||||
char *zIndexedBy = pFrom->u1.zIndexedBy;
|
||||
Index *pIdx;
|
||||
for(pIdx=pTab->pIndex;
|
||||
pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy);
|
||||
pIdx=pIdx->pNext
|
||||
);
|
||||
if( !pIdx ){
|
||||
sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0);
|
||||
pParse->checkSchema = 1;
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pFrom->pIBIndex = pIdx;
|
||||
Table *pTab = pFrom->pTab;
|
||||
char *zIndexedBy = pFrom->u1.zIndexedBy;
|
||||
Index *pIdx;
|
||||
assert( pTab!=0 );
|
||||
assert( pFrom->fg.isIndexedBy!=0 );
|
||||
|
||||
for(pIdx=pTab->pIndex;
|
||||
pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy);
|
||||
pIdx=pIdx->pNext
|
||||
);
|
||||
if( !pIdx ){
|
||||
sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0);
|
||||
pParse->checkSchema = 1;
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pFrom->pIBIndex = pIdx;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Detect compound SELECT statements that use an ORDER BY clause with
|
||||
** an alternative collating sequence.
|
||||
@@ -5195,7 +5197,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
}
|
||||
|
||||
/* Locate the index named by the INDEXED BY clause, if any. */
|
||||
if( sqlite3IndexedByLookup(pParse, pFrom) ){
|
||||
if( pFrom->fg.isIndexedBy && sqlite3IndexedByLookup(pParse, pFrom) ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user