SQLite

Check-in [ed1b30dc93]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Set the NULLEQ flag on the sequence counter comparison in the ORDER BY LIMIT optimization, to avoid coverage complaints about not testing the NULL case.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | orderby-limit
Files: files | file ages | folders
SHA1: ed1b30dc932a7c03e173b130c5f55f9989c7e0b4
User & Date: drh 2016-05-20 13:44:58.389
Context
2016-05-20
14:11
For queries with both ORDER BY and LIMIT, if the rows of the inner loop are emitted in ORDER BY order and the LIMIT has been reached, then optimize by exiting the inner loop and continuing with the next cycle of the first outer loop. (check-in: 559733b09e user: drh tags: trunk)
13:44
Set the NULLEQ flag on the sequence counter comparison in the ORDER BY LIMIT optimization, to avoid coverage complaints about not testing the NULL case. (Closed-Leaf check-in: ed1b30dc93 user: drh tags: orderby-limit)
00:21
A few simple test cases for the ORDER BY LIMIT optimization. (check-in: 08849eab0f user: drh tags: orderby-limit)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
607
608
609
610
611
612
613

614
615
616
617
618
619
620
      /* If the inner loop is driven by an index such that values from
      ** the same iteration of the inner loop are in sorted order, then
      ** immediately jump to the next iteration of an inner loop if the
      ** entry from the current iteration does not fit into the top
      ** LIMIT+OFFSET entries of the sorter. */
      int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
      sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);

      VdbeCoverage(v);
    }
    sqlite3VdbeJumpHere(v, addr);
  }
}

/*







>







607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
      /* If the inner loop is driven by an index such that values from
      ** the same iteration of the inner loop are in sorted order, then
      ** immediately jump to the next iteration of an inner loop if the
      ** entry from the current iteration does not fit into the top
      ** LIMIT+OFFSET entries of the sorter. */
      int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
      sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
      sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
      VdbeCoverage(v);
    }
    sqlite3VdbeJumpHere(v, addr);
  }
}

/*