From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 5/8] vinyl: explicitly pass column mask to vy_check_is_unique Date: Sun, 14 Oct 2018 21:16:49 +0300 [thread overview] Message-ID: <e83bedd2a0c78bf1235e03d791cde437ab912b96.1539539421.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1539539421.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1539539421.git.vdavydov.dev@gmail.com> This patch is a preparation for removing vy_stmt_column_mask. --- src/box/vinyl.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index bd007645..4e6c5d56 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -1475,9 +1475,6 @@ vy_check_is_unique_secondary(struct vy_tx *tx, const struct vy_read_view **rv, if (!lsm->check_is_unique) return 0; - if (key_update_can_be_skipped(lsm->key_def->column_mask, - vy_stmt_column_mask(stmt))) - return 0; if (lsm->key_def->is_nullable && vy_tuple_key_contains_null(stmt, lsm->key_def)) return 0; @@ -1517,17 +1514,22 @@ vy_check_is_unique_secondary(struct vy_tx *tx, const struct vy_read_view **rv, /** * Check if insertion of a new tuple violates unique constraint * of any index of the space. - * @param env Vinyl environment. - * @param tx Current transaction. - * @param space Space to check. - * @param stmt New tuple. + * @param env Vinyl environment. + * @param tx Current transaction. + * @param space Space to check. + * @param stmt New tuple. + * @param column_mask Mask of columns changed by the operation. + * Used to optimize out uniqueness check in + * secondary indexes when an inserted tuple + * is a result of an UPDATE operation. * * @retval 0 Success, unique constraint is satisfied. * @retval -1 Duplicate is found or read error occurred. */ static int vy_check_is_unique(struct vy_env *env, struct vy_tx *tx, - struct space *space, struct tuple *stmt) + struct space *space, struct tuple *stmt, + uint64_t column_mask) { assert(space->index_count > 0); assert(vy_stmt_type(stmt) == IPROTO_INSERT || @@ -1560,6 +1562,9 @@ vy_check_is_unique(struct vy_env *env, struct vy_tx *tx, */ for (uint32_t i = 1; i < space->index_count; i++) { struct vy_lsm *lsm = vy_lsm(space->index[i]); + if (key_update_can_be_skipped(lsm->key_def->column_mask, + column_mask)) + continue; if (vy_check_is_unique_secondary(tx, rv, space_name(space), index_name_by_id(space, i), lsm, stmt) != 0) @@ -1721,7 +1726,8 @@ vy_perform_update(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt, assert(stmt->old_tuple != NULL); assert(stmt->new_tuple != NULL); - if (vy_check_is_unique(env, tx, space, stmt->new_tuple) != 0) + if (vy_check_is_unique(env, tx, space, stmt->new_tuple, + column_mask) != 0) return -1; vy_stmt_set_flags(stmt->new_tuple, VY_STMT_UPDATE); @@ -1853,7 +1859,7 @@ vy_insert_first_upsert(struct vy_env *env, struct vy_tx *tx, assert(tx != NULL && tx->state == VINYL_TX_READY); assert(space->index_count > 0); assert(vy_stmt_type(stmt) == IPROTO_INSERT); - if (vy_check_is_unique(env, tx, space, stmt) != 0) + if (vy_check_is_unique(env, tx, space, stmt, COLUMN_MASK_FULL) != 0) return -1; struct vy_lsm *pk = vy_lsm(space->index[0]); assert(pk->index_id == 0); @@ -2121,7 +2127,8 @@ vy_insert(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt, request->tuple_end); if (stmt->new_tuple == NULL) return -1; - if (vy_check_is_unique(env, tx, space, stmt->new_tuple) != 0) + if (vy_check_is_unique(env, tx, space, stmt->new_tuple, + COLUMN_MASK_FULL) != 0) return -1; if (vy_tx_set(tx, pk, stmt->new_tuple) != 0) return -1; @@ -2173,7 +2180,8 @@ vy_replace(struct vy_env *env, struct vy_tx *tx, struct txn_stmt *stmt, request->tuple_end); if (stmt->new_tuple == NULL) return -1; - if (vy_check_is_unique(env, tx, space, stmt->new_tuple) != 0) + if (vy_check_is_unique(env, tx, space, stmt->new_tuple, + COLUMN_MASK_FULL) != 0) return -1; /* * Get the overwritten tuple from the primary index if -- 2.11.0
next prev parent reply other threads:[~2018-10-14 18:16 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-14 18:16 [PATCH 0/8] Get rid of Vinyl's mem_format_with_colmask Vladimir Davydov 2018-10-14 18:16 ` [PATCH 1/8] vinyl: move update optimization from write iterator to tx Vladimir Davydov 2018-10-23 7:35 ` [tarantool-patches] " Konstantin Osipov 2018-10-14 18:16 ` [PATCH 2/8] vinyl: factor out common code of UPDATE and UPSERT Vladimir Davydov 2018-10-23 7:36 ` [tarantool-patches] " Konstantin Osipov 2018-10-14 18:16 ` [PATCH 3/8] vinyl: do not use column mask as trigger for turning REPLACE into INSERT Vladimir Davydov 2018-10-23 7:37 ` [tarantool-patches] " Konstantin Osipov 2018-10-14 18:16 ` [PATCH 4/8] vinyl: explicitly pass column mask to vy_tx_set Vladimir Davydov 2018-10-14 18:16 ` Vladimir Davydov [this message] 2018-10-14 18:16 ` [PATCH 6/8] vinyl: zap vy_stmt_column_mask and mem_format_with_colmask Vladimir Davydov 2018-10-14 18:16 ` [PATCH 7/8] tuple: zap tuple_format_dup Vladimir Davydov 2018-10-14 18:16 ` [PATCH 8/8] tuple: zap tuple_extra Vladimir Davydov 2018-10-23 7:42 ` [tarantool-patches] " Konstantin Osipov 2018-10-23 8:32 ` Vladimir Davydov 2018-10-23 7:32 ` [tarantool-patches] Re: [PATCH 0/8] Get rid of Vinyl's mem_format_with_colmask Konstantin Osipov 2018-10-23 8:22 ` Vladimir Davydov 2018-10-24 11:13 ` Vladimir Davydov
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=e83bedd2a0c78bf1235e03d791cde437ab912b96.1539539421.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 5/8] vinyl: explicitly pass column mask to vy_check_is_unique' \ /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