From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: non-integer constant in ORDER BY: why exactly, and documentation? |
Date: | 2012-10-11 21:06:23 |
Message-ID: | 28246.1349989583@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ken Tanzer <ken(dot)tanzer(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | A.M. | 2012-10-11 21:07:28 | Re: non-integer constant in ORDER BY: why exactly, and documentation? |
Previous Message | John R Pierce | 2012-10-11 21:06:14 | Re: moving from MySQL to pgsql |