Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WV3cR-0006sc-Qs for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Apr 2014 18:41:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WV3cQ-0003dn-IA for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Apr 2014 18:41:06 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WV3cP-0003dg-JO for pgsql-bugs@postgresql.org; Tue, 01 Apr 2014 18:41:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WV3cN-0006Ak-1k for pgsql-bugs@postgresql.org; Tue, 01 Apr 2014 18:41:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s31If1vE024145; Tue, 1 Apr 2014 14:41:01 -0400 From: Tom Lane To: ilussier@accovia.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9820: Parentheses removed in chech constraint In-reply-to: <20140401150157.363.83570@wrigleys.postgresql.org> References: <20140401150157.363.83570@wrigleys.postgresql.org> Comments: In-reply-to ilussier@accovia.com message dated "Tue, 01 Apr 2014 15:01:57 -0000" Date: Tue, 01 Apr 2014 14:41:01 -0400 Message-ID: <24144.1396377661@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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