From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 53EE143040A for ; Wed, 12 Aug 2020 18:15:46 +0300 (MSK) From: imeevma@tarantool.org Date: Wed, 12 Aug 2020 18:15:45 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v1 1/7] box: add has_vararg option for functions List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org The has_vararg option allows us to work with functions with a variable number of arguments. This is required for built-in SQL functions. Suppose this option is TRUE for a built-in SQL function. Then: 1) If param_list is empty, all arguments can be of any type. 2) If the length of param_list is not less than the number of the given arguments, the types of the given arguments must be compatible with the corresponding types described in param_list. 3) If the length of param_list is less than the number of given arguments, the rest of the arguments must be compatible with the last type in param_list. Part of #4159 --- src/box/func_def.c | 5 +++++ src/box/func_def.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/box/func_def.c b/src/box/func_def.c index 11d2bdb84..be12ce970 100644 --- a/src/box/func_def.c +++ b/src/box/func_def.c @@ -40,10 +40,13 @@ const char *func_aggregate_strs[] = {"none", "group"}; const struct func_opts func_opts_default = { /* .is_multikey = */ false, + /* .has_vararg = */ false, }; const struct opt_def func_opts_reg[] = { OPT_DEF("is_multikey", OPT_BOOL, struct func_opts, is_multikey), + OPT_DEF("has_vararg", OPT_BOOL, struct func_opts, has_vararg), + OPT_END, }; int @@ -51,6 +54,8 @@ func_opts_cmp(struct func_opts *o1, struct func_opts *o2) { if (o1->is_multikey != o2->is_multikey) return o1->is_multikey - o2->is_multikey; + if (o1->has_vararg != o2->has_vararg) + return o1->has_vararg - o2->has_vararg; return 0; } diff --git a/src/box/func_def.h b/src/box/func_def.h index d99d89190..89d5a404a 100644 --- a/src/box/func_def.h +++ b/src/box/func_def.h @@ -68,6 +68,12 @@ struct func_opts { * packed in array. */ bool is_multikey; + /** + * TRUE if the function can have a variable number of arguments. + * + * Currently only used in built-in SQL functions. + */ + bool has_vararg; }; extern const struct func_opts func_opts_default; -- 2.25.1