From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 6A622446439 for ; Thu, 24 Sep 2020 20:01:00 +0300 (MSK) From: Timur Safin Date: Thu, 24 Sep 2020 20:00:14 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2.X 1/7] 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 wrapper around `tuple_validate_raw` without revealing access to tuple internals. Part of #5273 --- src/box/tuple.c | 6 ++++++ src/box/tuple.h | 11 +++++++++++ src/exports.h | 1 + 3 files changed, 18 insertions(+) diff --git a/src/box/tuple.c b/src/box/tuple.c index f3965476e..ddf41567c 100644 --- a/src/box/tuple.c +++ b/src/box/tuple.c @@ -748,6 +748,12 @@ 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 diff --git a/src/box/tuple.h b/src/box/tuple.h index 53ae690cc..ed0501464 100644 --- a/src/box/tuple.h +++ b/src/box/tuple.h @@ -283,6 +283,17 @@ box_tuple_update(box_tuple_t *tuple, const char *expr, const char *expr_end); box_tuple_t * box_tuple_upsert(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 */ /** diff --git a/src/exports.h b/src/exports.h index 48894ea72..592b388bb 100644 --- a/src/exports.h +++ b/src/exports.h @@ -77,6 +77,7 @@ EXPORT(box_tuple_to_buf) EXPORT(box_tuple_unref) EXPORT(box_tuple_update) EXPORT(box_tuple_upsert) +EXPORT(box_tuple_validate) EXPORT(box_tuple_validate_key_parts) EXPORT(box_txn) EXPORT(box_txn_alloc) -- 2.20.1