/ Check-in [36c75fd5]
Login

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

Overview
Comment:Disable the ORDER BY LIMIT optimization in queries using window functions. This fixes a problem that was introduced by check-in [206720129ed2fa8875a286] which attempted to fix ticket [9936b2fa443fec03ff25f9]. This changes is a fix for the follow-in tocket [510cde277783b5fb5de628].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.25
Files: files | file ages | folders
SHA3-256: 36c75fd5b7cddb48be74f4f86fafe588b3e597a80d226eeb43b77cbd3817572e
User & Date: drh 2018-09-17 15:25:21
Context
2018-09-18
20:20
Version 3.25.1 check-in: 2ac9003d user: drh tags: release, version-3.25.1, branch-3.25
2018-09-17
15:25
Disable the ORDER BY LIMIT optimization in queries using window functions. This fixes a problem that was introduced by check-in [206720129ed2fa8875a286] which attempted to fix ticket [9936b2fa443fec03ff25f9]. This changes is a fix for the follow-in tocket [510cde277783b5fb5de628]. check-in: 36c75fd5 user: drh tags: branch-3.25
15:19
Disable the ORDER BY LIMIT optimization in queries using window functions. This fixes a problem that was introduced by check-in [206720129ed2fa8875a286] which attempted to fix ticket [9936b2fa443fec03ff25f9]. This changes is a fix for the follow-in tocket [510cde277783b5fb5de628]. check-in: c6c9585f user: drh tags: trunk
14:18
Fix a false-positive in the post-ALTER-TABLE schema verification logic that prevents ALTER TABLE from working if the table being altered has a trigger that references any column of a virtual table. Ticket [b41031ea2b537237]. check-in: 5ce568c0 user: drh tags: branch-3.25
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  6082   6082         int regGosub = ++pParse->nMem;
  6083   6083   
  6084   6084         sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
  6085   6085   
  6086   6086         sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
  6087   6087         sqlite3VdbeResolveLabel(v, addrGosub);
  6088   6088         VdbeNoopComment((v, "inner-loop subroutine"));
         6089  +      sSort.labelOBLopt = 0;
  6089   6090         selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
  6090   6091         sqlite3VdbeResolveLabel(v, iCont);
  6091   6092         sqlite3VdbeAddOp1(v, OP_Return, regGosub);
  6092   6093         VdbeComment((v, "end inner-loop subroutine"));
  6093   6094         sqlite3VdbeResolveLabel(v, iBreak);
  6094   6095       }else
  6095   6096   #endif /* SQLITE_OMIT_WINDOWFUNC */

Changes to test/window1.test.

   522    522   do_catchsql_test 11.3 {
   523    523     CREATE INDEX t6i ON t6(sum(b) OVER ());
   524    524   } {1 {misuse of window function sum()}}
   525    525   do_catchsql_test 11.4 {
   526    526     CREATE INDEX t6i ON t6(lead(b) OVER ());
   527    527   } {1 {misuse of window function lead()}}
   528    528   
   529         -finish_test
          529  +# 2018-09-17 ticket 510cde277783b5fb5de628393959849dff377eb3
          530  +# Endless loop on a query with window functions and a limit
          531  +#
          532  +do_execsql_test 12.100 {
          533  +  DROP TABLE IF EXISTS t1;
          534  +  CREATE TABLE t1(id INT, b VARCHAR, c VARCHAR);
          535  +  INSERT INTO t1 VALUES(1, 'A', 'one');
          536  +  INSERT INTO t1 VALUES(2, 'B', 'two');
          537  +  INSERT INTO t1 VALUES(3, 'C', 'three');
          538  +  INSERT INTO t1 VALUES(4, 'D', 'one');
          539  +  INSERT INTO t1 VALUES(5, 'E', 'two');
          540  +  SELECT id, b, lead(c,1) OVER(ORDER BY c) AS x 
          541  +    FROM t1 WHERE id>1
          542  +   ORDER BY b LIMIT 1;
          543  +} {2 B two}
          544  +do_execsql_test 12.110 {
          545  +  INSERT INTO t1 VALUES(6, 'F', 'three');
          546  +  INSERT INTO t1 VALUES(7, 'G', 'one');
          547  +  SELECT id, b, lead(c,1) OVER(ORDER BY c) AS x
          548  +    FROM t1 WHERE id>1
          549  +   ORDER BY b LIMIT 2;
          550  +} {2 B two 3 C three}
   530    551   
          552  +finish_test