[Tarantool-patches] [PATCH 11/14] WIP: module api: expose box_tuple_validate_key_parts()

Alexander Turenko alexander.turenko at tarantool.org
Wed Sep 23 04:14:16 MSK 2020


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



More information about the Tarantool-patches mailing list