From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp15.mail.ru (smtp15.mail.ru [94.100.176.133]) (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 2CCE4446439 for ; Fri, 25 Sep 2020 00:01:15 +0300 (MSK) From: Timur Safin Date: Fri, 25 Sep 2020 00:00:33 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1.10 1/9] module api: export box_tuple_validate List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org For external merger we need means to valudate tuple data, thus exporting `box_tuple_validate` which is simple wrapper around `tuple_validate_raw` without revealing access to tuple internals. Part of #5273 --- src/box/tuple.c | 8 ++++++++ src/box/tuple.h | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/box/tuple.c b/src/box/tuple.c index 1db69e414..d97f6cef5 100644 --- a/src/box/tuple.c +++ b/src/box/tuple.c @@ -576,6 +576,14 @@ box_tuple_new(box_tuple_format_t *format, const char *data, const char *end) return tuple_bless(ret); } +int +box_tuple_validate(box_tuple_format_t *format, box_tuple_t *tuple) +{ + return tuple_validate_raw(format, tuple_data(tuple)); +} + +/* }}} box_tuple_* */ + int tuple_snprint(char *buf, int size, const struct tuple *tuple) { diff --git a/src/box/tuple.h b/src/box/tuple.h index 5c6dc6b8c..afa334eab 100644 --- a/src/box/tuple.h +++ b/src/box/tuple.h @@ -284,6 +284,17 @@ box_tuple_t * box_tuple_upsert(const box_tuple_t *tuple, const char *expr, const char *expr_end); +/** + * Check tuple data correspondence to the space format. + * @param format Format to which the tuple must match. + * @param tuple Tuple to validate. + * + * @retval 0 The tuple is valid. + * @retval -1 The tuple is invalid. + */ +int +box_tuple_validate(box_tuple_format_t *format, box_tuple_t *tuple); + /** \endcond public */ /** -- 2.20.1