Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: refactor vdbe_emit_open_cursor calls
Date: Tue, 10 Jul 2018 18:45:44 +0300	[thread overview]
Message-ID: <15e20c40-fc3d-0b1d-271c-5dfaa76d6dd7@tarantool.org> (raw)
In-Reply-To: <665e7af1-3a3c-ed51-e9e8-097811a4a7a6@tarantool.org>

> 1. Still out dated. Where is '@param space'?
+ * @param space Pointer to space object.

> 2. Why vdbe_emit_open_cursor opens the cursor using index_id,
> but opcode OP_OpenRead/Write still uses it as tnum?
It is much more convenient to do this as a part of next commit.
I temporary put this changes as a commit at head 
"sql: uniform OP_Open{Write,Read} ops to use tnum"

diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index d84f1c0..699a4e8 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -891,9 +891,10 @@ analyzeOneTable(Parse * pParse,	/* Parser context */
 		/* Open a read-only cursor on the index being analyzed. */
 		struct space *space =
 			space_by_id(SQLITE_PAGENO_TO_SPACEID(pIdx->tnum));
+		int idx_id = SQLITE_PAGENO_TO_INDEXID(pIdx->tnum);
 		assert(space != NULL);
-		sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum,
-				  0, (void *) space, P4_SPACEPTR);
+		sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, idx_id, 0,
+				  (void *) space, P4_SPACEPTR);
 		VdbeComment((v, "%s", pIdx->zName));
 
 		/* Invoke the stat_init() function. The arguments are:
diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c
index 24122e8..ca1e77d 100644
--- a/src/box/sql/delete.c
+++ b/src/box/sql/delete.c
@@ -335,10 +335,7 @@ sql_table_delete_from(struct Parse *parse, struct SrcList *tab_list,
 				iAddrOnce = sqlite3VdbeAddOp0(v, OP_Once);
 				VdbeCoverage(v);
 			}
-			int tnum =
-				SQLITE_PAGENO_FROM_SPACEID_AND_INDEXID(space_id,
-								       0);
-			sqlite3VdbeAddOp4(v, OP_OpenWrite, tab_cursor, tnum, 0,
+			sqlite3VdbeAddOp4(v, OP_OpenWrite, tab_cursor, 0, 0,
 					  (void *) space, P4_SPACEPTR);
 			VdbeComment((v, "%s", space->index[0]->def->name));
 
diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index bb1a225..6aede16 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -1622,7 +1622,9 @@ sqlite3OpenTableAndIndices(Parse * pParse,	/* Parsing context */
 				p5 = 0;
 			}
 			if (aToOpen == 0 || aToOpen[i + 1]) {
-				sqlite3VdbeAddOp4(v, op, iIdxCur, pIdx->tnum, 0,
+				int idx_id =
+					SQLITE_PAGENO_TO_INDEXID(pIdx->tnum);
+				sqlite3VdbeAddOp4(v, op, iIdxCur, idx_id, 0,
 						  (void *) space, P4_SPACEPTR);
 				sqlite3VdbeChangeP5(v, p5);
 				VdbeComment((v, "%s", pIdx->zName));
diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index 1e8a4c9..8ff5bbc 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -691,9 +691,12 @@ sqlite3Pragma(Parse * pParse, Token * pId,	/* First part of [schema.]id field */
 					struct space *space =
 						space_cache_find(pIdx->pTable->
 								 def->id);
+					int idx_id =
+						SQLITE_PAGENO_TO_INDEXID(pIdx->
+									 tnum);
 					assert(space != NULL);
 					sqlite3VdbeAddOp4(v, OP_OpenRead, i,
-							  pIdx->tnum,0,
+							  idx_id, 0,
 							  (void *) space,
 							  P4_SPACEPTR);
 
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 6d7db13..88579bf 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -3159,9 +3159,8 @@ case OP_ReopenIdx: {
 	pCur = p->apCsr[pOp->p1];
 	p2 = pOp->p2;
 	if (pCur && pCur->uc.pCursor->space == pOp->p4.space &&
-	    pCur->uc.pCursor->index->def->iid == SQLITE_PAGENO_TO_INDEXID(p2)) {
+	    pCur->uc.pCursor->index->def->iid == 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_OpenRead to force a reopen
 	 */
@@ -3178,7 +3177,7 @@ case OP_OpenWrite:
 	}
 	p2 = pOp->p2;
 	struct space *space = pOp->p4.space;
-	struct index *index = space_index(space, SQLITE_PAGENO_TO_INDEXID(p2));
+	struct index *index = space_index(space, p2);
 	assert(index != NULL);
 	/*
 	 * Since Tarantool iterator provides the full tuple,

  reply	other threads:[~2018-07-10 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 12:42 [tarantool-patches] " Kirill Shcherbatov
2018-07-10 11:48 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-10 13:44   ` Kirill Shcherbatov
2018-07-10 14:59     ` Vladislav Shpilevoy
2018-07-10 15:45       ` Kirill Shcherbatov [this message]
2018-07-10 15:56         ` Vladislav Shpilevoy
2018-07-10 16:37           ` Kirill Shcherbatov
2018-07-10 16:52             ` Vladislav Shpilevoy
2018-07-10 13:45 ` [tarantool-patches] [PATCH v1 2/2] sql: remove OP_LoadPtr Kirill Shcherbatov
2018-07-10 14:59   ` [tarantool-patches] " Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15e20c40-fc3d-0b1d-271c-5dfaa76d6dd7@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/1] sql: refactor vdbe_emit_open_cursor calls' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox