From 1f97d2618b6c2f7d5ed7b76b71f1f6ffcf15ff8c Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 29 Mar 2021 13:47:20 +0000 Subject: [PATCH] The comparison opcodes (ex: OP_Eq) now set the iCompare flag so that the result of comparison can be used by subsequent OP_Jump or OP_ElseNotEq opcodes. FossilOrigin-Name: bd00df8f07b7163b0712590d2bb517e838a36c994dc47d7b39b5a07d14e6e6af --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/vdbe.c | 10 ++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ce0a96a9df..d12e048784 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Alternative\simplementation\sof\sthe\scomparison\sopcode\sspeed-up\sof\ncheck-in\s[4a8805d9a66dc888]\sthat\sshould\spass\smuster\swith\sUBSAN. -D 2021-03-28T23:37:56.856 +C The\scomparison\sopcodes\s(ex:\sOP_Eq)\snow\sset\sthe\siCompare\sflag\sso\sthat\sthe\nresult\sof\scomparison\scan\sbe\sused\sby\ssubsequent\sOP_Jump\sor\sOP_ElseNotEq\nopcodes. +D 2021-03-29T13:47:20.333 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -614,7 +614,7 @@ F src/upsert.c df8f1727d62b5987c4fd302cd4d7c0c84ae57cd65683c5a34a740dfe24039235 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 F src/util.c 41c7a72da1df47864faa378a1c720b38adb288c6838cb6be5594511b6287a048 F src/vacuum.c 492422c1463c076473bae1858799c7a0a5fe87a133d1223239447c422cd26286 -F src/vdbe.c c626ed23dedf2501e1cd97bc3e3e78dd95fc773c507827b0a0ba3cf14b008142 +F src/vdbe.c ea4ab60e1752dbfeecac18805f12d04da310febd1054e15fc247fac45ea4a93f F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe F src/vdbeInt.h 000d9ab1ea4cb55a80de15e28f3f595645b4fddef34bca4347fb3db8031d9041 F src/vdbeapi.c 4a43e303ec3354c785f453e881521969378e85628278ab74ba4a9df790c0d93b @@ -1911,7 +1911,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 36624d3740a8d095eee061bcc5037deabddb88a53444ec1a956a8af7684efa43 -R 66682903058dce39de324695f35d0b74 +P afb18f64541effaeaada2d72c7c91adfe5ec3e2b1418c0bc281083125fb5badb +R 710aa276e8312c2c05d4d33f5218ed6e +T *branch * compare-opcode-opt +T *sym-compare-opcode-opt * +T -sym-trunk * U drh -Z 8dbf744cc2e2ce2434fc7ddbd088d521 +Z f0d21120c3a7328d4a1225e5a853d72e diff --git a/manifest.uuid b/manifest.uuid index 4cf95da347..68cec3fe06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afb18f64541effaeaada2d72c7c91adfe5ec3e2b1418c0bc281083125fb5badb \ No newline at end of file +bd00df8f07b7163b0712590d2bb517e838a36c994dc47d7b39b5a07d14e6e6af \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 0026ed377b..57cbf864f4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1945,6 +1945,9 @@ case OP_Cast: { /* in1 */ ** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the ** content of r[P2] is only changed if the new value is NULL or 0 (false). ** In other words, a prior r[P2] value will not be overwritten by 1 (true). +** +** This opcode saves the result of comparison for use by the new +** OP_Jump opcode. */ /* Opcode: Ne P1 P2 P3 P4 P5 ** Synopsis: IF r[P3]!=r[P1] @@ -1985,6 +1988,9 @@ case OP_Cast: { /* in1 */ ** numeric, then a numeric comparison is used. If the two values ** are of different types, then numbers are considered less than ** strings and strings are considered less than blobs. +** +** This opcode saves the result of comparison for use by the new +** OP_Jump opcode. */ /* Opcode: Le P1 P2 P3 P4 P5 ** Synopsis: IF r[P3]<=r[P1] @@ -2044,9 +2050,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ ** then the result is always NULL. ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. */ + iCompare = 1; /* Operands are not equal */ if( pOp->p5 & SQLITE_STOREP2 ){ pOut = &aMem[pOp->p2]; - iCompare = 1; /* Operands are not equal */ memAboutToChange(p, pOut); MemSetTypeFlag(pOut, MEM_Null); REGISTER_TRACE(pOp->p2, pOut); @@ -2118,6 +2124,7 @@ compare_op: }else{ res2 = sqlite3aGTb[pOp->opcode]; } + iCompare = res; /* Undo any changes made by applyAffinity() to the input registers. */ assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); @@ -2127,7 +2134,6 @@ compare_op: if( pOp->p5 & SQLITE_STOREP2 ){ pOut = &aMem[pOp->p2]; - iCompare = res; if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){ /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1 ** and prevents OP_Ne from overwriting NULL with 0. This flag