Re: Missing free_var() at end of accum_sum_final()?

Поиск
Список
Период
Сортировка
От Joel Jacobson
Тема Re: Missing free_var() at end of accum_sum_final()?
Дата
Msg-id ebf7f18e-c9b6-4c4d-b0d1-47611e58f781@app.fastmail.com
обсуждение исходный текст
Ответ на Re: Missing free_var() at end of accum_sum_final()?  (Michael Paquier <michael@paquier.xyz>)
Ответы Re: Missing free_var() at end of accum_sum_final()?  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
On Thu, Feb 16, 2023, at 07:26, Michael Paquier wrote:
> Indeed, it is true that any code path of numeric.c that relies on a
> NumericVar with an allocation done in its buffer is careful enough to
> free it, except for generate_series's SRF where one step of the
> computation is done.  I don't see directly why you could not do the
> following:
> @@ -11973,6 +11973,9 @@ accum_sum_final(NumericSumAccum *accum, 
> NumericVar *result)
>     /* And add them together */
>     add_var(&pos_var, &neg_var, result);
> 
> +   free_var(&pos_var);
> +   free_var(&neg_var);
> +

Thanks for looking and explaining.

I added the free_var() calls after strip_var() to match the similar existing code at the end of sqrt_var().
Not that it matters, but thought it looked nicer to keep them in the same order.

/Joel
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jim Jones
Дата:
Сообщение: Re: [PATCH] Add pretty-printed XML output option
Следующее
От: tender wang
Дата:
Сообщение: wrong query result due to wang plan