Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add further tests for new window function functionality. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | window-functions |
Files: | files | file ages | folders |
SHA3-256: |
1fbddf01b1c3fff95b05e2f2f709754e |
User & Date: | dan 2019-03-18 21:19:40.529 |
Context
2019-03-19
| ||
06:40 | Ensure that all the new window-function keywords can still be used as SQL identifiers. (check-in: a6d61dfd47 user: dan tags: window-functions) | |
2019-03-18
| ||
21:19 | Add further tests for new window function functionality. (check-in: 1fbddf01b1 user: dan tags: window-functions) | |
18:55 | Always evaluate window functions using the alternative path usually only used by EXCLUDE frames if the SQLITE_QueryFlattener test flag is set. (check-in: 2879a691ac user: dan tags: window-functions) | |
Changes
Changes to src/window.c.
︙ | |||
244 245 246 247 248 249 250 | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | - - - - - - - - + + - - - - - - - + | return; error_out: sqlite3_result_error( pCtx, "second argument to nth_value must be a positive integer", -1 ); } |
︙ | |||
400 401 402 403 404 405 406 | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | - - + + | struct CallCount *p; UNUSED_PARAMETER(nArg); assert( nArg==0 ); p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p)); p->nStep++; } static void cume_distValueFunc(sqlite3_context *pCtx){ struct CallCount *p; |
︙ | |||
525 526 527 528 529 530 531 | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | - + | sqlite3_value_free(p->pVal); p->pVal = 0; } } } static void last_valueValueFunc(sqlite3_context *pCtx){ struct LastValueCtx *p; |
︙ | |||
1401 1402 1403 1404 1405 1406 1407 | 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 | - - | sqlite3VdbeJumpHere(v, addrIsNull); }else if( pWin->regApp ){ assert( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ); assert( bInverse==0 || bInverse==1 ); sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1); |
︙ | |||
1502 1503 1504 1505 1506 1507 1508 | 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 | - - - + + + + + + | && (pWin->eStart!=TK_UNBOUNDED) ){ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult); sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult); sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
︙ | |||
1824 1825 1826 1827 1828 1829 1830 1831 | 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 | + + + + + + - - - - + + + + | sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); sqlite3ReleaseTempReg(pParse, reg1); sqlite3ReleaseTempReg(pParse, reg2); } /* ** Helper function for sqlite3WindowCodeStep(). Each call to this function ** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE ** operation. Refer to the header comment for sqlite3WindowCodeStep() for ** details. */ static int windowCodeOp( |
︙ | |||
1853 1854 1855 1856 1857 1858 1859 | 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 | - - - - + - - - - - - - - - - - - - + + + + + + + + + + - - + - - - + - + - - + - - - + | assert( regCountdown==0 && jumpOnEof==0 ); return 0; } if( regCountdown>0 ){ if( pMWin->eType==TK_RANGE ){ addrNextRange = sqlite3VdbeCurrentAddr(v); |
︙ | |||
1908 1909 1910 1911 1912 1913 1914 | 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 | + - + | assert( pMWin->regEndRowid ); sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regStartRowid, 1); }else{ windowAggStep(pParse, pMWin, csr, 1, p->regArg); } break; default: |
︙ | |||
2417 2418 2419 2420 2421 2422 2423 | 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 | - - | } break; default: s.eDelete = WINDOW_AGGINVERSE; break; } |
︙ | |||
2497 2498 2499 2500 2501 2502 2503 | 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 | - + | windowCheckValue(pParse, regStart, 0 + (pMWin->eType==TK_RANGE ? 3 : 0)); } if( regEnd ){ sqlite3ExprCode(pParse, pMWin->pEnd, regEnd); windowCheckValue(pParse, regEnd, 1 + (pMWin->eType==TK_RANGE ? 3 : 0)); } |
︙ |
Changes to test/window3.test.
cannot compute difference between binary files
Changes to test/windowerr.tcl.
︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | + + | 3 "ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING" 4 "ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING" 5 "ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING" 6 "ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING" 7 "ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING" 8 "PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING" } { errorsql_test 1.$tn " SELECT a, sum(b) OVER ( $frame ) FROM t1 ORDER BY 1 " } |
︙ |
Changes to test/windowerr.test.
︙ | |||
74 75 76 77 78 79 80 81 82 | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | + + + + + + + | # PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column do_test 1.7 { catch { execsql { SELECT a, sum(b) OVER ( ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING ) FROM t1 ORDER BY 1 } } } 1 # PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column do_test 1.8 { catch { execsql { SELECT a, sum(b) OVER ( PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING ) FROM t1 ORDER BY 1 } } } 1 finish_test |