Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v1 3/4] box: introduce box_space_id_by_name
Date: Tue, 5 Jun 2018 16:31:41 +0300	[thread overview]
Message-ID: <f173f442-d006-b420-5c66-aa3872ea1eca@tarantool.org> (raw)
In-Reply-To: <ff77971d-82e8-eee3-5715-d8d832662c11@tarantool.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);

  reply	other threads:[~2018-06-05 13:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 11:22 [tarantool-patches] [PATCH v1 0/4] sql: remove Triggers to server Kirill Shcherbatov
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 1/4] box: move db->pShchema init to sql_init Kirill Shcherbatov
2018-05-31 17:36   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-01 20:24     ` Kirill Shcherbatov
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 2/4] sql: fix sql len in tarantoolSqlite3RenameTrigger Kirill Shcherbatov
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 3/4] box: introduce box_space_id_by_name Kirill Shcherbatov
2018-05-31 17:36   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-01 20:24     ` Kirill Shcherbatov
2018-06-04 13:27       ` Vladislav Shpilevoy
2018-06-04 19:21         ` Kirill Shcherbatov
2018-06-05 13:31           ` Vladislav Shpilevoy [this message]
2018-05-31 11:22 ` [tarantool-patches] [PATCH v1 4/4] sql: move Triggers to server Kirill Shcherbatov
2018-05-31 17:36   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-01 20:24     ` Kirill Shcherbatov
2018-06-01 20:25       ` Kirill Shcherbatov
2018-06-04 13:27         ` Vladislav Shpilevoy
2018-06-04 19:21           ` Kirill Shcherbatov
2018-06-05 13:31             ` Vladislav Shpilevoy
2018-06-09  9:32               ` Kirill Shcherbatov
2018-06-01 18:51   ` Konstantin Osipov
2018-05-31 17:36 ` [tarantool-patches] Re: [PATCH v1 0/4] sql: remove " Vladislav Shpilevoy
2018-06-04 13:27 ` Vladislav Shpilevoy
2018-06-05 13:31 ` Vladislav Shpilevoy

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=f173f442-d006-b420-5c66-aa3872ea1eca@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 3/4] box: introduce box_space_id_by_name' \
    /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