From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 04/12] alter: use space_index instead of index_find where appropriate Date: Sat, 7 Apr 2018 16:38:01 +0300 Message-Id: <8e2e1d73d9714d8f5c4431c8b59a96bfd5b392d2.1523105106.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: Using index_find_xc() in AlterSpaceOp::commit and rollback is confusing, because these functions may not throw. Let's use space_index instead as we are sure that the index we are looking for must exist. While we are at it, add some missing assertions. --- src/box/alter.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index ec7af24b..36310f1c 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -1006,8 +1006,9 @@ DropIndex::alter(struct alter_space *alter) void DropIndex::commit(struct alter_space *alter, int64_t /* signature */) { - struct index *index = index_find_xc(alter->old_space, - old_index_def->iid); + struct index *index = space_index(alter->old_space, + old_index_def->iid); + assert(index != NULL); index_commit_drop(index); } @@ -1105,6 +1106,7 @@ ModifyIndex::commit(struct alter_space *alter, int64_t signature) { struct index *new_index = space_index(alter->new_space, new_index_def->iid); + assert(new_index != NULL); index_commit_modify(new_index, signature); } @@ -1186,8 +1188,9 @@ CreateIndex::alter(struct alter_space *alter) /** * Get the new index and build it. */ - struct index *new_index = index_find_xc(alter->new_space, - new_index_def->iid); + struct index *new_index = space_index(alter->new_space, + new_index_def->iid); + assert(new_index != NULL); space_build_secondary_key_xc(alter->new_space, alter->new_space, new_index); } @@ -1195,16 +1198,18 @@ CreateIndex::alter(struct alter_space *alter) void CreateIndex::commit(struct alter_space *alter, int64_t signature) { - struct index *new_index = index_find_xc(alter->new_space, - new_index_def->iid); + struct index *new_index = space_index(alter->new_space, + new_index_def->iid); + assert(new_index != NULL); index_commit_create(new_index, signature); } void CreateIndex::rollback(struct alter_space *alter) { - struct index *new_index = index_find_xc(alter->new_space, - new_index_def->iid); + struct index *new_index = space_index(alter->new_space, + new_index_def->iid); + assert(new_index != NULL); index_abort_create(new_index); } @@ -1269,8 +1274,10 @@ RebuildIndex::commit(struct alter_space *alter, int64_t signature) { struct index *old_index = space_index(alter->old_space, old_index_def->iid); + assert(old_index != NULL); struct index *new_index = space_index(alter->new_space, new_index_def->iid); + assert(new_index != NULL); index_commit_drop(old_index); index_commit_create(new_index, signature); } @@ -1280,6 +1287,7 @@ RebuildIndex::rollback(struct alter_space *alter) { struct index *new_index = space_index(alter->new_space, new_index_def->iid); + assert(new_index != NULL); index_abort_create(new_index); } -- 2.11.0