[Tarantool-patches] [PATCH v1 05/13] sql: remove sql_vdbemem_finalize()

Mergen Imeev imeevma at tarantool.org
Tue Sep 21 13:47:54 MSK 2021


Thank you for the review! My answer below.

On Tue, Sep 14, 2021 at 11:23:15PM +0200, Vladislav Shpilevoy wrote:
> Good job on the patch!
> 
> > 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?

> > +	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));
> > +


More information about the Tarantool-patches mailing list