Re: [HACKERS] DISTINCT ON

2009-11-04 Thread Emmanuel Cecchet
Tom Lane wrote: Greg Stark writes: On Wed, Nov 4, 2009 at 3:17 AM, Emmanuel Cecchet wrote: SELECT DISTINCT ON ('1'::varchar, '1'::varchar) a FROM (SELECT 1 AS a) AS a ORDER BY '1'::varchar, '1'::varchar, '2'::varchar; This sounds familiar. What version of Postgres are y

Re: [HACKERS] DISTINCT ON

2009-11-03 Thread Tom Lane
Greg Stark writes: > On Wed, Nov 4, 2009 at 3:17 AM, Emmanuel Cecchet wrote: >> SELECT DISTINCT ON ('1'::varchar,  '1'::varchar) a FROM (SELECT 1 AS a) AS a >> ORDER BY '1'::varchar, '1'::varchar, '2'::varchar; > This sounds familiar. What version of Postgres are you testing this on? Presumabl

Re: [HACKERS] DISTINCT ON

2009-11-03 Thread Robert Haas
On Nov 3, 2009, at 10:17 PM, Emmanuel Cecchet wrote: Hi all, It looks like Postgres has a restriction in DISTINCT ON queries where the DISTINCT ON expressions must match the left side of the ORDER BY list. The issue is that if a DISTINCT ON ... has multiple instances of a particular ex

Re: [HACKERS] DISTINCT ON

2009-11-03 Thread Greg Stark
On Wed, Nov 4, 2009 at 3:17 AM, Emmanuel Cecchet wrote: > For example, this query returns an error (but I guess it shouldn't): > > SELECT DISTINCT ON ('1'::varchar,  '1'::varchar) a FROM (SELECT 1 AS a) AS a > ORDER BY '1'::varchar, '1'::varchar, '2'::varchar; This sounds familiar. What version

[HACKERS] DISTINCT ON

2009-11-03 Thread Emmanuel Cecchet
Hi all, It looks like Postgres has a restriction in DISTINCT ON queries where the DISTINCT ON expressions must match the left side of the ORDER BY list. The issue is that if a DISTINCT ON ... has multiple instances of a particular expression, this check doesn't seem to fire correctly. For exa