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 v1 05/13] sql: remove sql_vdbemem_finalize() Date: Thu, 23 Sep 2021 00:47:02 +0200 [thread overview] Message-ID: <19258650-a98e-a6e0-f1c8-b2f12a2a4ca3@tarantool.org> (raw) In-Reply-To: <20210921104754.GB16139@tarantool.org> Thanks for the fixes! >>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c >>> index 12dc9126b..dfab86c50 100644 >>> --- a/src/box/sql/vdbe.c >>> +++ b/src/box/sql/vdbe.c >>> @@ -4204,16 +4204,32 @@ case OP_AggStep: { >>> * the step function was not previously called. >>> */ >>> case OP_AggFinal: { >>> - Mem *pMem; >>> assert(pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor)); >>> - pMem = &aMem[pOp->p1]; >>> - assert(mem_is_null(pMem) || mem_is_agg(pMem)); >>> - if (sql_vdbemem_finalize(pMem, pOp->p4.func) != 0) >>> + struct func_sql_builtin *func = (struct func_sql_builtin *)pOp->p4.func; >>> + struct Mem *pIn1 = &aMem[pOp->p1]; >>> + assert(mem_is_null(pIn1) || mem_is_agg(pIn1)); >>> + >>> + struct sql_context ctx; >>> + memset(&ctx, 0, sizeof(ctx)); >>> + struct Mem t; >> >> Please, use mem_create(). Also for the context I would propose to add >> sql_context_create(). So as not to touch internals of the struct here >> directly. >> > I suggest to leave it as it is for now, since I plan to completely drop > struct sql_context from finalize functions in a few patches in this patch-set. > What do you think? mem_create() would be just -3 and +1 line in the patch. I suggest to use it. Previously memset was tolerated because it was done in mem.c, where it is allowed to touch Mem internals directly. >>> + memset(&t, 0, sizeof(t)); >>> + t.type = MEM_TYPE_NULL; >>> + assert(t.flags == 0); >>> + t.db = pIn1->db; >>> + ctx.pOut = &t; >>> + ctx.pMem = pIn1; >>> + ctx.func = pOp->p4.func; >>> + func->finalize(&ctx); >>> + assert((pIn1->flags & MEM_Dyn) == 0); >>> + if (pIn1->szMalloc > 0) >>> + sqlDbFree(pIn1->db, pIn1->zMalloc); >>> + memcpy(pIn1, &t, sizeof(t)); >>> +
next prev parent reply other threads:[~2021-09-22 22:47 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-10 16:01 [Tarantool-patches] [PATCH v1 00/13] sql: reworks aggregate functions Mergen Imeev via Tarantool-patches 2021-09-10 16:01 ` [Tarantool-patches] [PATCH v1 01/13] sql: use register P1 for number of arguments Mergen Imeev via Tarantool-patches 2021-09-10 16:01 ` [Tarantool-patches] [PATCH v1 02/13] sql: remove AggStep0 and OP_BuiltinFunction0 Mergen Imeev via Tarantool-patches 2021-09-10 16:27 ` Mergen Imeev via Tarantool-patches 2021-09-14 21:21 ` Vladislav Shpilevoy via Tarantool-patches 2021-09-10 16:01 ` [Tarantool-patches] [PATCH v1 03/13] sql: move collation to struct sql_context Mergen Imeev via Tarantool-patches 2021-09-14 21:22 ` Vladislav Shpilevoy via Tarantool-patches 2021-09-21 10:40 ` Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 04/13] sql: introduce mem_append() Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 05/13] sql: remove sql_vdbemem_finalize() Mergen Imeev via Tarantool-patches 2021-09-14 21:23 ` Vladislav Shpilevoy via Tarantool-patches 2021-09-21 10:47 ` Mergen Imeev via Tarantool-patches 2021-09-22 22:47 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 06/13] sql: rework SUM() Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 07/13] sql: rework TOTAL() Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 08/13] sql: rework AVG() Mergen Imeev via Tarantool-patches 2021-09-14 21:24 ` Vladislav Shpilevoy via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 09/13] sql: rework COUNT() Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 10/13] sql: rework MIN() and MAX() Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 11/13] sql: rework GROUP_CONCAT() Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 12/13] sql: remove copying of result in finalizers Mergen Imeev via Tarantool-patches 2021-09-14 21:24 ` Vladislav Shpilevoy via Tarantool-patches 2021-09-21 10:49 ` Mergen Imeev via Tarantool-patches 2021-09-10 16:02 ` [Tarantool-patches] [PATCH v1 13/13] sql: remove MEM_TYPE_AGG 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=19258650-a98e-a6e0-f1c8-b2f12a2a4ca3@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v1 05/13] sql: remove sql_vdbemem_finalize()' \ /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