X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0EE34DAFA1 for ; Wed, 26 Oct 2005 21:55:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70096-07 for ; Thu, 27 Oct 2005 00:55:28 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D2205DAF8E for ; Wed, 26 Oct 2005 21:55:30 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9R0tWUl013075; Wed, 26 Oct 2005 20:55:32 -0400 (EDT) To: dave.bath@unix.net Cc: pgsql-sql@postgresql.org Subject: Re: Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum In-reply-to: <200510271042.11487.dave.bath@unix.net> References: <200510261015.17623.lawgon@thenilgiris.com> <200510261622.40874.dave.bath@unix.net> <2827.1130310024@sss.pgh.pa.us> <200510271042.11487.dave.bath@unix.net> Comments: In-reply-to "Bath, David" message dated "Thu, 27 Oct 2005 10:42:10 +1000" Date: Wed, 26 Oct 2005 20:55:31 -0400 Message-ID: <13074.1130374531@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/350 X-Sequence-Number: 23203 "Bath, David" writes: > you wrote (2005-10-26 17:00) >>> Sybase/MS-SQL's check constraint model asserts the constraint >>> BEFORE the trigger, which discourages you from attempting to> >>> check and handle meaning of data! >> Er, doesn't PG do it that way too? > Well, it works for me! You're right of course. I was confusing this with a related problem that people occasionally complain about, which is that datatype-related errors are thrown before the trigger can do anything about them. For instance, you can't stuff "abc" into a int4 field and hope that the trigger will have a chance to replace it with something valid. (Yes, people have asked for that :-() A less silly example is that domain constraints on a field of a domain type get checked before the trigger can run. regards, tom lane