mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Experimental implementation of NULLS FIRST/LAST. This branch still has problems - the most significant of which is that ORDER BY clauses with a non-default NULLS FIRST/LAST qualifier can never use an index.
FossilOrigin-Name: 07babb0f897fc8c9cb5b30481899c32fdd743f3f3ca508d8d957826252107dd5
This commit is contained in:
@@ -1031,7 +1031,7 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
for(i=0; i<nOrderBy; i++){
|
||||
Expr *pExpr = pOrderBy->a[i].pExpr;
|
||||
pIdxOrderBy[i].iColumn = pExpr->iColumn;
|
||||
pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
|
||||
pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
|
||||
}
|
||||
|
||||
*pmNoOmit = mNoOmit;
|
||||
@@ -3836,6 +3836,7 @@ static i8 wherePathSatisfiesOrderBy(
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) continue;
|
||||
if( iColumn!=XN_ROWID ){
|
||||
pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
|
||||
if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;
|
||||
@@ -3849,10 +3850,11 @@ static i8 wherePathSatisfiesOrderBy(
|
||||
if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){
|
||||
/* Make sure the sort order is compatible in an ORDER BY clause.
|
||||
** Sort order is irrelevant for a GROUP BY clause. */
|
||||
assert( (pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL)==0 );
|
||||
if( revSet ){
|
||||
if( (rev ^ revIdx)!=pOrderBy->a[i].sortOrder ) isMatch = 0;
|
||||
if( (rev ^ revIdx)!=pOrderBy->a[i].sortFlags ) isMatch = 0;
|
||||
}else{
|
||||
rev = revIdx ^ pOrderBy->a[i].sortOrder;
|
||||
rev = revIdx ^ pOrderBy->a[i].sortFlags;
|
||||
if( rev ) *pRevMask |= MASKBIT(iLoop);
|
||||
revSet = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user