Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When the result of a subquery is to be stored in a register and that subquery has an ORDER BY clause and an OFFSET, NULL out the destination register before starting the ORDER BY so that the register will be set correctly even if the OFFSET is larger than the number of output rows. Fix for the problem reported in forum post 0ec80f12d02acb3f. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9282bcde301cee2a5c3c068b5b0b7ce9 |
User & Date: | drh 2022-01-12 20:31:14.514 |
Context
2022-01-13
| ||
21:22 | Add --schema S option to .import (check-in: 38d9dbca16 user: larrybr tags: trunk) | |
2022-01-12
| ||
20:31 | When the result of a subquery is to be stored in a register and that subquery has an ORDER BY clause and an OFFSET, NULL out the destination register before starting the ORDER BY so that the register will be set correctly even if the OFFSET is larger than the number of output rows. Fix for the problem reported in forum post 0ec80f12d02acb3f. (check-in: 9282bcde30 user: drh tags: trunk) | |
01:42 | Make tool/mctimec.tcl effect more regular and obvious (check-in: 02aaa10f34 user: larrybr tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 | sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead); nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey); } #endif iTab = pSort->iECursor; if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){ regRowid = 0; regRow = pDest->iSdst; }else{ regRowid = sqlite3GetTempReg(pParse); if( eDest==SRT_EphemTab || eDest==SRT_Table ){ regRow = sqlite3GetTempReg(pParse); nColumn = 0; | > > > | 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 | sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead); nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey); } #endif iTab = pSort->iECursor; if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){ if( eDest==SRT_Mem && p->iOffset ){ sqlite3VdbeAddOp2(v, OP_Null, 0, pDest->iSdst); } regRowid = 0; regRow = pDest->iSdst; }else{ regRowid = sqlite3GetTempReg(pParse); if( eDest==SRT_EphemTab || eDest==SRT_Table ){ regRow = sqlite3GetTempReg(pParse); nColumn = 0; |
︙ | ︙ |
Changes to test/subquery.test.
︙ | ︙ | |||
589 590 591 592 593 594 595 596 597 | # is plugged. # do_execsql_test subquery-8.1 { CREATE TABLE t8(a TEXT, b INT); SELECT (SELECT 0 FROM (SELECT * FROM t1)) AS x WHERE x; SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x; } {} finish_test | > > > > > > > > > > > > > > > > > > > | 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | # is plugged. # do_execsql_test subquery-8.1 { CREATE TABLE t8(a TEXT, b INT); SELECT (SELECT 0 FROM (SELECT * FROM t1)) AS x WHERE x; SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x; } {} # 2022-01-12 https://sqlite.org/forum/forumpost/0ec80f12d02acb3f # reset_db do_execsql_test subquery-9.1 { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(1),(1); SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 100) FROM t1; } {{} {} {}} do_execsql_test subquery-9.2 { SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 0) FROM t1; } {1 1 1} do_execsql_test subquery-9.3 { INSERT INTO t1 VALUES(2); SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 1) FROM t1; } {2 2 2 2} do_execsql_test subquery-9.4 { SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 2) FROM t1; } {{} {} {} {}} finish_test |