X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 90F9C5284D for ; Tue, 14 Jun 2005 00:39:58 -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 30452-03 for ; Tue, 14 Jun 2005 03:39:48 +0000 (GMT) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id 2F2655281E for ; Tue, 14 Jun 2005 00:39:47 -0300 (ADT) Received: (qmail 28068 invoked from network); 14 Jun 2005 03:39:47 -0000 Received: from unknown (HELO localhost) (207.228.252.42) by 0 with SMTP; 14 Jun 2005 03:39:47 -0000 From: "Greg Sabino Mullane" To: pgsql-sql@postgresql.org Cc: twanger@bluetwanger.de Cc: twanger@bluetwanger.de Subject: Re: getting details about integrity constraint violation X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <1117725916.7345.2.camel@localhost.localdomain> Date: Tue, 14 Jun 2005 03:39:47 -0000 X-Mailer: JoyMail 1.48 Message-ID: <873b36387522e9a014ec0c75cbb63338@biglumber.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.131 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/159 X-Sequence-Number: 21760 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Markus Bertheau asked: > how would I find out details about for example what constraint was > violated by an insert statement? The SQL state tells me, that a unique > constraint was violated, but it doesn't say which one. Simply name the table constraints yourself with a descriptive name, so you always know exactly what is going on: greg=# create table unitest(a int, b text); CREATE TABLE greg=# alter table unitest add constraint "unitest_column_a_is_not_unique" unique(a); NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "unitest_column_a_is_not_unique" for table "unitest" greg=# insert into unitest (a) values (1); INSERT 0 1 greg=# insert into unitest (a) values (1); ERROR: duplicate key violates unique constraint "unitest_column_a_is_not_unique" - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200506121520 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iD8DBQFCrIsevJuQZxSWSsgRAh+gAJ94AsB7rZzpxT7pogC1tgbPaQJzJQCg5YkC E9dXkQk4qP8r8zjCEucxpt0= =NDgJ -----END PGP SIGNATURE-----