Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: v.shpilevoy@tarantool.org, tsafin@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 05/10] sql: use has_vararg for built-in functions
Date: Fri, 14 Aug 2020 18:05:00 +0300	[thread overview]
Message-ID: <4ab6e3c46bd2d5d597b33e55b650af91e040708b.1597417321.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1597417321.git.imeevma@gmail.com>

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

  parent reply	other threads:[~2020-08-14 15:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14 15:04 [Tarantool-patches] [PATCH v2 00/10] sql: properly check arguments types of " imeevma
2020-08-14 15:04 ` [Tarantool-patches] [PATCH v2 01/10] sql: do not return UNSIGNED in " imeevma
2020-08-22 14:23   ` Vladislav Shpilevoy
2020-08-14 15:04 ` [Tarantool-patches] [PATCH v2 02/10] sql: fix functions return types imeevma
2020-08-22 14:24   ` Vladislav Shpilevoy
2020-08-14 15:04 ` [Tarantool-patches] [PATCH v2 03/10] sql: change signature of trim() imeevma
2020-08-22 14:26   ` Vladislav Shpilevoy
2020-08-14 15:04 ` [Tarantool-patches] [PATCH v2 04/10] box: add new options for functions imeevma
2020-08-22 14:28   ` Vladislav Shpilevoy
2020-08-14 15:05 ` imeevma [this message]
2020-08-14 15:05 ` [Tarantool-patches] [PATCH v2 06/10] sql: add overloaded versions of the functions imeevma
2020-08-22 14:29   ` Vladislav Shpilevoy
2020-08-14 15:05 ` [Tarantool-patches] [PATCH v2 07/10] sql: move built-in function definitions in _func imeevma
2020-08-22 14:30   ` Vladislav Shpilevoy
2020-08-14 15:05 ` [Tarantool-patches] [PATCH v2 08/10] box: add param_list to 'struct func' imeevma
2020-08-22 14:30   ` Vladislav Shpilevoy
2020-08-14 15:05 ` [Tarantool-patches] [PATCH v2 09/10] sql: check built-in functions argument types imeevma
2020-08-14 15:05 ` [Tarantool-patches] [PATCH v2 10/10] sql: refactor sql/func.c imeevma
2020-08-22 14:31   ` Vladislav Shpilevoy
2020-08-22 14:25 ` [Tarantool-patches] [PATCH v2 00/10] sql: properly check arguments types of built-in functions Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ab6e3c46bd2d5d597b33e55b650af91e040708b.1597417321.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tsafin@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 05/10] sql: use has_vararg for built-in functions' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox