sqlite/sqlite-bug1075889.patch

42 lines
1.5 KiB
Diff
Raw Normal View History

Upstream fix for the issue that caused nautilus to crash.
RHBZ: #1075889
--- src/where.c
+++ src/where.c
@@ -4855,18 +4855,10 @@
** rowid appears in the ORDER BY clause, the corresponding WhereLoop is
** automatically order-distinct.
*/
assert( pOrderBy!=0 );
-
- /* Sortability of virtual tables is determined by the xBestIndex method
- ** of the virtual table itself */
- if( pLast->wsFlags & WHERE_VIRTUALTABLE ){
- testcase( nLoop>0 ); /* True when outer loops are one-row and match
- ** no ORDER BY terms */
- return pLast->u.vtab.isOrdered;
- }
if( nLoop && OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ) return 0;
nOrderBy = pOrderBy->nExpr;
testcase( nOrderBy==BMS-1 );
if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */
@@ -4875,11 +4867,14 @@
orderDistinctMask = 0;
ready = 0;
for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){
if( iLoop>0 ) ready |= pLoop->maskSelf;
pLoop = iLoop<nLoop ? pPath->aLoop[iLoop] : pLast;
- assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );
+ if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
+ if( pLoop->u.vtab.isOrdered ) obSat = obDone;
+ break;
+ }
iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
/* Mark off any ORDER BY term X that is a column in the table of
** the current loop for which there is term in the WHERE
** clause of the form X IS NULL or X=? that reference only outer