[tarantool-patches] Re: [PATCH v1 3/4] box: introduce box_space_id_by_name

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Jun 5 16:31:41 MSK 2018


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);





More information about the Tarantool-patches mailing list