From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 03/10] sql: remove index hash from struct Table Date: Sun, 12 Aug 2018 17:12:59 +0300 [thread overview] Message-ID: <20a381ab0d57bd5e6e4058db711d7caf7515c7a7.1534001739.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1534001739.git.korablev@tarantool.org> In-Reply-To: <cover.1534001739.git.korablev@tarantool.org> 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
next prev parent reply other threads:[~2018-08-12 14:13 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-12 14:12 [tarantool-patches] [PATCH 00/10] sql: cleanup in struct Index and " Nikita Pettik 2018-08-12 14:12 ` [tarantool-patches] [PATCH 01/10] sql: remove suport of ALTER TABLE ADD COLUMN Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-12 14:12 ` [tarantool-patches] [PATCH 02/10] sql: remove string of fields collation from Table Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-12 14:12 ` Nikita Pettik [this message] 2018-08-13 20:24 ` [tarantool-patches] Re: [PATCH 03/10] sql: remove index hash from struct Table Vladislav Shpilevoy 2018-08-12 14:13 ` [tarantool-patches] [PATCH 04/10] sql: remove flags " Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-12 14:13 ` [tarantool-patches] [PATCH 05/10] sql: remove affinity string of columns from Index Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-21 16:31 ` n.pettik 2018-08-24 21:04 ` Vladislav Shpilevoy 2018-08-26 19:45 ` n.pettik 2018-08-12 14:13 ` [tarantool-patches] [PATCH 06/10] sql: completely remove support of partial indexes Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-21 16:31 ` n.pettik 2018-08-24 21:04 ` Vladislav Shpilevoy 2018-08-26 19:44 ` n.pettik 2018-08-12 14:13 ` [tarantool-patches] [PATCH 07/10] sql: remove index type from struct Index Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-21 16:31 ` n.pettik 2018-08-12 14:13 ` [tarantool-patches] [PATCH 08/10] sql: use secondary indexes to process OP_Delete Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-12 14:13 ` [tarantool-patches] [PATCH 09/10] sql: disable ON CONFLICT actions for indexes Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-21 16:31 ` n.pettik 2018-08-24 21:04 ` Vladislav Shpilevoy 2018-08-26 19:44 ` n.pettik 2018-08-27 17:24 ` Vladislav Shpilevoy 2018-08-12 14:13 ` [tarantool-patches] [PATCH 10/10] sql: move autoincrement field number to server Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-21 16:31 ` n.pettik 2018-08-24 21:03 ` Vladislav Shpilevoy 2018-08-26 19:44 ` n.pettik 2018-08-27 17:24 ` Vladislav Shpilevoy 2018-08-27 17:24 ` [tarantool-patches] Re: [PATCH 00/10] sql: cleanup in struct Index and struct Table Vladislav Shpilevoy 2018-08-29 14:11 ` Kirill Yukhin
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=20a381ab0d57bd5e6e4058db711d7caf7515c7a7.1534001739.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 03/10] sql: remove index hash from struct Table' \ /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