[Tarantool-patches] [PATCH] fix: don't request absent tuple field

Ilya Kosarev i.kosarev at tarantool.org
Wed Nov 13 21:20:24 MSK 2019


During replacement of tuple_field_bool_xc with it's non-xc version
turned out that it might be called even if there is not enough fields
in processed tuple. Now it is fixed.

Part of #4247
---
https://github.com/tarantool/tarantool/tree/i.kosarev/fix-tuple-field-request
https://github.com/tarantool/tarantool/issues/4247

 src/box/alter.cc | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 32f84ded7..6741b7aa4 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -5265,12 +5265,13 @@ ck_constraint_def_new_from_tuple(struct tuple *tuple)
 	const char *expr_str =
 		tuple_field_str_xc(tuple, BOX_CK_CONSTRAINT_FIELD_CODE,
 				   &expr_str_len);
-	bool out;
-	if (tuple_field_bool(tuple, BOX_CK_CONSTRAINT_FIELD_IS_ENABLED,
-			     &out) != 0)
-		diag_raise();
-	bool is_enabled =
-		tuple_field_count(tuple) <= BOX_CK_CONSTRAINT_FIELD_IS_ENABLED || out;
+	bool is_enabled = true;
+	if (tuple_field_count(tuple) > BOX_CK_CONSTRAINT_FIELD_IS_ENABLED) {
+		if (tuple_field_bool(tuple,
+				     BOX_CK_CONSTRAINT_FIELD_IS_ENABLED,
+				     &is_enabled) != 0)
+			diag_raise();
+	}
 	struct ck_constraint_def *ck_def =
 		ck_constraint_def_new(name, name_len, expr_str, expr_str_len,
 				      space_id, language, is_enabled);
-- 
2.17.1



More information about the Tarantool-patches mailing list