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 D0D0624B53 for ; Tue, 5 Jun 2018 09:31:48 -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 OyLoqxZbP8xl for ; Tue, 5 Jun 2018 09:31:48 -0400 (EDT) Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 03CF0244FB for ; Tue, 5 Jun 2018 09:31:47 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 3/4] box: introduce box_space_id_by_name References: <95c32aa69c7040aa5a63164e19de8ac8f06d9ce3.1527765756.git.kshcherbatov@tarantool.org> <91765db9-575c-9d10-c678-ff1f3b230735@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Tue, 5 Jun 2018 16:31:41 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Kirill Shcherbatov , tarantool-patches@freelists.org Hello. Thanks for the fixes! The schema_find_id is still in C++ since it has tuple_field_u32_xc. XC means exception. I removed it and slightly refactored other code. The commit is force pushed and LGTM. diff --git a/src/box/schema.cc b/src/box/schema.cc index a85a09f9d..5d32e6153 100644 --- a/src/box/schema.cc +++ b/src/box/schema.cc @@ -226,7 +226,6 @@ int schema_find_id(uint32_t system_space_id, uint32_t index_id, const char *name, uint32_t len, uint32_t *object_id) { - *object_id = BOX_ID_NIL; if (len > BOX_NAME_MAX) { diag_set(SystemError, "name length %d is greater than BOX_NAME_MAX", len); @@ -257,13 +256,14 @@ schema_find_id(uint32_t system_space_id, uint32_t index_id, region_truncate(region, used); return -1; } - int rc = 0; struct tuple *tuple; - if (iterator_next(it, &tuple) != 0) { - rc = -1; - } else if (tuple) { + int rc = iterator_next(it, &tuple); + if (rc == 0) { /* id is always field #1 */ - *object_id = tuple_field_u32_xc(tuple, 0); + if (tuple == NULL) + *object_id = BOX_ID_NIL; + else if (tuple_field_u32(tuple, 0, object_id) != 0) + return -1; } iterator_delete(it); region_truncate(region, used);