[Tarantool-patches] [PATCH v1 13/21] sql: refactor VERSION() function
imeevma at tarantool.org
imeevma at tarantool.org
Fri Oct 8 20:31:57 MSK 2021
Part of #4145
---
src/box/sql/func.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index d462f66b5..fb7fd772e 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -998,6 +998,15 @@ func_uuid(struct sql_context *ctx, int argc, struct Mem *argv)
mem_set_uuid(ctx->pOut, &uuid);
}
+/** Implementation of the VERSION() function. */
+static void
+func_version(struct sql_context *ctx, int argc, struct Mem *argv)
+{
+ (void)argc;
+ (void)argv;
+ return mem_set_str0_static(ctx->pOut, (char *)tarantool_version());
+}
+
static const unsigned char *
mem_as_ustr(struct Mem *mem)
{
@@ -1321,22 +1330,6 @@ likeFunc(sql_context *context, int argc, struct Mem *argv)
mem_set_bool(context->pOut, res == MATCH);
}
-/**
- * Implementation of the version() function. The result is the
- * version of the Tarantool that is running.
- *
- * @param context Context being used.
- * @param unused1 Unused.
- * @param unused2 Unused.
- */
-static void
-sql_func_version(struct sql_context *context, int argc, struct Mem *argv)
-{
- (void)argc;
- (void)argv;
- sql_result_text(context, tarantool_version(), -1, SQL_STATIC);
-}
-
/*
* Implementation of the QUOTE() function. This function takes a single
* argument. If the argument is numeric, the return value is the same as
@@ -1889,7 +1882,7 @@ static struct sql_func_definition definitions[] = {
NULL},
{"UUID", 0, {}, FIELD_TYPE_UUID, func_uuid, NULL},
{"UUID", 1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_UUID, func_uuid, NULL},
- {"VERSION", 0, {}, FIELD_TYPE_STRING, sql_func_version, NULL},
+ {"VERSION", 0, {}, FIELD_TYPE_STRING, func_version, NULL},
{"ZEROBLOB", 1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_VARBINARY,
func_zeroblob, NULL},
};
--
2.25.1
More information about the Tarantool-patches
mailing list