From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 A3D8F43040F for ; Fri, 14 Aug 2020 18:05:01 +0300 (MSK) From: imeevma@tarantool.org Date: Fri, 14 Aug 2020 18:05:00 +0300 Message-Id: <4ab6e3c46bd2d5d597b33e55b650af91e040708b.1597417321.git.imeevma@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 05/10] sql: use has_vararg for built-in functions List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org After this patch, the has_varargs option will be used to determine that the function has a variable number of arguments. Part of #4159 --- src/box/sql/func.c | 3 ++- src/box/sql/resolve.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index e5da21191..1afee4924 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -2182,7 +2182,7 @@ sql_func_by_signature(const char *name, int argc) if (base == NULL || !base->def->exports.sql) return NULL; - if (base->def->param_count != -1 && base->def->param_count != argc) + if (!base->def->opts.has_vararg && base->def->param_count != argc) return NULL; return base; } @@ -2928,6 +2928,7 @@ func_sql_builtin_new(struct func_def *def) def->returns = sql_builtins[idx].returns; def->aggregate = sql_builtins[idx].aggregate; def->exports.sql = sql_builtins[idx].export_to_sql; + def->opts.has_vararg = sql_builtins[idx].param_count == -1; return &func->base; } diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c index 6f625dc18..5238555c3 100644 --- a/src/box/sql/resolve.c +++ b/src/box/sql/resolve.c @@ -614,7 +614,7 @@ resolveExprStep(Walker * pWalker, Expr * pExpr) pNC->nErr++; return WRC_Abort; } - if (func->def->param_count != -1 && + if (!func->def->opts.has_vararg && func->def->param_count != n) { uint32_t argc = func->def->param_count; const char *err = tt_sprintf("%d", argc); -- 2.25.1