From: Greg Sabino Mullane <greg@turnstep.com>
To: pgsql-sql@postgresql.org
Cc: twanger@bluetwanger.de
Subject: Re: getting details about integrity constraint violation
Date: Tue, 14 Jun 2005 03:39:47 -0000
Message-ID: <873b36387522e9a014ec0c75cbb63338@biglumber.com> (raw)
In-Reply-To: <1117725916.7345.2.camel@localhost.localdomain>
-----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-----
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: greg@turnstep.com, twanger@bluetwanger.de
Subject: Re: getting details about integrity constraint violation
In-Reply-To: <873b36387522e9a014ec0c75cbb63338@biglumber.com>
* 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