Re: BUG #16122: segfault pg_detoast_datum (datum=0x0) at fmgr.c:1833numrange query

Поиск
Список
Период
Сортировка
От Andrey Borodin
Тема Re: BUG #16122: segfault pg_detoast_datum (datum=0x0) at fmgr.c:1833numrange query
Дата
Msg-id DE43C854-F3BD-4247-93F3-2774B643445C@yandex-team.ru
обсуждение исходный текст
Ответ на Re: BUG #16122: segfault pg_detoast_datum (datum=0x0) at fmgr.c:1833numrange query  (Andrey Borodin <x4mmm@yandex-team.ru>)
Ответы Re: BUG #16122: segfault pg_detoast_datum (datum=0x0) at fmgr.c:1833 numrange query  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs

> 4 янв. 2020 г., в 0:05, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):
>
> I believe line should be not like
> +    for (i = upper_index - 1; i >= 0; i--)
> but rather
> +    for (i = min(upper_index, hist_nvalues - 2); i >= 0; i--)
>
> I will dig into this during this CF. Currently, that's my 2 cents.
I think I have a little more correct fix.

As far as I understand, we have an array of bin lower bounds hist_lower with size hist_nvalues.
There is a function get_position(..,value, lower, upper), which calculates relative position of value between lower and
upperbound. 
We call get_position(typcache, lower, &hist_lower[i], &hist_lower[i + 1]); when i is last bin, i.e. i + 1 ==
hist_nvalues,thus passing bogus upper to get_position(). 
PFA possible fix for this.

Upper in the code same situation when upper is undefined is treated as if get_position returned 0.
Also, while get_position() is not prepared to bogus upper, but it is well aware of infinite bounds. We could just add
lastinfinite value to hist_lower and remove upper_index < hist_nvalues - 1 and i + 1 != hist_nvalues checks entirely. 

Best regards, Andrey Borodin.

Вложения

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

Предыдущее
От: Johan Fredrik Øhman
Дата:
Сообщение: Re: BUG #16182: Error in logs from "renaming temporary statistics"
Следующее
От: ZHAO JINGJING
Дата:
Сообщение: postgresql mac operation issue 10.11