Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add extra OOM test. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | exp-window-functions |
Files: | files | file ages | folders |
SHA3-256: |
ac251f72608c27c1512a0b3457524f53 |
User & Date: | dan 2018-06-15 20:46:12.018 |
Context
2018-06-18
| ||
16:55 | Add new API function sqlite3_create_window_function(), for creating new aggregate window functions. (check-in: da03fb4318 user: dan tags: exp-window-functions) | |
2018-06-15
| ||
20:46 | Add extra OOM test. (check-in: ac251f7260 user: dan tags: exp-window-functions) | |
19:01 | Fix another problem in lead()/lag(). And some errors that could occur following OOM faults. (check-in: fadd4dc119 user: dan tags: exp-window-functions) | |
Changes
Changes to src/window.c.
︙ | ︙ | |||
623 624 625 626 627 628 629 | ** linked list passed as the second argument (pWin) ** ** Append the node to output expression-list (*ppSub). And replace it ** with a TK_COLUMN that reads the (N-1)th element of table ** pWin->iEphCsr, where N is the number of elements in (*ppSub) after ** appending the new one. */ | | < | < | 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | ** linked list passed as the second argument (pWin) ** ** Append the node to output expression-list (*ppSub). And replace it ** with a TK_COLUMN that reads the (N-1)th element of table ** pWin->iEphCsr, where N is the number of elements in (*ppSub) after ** appending the new one. */ static void selectWindowRewriteEList( Parse *pParse, Window *pWin, ExprList *pEList, /* Rewrite expressions in this list */ ExprList **ppSub /* IN/OUT: Sub-select expression-list */ ){ Walker sWalker; WindowRewrite sRewrite; memset(&sWalker, 0, sizeof(Walker)); memset(&sRewrite, 0, sizeof(WindowRewrite)); sRewrite.pSub = *ppSub; sRewrite.pWin = pWin; sWalker.pParse = pParse; sWalker.xExprCallback = selectWindowRewriteExprCb; sWalker.xSelectCallback = selectWindowRewriteSelectCb; sWalker.u.pRewrite = &sRewrite; (void)sqlite3WalkExprList(&sWalker, pEList); *ppSub = sRewrite.pSub; } /* ** Append a copy of each expression in expression-list pAppend to ** expression list pList. Return a pointer to the result list. */ static ExprList *exprListAppendList( |
︙ | ︙ | |||
705 706 707 708 709 710 711 | p->pHaving = 0; /* Assign a cursor number for the ephemeral table used to buffer rows. ** The OpenEphemeral instruction is coded later, after it is known how ** many columns the table will have. */ pMWin->iEphCsr = pParse->nTab++; | | < | < | 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | p->pHaving = 0; /* Assign a cursor number for the ephemeral table used to buffer rows. ** The OpenEphemeral instruction is coded later, after it is known how ** many columns the table will have. */ pMWin->iEphCsr = pParse->nTab++; selectWindowRewriteEList(pParse, pMWin, p->pEList, &pSublist); selectWindowRewriteEList(pParse, pMWin, p->pOrderBy, &pSublist); pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0); /* Create the ORDER BY clause for the sub-select. This is the concatenation ** of the window PARTITION and ORDER BY clauses. Append the same ** expressions to the sub-select expression list. They are required to ** figure out where boundaries for partitions and sets of peer rows. */ pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0); |
︙ | ︙ |
Changes to test/window1.test.
︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 270 | lead(y, 2) OVER win, lead(y, 3, 'default') OVER win FROM t1 WINDOW win AS (ORDER BY x) } { 4 6 8 6 8 10 8 10 default 10 {} default {} {} default } finish_test | > > > > | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | lead(y, 2) OVER win, lead(y, 3, 'default') OVER win FROM t1 WINDOW win AS (ORDER BY x) } { 4 6 8 6 8 10 8 10 default 10 {} default {} {} default } do_execsql_test 7.3 { SELECT row_number() OVER (ORDER BY x) FROM t1 } {1 2 3 4 5} finish_test |
Changes to test/windowfault.test.
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 50 51 | min(d) OVER win FROM t1 WINDOW win AS (ORDER BY a) } } -test { faultsim_test_result {0 {1 1 1 1 4 4 {} 8 {} 4 4 2 2 2 1 4 8 8 12 4 8 4 3 3 3 2 4 12 8 {} 8 12 4}} } finish_test | > > > > > > > > > > > > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | min(d) OVER win FROM t1 WINDOW win AS (ORDER BY a) } } -test { faultsim_test_result {0 {1 1 1 1 4 4 {} 8 {} 4 4 2 2 2 1 4 8 8 12 4 8 4 3 3 3 2 4 12 8 {} 8 12 4}} } do_faultsim_test 2 -faults oom-* -prep { faultsim_restore_and_reopen } -body { execsql { SELECT min(d) OVER win, max(d) OVER win FROM t1 WINDOW win AS (ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) } } -test { faultsim_test_result {0 {4 12 8 12 12 12}} } finish_test |