Re: non-integer constant in ORDER BY: why exactly, and documentation? - Mailing list pgsql-general

From Tom Lane
Subject Re: non-integer constant in ORDER BY: why exactly, and documentation?
Date
Msg-id 28246.1349989583@sss.pgh.pa.us
Whole thread Raw
In response to non-integer constant in ORDER BY: why exactly, and documentation?  (Ken Tanzer <ken.tanzer@gmail.com>)
Responses Re: non-integer constant in ORDER BY: why exactly, and documentation?  (Ken Tanzer <ken.tanzer@gmail.com>)
List pgsql-general
Ken Tanzer <ken.tanzer@gmail.com> writes:
> Hi.  I recently ran a query that generate the same error as this:
> SELECT * FROM generate_series(1,10) ORDER BY 'foo';
> ERROR:  non-integer constant in ORDER BY

> I am curious though about why this "limitation" exists.  I get that integer
> constants are reserved for sorting by column numbers.  But if Postgres
> already knows that it's a non-integer constant,  why not let it go through
> with the (admittedly pointless) ordering?

I think the argument was that it's almost certainly a mistake, so we're
more helpful by throwing an error than by silently executing a query
that probably won't do what the user was expecting.  In this particular
example, it seems quite likely that the programmer meant "foo" (ie a
quoted column reference) and got the quote style wrong ...

            regards, tom lane


pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: non-integer constant in ORDER BY: why exactly, and documentation?
Next
From: John R Pierce
Date:
Subject: Re: moving from MySQL to pgsql