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 E1407281CF for ; Sun, 12 Aug 2018 10:13:24 -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 7YXY43lzKwCL for ; Sun, 12 Aug 2018 10:13:24 -0400 (EDT) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 59E5928100 for ; Sun, 12 Aug 2018 10:13:24 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 03/10] sql: remove index hash from struct Table Date: Sun, 12 Aug 2018 17:12:59 +0300 Message-Id: <20a381ab0d57bd5e6e4058db711d7caf7515c7a7.1534001739.git.korablev@tarantool.org> In-Reply-To: References: In-Reply-To: References: 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: v.shpilevoy@tarantool.org, Nikita Pettik Part of #3561 --- src/box/sql/build.c | 41 +++++++---------------------------------- src/box/sql/sqliteInt.h | 1 - 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 48ced1766..78206a1ed 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -197,8 +197,11 @@ sqlite3LocateIndex(sqlite3 * db, const char *zName, const char *zTable) if (pTab == NULL) return NULL; - - return sqlite3HashFind(&pTab->idxHash, zName); + for (struct Index *idx = pTab->pIndex; idx != NULL; idx = idx->pNext) { + if (strcmp(zName, idx->def->name) == 0) + return idx; + } + return NULL; } /* @@ -224,12 +227,8 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 * db, Index * pIndex) { assert(pIndex != 0); - assert(&pIndex->pTable->idxHash); struct session *user_session = current_session(); - - pIndex = sqlite3HashInsert(&pIndex->pTable->idxHash, - pIndex->def->name, 0); if (ALWAYS(pIndex)) { if (pIndex->pTable->pIndex == pIndex) { pIndex->pTable->pIndex = pIndex->pNext; @@ -331,19 +330,8 @@ deleteTable(sqlite3 * db, Table * pTable) /* Delete all indices associated with this table. */ for (pIndex = pTable->pIndex; pIndex; pIndex = pNext) { pNext = pIndex->pNext; - if ((db == 0 || db->pnBytesFreed == 0)) { - char *zName = pIndex->def->name; - TESTONLY(Index * - pOld =) sqlite3HashInsert(&pTable->idxHash, - zName, 0); - assert(pOld == pIndex || pOld == 0); - } freeIndex(db, pIndex); } - - /* Delete the Table structure itself. - */ - sqlite3HashClear(&pTable->idxHash); assert(pTable->def != NULL); /* Do not delete pTable->def allocated on region. */ if (!pTable->def->opts.is_temporary) @@ -463,7 +451,6 @@ sql_table_new(Parse *parser, char *name) table->iAutoIncPKey = -1; table->pSchema = db->pSchema; - sqlite3HashInit(&table->idxHash); table->nTabRef = 1; return table; } @@ -2840,7 +2827,7 @@ sql_create_index(struct Parse *parse, struct Token *token, if (name == NULL) goto exit_create_index; assert(token->z != NULL); - if (sqlite3HashFind(&table->idxHash, name) != NULL) { + if (sqlite3LocateIndex(db, name, table->def->name) != NULL) { if (!if_not_exist) { sqlite3ErrorMsg(parse, "index %s.%s already exists", @@ -3088,14 +3075,6 @@ sql_create_index(struct Parse *parse, struct Token *token, */ assert(parse->nErr == 0); if (db->init.busy) { - struct Index *p = sqlite3HashInsert(&table->idxHash, - index->def->name, index); - if (p != NULL) { - /* Malloc must have failed. */ - assert(p == index); - sqlite3OomFault(db); - goto exit_create_index; - } user_session->sql_flags |= SQLITE_InternChanges; index->def->iid = db->init.index_id; } @@ -3875,7 +3854,6 @@ sqlite3Reindex(Parse * pParse, Token * pName1, Token * pName2) char *z = 0; /* Name of index */ char *zTable = 0; /* Name of indexed table */ Table *pTab; /* A table in the database */ - Index *pIndex; /* An index associated with pTab */ sqlite3 *db = pParse->db; /* The database connection */ assert(db->pSchema != NULL); @@ -3918,12 +3896,7 @@ sqlite3Reindex(Parse * pParse, Token * pName1, Token * pName2) goto exit_reindex; } - pIndex = sqlite3HashFind(&pTab->idxHash, z); - if (pIndex != NULL) { - sql_set_multi_write(pParse, false); - sqlite3RefillIndex(pParse, pIndex); - return; - } + sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed"); diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index 9c861518f..5757efe49 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -1874,7 +1874,6 @@ struct Savepoint { */ struct Table { Index *pIndex; /* List of SQL indexes on this table. */ - Hash idxHash; /* All (named) indices indexed by name */ u32 nTabRef; /* Number of pointers to this Table */ i16 iAutoIncPKey; /* If PK is marked INTEGER PRIMARY KEY AUTOINCREMENT, store column number here, -1 otherwise Tarantool specifics */ -- 2.15.1