aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2022-09-20 19:22:17 +0000
committerdrh <>2022-09-20 19:22:17 +0000
commit8b9a3d1fc8481c691f66e0793b63f8de29ca59cd (patch)
tree1f6897ce490a74a71d59b3db6f12cd97e62280cf /src
parent5a0771a1f4b9b9baddb634cbadd823434b3f9346 (diff)
downloadsqlite-8b9a3d1fc8481c691f66e0793b63f8de29ca59cd.tar.gz
sqlite-8b9a3d1fc8481c691f66e0793b63f8de29ca59cd.zip
Modify the OP_IfNotOpen opcode so that the jump is taken if the cursor is open
but was previously set to a NULL row using OP_NullRow. FossilOrigin-Name: 1292d68caa7086610ddda343f3852e63de8da1eb66536ee4716b6529f5a31bc6
Diffstat (limited to 'src')
-rw-r--r--src/expr.c2
-rw-r--r--src/vdbe.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c
index 064e78fde..baa0fe647 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3223,7 +3223,7 @@ void sqlite3CodeRhsOfIN(
sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
}
if( addrOnce ){
- sqlite3VdbeAddOp2(v, OP_Rewind, iTab, sqlite3VdbeCurrentAddr(v)+1);
+ sqlite3VdbeAddOp1(v, OP_NullRow, iTab);
sqlite3VdbeJumpHere(v, addrOnce);
/* Subroutine return */
assert( ExprUseYSub(pExpr) );
diff --git a/src/vdbe.c b/src/vdbe.c
index 686ebf175..ebf52e67a 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -4897,12 +4897,16 @@ case OP_SeekHit: {
/* Opcode: IfNotOpen P1 P2 * * *
** Synopsis: if( !csr[P1] ) goto P2
**
-** If cursor P1 is not open, jump to instruction P2. Otherwise, fall through.
+** If cursor P1 is not open or if P1 is set to a NULL row using the
+** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through.
*/
case OP_IfNotOpen: { /* jump */
+ VdbeCursor *pCur;
+
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
- VdbeBranchTaken(p->apCsr[pOp->p1]==0, 2);
- if( !p->apCsr[pOp->p1] ){
+ pCur = p->apCsr[pOp->p1];
+ VdbeBranchTaken(pCur==0 || pCur->nullRow, 2);
+ if( pCur==0 || pCur->nullRow ){
goto jump_to_p2_and_check_for_interrupt;
}
break;