Re: inconsistency in aliasing

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: inconsistency in aliasing
Date: 2009-01-14 12:07:51
Message-ID: 66444c23-faae-43e3-bc53-007c54d690f8@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Reg Me Please wrote:

> > critik=# select current_timestamp::abstime::int4 as score order
by score +
> > 1; ERROR: column "score" does not exist
> > LINE 1: ...urrent_timestamp::abstime::int4 as score order by
score + 1 ...
> >
> > Any idea ?
> >
> > Thanks,
>
> Looks and smells like a bug.

Read
http://www.postgresql.org/docs/8.3/static/queries-order.html

<quote>
The sort expression(s) can be any expression that would be valid in
the query's select list
</quote>

score+1 is not valid in the query's select list (as well as "score"
anyway)

<quote>
For backwards compatibility with the SQL92 version of the standard, a
sort_expression can instead be the name or number of an output column
</quote>

so that's why "score" alone works in the order by, despite it not being
valid in the select list.

<quote>
Note that an output column name has to stand alone, it's not allowed
as part of an expression
</quote>

Which looks like the very issue discussed here, and it just behaves as
documented.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thom Brown 2009-01-14 12:09:46 Logging on Gentoo
Previous Message Emanuel Calvo Franco 2009-01-14 12:04:20 Re: [ADMIN] Problem with pg_dump

Browse pgsql-hackers by date

  From Date Subject
Next Message Lennin Caro 2009-01-14 13:53:57 Re: inconsistency in aliasing
Previous Message Alvaro Herrera 2009-01-14 11:44:23 Re: Updates of SE-PostgreSQL 8.4devel patches (r1403)