From 1c9599bef66af149604a1129b1e2f725d6a5069d Mon Sep 17 00:00:00 2001
From: Mergen Imeev <imeevma@tarantool.org>
Date: Fri, 8 Jul 2022 13:23:27 +0300
Subject: [PATCH] sql: drop unused opcode IteratorReopen

Opcode IteratorReopen is not used and should be dropped.

Part of #7358

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
---
 src/box/sql/vdbe.c  | 22 +---------------------
 src/box/sql/where.c |  2 +-
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index fe8ad12ebd..4fef24b700 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -2270,17 +2270,6 @@ case OP_TTransaction: {
 	break;
 }
 
-/* Opcode: IteratorReopen P1 P2 P3 P4 P5
- * Synopsis: index id = P2, space ptr = P4
- *
- * The IteratorReopen opcode works exactly like IteratorOpen except
- * that it first checks to see if the cursor on P1 is already open
- * with the same index and if it is this opcode becomes a no-op.
- * In other words, if the cursor is already open, do not reopen
- * it.
- *
- * The IteratorReopen opcode may only be used with P5 == 0.
- */
 /* Opcode: IteratorOpen P1 P2 P3 P4 P5
  * Synopsis: index id = P2, space ptr = P4 or reg[P3]
  *
@@ -2291,16 +2280,8 @@ case OP_TTransaction: {
  * If P4 was not set, then P3 supposed to be the register
  * containing space pointer.
  */
-case OP_IteratorReopen: {
-	assert(pOp->p5 == 0);
+case OP_IteratorOpen: {
 	struct VdbeCursor *cur = p->apCsr[pOp->p1];
-	if (cur != NULL && cur->uc.pCursor->space == pOp->p4.space &&
-	    cur->uc.pCursor->index->def->iid == (uint32_t)pOp->p2)
-		goto open_cursor_set_hints;
-	/* If the cursor is not currently open or is open on a different
-	 * index, then fall through into OP_OpenCursor to force a reopen
-	 */
-case OP_IteratorOpen:
 	if (box_schema_version() != p->schema_ver &&
 	    (pOp->p5 & OPFLAG_SYSTEMSP) == 0) {
 		p->expired = 1;
@@ -2336,7 +2317,6 @@ case OP_IteratorOpen:
 	/* Key info still contains sorter order and collation. */
 	cur->key_def = index->def->key_def;
 	cur->nullRow = 1;
-open_cursor_set_hints:
 	cur->uc.pCursor->hints = pOp->p5 & OPFLAG_SEEKEQ;
 	break;
 }
diff --git a/src/box/sql/where.c b/src/box/sql/where.c
index 6d8d2660f3..3ff12ccc4b 100644
--- a/src/box/sql/where.c
+++ b/src/box/sql/where.c
@@ -4625,7 +4625,7 @@ sqlWhereBegin(Parse * pParse,	/* The parser context */
 			} else if (iAuxArg
 				   && (wctrlFlags & WHERE_OR_SUBCLAUSE) != 0) {
 				iIndexCur = iAuxArg;
-				op = OP_IteratorReopen;
+				assert(op == OP_IteratorOpen);
 			} else {
 				iIndexCur = pParse->nTab++;
 			}
-- 
GitLab