From: drh Date: Tue, 29 Sep 2020 20:22:19 +0000 (+0000) Subject: Coverage testing of the OP_SeekScan opcode. Fix a problem that comes up when X-Git-Tag: version-3.34.0~82^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b2949c36ec15d1f340e59345e236129397b4595;p=thirdparty%2Fsqlite.git Coverage testing of the OP_SeekScan opcode. Fix a problem that comes up when OP_SeekScan reaches the end of the table. FossilOrigin-Name: 9e57e758a6a33f54d28a546b4eebfb5cfacef30dc4e0207e43bb9d2c06fc3439 --- diff --git a/manifest b/manifest index 9da918b734..d06d277e87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomments\son\sthe\snew\sOP_SeekScan\sopcode. -D 2020-09-29T17:29:11.276 +C Coverage\stesting\sof\sthe\sOP_SeekScan\sopcode.\s\sFix\sa\sproblem\sthat\scomes\sup\swhen\nOP_SeekScan\sreaches\sthe\send\sof\sthe\stable. +D 2020-09-29T20:22:20.000 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -607,7 +607,7 @@ F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 F src/util.c c0c7977de7ef9b8cb10f6c85f2d0557889a658f817b0455909a49179ba4c8002 F src/vacuum.c 492422c1463c076473bae1858799c7a0a5fe87a133d1223239447c422cd26286 -F src/vdbe.c f1dfd1fc1911876ac8ade2d1e9c3055242ec9de857fc7f72c9c75f712e6acde3 +F src/vdbe.c a5f9dbd62905ce5f7fde94c4b6e9d24eeb0e1844a4f352d7ce7b447bad62afcb F src/vdbe.h 83603854bfa5851af601fc0947671eb260f4363e62e960e8a994fb9bbcd2aaa1 F src/vdbeInt.h 3ca5e9fd6e095a8b6cf6bc3587a46fc93499503b2fe48951e1034ba9e2ce2f6e F src/vdbeapi.c c5e7cb2ab89a24d7f723e87b508f21bfb1359a04db5277d8a99fd1e015c12eb9 @@ -624,7 +624,7 @@ F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c 3df26a33dc4f54e8771600fb7fdebe1ece0896c2ad68c30ab40b017aa4395049 F src/where.c da9c0d503f81cc8444eb3525b75eec2bb3d198f4d5939b207977f2fc20d85b54 F src/whereInt.h 59077fbd0b3d01bc8715e746c86a99ebf4c85bde8a57077ec04d2a23e59666ec -F src/wherecode.c 89d14a834b48b9ead4415024a79a4895a3d4363b37e377a487479e9ed59118db +F src/wherecode.c 8d5e5973bcb5348877ac07ec85fb98cc3bb3b3377b79845cb39b3e812194cc47 F src/whereexpr.c 2a05552e808047a93845278c98c6ca64a265fa8e9ffd087c161bb11bfe339866 F src/window.c edd6f5e25a1e8f2b6f5305b7f5f7da7bb35f07f0d432b255b1d4c2fcab4205aa F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1880,7 +1880,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 2206a2c848a122ee220c89427f9be0460cba0706f58852139d7b37184ce29a29 -R 1f20d571e0b39b4a04d29411b17457a4 +P 6110fdd5bb7b4ae5c065404c802ae726362ef084966b73cffe58c4bfb98689d2 +R 5208a223b9abbea3e3bc1a7c83370262 U drh -Z fc780e21a0f22dec17fca15dd256ba17 +Z 4e19dcf82e793fd815f6f64707a372c6 diff --git a/manifest.uuid b/manifest.uuid index f5cbb057c3..bb134a3818 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6110fdd5bb7b4ae5c065404c802ae726362ef084966b73cffe58c4bfb98689d2 \ No newline at end of file +9e57e758a6a33f54d28a546b4eebfb5cfacef30dc4e0207e43bb9d2c06fc3439 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index dacda15074..3b52662468 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4477,28 +4477,47 @@ case OP_SeekScan: { rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res); if( rc ) goto abort_due_to_error; if( res>0 ){ + seekscan_search_fail: #ifdef SQLITE_DEBUG - if( db->flags&SQLITE_VdbeTrace ){ - printf("... %d steps and then skip\n", pOp->p1 - n); - } + if( db->flags&SQLITE_VdbeTrace ){ + printf("... %d steps and then skip\n", pOp->p1 - n); + } #endif pOp++; + VdbeBranchTaken(1,3); goto jump_to_p2; } if( res==0 ){ #ifdef SQLITE_DEBUG - if( db->flags&SQLITE_VdbeTrace ){ - printf("... %d steps and then success\n", pOp->p1 - n); - } + if( db->flags&SQLITE_VdbeTrace ){ + printf("... %d steps and then success\n", pOp->p1 - n); + } #endif pOp += 2; + VdbeBranchTaken(2,3); + break; + } + if( n<=0 ){ +#ifdef SQLITE_DEBUG + if( db->flags&SQLITE_VdbeTrace ){ + printf("... fall through after %d steps\n", pOp->p1); + } +#endif + VdbeBranchTaken(0,3); break; } - if( n<=0 ) break; n--; rc = sqlite3BtreeNext(pC->uc.pCursor, 0); - if( rc ) goto abort_due_to_error; + if( rc ){ + if( rc==SQLITE_DONE ){ + rc = SQLITE_OK; + goto seekscan_search_fail; + }else{ + goto abort_due_to_error; + } + } } + break; } diff --git a/src/wherecode.c b/src/wherecode.c index 4e10c79d8d..9dbc1d4b00 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1807,7 +1807,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 ){ assert( op==OP_SeekGE ); assert( regBignull==0 ); - sqlite3VdbeAddOp1(v, OP_SeekScan, 10); + sqlite3VdbeAddOp1(v, OP_SeekScan, 10); VdbeCoverage(v); } sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); VdbeCoverage(v);