X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 88D559DCB92 for ; Fri, 27 Jan 2006 20:40:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30563-07 for ; Fri, 27 Jan 2006 20:40:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 55BD99DCBB6 for ; Fri, 27 Jan 2006 20:40:23 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k0S0eMd9031909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Jan 2006 17:40:25 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k0S0eMWR020560; Fri, 27 Jan 2006 17:40:22 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k0S0eM8H020559; Fri, 27 Jan 2006 17:40:22 -0700 (MST) (envelope-from mfuhr) Date: Fri, 27 Jan 2006 17:40:22 -0700 From: Michael Fuhr To: "Kashmira Patel (kupatel)" Cc: pgsql-sql@postgresql.org Subject: Re: Question about check constraints Message-ID: <20060128004022.GA20476@winnie.fuhr.org> References: <18AE59788A3FC640A367E5652E664D8001731288@xmb-sjc-237.amer.cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18AE59788A3FC640A367E5652E664D8001731288@xmb-sjc-237.amer.cisco.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.113 required=5 tests=[AWL=0.113] X-Spam-Score: 0.113 X-Spam-Level: X-Archive-Number: 200601/201 X-Sequence-Number: 23990 On Fri, Jan 27, 2006 at 03:06:26PM -0800, Kashmira Patel (kupatel) wrote: > I have a table where two columns have two different check constraints > associated with them. When I update one column, the check constraint on > the other column is also executed. Is there a way to avoid this? I want > to check only for the condition defined for the column being updated. I don't think you can change this behavior: each CHECK constraint is evaluated for the new row regardless of whether a particular column changed or not. However, you could enforce the constraints with a trigger and skip checks where NEW.column is the same as OLD.column. Why the concern? Are the checks expensive? Do they have side effects? What do they do? -- Michael Fuhr