From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Mergen Imeev <imeevma@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 3/3] sql: replace MEM-type flags by enum mem_type Date: Mon, 24 May 2021 17:26:22 +0200 [thread overview] Message-ID: <ec5eb5b4-cd38-1db0-368b-aff3cbb7df67@tarantool.org> (raw) In-Reply-To: <20210524105630.GA82983@tarantool.org> Hi! Thanks for the fixes! See 4 new comments below, somehow I didn't notice them first time. > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index b6ff6397f..1bd70c37f 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -1236,7 +1297,8 @@ mem_move(struct Mem *to, struct Mem *from) > { > mem_destroy(to); > memcpy(to, from, sizeof(*to)); > - from->flags = MEM_Null; > + from->type = MEM_TYPE_NULL; > + from->flags = 0; 1. Flags are already 0 after mem_destroy(). > from->szMalloc = 0; > from->zMalloc = NULL; > } > @@ -1295,8 +1357,9 @@ mem_concat(struct Mem *a, struct Mem *b, struct Mem *result) > if (sqlVdbeMemGrow(result, size, result == a) != 0) > return -1; > > - result->flags = a->flags & (MEM_Str | MEM_Blob); > - if ((result->flags & MEM_Blob) != 0) > + result->type = a->type == MEM_TYPE_STR ? MEM_TYPE_STR : MEM_TYPE_BIN; 2. You could also make `result->type = a->type;`. Without `?:`. A->type is anyway either STR or BIN. > + result->flags = 0; > + if (result->type == MEM_TYPE_BIN) > result->field_type = FIELD_TYPE_VARBINARY; > if (result != a) > @@ -2322,12 +2395,13 @@ sql_vdbemem_finalize(struct Mem *mem, struct func *func) > assert(func != NULL); > assert(func->def->language == FUNC_LANGUAGE_SQL_BUILTIN); > assert(func->def->aggregate == FUNC_AGGREGATE_GROUP); > - assert((mem->flags & MEM_Null) != 0 || func == mem->u.func); > + assert(mem->type == MEM_TYPE_NULL || func == mem->u.func); > sql_context ctx; > memset(&ctx, 0, sizeof(ctx)); > Mem t; > memset(&t, 0, sizeof(t)); > - t.flags = MEM_Null; > + t.type = MEM_TYPE_NULL; > + t.flags = 0; 3. It is already 0 after memset() above. > t.db = mem->db; > t.field_type = field_type_MAX; > ctx.pOut = &t; > diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c > index ba5c08a00..1aa201466 100644 > --- a/src/box/sql/vdbemem.c > +++ b/src/box/sql/vdbemem.c > @@ -93,7 +93,8 @@ valueNew(sql * db, struct ValueNewStat4Ctx *p) > pRec->aMem = (Mem *)((char *) pRec + > ROUND8(sizeof(UnpackedRecord))); > for (uint32_t i = 0; i < part_count; i++) { > - pRec->aMem[i].flags = MEM_Null; > + pRec->aMem[i].type = MEM_NULL; > + pRec->aMem[i].flags = 0; 4. Flags are already 0 - the memory was allocated using sqlDbMallocZero(). > pRec->aMem[i].db = db; > } > p->ppRec[0] = pRec;
next prev parent reply other threads:[~2021-05-24 15:26 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-27 16:55 [Tarantool-patches] [PATCH v2 0/3] Replace " Mergen Imeev via Tarantool-patches 2021-04-27 16:55 ` [Tarantool-patches] [PATCH v2 3/3] sql: replace " Mergen Imeev via Tarantool-patches 2021-04-29 21:09 ` Vladislav Shpilevoy via Tarantool-patches 2021-05-17 12:18 ` Mergen Imeev via Tarantool-patches 2021-05-17 12:34 ` Mergen Imeev via Tarantool-patches 2021-05-21 18:59 ` Vladislav Shpilevoy via Tarantool-patches 2021-05-24 10:56 ` Mergen Imeev via Tarantool-patches 2021-05-24 15:26 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-05-25 11:13 ` Mergen Imeev via Tarantool-patches 2021-05-25 21:33 ` [Tarantool-patches] [PATCH v2 0/3] Replace " Vladislav Shpilevoy via Tarantool-patches 2021-05-26 8:06 ` Kirill Yukhin 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=ec5eb5b4-cd38-1db0-368b-aff3cbb7df67@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 3/3] sql: replace MEM-type flags by enum mem_type' \ /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