From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v2 04/10] box: add new options for functions Date: Fri, 14 Aug 2020 18:04:59 +0300 [thread overview] Message-ID: <65c71dc224b0365954c396486c87738fb9ca5baf.1597417321.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1597417321.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. The is_overloaded option allows us to deal with functions that can take STRING or VARBINARY arguments. In case the first of these arguments is of type VARBINARY, we use the overloaded version of the function. By default, we use the STRING version of the function. The has_overload option indicates that the function has an overloaded version that accepts VARBINARY. See an explanation of the is_overloaded option. Part of #4159 --- src/box/func_def.c | 13 +++++++++++++ src/box/func_def.h | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/box/func_def.c b/src/box/func_def.c index 11d2bdb84..29929aea3 100644 --- a/src/box/func_def.c +++ b/src/box/func_def.c @@ -40,10 +40,17 @@ const char *func_aggregate_strs[] = {"none", "group"}; const struct func_opts func_opts_default = { /* .is_multikey = */ false, + /* .is_overloaded = */ false, + /* .has_overload = */ false, + /* .has_vararg = */ false, }; const struct opt_def func_opts_reg[] = { OPT_DEF("is_multikey", OPT_BOOL, struct func_opts, is_multikey), + OPT_DEF("is_overloaded", OPT_BOOL, struct func_opts, is_overloaded), + OPT_DEF("has_overload", OPT_BOOL, struct func_opts, has_overload), + OPT_DEF("has_vararg", OPT_BOOL, struct func_opts, has_vararg), + OPT_END, }; int @@ -51,6 +58,12 @@ 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->is_overloaded != o2->is_overloaded) + return o1->is_overloaded - o2->is_overloaded; + if (o1->has_overload != o2->has_overload) + return o1->has_overload - o2->has_overload; + 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..bab2186da 100644 --- a/src/box/func_def.h +++ b/src/box/func_def.h @@ -68,6 +68,24 @@ struct func_opts { * packed in array. */ bool is_multikey; + /** + * True if this function is overloaded version of another function. + * + * Currently only used in built-in SQL functions. + */ + bool is_overloaded; + /** + * True if this function has overloaded version. + * + * Currently only used in built-in SQL functions. + */ + bool has_overload; + /** + * 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-14 15:04 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 built-in functions 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 ` imeevma [this message] 2020-08-22 14:28 ` [Tarantool-patches] [PATCH v2 04/10] box: add new options for functions Vladislav Shpilevoy 2020-08-14 15:05 ` [Tarantool-patches] [PATCH v2 05/10] sql: use has_vararg for built-in functions imeevma 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=65c71dc224b0365954c396486c87738fb9ca5baf.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 04/10] box: add new options 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