From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B142A442A00 for ; Wed, 13 Nov 2019 21:20:27 +0300 (MSK) From: Ilya Kosarev Date: Wed, 13 Nov 2019 21:20:24 +0300 Message-Id: <20191113182024.28096-1-i.kosarev@tarantool.org> Subject: [Tarantool-patches] [PATCH] fix: don't request absent tuple field List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org 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