Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column - Mailing list pgsql-performance

From Jochen Erwied
Subject Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column
Date
Msg-id 1923741490.20110225010312@erwied.eu
Whole thread Raw
In response to Possible parser bug? .... Re: Picking out the most recent row using a time stamp column  (Dave Crooke <dcrooke@gmail.com>)
List pgsql-performance
Friday, February 25, 2011, 12:53:08 AM you wrote:

> select distinct on (a,    b,    c)
> a,   b c,   time_stamp,    value

Without the comma, you declare 'b AS c'

> from data
> order by a, b, c, time_stamp desc;

> The output produced is the same as this query:

> select distinct on (a,    b)
> a,   b,   time_stamp,    value
> from data
> order by a, b, time_stamp desc;

the 'c' is optimized away, since it is an alias for b, and thus redundant
for the distinct.

> Not sure if this is considered a parser bug or not, but it feels slightly
> odd not to get an error.

No error, just plain SQL :-)



--
Jochen Erwied     |   home: jochen@erwied.eu     +49-208-38800-18, FAX: -19
Sauerbruchstr. 17 |   work: joe@mbs-software.de  +49-2151-7294-24, FAX: -50
D-45470 Muelheim  | mobile: jochen.erwied@vodafone.de       +49-173-5404164


pgsql-performance by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Picking out the most recent row using a time stamp column
Next
From: Shaun Thomas
Date:
Subject: Re: Picking out the most recent row using a time stamp column