From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 2B21D446443 for ; Wed, 23 Sep 2020 04:14:26 +0300 (MSK) From: Alexander Turenko Date: Wed, 23 Sep 2020 04:14:16 +0300 Message-Id: <37b501a1982f903cef55e90e89fe3d42931e93d9.1600817803.git.alexander.turenko@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 11/14] WIP: module api: expose box_tuple_validate_key_parts() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org, Alexander Turenko XXX: Add a module API test. Part of #5273 --- src/box/key_def_api.c | 6 ++++++ src/box/key_def_api.h | 12 ++++++++++++ src/exports.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/box/key_def_api.c b/src/box/key_def_api.c index 25dd416aa..b8a0d5807 100644 --- a/src/box/key_def_api.c +++ b/src/box/key_def_api.c @@ -269,6 +269,12 @@ box_key_def_dump_parts(const box_key_def_t *key_def, uint32_t *part_count_ptr) return parts; } +int +box_tuple_validate_key_parts(box_key_def_t *key_def, box_tuple_t *tuple) +{ + return tuple_validate_key_parts(key_def, tuple); +} + int box_tuple_compare(box_tuple_t *tuple_a, box_tuple_t *tuple_b, box_key_def_t *key_def) diff --git a/src/box/key_def_api.h b/src/box/key_def_api.h index f78203a3a..16934eeb4 100644 --- a/src/box/key_def_api.h +++ b/src/box/key_def_api.h @@ -190,6 +190,18 @@ box_key_def_delete(box_key_def_t *key_def); API_EXPORT box_key_part_def_t * box_key_def_dump_parts(const box_key_def_t *key_def, uint32_t *part_count_ptr); +/** + * Check that tuple fields match with given key definition. + * + * @param key_def Key definition. + * @param tuple Tuple to validate. + * + * @retval 0 The tuple is valid. + * @retval -1 The tuple is invalid. + */ +API_EXPORT int +box_tuple_validate_key_parts(box_key_def_t *key_def, box_tuple_t *tuple); + /** * Compare tuples using the key definition. * @param tuple_a first tuple diff --git a/src/exports.h b/src/exports.h index ff03cfa68..45a62421e 100644 --- a/src/exports.h +++ b/src/exports.h @@ -74,6 +74,7 @@ EXPORT(box_tuple_to_buf) EXPORT(box_tuple_unref) EXPORT(box_tuple_update) EXPORT(box_tuple_upsert) +EXPORT(box_tuple_validate_key_parts) EXPORT(box_txn) EXPORT(box_txn_alloc) EXPORT(box_txn_begin) -- 2.25.0