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].
FossilOrigin-Name: 32a88bdd4be5acdc1b80856bf6e32724dc3a467d5050bec0fe1a3dfedcc06f34
This commit is contained in:
parent
9216de8a23
commit
46daa99b8d
15
manifest
15
manifest
@ -1,12 +1,13 @@
|
||||
B fd5abb1a7b5a55127d5c0d5ff448020d8bccab44e4f5afe1eb88fc19578af735
|
||||
C Provide\sthe\sability\sto\suse\sthe\sSELECTTRACE()\sdebugging\smacro\soutside\sof\sthe\nselect.c\ssource\sfile.\s\sUse\sthis\sto\sadd\sa\snew\sSELECTTRACE()\sentry\sin\nwindow.c\sfor\simproved\stracing\sof\swindow-function\sparse-tree\srewriting.
|
||||
D 2020-06-11T00:57:09.771
|
||||
C Avoid\srewriting\scompound\sSELECT\sstatements\sthat\suse\sa\sdifferent\scollation\ssequence\sfor\sORDER\sBY\sand\srecord\sprocessing\sa\ssecond\stime\sif\sthey\scontain\swindow\sfunctions.\sFix\sfor\s[b706351c].
|
||||
D 2020-06-11T15:53:54.084
|
||||
F src/global.c 0409ae635839e0bef26a69b68be64126ab6cba62ac19bd7694f1652e591c4c17
|
||||
F src/select.c 733ae255f1d10d95bbb8a7c13203a62eb79badc775eb2b2315e7ab4e35d45bad
|
||||
F src/select.c 4cf6adb522701a8f9d31b813898c0ec0b3409d343ba131a6f9659d49b76e222a
|
||||
F src/sqliteInt.h fe320867c4f48eeeca523062c5668508b3f9b88d65690d42610bd138a5fdb5c4
|
||||
F src/test1.c e9f68f157f8fd027ee4c32c4b427f4eed274749bfb745427e2d954fa89d95ad3
|
||||
F src/window.c 88a63e6948ea924b3cf9ad8aff5ea1fa53bebdb2f13340867205fda16ed0f19c
|
||||
P fd5abb1a7b5a55127d5c0d5ff448020d8bccab44e4f5afe1eb88fc19578af735
|
||||
R b3d2143c6508e1f1efd9ec1303abeeea
|
||||
U drh
|
||||
Z 41a1b9acde17079fb4a53b14e25df793
|
||||
F test/window1.test 9d7f4990e5b36d95af93b189da4aa75216c6690ce95cced3c8b6d3234be51c2c
|
||||
P 30c6d895b573d5f2a53487b3b7a0d20be7e382c7a0bc87336bd43fbd2fa89bf4
|
||||
R d77969df2abe7d3c02ea74b2057f9f3a
|
||||
U dan
|
||||
Z 0af3852064f40e6db0fa611ce2dd7e61
|
||||
|
@ -1 +1 @@
|
||||
30c6d895b573d5f2a53487b3b7a0d20be7e382c7a0bc87336bd43fbd2fa89bf4
|
||||
32a88bdd4be5acdc1b80856bf6e32724dc3a467d5050bec0fe1a3dfedcc06f34
|
@ -4621,6 +4621,14 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){
|
||||
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;
|
||||
}
|
||||
|
@ -1917,4 +1917,34 @@ do_execsql_test 62.4 {
|
||||
) 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
|
||||
|
Loading…
Reference in New Issue
Block a user