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 08/10] sql: use secondary indexes to process OP_Delete Date: Sun, 12 Aug 2018 17:13:04 +0300 [thread overview] Message-ID: <2cb98faa8403229595d38b55ca6c8bd790bd9c81.1534001739.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1534001739.git.korablev@tarantool.org> In-Reply-To: <cover.1534001739.git.korablev@tarantool.org> Before this patch OP_Delete used only primary index to delete entry. Since it already operates on cursor, which in turn can be open on secondary index, lets pass index id to internal routine to use it. This is required in order to remove duplicates from secondary indexes while processing INSERT/UPDATE OR REPLACE statement. --- src/box/sql.c | 17 +++++------------ src/box/sql/tarantoolInt.h | 16 +++++++++++++++- src/box/sql/vdbe.c | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/box/sql.c b/src/box/sql.c index a0aced27b..de617c8b0 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -542,23 +542,15 @@ int tarantoolSqlite3Delete(BtCursor *pCur, u8 flags) &key_size); if (key == NULL) return SQL_TARANTOOL_DELETE_FAIL; - - rc = sql_delete_by_key(pCur->space, key, key_size); + rc = sql_delete_by_key(pCur->space, pCur->index->def->iid, key, + key_size); return rc == 0 ? SQLITE_OK : SQL_TARANTOOL_DELETE_FAIL; } -/** - * Delete entry from space by its key. - * - * @param space Space which contains record to be deleted. - * @param key Key of record to be deleted. - * @param key_size Size of key. - * - * @retval SQLITE_OK on success, SQL_TARANTOOL_DELETE_FAIL otherwise. - */ int -sql_delete_by_key(struct space *space, char *key, uint32_t key_size) +sql_delete_by_key(struct space *space, uint32_t iid, char *key, + uint32_t key_size) { struct request request; struct tuple *unused; @@ -567,6 +559,7 @@ sql_delete_by_key(struct space *space, char *key, uint32_t key_size) request.key = key; request.key_end = key + key_size; request.space_id = space->def->id; + request.index_id = iid; int rc = box_process_rw(&request, space, &unused); return rc == 0 ? SQLITE_OK : SQL_TARANTOOL_DELETE_FAIL; diff --git a/src/box/sql/tarantoolInt.h b/src/box/sql/tarantoolInt.h index 94517f608..31dc1b1bc 100644 --- a/src/box/sql/tarantoolInt.h +++ b/src/box/sql/tarantoolInt.h @@ -66,8 +66,22 @@ int tarantoolSqlite3Insert(struct space *space, const char *tuple, int tarantoolSqlite3Replace(struct space *space, const char *tuple, const char *tuple_end); int tarantoolSqlite3Delete(BtCursor * pCur, u8 flags); + +/** + * Delete entry from space by its key. + * + * @param space Space which contains record to be deleted. + * @param iid Index id. + * @param key Key of record to be deleted. + * @param key_size Size of key. + * + * @retval SQLITE_OK on success, SQL_TARANTOOL_DELETE_FAIL + * otherwise. + */ int -sql_delete_by_key(struct space *space, char *key, uint32_t key_size); +sql_delete_by_key(struct space *space, uint32_t iid, char *key, + uint32_t key_size); + int tarantoolSqlite3ClearTable(struct space *space); /** diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index dc5146f81..e1eaf91a4 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -4344,7 +4344,7 @@ case OP_SDelete: { struct space *space = space_by_id(pOp->p1); assert(space != NULL); assert(space_is_system(space)); - rc = sql_delete_by_key(space, pIn2->z, pIn2->n); + rc = sql_delete_by_key(space, 0, pIn2->z, pIn2->n); if (rc) goto abort_due_to_error; if (pOp->p5 & OPFLAG_NCHANGE) -- 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 struct Table 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 ` [tarantool-patches] [PATCH 03/10] sql: remove index hash from struct Table Nikita Pettik 2018-08-13 20:24 ` [tarantool-patches] " 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 ` Nikita Pettik [this message] 2018-08-13 20:24 ` [tarantool-patches] Re: [PATCH 08/10] sql: use secondary indexes to process OP_Delete 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=2cb98faa8403229595d38b55ca6c8bd790bd9c81.1534001739.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 08/10] sql: use secondary indexes to process OP_Delete' \ /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