[Tarantool-patches] [PATCH v5 36/52] sql: introduce mem_set_agg()

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Apr 13 02:37:49 MSK 2021


Thanks for the fixes!

> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index b2598816d..af11ae1d5 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -612,6 +612,23 @@ mem_set_frame(struct Mem *mem, struct VdbeFrame *frame)
>  	mem->u.pFrame = frame;
>  }
>  
> +int
> +mem_set_agg(struct Mem *mem, struct func *func, int size)
> +{
> +	if (size <= 0) {
> +		mem_clear(mem);
> +		return 0;
> +	}
> +	if (sqlVdbeMemGrow(mem, size, 0) != 0)
> +		return -1;
> +	memset(mem->z, 0, size);
> +	mem->n = size;
> +	mem->flags = MEM_Agg;

What if it already was MEM_Agg before? sqlVdbeMemGrow()
didn't clear the old value. It clears only MEM_Dyn.

> +	mem->u.func = func;
> +	mem->field_type = field_type_MAX;
> +	return 0;
> +}


More information about the Tarantool-patches mailing list