]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the OP_NullRow opcode so that it works even if it applied to an
authordrh <>
Tue, 14 Jun 2022 22:21:23 +0000 (22:21 +0000)
committerdrh <>
Tue, 14 Jun 2022 22:21:23 +0000 (22:21 +0000)
ephemeral cursor that has not yet been created.

FossilOrigin-Name: 0e925654c24774933c7738c68f704b229c68e18c8baa45f506b8d6f09164d0d8

manifest
manifest.uuid
src/vdbe.c
src/vdbeInt.h
test/join8.test

index ec248f19dd74fe5d4594271b6d8e63c3816f6611..cdcbb2ec413309c93eb7c4a84f5a529f55e83cc0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\smissing\sSQLITE_FCNTL_SIZE_HINT\scall\sto\sa\spath\staken\sduring\stransaction\srollback.
-D 2022-06-14T21:34:13.357
+C Fix\sthe\sOP_NullRow\sopcode\sso\sthat\sit\sworks\seven\sif\sit\sapplied\sto\san\nephemeral\scursor\sthat\shas\snot\syet\sbeen\screated.
+D 2022-06-14T22:21:23.940
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -642,9 +642,9 @@ F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937
 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
 F src/util.c 602fe229f32a96ceccae4f40824129669582096f7c355f53dbac156c9fecef23
 F src/vacuum.c bb346170b0b54c6683bba4a5983aea40485597fdf605c87ec8bc2e199fe88cd8
-F src/vdbe.c 1da334a0eed3718cfb8c411b1e5c1865b67ecc7df463e7676cbddd106eaea1ab
+F src/vdbe.c 1c254d8ae4eeed388ed61e32a285571cfaf7d8c38c21f335eef20edc0c60c5e8
 F src/vdbe.h 07641758ca8b4f4c6d81ea667ea167c541e6ece21f5574da11e3d21ec37e2662
-F src/vdbeInt.h ef43f7fdc5fde29fc3fd29c506c12830f366178fdb4edbbf0cbc3dfbd1278b5f
+F src/vdbeInt.h 2cad0aeeb106371ed0e0946bab89f60627087068847afc2451c05056961c18da
 F src/vdbeapi.c 354c893f1500cf524cc45c32879b9c68893a28b77e3442c24668d6afe4236217
 F src/vdbeaux.c 75c4f75ed7e1d12eb3d80093a160ec998c839f3008a1c3c967fc5acf522d0e3c
 F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd
@@ -1167,7 +1167,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
 F test/join5.test d22b6cba8fb59ab3f1c82701434c360705eb12d4ce200c449f37b018fc47681a
 F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c
 F test/join7.test 2268dcbb54b724391dda3748ea95c60d960607ffeed67885675998e7117697f6
-F test/join8.test aa3294b62e6a2a7622dbab864ac924820af910309835013ffac8421c733e9f8f
+F test/join8.test e3c8ca1419e3519596a7ef129246ed118d2508b1ebb69ea83b51ea0eda32037c
 F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05
 F test/joinA.test 7eab225dc1c1ab258a5e62513a4ed7cabbd3db971d59d5d92f4fb6fa14c12f6a
 F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded
@@ -1976,8 +1976,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b1be2259e2e08ec22a88bc9a18b3ab4d83246ad4c635c05cdf80d3eff84df06a
-R 61c4b9fc53ecc0a0dccc78e4998e97a0
-U dan
-Z 592beddfe13fc924a17e7bd0bf00ea44
+P 6c3266c1b4fc446c7c3a40a8816caf4f9fe0cafe4f27cdafecac61425a17927e
+R 76c655ef409274be060169c56d9cdb33
+U drh
+Z 17cec38f8d64f2ebe20fa6b2787372c5
 # Remove this line to create a well-formed Fossil manifest.
