[Tarantool-patches] [PATCH v2 2/6] sql: introduce sql_func_find()
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Fri Aug 6 01:15:20 MSK 2021
Thanks for the patch!
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 28d383293..9514d070a 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -2655,6 +2643,30 @@ static struct {
> },
> };
>
> +struct func *
> +sql_func_find(struct Expr *expr)
> +{
> + const char *name = expr->u.zToken;
> + struct func *func = func_by_name(name, strlen(name));
> + if (func == NULL) {
> + diag_set(ClientError, ER_NO_SUCH_FUNCTION, name);
> + return NULL;
> + }
> + if (!func->def->exports.sql) {
> + diag_set(ClientError, ER_SQL_PARSER_GENERIC,
> + tt_sprintf("function %s() is not available in SQL",
> + name));
> + return NULL;
> + }
> + int n = expr->x.pList ? expr->x.pList->nExpr : 0;
!= NULL.
> + if (func->def->param_count != -1 && func->def->param_count != n) {
> + diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, name,
> + tt_sprintf("%d", func->def->param_count), n);
> + return NULL;
> + }
> + return func;
> +}
More information about the Tarantool-patches
mailing list