]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Use OP_Copy instead of OP_SCopy when moving results out of a subquery,
authordrh <drh@noemail.net>
Thu, 3 Apr 2014 16:29:31 +0000 (16:29 +0000)
committerdrh <drh@noemail.net>
Thu, 3 Apr 2014 16:29:31 +0000 (16:29 +0000)
to prevent the subquery results from changing out from under the outer
query.  Fix for ticket [1e64dd782a126f48d78].

FossilOrigin-Name: d5513dfa23baa0b0a095aaf17d19aacd30dcef61

manifest
manifest.uuid
src/where.c
test/whereG.test

index a63a365841f112d03aef9640d90b1236868386ed..4bcee0a83236fd028ad302916096542b9beaa065 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stypo\sin\sthe\s"Synopsis:"\scomment\sfor\sthe\sOP_VFilter\sopcode.
-D 2014-04-03T14:31:00.074
+C Use\sOP_Copy\sinstead\sof\sOP_SCopy\swhen\smoving\sresults\sout\sof\sa\ssubquery,\nto\sprevent\sthe\ssubquery\sresults\sfrom\schanging\sout\sfrom\sunder\sthe\souter\nquery.\s\sFix\sfor\sticket\s[1e64dd782a126f48d78].
+D 2014-04-03T16:29:31.330
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -291,7 +291,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
 F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45
-F src/where.c 7d539cedb1c6a6d6b5d2075b8fea3a48db4838eb
+F src/where.c ebad891b7494d0c5f925cf7ab135380bd958cba3
 F src/whereInt.h 2564055b440e44ebec8b47f237bbccae6719b7af
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -1092,7 +1092,7 @@ F test/whereC.test d6f4ecd4fa2d9429681a5b22a25d2bda8e86ab8a
 F test/whereD.test 6c2feb79ef1f68381b07f39017fe5f9b96da8d62
 F test/whereE.test b3a055eef928c992b0a33198a7b8dc10eea5ad2f
 F test/whereF.test 5b2ba0dbe8074aa13e416b37c753991f0a2492d7
-F test/whereG.test eb3a46b3eaf38e25e3013433b2db8a25a866c215
+F test/whereG.test 2533b72ed4a31fd1687230a499b557b911525344
 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
 F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
 F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c
@@ -1159,7 +1159,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 9d2ae6342c8afa904bec591ebe134ff7f536b71c
-R 06523ad1e0d97e48aa9a162217a28d3b
+P 48ecdd4aff03741f96c070dced69c3c273b652cb
+Q +ec6a06246e04eee5f25f1c28507df73b697099c0
+R b6a2fefa5b61ea0e64da4db2aaa10286
 U drh
-Z 64c7c8526eed6d4962d61576f8ab00f6
+Z f1f1ceb5f31f4e26d736a13a2a5aca0f
index 5984b7794c03e0843926df7c46cd7cf261d67ae5..601b0b4f2e891d4aa1718821a9d0c7e8b00bc155 100644 (file)
@@ -1 +1 @@
-48ecdd4aff03741f96c070dced69c3c273b652cb
\ No newline at end of file
+d5513dfa23baa0b0a095aaf17d19aacd30dcef61
\ No newline at end of file
index 93ee8c59c310f0a441a2068e69cb7fe22701c136..dd6893f69f0e504441b2cf11f307702efc9efcad 100644 (file)
@@ -5924,7 +5924,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
       for(; k<last; k++, pOp++){
         if( pOp->p1!=pLevel->iTabCur ) continue;
         if( pOp->opcode==OP_Column ){
-          pOp->opcode = OP_SCopy;
+          pOp->opcode = OP_Copy;
           pOp->p1 = pOp->p2 + pTabItem->regResult;
           pOp->p2 = pOp->p3;
           pOp->p3 = 0;
index 490fffe64e0358bc86e8a5f5df5002e5e886d3b6..17d56532232a98bbc1c527d098d5a3fd4ab3466b 100644 (file)
@@ -166,5 +166,18 @@ do_eqp_test whereG-3.4 {
   SELECT * FROM a, b WHERE a2=5 AND a1=b1;
 } {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}
 
+# Ticket [1e64dd782a126f48d78c43a664844a41d0e6334e]:
+# Incorrect result in a nested GROUP BY/DISTINCT due to the use of an OP_SCopy
+# where an OP_Copy was needed.
+#
+do_execsql_test whereG-4.0 {
+  CREATE TABLE t4(x);
+  INSERT INTO t4 VALUES('right'),('wrong');
+  SELECT DISTINCT x
+   FROM (SELECT x FROM t4 GROUP BY x)
+   WHERE x='right'
+   ORDER BY x;
+} {right}
+
 
 finish_test