pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: ilussier@accovia.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9820: Parentheses removed in chech constraint
Date: Tue, 01 Apr 2014 14:41:01 -0400
Message-ID: <24144.1396377661@sss.pgh.pa.us> (raw)
In-Reply-To: <20140401150157.363.83570@wrigleys.postgresql.org>
References: <20140401150157.363.83570@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

ilussier@accovia.com writes:
> alter table table_name add constraint c1 CHECK ( (type = 0 AND field1 IS NOT
> NULL AND field2 IS NOT NULL AND field3 IS NOT NULL) OR (type_id = 1 AND
> field1 IS NULL AND field2 IS NULL AND field3 IS NULL) )

> At the execution of the query, the parentheses that defines condition 1 and
> condition 2 are removed.  By removing the parentheses, the expression does
> not means the same thing.

Sure it does.  AND binds more tightly than OR.

You did not state what your actual problem is, but whether or not the
constraint-printer adds logically redundant parentheses isn't it...

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <24144.1396377661@sss.pgh.pa.us>
Permalink:  ../24144.1396377661@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24144.1396377661@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ilussier@accovia.com
  Subject: Re: BUG #9820: Parentheses removed in chech constraint
  In-Reply-To: <24144.1396377661@sss.pgh.pa.us>
  References: <20140401150157.363.83570@wrigleys.postgresql.org> <24144.1396377661@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox