From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v1 1/7] box: add has_vararg option for functions Date: Wed, 12 Aug 2020 18:15:45 +0300 [thread overview] Message-ID: <cbdd225bf160e1dede056764f46fe671c1d7cd36.1597244875.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1597244875.git.imeevma@gmail.com> 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
next prev parent reply other threads:[~2020-08-12 15:15 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-12 15:15 [Tarantool-patches] [PATCH v1 0/7] sql: properly check arguments types of built-in functions imeevma 2020-08-12 15:15 ` imeevma [this message] 2020-08-12 15:15 ` [Tarantool-patches] [PATCH v1 2/7] sql: do not return UNSIGNED in " imeevma 2020-08-12 15:15 ` [Tarantool-patches] [PATCH v1 3/7] sql: move built-in function definitions in _func imeevma 2020-08-12 15:15 ` [Tarantool-patches] [PATCH v1 4/7] box: add param_list to 'struct func' imeevma 2020-08-12 15:15 ` [Tarantool-patches] [PATCH v1 5/7] sql: check built-in functions argument types imeevma 2020-08-12 15:15 ` [Tarantool-patches] [PATCH v1 6/7] sql: VARBINARY and STRING in built-in functions imeevma 2020-08-12 15:15 ` [Tarantool-patches] [PATCH v1 7/7] sql: refactor sql/func.c imeevma
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=cbdd225bf160e1dede056764f46fe671c1d7cd36.1597244875.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v1 1/7] box: add has_vararg option for 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