Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Avoid rewriting compound SELECT statements that use a different collation sequence for ORDER BY and record processing a second time if they contain window functions. Fix for [b706351c]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
32a88bdd4be5acdc1b80856bf6e32724 |
User & Date: | dan 2020-06-11 15:53:54 |
Context
2020-06-17
| ||
12:37 | Merge miscellaneous fixes from trunk into the 3.32 branch. (check-in: d55b8e79 user: drh tags: branch-3.32) | |
2020-06-11
| ||
16:04 | Add a new assert() to the SELECT processing. (check-in: 98cea4a3 user: drh tags: trunk) | |
15:53 | Avoid rewriting compound SELECT statements that use a different collation sequence for ORDER BY and record processing a second time if they contain window functions. Fix for [b706351c]. (check-in: 32a88bdd user: dan tags: trunk) | |
00:57 | Provide the ability to use the SELECTTRACE() debugging macro outside of the select.c source file. Use this to add a new SELECTTRACE() entry in window.c for improved tracing of window-function parse-tree rewriting. (check-in: 30c6d895 user: drh tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 | Token dummy; if( p->pPrior==0 ) return WRC_Continue; if( p->pOrderBy==0 ) return WRC_Continue; for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){} if( pX==0 ) return WRC_Continue; a = p->pOrderBy->a; for(i=p->pOrderBy->nExpr-1; i>=0; i--){ if( a[i].pExpr->flags & EP_Collate ) break; } if( i<0 ) return WRC_Continue; /* If we reach this point, that means the transformation is required. */ | > > > > > > > > | 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 | Token dummy; if( p->pPrior==0 ) return WRC_Continue; if( p->pOrderBy==0 ) return WRC_Continue; for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){} if( pX==0 ) return WRC_Continue; a = p->pOrderBy->a; #ifndef SQLITE_OMIT_WINDOWFUNC /* If iOrderByCol is already non-zero, then it has already been matched ** to a result column of the SELECT statement. This occurs when the ** SELECT is rewritten for window-functions processing and then passed ** to sqlite3SelectPrep() and similar a second time. The rewriting done ** by this function is not required in this case. */ if( a[0].u.x.iOrderByCol ) return WRC_Continue; #endif for(i=p->pOrderBy->nExpr-1; i>=0; i--){ if( a[i].pExpr->flags & EP_Collate ) break; } if( i<0 ) return WRC_Continue; /* If we reach this point, that means the transformation is required. */ |
︙ | ︙ |
Changes to test/window1.test.
︙ | ︙ | |||
1912 1913 1914 1915 1916 1917 1918 1919 1920 | do_execsql_test 62.4 { SELECT * FROM ( SELECT sum(b) OVER() AS c FROM t1 UNION SELECT b AS c FROM t1 ) WHERE c>10; } {15.0 30.0} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 | do_execsql_test 62.4 { SELECT * FROM ( SELECT sum(b) OVER() AS c FROM t1 UNION SELECT b AS c FROM t1 ) WHERE c>10; } {15.0 30.0} #------------------------------------------------------------------------- reset_db do_execsql_test 63.1 { CREATE TABLE t1(b, x); CREATE TABLE t2(c, d); CREATE TABLE t3(e, f); } do_execsql_test 63.2 { SELECT max(b) OVER( ORDER BY SUM( (SELECT c FROM t2 UNION SELECT x ORDER BY c) ) ) FROM t1; } {{}} do_execsql_test 63.3 { SELECT sum(b) over( ORDER BY ( SELECT max(b) OVER( ORDER BY sum( (SELECT x AS c UNION SELECT 1234 ORDER BY c) ) ) AS e ORDER BY e ) ) FROM t1; } {{}} finish_test |