From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Subject: | Re: WITHIN GROUP patch |
Date: | 2013-12-06 22:57:17 |
Message-ID: | 87vbz1egz9.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
Tom> 2. For an ordered set function, n must equal aggnfixedargs. We
Tom> treat all n fixed arguments as contributing to the aggregate's
Tom> result collation, but ignore the sort arguments.
>> That doesn't work for getting a sensible collation out of
>> percentile_disc applied to a collatable type. (Which admittedly is
>> an extension to the spec, which allows only numeric and interval,
>> but it seems to me to be worth having.)
Tom> Meh. I don't think you can have that and also have the behavior
Tom> that multiple ORDER BY items aren't constrained to have the same
Tom> collation; at least not without some rule that amounts to a
Tom> special case for percentile_disc, which I'd resist.
What the submitted patch does (as discussed in the comment in
parse_collate) is to treat the sort argument as contributing to the
collation only if there is exactly one sort arg.
Consider a construct like:
select max(common_val)
from (select mode() within group (order by textcol) as common_val
from ... group by othercol) s;
(the same arguments for percentile_disc also apply to mode() and to
any other ordered set function that returns a value chosen from its
input sorted set)
Having this sort of thing not preserve the collation of textcol (or
fail) would be, IMO, surprising and undesirable.
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2013-12-06 23:16:19 | Re: writable FDWs / update targets confusion |
Previous Message | Tom Lane | 2013-12-06 22:41:41 | Re: WITHIN GROUP patch |