| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | John Keith Hohm <john(at)hohm(dot)net> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Suspected bug: outer WHERE reordered before inner WHERE -> input syntax ERROR |
| Date: | 2008-09-08 17:53:03 |
| Message-ID: | 2204.1220896383@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
John Keith Hohm <john(at)hohm(dot)net> writes:
> This fails with ERROR: invalid input syntax for integer: "JOHN":
> select * from (
> select * from (VALUES ('100'), ('JOHN')) as A (n)
> where trim(trim(n), '0123456789') = ''
> ) as B where n::integer <> -1;
This isn't a bug: the optimizer is entitled to rearrange WHERE clauses
any way it pleases. If you want an optimization fence between the inner
and outer SELECTS, add OFFSET 0 (or LIMIT ALL if you like).
> I'm also interested in responses of the form "why not just do X?".
It does raise the question of why you aren't just doing
where trim(n) != '-1'
I'm also wondering whether the logic is even consistent: something
with a minus sign in it will never get through the inner WHERE,
so what is the point of the outer one?
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | justin | 2008-09-08 17:53:45 | Re: How to check what is current postgres version |
| Previous Message | Markova, Nina | 2008-09-08 17:40:48 | How to check what is current postgres version |