| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Andy Shellam <andy-lists(at)networkmail(dot)eu> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: CHECK constraint removing brackets |
| Date: | 2010-01-11 20:15:18 |
| Message-ID: | 18738.1263240918@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Andy Shellam <andy-lists(at)networkmail(dot)eu> writes:
> With the above in mind, I decided on the following check to enforce this:
> (state = 'Unconfirmed'::client.order_state AND invoice_id = NULL) OR (state != 'Unconfirmed'::client.order_state AND invoice_id != NULL)
> However PostgreSQL (8.4.2) converts this to the following:
> state = 'Unconfirmed'::client.order_state AND invoice_id = NULL::integer OR state <> 'Unconfirmed'::client.order_state AND invoice_id <> NULL::integer
There is no "conversion" there, that means exactly the same thing.
(AND binds tighter than OR.)
I think your real problem is that you're trying to use "= NULL" and
"!= NULL" where you should say IS NULL or IS NOT NULL.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andy Shellam | 2010-01-11 23:27:35 | Re: CHECK constraint removing brackets |
| Previous Message | Scott Marlowe | 2010-01-11 20:14:12 | Re: CHECK constraint removing brackets |