[Tarantool-patches] [PATCH v2 1/3] sql: initialize MEM used in aggregate functions
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Fri Apr 30 00:02:06 MSK 2021
Hi! Thanks for the patch!
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 9c28d5122..d282b2cea 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -1798,14 +1798,13 @@ minmaxStep(sql_context * context, int NotUsed, sql_value ** argv)
> static void
> minMaxFinalize(sql_context * context)
> {
> - sql_value *pRes;
> - pRes = (sql_value *) sql_aggregate_context(context, 0);
> - if (pRes) {
> - if (pRes->flags) {
> - sql_result_value(context, pRes);
> - }
> - mem_destroy(pRes);
> - }
> + struct Mem *mem = context->pMem;
> + struct Mem *res;
> + if (!mem_is_agg(mem) || mem_get_agg(mem, (void **)&res) != 0)
You don't need `is_agg` check. `get` does the same already.
> + return;
> + if (!mem_is_null(res))
> + sql_result_value(context, res);
> + mem_destroy(res);
> }
More information about the Tarantool-patches
mailing list