[Tarantool-patches] [PATCH 1.10 1/9] module api: export box_tuple_validate

Timur Safin tsafin at tarantool.org
Fri Sep 25 00:00:33 MSK 2020


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



More information about the Tarantool-patches mailing list