pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jochen Erwied <jochen@pgsql-performance.erwied.eu>
To: Dave Crooke <dcrooke@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column
Date: Fri, 25 Feb 2011 01:03:12 +0100
Message-ID: <1923741490.20110225010312@erwied.eu> (raw)
In-Reply-To: <AANLkTinaxt=xjbxOpXTeoL7SZ6dxJgEU8eDtp2dEbHKq@mail.gmail.com>
References: <AANLkTinaxt=xjbxOpXTeoL7SZ6dxJgEU8eDtp2dEbHKq@mail.gmail.com>

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




view thread (2+ messages)

Message-ID: <1923741490.20110225010312@erwied.eu>
Permalink:  ../1923741490.20110225010312@erwied.eu/
Also on:    postgresql.org/message-id/1923741490.20110225010312@erwied.eu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jochen@pgsql-performance.erwied.eu, dcrooke@gmail.com
  Subject: Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column
  In-Reply-To: <1923741490.20110225010312@erwied.eu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox