pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedgetting details about integrity constraint violation
8+ messages / 6 participants
[nested] [flat]
* getting details about integrity constraint violation
@ 2005-06-02 15:25 Markus Bertheau <twanger@bluetwanger.de>
2005-06-02 16:32 ` Re: getting details about integrity constraint violation Tom Lane <tgl@sss.pgh.pa.us>
2005-06-14 03:39 ` Re: getting details about integrity constraint violation Greg Sabino Mullane <greg@turnstep.com>
0 siblings, 2 replies; 8+ messages in thread
From: Markus Bertheau @ 2005-06-02 15:25 UTC (permalink / raw)
To: pgsql-sql
Hi,
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. I cannot sensibly
react to such errors if I don't know what exactly happened.
I'd like to avoid parsing the text error message because it can be
different depending on the LC_MESSAGES the server / libpq runs with.
Markus
--
Markus Bertheau <twanger@bluetwanger.de>
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
2005-06-02 15:25 getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
@ 2005-06-02 16:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-06-03 18:42 ` Re: getting details about integrity constraint violation PFC <lists@boutiquenumerique.com>
1 sibling, 1 reply; 8+ messages in thread
From: Tom Lane @ 2005-06-02 16:32 UTC (permalink / raw)
To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql
Markus Bertheau <twanger@bluetwanger.de> writes:
> how would I find out details about for example what constraint was
> violated by an insert statement?
You can't, at the moment, except by parsing the text message.
The "error fields" facility in the FE/BE protocol could be extended
in that direction, and I think there's already been some discussion
about it; but no one has stepped up with a concrete proposal, much
less volunteered to do the work ...
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
2005-06-02 15:25 getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
2005-06-02 16:32 ` Re: getting details about integrity constraint violation Tom Lane <tgl@sss.pgh.pa.us>
@ 2005-06-03 18:42 ` PFC <lists@boutiquenumerique.com>
0 siblings, 0 replies; 8+ messages in thread
From: PFC @ 2005-06-03 18:42 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql
> The "error fields" facility in the FE/BE protocol could be extended
> in that direction, and I think there's already been some discussion
> about it; but no one has stepped up with a concrete proposal, much
> less volunteered to do the work ...
Um, if changing the protocol is a bother, you could also add parseable
infos to the error messages...
instead of :
"ERROR: duplicate key violates unique constraint "testinteg_one_key""
it would say
"ERROR: duplicate key violates unique constraint "testinteg_one_key"
[code:"XXXX" error:"integrity" type:"unique" column:"something"
constraint:"testinteg_one_key"]"
Which could be hackfully added by a "parseable" locale (but with a more
restrained form...)
SET lc_messages TO parseable
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
2005-06-02 15:25 getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
@ 2005-06-14 03:39 ` Greg Sabino Mullane <greg@turnstep.com>
2005-06-14 05:46 ` Re: getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
1 sibling, 1 reply; 8+ messages in thread
From: Greg Sabino Mullane @ 2005-06-14 03:39 UTC (permalink / raw)
To: pgsql-sql; +Cc: twanger@bluetwanger.de
-----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-----
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
2005-06-02 15:25 getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
2005-06-14 03:39 ` Re: getting details about integrity constraint violation Greg Sabino Mullane <greg@turnstep.com>
@ 2005-06-14 05:46 ` Markus Bertheau <twanger@bluetwanger.de>
2005-06-15 02:06 ` Re: getting details about integrity constraint violation Greg Sabino Mullane <greg@turnstep.com>
0 siblings, 1 reply; 8+ messages in thread
From: Markus Bertheau @ 2005-06-14 05:46 UTC (permalink / raw)
To: Greg Sabino Mullane <greg@turnstep.com>; +Cc: pgsql-sql
Dnia 14-06-2005, wto o godzinie 03:39 +0000, Greg Sabino Mullane
napisał(a):
> Simply name the table constraints yourself with a descriptive name, so you
> always know exactly what is going on:
And then I keep a list of all the constraint names and scan the error
message for it?
Markus
--
Markus Bertheau <twanger@bluetwanger.de>
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
2005-06-02 15:25 getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
2005-06-14 03:39 ` Re: getting details about integrity constraint violation Greg Sabino Mullane <greg@turnstep.com>
2005-06-14 05:46 ` Re: getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
@ 2005-06-15 02:06 ` Greg Sabino Mullane <greg@turnstep.com>
0 siblings, 0 replies; 8+ messages in thread
From: Greg Sabino Mullane @ 2005-06-15 02:06 UTC (permalink / raw)
To: pgsql-sql; +Cc: twanger@bluetwanger.de
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>> Simply name the table constraints yourself with a descriptive name, so you
>> always know exactly what is going on:
> And then I keep a list of all the constraint names and scan the error
> message for it?
Don't keep a list: just come up with a standard naming scheme, such as:
"tablename|colname|is_not_unique"
which should be human and machine parseable (perl example):
if ($error =~ m#^(.+)\|(.+)\|is_not_unique$#o) {
die qq{Whoops : looks like column "$2" of table "$1" needs to be unique\n};
}
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200506142204
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFCr4zivJuQZxSWSsgRAgGPAJ0awkoBmus6z1cLBRpsR5xmQPTfiACgpJxG
Ld90hEGDPrebBE3JGGL11L4=
=smQJ
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
@ 2005-06-03 08:00 KÖPFERL Robert <robert.koepferl@sonorys.at>
2005-06-03 09:00 ` Re: getting details about integrity constraint violation Markus Bertheau ☭ <twanger@bluetwanger.de>
0 siblings, 1 reply; 8+ messages in thread
From: KÖPFERL Robert @ 2005-06-03 08:00 UTC (permalink / raw)
To: ; +Cc: pgsql-sql
|
|You can't, at the moment, except by parsing the text message.
|
|The "error fields" facility in the FE/BE protocol could be extended
|in that direction, and I think there's already been some discussion
|about it; but no one has stepped up with a concrete proposal, much
|less volunteered to do the work ...
|
| regards, tom lane
So there must be at least a bunnch of error codes (which could be printed in
addition)?
Or has noone defined such, yet?
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting details about integrity constraint violation
2005-06-03 08:00 Re: getting details about integrity constraint violation KÖPFERL Robert <robert.koepferl@sonorys.at>
@ 2005-06-03 09:00 ` Markus Bertheau ☭ <twanger@bluetwanger.de>
0 siblings, 0 replies; 8+ messages in thread
From: Markus Bertheau ☭ @ 2005-06-03 09:00 UTC (permalink / raw)
To: KÖPFERL Robert <robert.koepferl@sonorys.at>; +Cc: pgsql-sql
В Птн, 03/06/2005 в 10:00 +0200, KÖPFERL Robert пишет:
> |
> |You can't, at the moment, except by parsing the text message.
> |
> |The "error fields" facility in the FE/BE protocol could be extended
> |in that direction, and I think there's already been some discussion
> |about it; but no one has stepped up with a concrete proposal, much
> |less volunteered to do the work ...
> |
> | regards, tom lane
>
>
> So there must be at least a bunnch of error codes (which could be printed in
> addition)?
There are, but they only say something along the lines of "unique
constraint violated", they don't say which one.
Markus
--
Markus Bertheau ☭ <twanger@bluetwanger.de>
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2005-06-15 02:06 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-02 15:25 getting details about integrity constraint violation Markus Bertheau <twanger@bluetwanger.de>
2005-06-02 16:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-06-03 18:42 ` PFC <lists@boutiquenumerique.com>
2005-06-14 03:39 ` Greg Sabino Mullane <greg@turnstep.com>
2005-06-14 05:46 ` Markus Bertheau <twanger@bluetwanger.de>
2005-06-15 02:06 ` Greg Sabino Mullane <greg@turnstep.com>
2005-06-03 08:00 Re: getting details about integrity constraint violation KÖPFERL Robert <robert.koepferl@sonorys.at>
2005-06-03 09:00 ` Markus Bertheau ☭ <twanger@bluetwanger.de>
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