index 8c3276f2434a20c933a876707a2a454e7b39eb5a..87fc83d3c0b056894814cb287167a4a83ba9f8f5 100644 (file)
@@ -1 +1 @@
-6c3266c1b4fc446c7c3a40a8816caf4f9fe0cafe4f27cdafecac61425a17927e
\ No newline at end of file
+0e925654c24774933c7738c68f704b229c68e18c8baa45f506b8d6f09164d0d8
\ No newline at end of file
index 553a64972dce0018d0acaa0b0947bf838d4dd574..9df28fe1f43389a0a9f4e0fa53be37a2bd19b75a 100644 (file)
@@ -4192,8 +4192,8 @@ case OP_OpenDup: {
   pCx->pgnoRoot = pOrig->pgnoRoot;
   pCx->isOrdered = pOrig->isOrdered;
   pCx->ub.pBtx = pOrig->ub.pBtx;
-  pCx->hasBeenDuped = 1;
-  pOrig->hasBeenDuped = 1;
+  pCx->noReuse = 1;
+  pOrig->noReuse = 1;
   rc = sqlite3BtreeCursor(pCx->ub.pBtx, pCx->pgnoRoot, BTREE_WRCSR, 
                           pCx->pKeyInfo, pCx->uc.pCursor);
   /* The sqlite3BtreeCursor() routine can only fail for the first cursor
@@ -4260,7 +4260,7 @@ case OP_OpenEphemeral: {
     aMem[pOp->p3].z = "";
   }
   pCx = p->apCsr[pOp->p1];
-  if( pCx && !pCx->hasBeenDuped &&  ALWAYS(pOp->p2<=pCx->nField) ){
+  if( pCx && !pCx->noReuse &&  ALWAYS(pOp->p2<=pCx->nField) ){
     /* If the ephermeral table is already open and has no duplicates from
     ** OP_OpenDup, then erase all existing content so that the table is
     ** empty again, rather than creating a new table. */
@@ -5847,6 +5847,7 @@ case OP_NullRow: {
     if( pC==0 ) goto no_mem;
     pC->seekResult = 0;
     pC->isTable = 1;
+    pC->noReuse = 1;
     pC->uc.pCursor = sqlite3BtreeFakeValidCursor();
   }
   pC->nullRow = 1;
index 2a2e403173f3ff7181f59b239b7964ed3780f136..0e17c7d91f87a5bfee117f8c31b4be7148850672 100644 (file)
@@ -86,7 +86,7 @@ struct VdbeCursor {
   Bool isEphemeral:1;     /* True for an ephemeral table */
   Bool useRandomRowid:1;  /* Generate new record numbers semi-randomly */
   Bool isOrdered:1;       /* True if the table is not BTREE_UNORDERED */
-  Bool hasBeenDuped:1;    /* This cursor was source or target of OP_OpenDup */
+  Bool noReuse:1;         /* OpenEphemeral may not reuse this cursor */
   u16 seekHit;            /* See the OP_SeekHit and OP_IfNoHope opcodes */
   union {                 /* pBtx for isEphermeral.  pAltMap otherwise */
     Btree *pBtx;            /* Separate file holding temporary table */
index 1706bbdce1ed8f5a3a04fdc13df789fc8f4cf143..e0211a849701fc35f20f9816d28b459ae41229f9 100644 (file)
@@ -729,4 +729,22 @@ do_execsql_test join8-23020 {
    WHERE d ISNULL
 } {- - - - y}
 
+# 2022-06-14
+# dbsqlfuzz 2f3101834d14325a976f601b9267a0fd323d6bbd
+#
+# When the OP_NullRow opcode creates a new cursor, it must
+# set the cursor to no-reuse so that an OP_OpenEphemeral in
+# a subroutine does not try to reuse it.
+#
+reset_db
+db null -
+do_execsql_test join8-24000 {
+  CREATE TABLE t4(b INT, c INT);
+  CREATE TABLE t5(a INT, f INT);
+  INSERT INTO t5 VALUES(1,2);
+  WITH t7(x, y) AS (SELECT 100, 200 FROM t5)
+    SELECT * FROM t4 JOIN t7 ON true RIGHT JOIN (SELECT y AS z FROM t7) AS t6 ON (x=z);
+} {- - - - 200}
+
+
 finish_test