From aab97195dc0ae6c43b045998dc3f25e4e58bca01 Mon Sep 17 00:00:00 2001 From: Nikita Pettik <korablev@tarantool.org> Date: Fri, 26 Oct 2018 17:00:57 +0300 Subject: [PATCH] sql: remove nKey from struct BtCursor nKey member (indicating number of parts in key) now is used only for COUNT routine. On the other hand, it is always equal to 0 (as well as key is really NULL), since functions which are relied on this argument (tarantoolSqlite3Count and tarantoolSqlite3EphemeralCount) are called to perform OP_Count opcode. In its turn, OP_Count is emitted only for queries like <SELECT COUNT(*) FROM tab>, i.e. simple queries without filter conditions. Hence, nothing prevents us from removing this field at all. --- src/box/sql.c | 7 ++----- src/box/sql/cursor.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/box/sql.c b/src/box/sql.c index c7b87e57a2..9aca618ced 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -340,8 +340,7 @@ int tarantoolSqlite3EphemeralCount(struct BtCursor *pCur, i64 *pnEntry) assert(pCur->curFlags & BTCF_TEphemCursor); struct index *primary_index = space_index(pCur->space, 0 /* PK */); - *pnEntry = index_count(primary_index, pCur->iter_type, pCur->key, - pCur->nKey); + *pnEntry = index_count(primary_index, pCur->iter_type, NULL, 0); return SQLITE_OK; } @@ -349,8 +348,7 @@ int tarantoolSqlite3Count(BtCursor *pCur, i64 *pnEntry) { assert(pCur->curFlags & BTCF_TaCursor); - *pnEntry = index_count(pCur->index, pCur->iter_type, pCur->key, - pCur->nKey); + *pnEntry = index_count(pCur->index, pCur->iter_type, NULL, 0); return SQLITE_OK; } @@ -1031,7 +1029,6 @@ key_alloc(BtCursor *cur, size_t key_size) } cur->key = new_key; } - cur->nKey = key_size; return 0; } diff --git a/src/box/sql/cursor.h b/src/box/sql/cursor.h index da711a7def..d40ca87c87 100644 --- a/src/box/sql/cursor.h +++ b/src/box/sql/cursor.h @@ -41,7 +41,6 @@ typedef struct BtCursor BtCursor; * for ordinary space, or to TEphemCursor for ephemeral space. */ struct BtCursor { - i64 nKey; /* Size of pKey, or last integer key */ u8 curFlags; /* zero or more BTCF_* flags defined below */ u8 eState; /* One of the CURSOR_XXX constants (see below) */ u8 hints; /* As configured by CursorSetHints() */ -- GitLab