Re: [BUGS] Crash with a CUBE query on 9.6

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: [BUGS] Crash with a CUBE query on 9.6
Дата
Msg-id ba984535-2b60-3fb9-f9ec-83279ed7c64b@iki.fi
обсуждение исходный текст
Ответ на Re: [BUGS] Crash with a CUBE query on 9.6  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [BUGS] Crash with a CUBE query on 9.6  (David Rowley <david.rowley@2ndquadrant.com>)
Список pgsql-bugs
On 12/19/2016 11:22 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> On 12/19/2016 09:37 PM, Tom Lane wrote:
>>> Probably, the loop in finalize_aggregates needs to be split into two,
>>> one over the pertrans states and then a second one over the peragg states.
>>> But this code has been hacked up enough since I last looked at it that
>>> I'm hesitant to try to fix it myself.
>
>> Yes, that seems straightforward. I came up with the attached. Will
>> commit tomorrow, barring objections.
>
> Code patch looks reasonable, but I do not get a crash on the proposed test
> case with current code.  I suspect that integer avg() and sum() don't
> actually share transstates, making the test case a bit off-point.

Hmm, it does crash here:

postgres=# select my_avg(distinct one),my_sum(distinct one) from 
(values(1),(3),(1)) t(one);
NOTICE:  avg_transfn called with 1
NOTICE:  avg_transfn called with 3
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.

In the patch I sent yesterday, the expected output was wrong, though. 
The query there didn't use DISTINCT, so it didn't crash.

Also  note that the test case uses my_avg() and my_sum() rather than the 
built-ins. If you replace them with the built-ins, it indeed doesn't 
crash because sum(int) and avg(int) have different transition functions. 
But this does crash with the built-ins, too:

postgres=# select avg(distinct one::numeric), sum(distinct one::numeric) 
from (values(1),(3),(1)) t(one);
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.

Fixed the expected output, and committed. Thanks!

- Heikki



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: [BUGS] 9.6rc1 Background worker starting multiple times
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [BUGS] Crash with a CUBE query on 9.6