]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix corer cases of vector IN operators where the RHS is a compound SELECT
authordrh <drh@noemail.net>
Tue, 6 Sep 2016 18:51:25 +0000 (18:51 +0000)
committerdrh <drh@noemail.net>
Tue, 6 Sep 2016 18:51:25 +0000 (18:51 +0000)
that includes an ORDER BY clause.

FossilOrigin-Name: 8329ac6f8d1edcc19c3e0559abe9a8011dbe1497

manifest
manifest.uuid
src/select.c
src/whereexpr.c

index 378bf072797dcd458ddd0b56ecc76e0ef271f67b..8def3253ea9069cd8ca9fa5770c0e628ea93bffb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sunnecessary\sbranch\sfrom\sexpr.c.
-D 2016-09-06T17:21:17.043
+C Fix\scorer\scases\sof\svector\sIN\soperators\swhere\sthe\sRHS\sis\sa\scompound\sSELECT\nthat\sincludes\san\sORDER\sBY\sclause.
+D 2016-09-06T18:51:25.666
 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 5017381e4853b1472e01d5bb926be1268eba429c
@@ -385,7 +385,7 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1
 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
 F src/resolve.c 24f40fd0c3475821d1ad762a3f2c3455cc839b42
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
-F src/select.c 4ccfc554a2d2313b0ac364120b1db9b74c41b248
+F src/select.c d6c1a6463a5e34352691e77f1475a63406c3984f
 F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7
 F src/sqlite.h.in 4a030e254e204570444b34bf7d40fb4a5416089e
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@@ -468,7 +468,7 @@ F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09
 F src/where.c 48d705e5196a0611a7be90698eade455ee238536
 F src/whereInt.h 14dd243e13b81cbb0a66063d38b70f93a7d6e613
 F src/wherecode.c b0d4febdd9de07ad68faadeacb30df9785f9b979
-F src/whereexpr.c c5ec87e234faf62ac2d4e7f7ce18fb1f4bd475ff
+F src/whereexpr.c e3db778ed205e982f31960896db71c50612ae009
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -1522,7 +1522,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 70319c3d76abd1e403fcf2a62668736b92a5f3d5
-R e9d987800340c93d5c8b755d8bc8e3a7
-U dan
-Z f81283c76e744b298a5230c53cc06749
+P 7cc9746c5414e02012efb8180f9eca2646800e74
+R 36f92754f7a81ed3dc243351ed6e664e
+U drh
+Z 50c7e7d129c621501eed665f9216f5e0
index a94fb71aebe66da8688123b4d4d3253df181f109..6e1c09ed3defc3713e86b834a1ac0d7e59738c1b 100644 (file)
@@ -1 +1 @@
-7cc9746c5414e02012efb8180f9eca2646800e74
\ No newline at end of file
+8329ac6f8d1edcc19c3e0559abe9a8011dbe1497
\ No newline at end of file
index e5bb4a748ac972b6b173e5c32b378d933a31e6d9..aa714ceb4895b2c834d98c7b453469827a0c8399 100644 (file)
@@ -2631,17 +2631,15 @@ static int generateOutputSubroutine(
     }
 
 #ifndef SQLITE_OMIT_SUBQUERY
-    /* If we are creating a set for an "expr IN (SELECT ...)" construct,
-    ** then there should be a single item on the stack.  Write this
-    ** item into the set table with bogus data.
+    /* If we are creating a set for an "expr IN (SELECT ...)".
     */
     case SRT_Set: {
       int r1;
-      assert( pIn->nSdst==1 || pParse->nErr>0 );
+      testcase( pIn->nSdst>1 && pParse->nErr==0 );
       r1 = sqlite3GetTempReg(pParse);
       sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, 
-          r1, pDest->zAffSdst,1);
-      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
+          r1, pDest->zAffSdst, pIn->nSdst);
+      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
       sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
       sqlite3ReleaseTempReg(pParse, r1);
       break;
index 92aed29bbc0bf8c7da1e4ecfdeb11c75ceaac174..e1059f73b4d49d5c39f02aacb37631384be73f20 100644 (file)
@@ -1209,9 +1209,13 @@ static void exprAnalyze(
   ** a virtual term for each vector component. The expression object
   ** used by each such virtual term is pExpr (the full vector IN(...) 
   ** expression). The WhereTerm.iField variable identifies the index within
-  ** the vector on the LHS that the virtual term represents.  */
+  ** the vector on the LHS that the virtual term represents.
+  **
+  ** This only works if the RHS is a simple SELECT, not a compound
+  */
   if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
    && pExpr->pLeft->op==TK_VECTOR
+   && pExpr->x.pSelect->pPrior==0
   ){
     int i;
     for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){