From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id F128B25C05 for ; Tue, 10 Jul 2018 11:45:47 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id proRWkzY9bQU for ; Tue, 10 Jul 2018 11:45:47 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id AC77824EFE for ; Tue, 10 Jul 2018 11:45:47 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: refactor vdbe_emit_open_cursor calls References: <94a3289e26898b8f779450bf620d8fef454844c7.1531140049.git.kshcherbatov@tarantool.org> <96598d88-35f2-3075-6f90-f2efecd2f0cd@tarantool.org> <665e7af1-3a3c-ed51-e9e8-097811a4a7a6@tarantool.org> From: Kirill Shcherbatov Message-ID: <15e20c40-fc3d-0b1d-271c-5dfaa76d6dd7@tarantool.org> Date: Tue, 10 Jul 2018 18:45:44 +0300 MIME-Version: 1.0 In-Reply-To: <665e7af1-3a3c-ed51-e9e8-097811a4a7a6@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy > 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,