]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When flattening a query of the form "SELECT * FROM (SELECT * FROM tbl WHERE x=?)...
authordan <dan@noemail.net>
Mon, 26 Sep 2016 14:39:05 +0000 (14:39 +0000)
committerdan <dan@noemail.net>
Mon, 26 Sep 2016 14:39:05 +0000 (14:39 +0000)
FossilOrigin-Name: cf7f9e6d5abff273dd2f8a8dce27d52e1449b3be

manifest
manifest.uuid
src/select.c

index c63bc38f9da3b56707f36fcff3b5a9a41b927d8c..b465f9514b97a927c969363ea397f9ebddbeb17f 100644 (file)
--- 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
index 771d6a8e05de554e74ef6282ed135698328421d3..3e2a0bc1b0d9dc8c4c57df56868c73448281b493 100644 (file)
@@ -1 +1 @@
-fe89225eab777c2c9cb1cbc31092b9e39f516842
\ No newline at end of file
+cf7f9e6d5abff273dd2f8a8dce27d52e1449b3be
\ No newline at end of file
index 6e4f4b99edb04dfd279eb092e83165e62d72c67d..a3badd12b51e853b96b43194c67f30b199211aef 100644 (file)
@@ -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);