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