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 4/4] sql: introduce mem_cmp_msgpack() Date: Sun, 11 Jul 2021 17:05:38 +0200 [thread overview] Message-ID: <20c6c37d-6364-8fdb-0aa5-c7c82407b143@tarantool.org> (raw) In-Reply-To: <28d370911c40124da91441be2f25cad49e4973b4.1625926838.git.imeevma@gmail.com> Thanks for the patch! See 4 comments below. On 10.07.2021 16:33, Mergen Imeev via Tarantool-patches wrote: > This patch introduces the mem_cmp_scalar() function that compares MEM 1. scalar -> msgpack. > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 576596c9f..471b69a18 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -2073,35 +2073,72 @@ mem_cmp_scalar(const struct Mem *a, const struct Mem *b, int *result, <...> > - > -/* > - * The input pBlob is guaranteed to be a Blob that is not marked > - * with MEM_Zero. Return true if it could be a zero-blob. > - */ > -static int > -isAllZero(const char *z, int n) > +int > +mem_cmp_msgpack(const struct Mem *a, const char *b, int *result, > + const struct coll *coll) 2. Maybe better make the function return 'b' after decoding via making it an out parameter. So as the caller could save mp_next() call. > { > - int i; > - for (i = 0; i < n; i++) { > - if (z[i]) > - return 0; > + struct Mem mem; > + switch (mp_typeof(*b)) { > + case MP_NIL: > + mem.type = MEM_TYPE_NULL; > + break; > + case MP_BOOL: > + mem.type = MEM_TYPE_BOOL; > + mem.u.b = mp_decode_bool(&b); > + break; > + case MP_UINT: > + mem.type = MEM_TYPE_UINT; > + mem.u.u = mp_decode_uint(&b); > + break; > + case MP_INT: > + mem.type = MEM_TYPE_INT; > + mem.u.i = mp_decode_int(&b); > + break; > + case MP_FLOAT: > + mem.type = MEM_TYPE_DOUBLE; > + mem.u.r = mp_decode_float(&b); > + break; > + case MP_DOUBLE: > + mem.type = MEM_TYPE_DOUBLE; > + mem.u.r = mp_decode_double(&b); > + break; > + case MP_STR: > + mem.type = MEM_TYPE_STR; > + mem.n = mp_decode_strl(&b); > + mem.z = (char *)b; > + mem.flags = MEM_Ephem; > + break; > + case MP_BIN: > + mem.type = MEM_TYPE_BIN; > + mem.n = mp_decode_binl(&b); > + mem.z = (char *)b; 3. Shouldn't this also have MEM_Ephem? > + break; > + case MP_ARRAY: > + case MP_MAP: > + *result = -1; > + return 0; > + case MP_EXT: { > + int8_t type; > + const char *buf = b; > + uint32_t len = mp_decode_extl(&b, &type); > + if (type == MP_UUID) { > + assert(len == UUID_LEN); > + mem.type = MEM_TYPE_UUID; > + b = buf; 4. You can decode &buf below without changing b. > + if (mp_decode_uuid(&b, &mem.u.uuid) == NULL) > + return -1; > + break; > + } > + b += len; > + mem.type = MEM_TYPE_BIN; > + mem.z = (char *)buf; > + mem.n = b - buf; > + break; > } > - return 1; > + default: > + unreachable(); > + } > + return mem_cmp_scalar(a, &mem, result, coll); > }
next prev parent reply other threads:[~2021-07-11 15:05 UTC|newest] Thread overview: 21+ 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 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 [this message] 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 4/4] sql: introduce mem_cmp_msgpack() Mergen Imeev via Tarantool-patches 2021-07-19 9:16 ` Timur Safin via Tarantool-patches 2021-07-19 10:07 ` Mergen Imeev 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=20c6c37d-6364-8fdb-0aa5-c7c82407b143@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 4/4] sql: introduce mem_cmp_msgpack()' \ /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