Re: [BUGS] Improper const-evaluation of HAVING with grouping sets and subquery pullup

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: [BUGS] Improper const-evaluation of HAVING with grouping sets and subquery pullup
Дата
Msg-id 871sm3ktl7.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на Re: [BUGS] Improper const-evaluation of HAVING with grouping sets and subquery pullup  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [BUGS] Improper const-evaluation of HAVING with grouping sets andsubquery pullup
Список pgsql-bugs
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>> x and y aren't constants, but z is.
Tom> OK, but that just means we should put PHV wrapping around only theTom> grouping-set columns.

Well, can we also take advantage of the fact that we know that anything
that's not in the grouping-set columns must be in an aggregate argument,
and just omit the PHV inside aggregate args? (And even if grouping
columns appear inside aggregate args, they are _not_ nulled out there.)
Tom> BTW, also need to think about GS expressions, eg
Tom> select x+y, sum(z) from (select 1 as x, 2 as y, 3 as z) sTom>  group by grouping sets (x+y);
Tom> Not real sure what needs to happen here.

That one currently works (note you have to add another grouping set to
test it, since the case of exactly one grouping set is reduced to plain
GROUP BY) because setrefs fixes up the reference after-the-fact,
replacing the outer x+y (or whatever it got munged to) with a Var based
on matching the sortgroupref. This currently fails:

select (x+y)*1, sum(z) from (select 1 as x, 2 as y, 3 as z) sgroup by grouping sets (x+y, x);

because the logic in setrefs that would normally detect that (x+y)
exists in the child tlist doesn't fire because the whole expression was
replaced by a constant.

With the patch to use PHVs it works, but I admit to some confusion over
exactly why.

-- 
Andrew (irc:RhodiumToad)


-- 
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 по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [BUGS] BUG #14853: Parameter type is required even when the querydoes not need to know the type
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: [BUGS] BUG #14853: Parameter type is required even when the querydoes not need to know the type