From 4c5ebee0b569bc0063ca76c35193454844a81adb Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 26 Sep 2016 14:39:05 +0000 Subject: [PATCH] =?utf8?q?When=20flattening=20a=20query=20of=20the=20form?= =?utf8?q?=20"SELECT=20*=20FROM=20(SELECT=20*=20FROM=20tbl=20WHERE=20x=3D?= =?utf8?q?=3F)=20WHERE=20y=3D=3F",=20ensure=20that=20the=20final=20WHERE?= =?utf8?q?=20clause=20is=20"x=3D=3F=20AND=20y=3D=3F"=20instead=20of=20"y?= =?utf8?q?=3D=3F=20AND=20x=3D=3F".=20Although=20it=20is=20still=20not=20gu?= =?utf8?q?aranteed,=20this=20makes=20the=20order=20in=20which=20WHERE=20cl?= =?utf8?q?ause=20terms=20are=20processed=20comport=20more=20closely=20to?= =?utf8?q?=20users=20expectations.?= FossilOrigin-Name: cf7f9e6d5abff273dd2f8a8dce27d52e1449b3be --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index c63bc38f9d..b465f9514b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Inline\sthe\srelevent\sparts\sof\ssqlite3ExprAlloc()\sinto\sspanExpr(),\sfor\sa\nperformance\simprovement. -D 2016-09-26T12:38:22.166 +C When\sflattening\sa\squery\sof\sthe\sform\s"SELECT\s*\sFROM\s(SELECT\s*\sFROM\stbl\sWHERE\sx=?)\sWHERE\sy=?",\sensure\sthat\sthe\sfinal\sWHERE\sclause\sis\s"x=?\sAND\sy=?"\sinstead\sof\s"y=?\sAND\sx=?".\sAlthough\sit\sis\sstill\snot\sguaranteed,\sthis\smakes\sthe\sorder\sin\swhich\sWHERE\sclause\sterms\sare\sprocessed\scomport\smore\sclosely\sto\susers\sexpectations. +D 2016-09-26T14:39:05.023 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f @@ -386,7 +386,7 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 3c3cf0dc719cd2a32ab5c1e10c26481dd565492e F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c fb9da69a36382cf9cf57fb7a93247bf3de5a81ae +F src/select.c 6dede310d202f7a0da7f4ac1921f153707fa3d4f F src/shell.c b80396d2fadce4681397707e30078bf416e1dec2 F src/sqlite.h.in 2683a291ed8db5228024267be6421f0de507b80e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1525,7 +1525,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 795454a3fa5f9ccc486593b5e16e8fad38c934fb -R 0064134bdfbafdb61f074a12abc7c569 -U drh -Z 916f6b7f03e59b6765f98d6400d7b198 +P fe89225eab777c2c9cb1cbc31092b9e39f516842 +R bd1b8b7597a40edc8cdb78ec48a115d9 +U dan +Z c695e6aeed2069a364c17cb8286df68b diff --git a/manifest.uuid b/manifest.uuid index 771d6a8e05..3e2a0bc1b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe89225eab777c2c9cb1cbc31092b9e39f516842 \ No newline at end of file +cf7f9e6d5abff273dd2f8a8dce27d52e1449b3be \ No newline at end of file diff --git a/src/select.c b/src/select.c index 6e4f4b99ed..a3badd12b5 100644 --- a/src/select.c +++ b/src/select.c @@ -3695,12 +3695,13 @@ static int flattenSubquery( assert( pParent->pHaving==0 ); pParent->pHaving = pParent->pWhere; pParent->pWhere = pWhere; - pParent->pHaving = sqlite3ExprAnd(db, pParent->pHaving, - sqlite3ExprDup(db, pSub->pHaving, 0)); + pParent->pHaving = sqlite3ExprAnd(db, + sqlite3ExprDup(db, pSub->pHaving, 0), pParent->pHaving + ); assert( pParent->pGroupBy==0 ); pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0); }else{ - pParent->pWhere = sqlite3ExprAnd(db, pParent->pWhere, pWhere); + pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere); } substSelect(db, pParent, iParent, pSub->pEList, 0); -- 2.47.2