From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 3/4] sql: introduce mem_cmp_scalar() Date: Sun, 11 Jul 2021 17:03:34 +0200 [thread overview] Message-ID: <ec1799e5-181a-e514-b56a-a56f7ad87843@tarantool.org> (raw) In-Reply-To: <b984af6a2ca9c6dab099423c3ddb0b72083f63a3.1625926838.git.imeevma@gmail.com> Hi! Thanks for the patch! See 3 comments below. > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index aa565277c..dc99bd390 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -144,11 +144,10 @@ minmaxFunc(sql_context * context, int argc, sql_value ** argv) > for (i = 1; i < argc; i++) { > if (mem_is_null(argv[i])) > return; > - if ((sqlMemCompare(argv[iBest], argv[i], pColl) ^ mask) >= > - 0) { > - testcase(mask == 0); > + int res; > + mem_cmp_scalar(argv[iBest], argv[i], &res, pColl); > + if ((res ^ mask) >= 0) 1. It seems that under certain conditions if cmp_scalar fails, res remains not initialized. Which can lead to behaviour changing from run to run. The same in the other places below. > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 2595e2fd4..576596c9f 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -59,6 +59,40 @@ enum { > BUF_SIZE = 32, > }; > > +enum mem_class { > + MEM_CLASS_NULL, > + MEM_CLASS_BOOL, > + MEM_CLASS_NUMBER, > + MEM_CLASS_STR, > + MEM_CLASS_BIN, > + MEM_CLASS_UUID, > + mem_class_max, > +}; 2. It might make sense to add a comment that these must be sorted exactly like enum mp_class. > + > +static inline enum mem_class > +mem_type_class(enum mem_type type) > +{ > + switch (type) { > + case MEM_TYPE_NULL: > + return MEM_CLASS_NULL; > + case MEM_TYPE_UINT: > + case MEM_TYPE_INT: > + case MEM_TYPE_DOUBLE: > + return MEM_CLASS_NUMBER; > + case MEM_TYPE_STR: > + return MEM_CLASS_STR; > + case MEM_TYPE_BIN: > + return MEM_CLASS_BIN; > + case MEM_TYPE_BOOL: > + return MEM_CLASS_BOOL; > + case MEM_TYPE_UUID: > + return MEM_CLASS_UUID; 3. It might work faster without branching if done like 'static enum mp_class mp_classes[]' - would allow to take the class for any type as simple as an array access operation.
next prev parent reply other threads:[~2021-07-11 15:03 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-10 14:33 [Tarantool-patches] [PATCH v2 0/4] Follow ups for uuid introduction Mergen Imeev via Tarantool-patches 2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 1/4] sql: introduce uuid to quote() Mergen Imeev via Tarantool-patches 2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 2/4] sql: allow to bind uuid values Mergen Imeev via Tarantool-patches 2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 3/4] sql: introduce mem_cmp_scalar() Mergen Imeev via Tarantool-patches 2021-07-11 15:03 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-07-11 17:51 ` Mergen Imeev via Tarantool-patches 2021-07-12 21:06 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-13 8:04 ` Mergen Imeev via Tarantool-patches 2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 4/4] sql: introduce mem_cmp_msgpack() Mergen Imeev via Tarantool-patches 2021-07-11 15:05 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-11 17:59 ` Mergen Imeev via Tarantool-patches 2021-07-12 21:09 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-13 8:10 ` Mergen Imeev via Tarantool-patches 2021-07-13 20:39 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-14 6:51 ` Mergen Imeev via Tarantool-patches 2021-07-14 21:53 ` Vladislav Shpilevoy via Tarantool-patches 2021-07-15 6:58 ` Mergen Imeev via Tarantool-patches 2021-07-15 20:44 ` [Tarantool-patches] [PATCH v2 0/4] Follow ups for uuid introduction Vladislav Shpilevoy via Tarantool-patches 2021-07-16 8:57 Mergen Imeev via Tarantool-patches 2021-07-16 8:57 ` [Tarantool-patches] [PATCH v2 3/4] sql: introduce mem_cmp_scalar() Mergen Imeev via Tarantool-patches 2021-07-19 9:17 ` Timur Safin via Tarantool-patches
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=ec1799e5-181a-e514-b56a-a56f7ad87843@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 3/4] sql: introduce mem_cmp_scalar()' \ /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