Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When determining if the subquery inserted by the window-function rewriter is an aggregate query, aggregate functions that are in parameters to another window function do not count. Fix for ticket [1f6f353b684fc708] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | early-winfunc-rewrite-dev |
Files: | files | file ages | folders |
SHA3-256: |
8583c3483c1b1ab2656f4b1886fc0a02 |
User & Date: | drh 2020-06-06 19:35:34 |
Original Comment: | When determining if the subquery inserted by the window-function rewriter is an aggregate query, aggregate functions that are in parameters to another window function do not count. |
Context
2020-06-06
| ||
20:48 | Merge multiple changes from trunk to address concerns with window-function parse-tree rewriting. (check-in: 05418b2a user: drh tags: branch-3.32-early-winfunc-rewrite) | |
19:54 | Fix a possible ASAN violation inside of debug-only code following an OOM. (check-in: 0e021887 user: drh tags: early-winfunc-rewrite-dev) | |
19:35 | When determining if the subquery inserted by the window-function rewriter is an aggregate query, aggregate functions that are in parameters to another window function do not count. Fix for ticket [1f6f353b684fc708] (check-in: 8583c348 user: drh tags: early-winfunc-rewrite-dev) | |
18:45 | Clearly distinguish between window functions and scalar functions in the debugging TreeView output. (check-in: 15babdcb user: drh tags: early-winfunc-rewrite-dev) | |
Changes
Changes to src/window.c.
︙ | ︙ | |||
932 933 934 935 936 937 938 939 940 941 942 943 944 945 | static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){ if( pExpr->op==TK_AGG_FUNCTION ){ if( pExpr->op2>=pWalker->walkerDepth ){ pExpr->op2++; }else if( pExpr->op2==pWalker->walkerDepth-1 ){ pWalker->eCode = 1; } } return WRC_Continue; } /* ** If the SELECT statement passed as the second argument does not invoke ** any SQL window functions, this function is a no-op. Otherwise, it | > > | 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){ if( pExpr->op==TK_AGG_FUNCTION ){ if( pExpr->op2>=pWalker->walkerDepth ){ pExpr->op2++; }else if( pExpr->op2==pWalker->walkerDepth-1 ){ pWalker->eCode = 1; } }else if( ExprHasProperty(pExpr, EP_WinFunc) ){ return WRC_Prune; } return WRC_Continue; } /* ** If the SELECT statement passed as the second argument does not invoke ** any SQL window functions, this function is a no-op. Otherwise, it |
︙ | ︙ |
Changes to test/window1.test.
︙ | ︙ | |||
1843 1844 1845 1846 1847 1848 1849 1850 1851 | CREATE TABLE t3(y); INSERT INTO t3(y) VALUES(5),(11),(-9); SELECT ( SELECT max(y) OVER( ORDER BY (SELECT x FROM (SELECT sum(y) AS x FROM t1))) ) FROM t3; } {5} finish_test | > > > > > > > > > > | 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 | CREATE TABLE t3(y); INSERT INTO t3(y) VALUES(5),(11),(-9); SELECT ( SELECT max(y) OVER( ORDER BY (SELECT x FROM (SELECT sum(y) AS x FROM t1))) ) FROM t3; } {5} # 2020-06-06 ticket 1f6f353b684fc708 reset_db do_execsql_test 58.1 { CREATE TABLE a(a, b, c); INSERT INTO a VALUES(1, 2, 3); INSERT INTO a VALUES(4, 5, 6); SELECT sum(345+b) OVER (ORDER BY b), sum(avg(678)) OVER (ORDER BY c) FROM a; } {347 678.0} finish_test |