1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Fix the OP_SeekRowid opcode so that it works correctly with a Real argument

without damaging the value in the register that is the argument.
Ticket [b2d4edaffdc156cc].  Test cases in TH3.

FossilOrigin-Name: 3cde82c86b963fa75192907d548febd3882c7d8fc7daf1903fadd5ca46623be1
This commit is contained in:
drh
2019-10-07 01:05:57 +00:00
parent 705e73344e
commit b29ef5ef03
3 changed files with 21 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
C Omit\sthe\scheck\sfor\sconflicting\sshared-cache\slocks\sin\ssqlite3Prepare()\sif\sthe\ndatabase\sconnection\suses\sno\sshared\scache.\s\sWe\smight\sbe\sable\sto\sgo\sback\sand\nremove\sthis\scode\scompletely,\sdue\sto\sthe\snewer\sSchema.iGeneration\slogic,\sbut\nthat\swill\stake\smore\sanalysis.\s\sThis\scheck-in\sgives\sthe\sspeed\sbenefit\sbut\snot\nthe\sreduction\sin\scode\ssize.
D 2019-10-05T19:53:21.900
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-07T01:05:57.547
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 c988e4e237697232804c4e59408ebe8112c24620b5504bea3942c9280a9de588
F src/vdbe.c 6df0a99dfbdd9dec542a94f06dd9a8a575acc87047937b2b801ac9d68eb3c96f
F src/vdbe.h 3f2b571e702e77e6bf031f0236e554aedfae643e991f69000320f481408455cf
F src/vdbeInt.h e95de5129124d77f01439e6635012adfaf23c0017bff47296126143cf18bd0c6
F src/vdbeapi.c 95001d0f84ee3cda344fed98ca0d7961deb4fc836b83495630d0af1f7cc4789e
@@ -1846,7 +1846,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 fc8d45086dc2bcb9bce756088e99e63cbeedf9129139fb0e6a48b43c4f502180
R 4347c46389181ab98e1ca993ae5d2560
P 0b73a09270dfafb27f8d1762b547ef8178c9da66f45e7153ff0b76272dfa92f5
R e6de42fa154e4ab1e333f543b12bcf01
U drh
Z 36eb308ab97c3a3dee1bd800aab329c1
Z cb13c52744b53be5d17143f1f2ff1518

View File

@@ -1 +1 @@
0b73a09270dfafb27f8d1762b547ef8178c9da66f45e7153ff0b76272dfa92f5
3cde82c86b963fa75192907d548febd3882c7d8fc7daf1903fadd5ca46623be1

View File

@@ -4539,23 +4539,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
@@ -4566,7 +4570,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 */