From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: imeevma@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 10/10] sql: refactor sql/func.c Date: Sat, 22 Aug 2020 16:31:06 +0200 [thread overview] Message-ID: <59a52e9c-c405-55e2-55a5-22bac51471e5@tarantool.org> (raw) In-Reply-To: <847d1f4dd9b5b582f178e23361bbb746d2f12c04.1597417321.git.imeevma@gmail.com> Thanks for the patch! See 3 comments below. On 14.08.2020 17:05, imeevma@tarantool.org wrote: > After changing the way of checking the types of arguments, some of the > code in sql/func.c is no longer used. This patch removes this code. > > Follow-up of #4159 > --- > src/box/sql/func.c | 841 +++++---------------------------------------- > 1 file changed, 87 insertions(+), 754 deletions(-) > > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index c289f2de0..de1e4d13d 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c 1. Why didn't you simplify some funtions? - lengthFunc(). Is it allowed to pass numbers into it legally? Perhaps it is, I just don't remember. - position_func(). It has a some complicated check of argument types. I think now you can make it a bit simpler. - lower/upper(). They still check for non-blob argument. - like(). Also still checks for non-str types. > @@ -504,44 +504,21 @@ absFunc(sql_context * context, int argc, sql_value ** argv) > { > assert(argc == 1); > UNUSED_PARAMETER(argc); > - switch (sql_value_type(argv[0])) { > - case MP_UINT: { > - sql_result_uint(context, sql_value_uint64(argv[0])); > - break; > - } > - case MP_INT: { > + enum mp_type type = sql_value_type(argv[0]); > + if (type == MP_NIL) > + return sql_result_null(context); > + if (type == MP_UINT) > + return sql_result_uint(context, sql_value_uint64(argv[0])); > + if (type == MP_INT) { 2. Would look better as a switch. > int64_t value = sql_value_int64(argv[0]); > assert(value < 0); > - sql_result_uint(context, -value); > - break; > - } > @@ -2229,703 +2189,76 @@ static struct { > uint16_t flags; > void (*call)(sql_context *ctx, int argc, sql_value **argv); > void (*finalize)(sql_context *ctx); > - /** Members below are related to struct func_def. */ > - bool is_deterministic; > - int param_count; > - enum field_type returns; > - enum func_aggregate aggregate; > - bool export_to_sql; > } sql_builtins[] = { > - {.name = "ABS", > - .param_count = 1, > - .returns = FIELD_TYPE_NUMBER, > - .aggregate = FUNC_AGGREGATE_NONE, > - .is_deterministic = true, > - .flags = 0, > - .call = absFunc, > - .finalize = NULL, > - .export_to_sql = true, > - }, { 3. These removals I don't like. I think we don't need to expose anything into _func. All could be done in there instead, and would look simpler, IMO. As I explained in the previous emails in this thread.
next prev parent reply other threads:[~2020-08-22 14:31 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 ` [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 ` [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 [this message] 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=59a52e9c-c405-55e2-55a5-22bac51471e5@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=imeevma@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=tsafin@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 10/10] sql: refactor sql/func.c' \ /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