]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the OP_SeekRowid opcode so that it works correctly with a Real argument
authordrh <drh@noemail.net>
Thu, 10 Oct 2019 15:57:44 +0000 (15:57 +0000)
committerdrh <drh@noemail.net>
Thu, 10 Oct 2019 15:57:44 +0000 (15:57 +0000)
without damaging the value in the register that is the argument.
Ticket [b2d4edaffdc156cc].  Test cases in TH3.

FossilOrigin-Name: b02630fe6ef666abaf07bffcae8696ce2c0047b2efef3f7d95622dd6df555ea6

manifest
manifest.uuid
src/vdbe.c

index 2dd3191d28cb77f5a93053155664522962247407..4e1018edebfab50d2e1efcb1da0139293fce5d66 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Be\ssure\sto\srewrite\scolumn\sreferences\sinside\sFILTER\sclauses\sand\swindow\sframe\sdefinitions\swhen\sflattening\squeries.\sFix\sfor\s[1079ad19].
-D 2019-10-10T15:48:16.906
+C Fix\sthe\sOP_SeekRowid\sopcode\sso\sthat\sit\sworks\scorrectly\swith\sa\sReal\sargument\nwithout\sdamaging\sthe\svalue\sin\sthe\sregister\sthat\sis\sthe\sargument.\nTicket\s[b2d4edaffdc156cc].\s\sTest\scases\sin\sTH3.
+D 2019-10-10T15:57:44.097
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -597,7 +597,7 @@ F src/upsert.c 710c91bb13e3c3fed5b6fe17cb13e09560bdd003ad8b8c51e6b16c80cfc48b10
 F src/utf.c 2f0fac345c7660d5c5bd3df9e9d8d33d4c27f366bcfb09e07443064d751a0507
 F src/util.c fffdfa627be74d69ef425f92db124e7148af449bb8a3286e79577c42bca84061
 F src/vacuum.c 82dcec9e7b1afa980288718ad11bc499651c722d7b9f32933c4d694d91cb6ebf
-F src/vdbe.c 7f43ed8e055a4290535d2e4520d33f0ac6cc00ef76a0c099e4c6bd85be74a6b9
+F src/vdbe.c da4030a71acf42be18001b9b7067d6d34ffb76610603ce6fafa52854b9e52936
 F src/vdbe.h 3f2b571e702e77e6bf031f0236e554aedfae643e991f69000320f481408455cf
 F src/vdbeInt.h e95de5129124d77f01439e6635012adfaf23c0017bff47296126143cf18bd0c6
 F src/vdbeapi.c 95001d0f84ee3cda344fed98ca0d7961deb4fc836b83495630d0af1f7cc4789e
@@ -1846,8 +1846,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 12e28cc7d92036fee7cfef29247f15fc5c7b49858cbe9044e983713f0de3dfc6
-Q +ccba7202b69d239724c3b589439c9c3b0e1bba237accfeb11c39d492522b8719
-R 3d1afcb626c959dc82e65f7f4b28b882
+P df2060f34fcb2a38c016df92079df5b64017fa31c97b2eef51eab7a9b5b940bf
+Q +3cde82c86b963fa75192907d548febd3882c7d8fc7daf1903fadd5ca46623be1
+R 688d57f533a2b892381419566993e03a
 U drh
-Z 20fa943f1f19192968c27125ebff38b0
+Z 225b405e5ada8452f3ee794146373472
index e64f92896f0ba2120d869e7520d5df1a87ca504e..3c1226d7a7027bb603fc83224289d844a7cc2c67 100644 (file)
@@ -1 +1 @@
-df2060f34fcb2a38c016df92079df5b64017fa31c97b2eef51eab7a9b5b940bf
\ No newline at end of file
+b02630fe6ef666abaf07bffcae8696ce2c0047b2efef3f7d95622dd6df555ea6
\ No newline at end of file
index 40d83265e51f58b9e1b292e6bec7a3f841b5b484..777582b9d61620d6495a980fe27386aa6d30ea2a 100644 (file)
@@ -4538,23 +4538,27 @@ case OP_SeekRowid: {        /* jump, in3 */
   pIn3 = &aMem[pOp->p3];
   testcase( pIn3->flags & MEM_Int );
   testcase( pIn3->flags & MEM_IntReal );
+  testcase( pIn3->flags & MEM_Real );
+  testcase( (pIn3->flags & (MEM_Str|MEM_Int))==MEM_Str );
   if( (pIn3->flags & (MEM_Int|MEM_IntReal))==0 ){
-    /* Make sure pIn3->u.i contains a valid integer representation of
-    ** the key value, but do not change the datatype of the register, as
-    ** other parts of the perpared statement might be depending on the
-    ** current datatype. */
-    u16 origFlags = pIn3->flags;
-    int isNotInt;
-    applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
-    isNotInt = (pIn3->flags & MEM_Int)==0;
-    pIn3->flags = origFlags;
-    if( isNotInt ) goto jump_to_p2;
+    /* If pIn3->u.i does not contain an integer, compute iKey as the
+    ** integer value of pIn3.  Jump to P2 if pIn3 cannot be converted
+    ** into an integer without loss of information.  Take care to avoid
+    ** changing the datatype of pIn3, however, as it is used by other
+    ** parts of the prepared statement. */
+    Mem x = pIn3[0];
+    applyAffinity(&x, SQLITE_AFF_NUMERIC, encoding);
+    if( (x.flags & MEM_Int)==0 ) goto jump_to_p2;
+    iKey = x.u.i;
+    goto notExistsWithKey;
   }
   /* Fall through into OP_NotExists */
 case OP_NotExists:          /* jump, in3 */
   pIn3 = &aMem[pOp->p3];
   assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid );
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
+  iKey = pIn3->u.i;
+notExistsWithKey:
   pC = p->apCsr[pOp->p1];
   assert( pC!=0 );
 #ifdef SQLITE_DEBUG
@@ -4565,7 +4569,6 @@ case OP_NotExists:          /* jump, in3 */
   pCrsr = pC->uc.pCursor;
   assert( pCrsr!=0 );
   res = 0;
-  iKey = pIn3->u.i;
   rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
   assert( rc==SQLITE_OK || res==0 );
   pC->movetoTarget = iKey;  /* Used by OP_Delete */