SQLSTATE code for duplicate constraint

Started by Dan Langilleover 18 years ago2 messagesgeneral
Jump to latest
#1Dan Langille
dan@langille.org

Hi folks,

With reference to:

http://www.postgresql.org/docs/8.2/interactive/errcodes-appendix.html

What error code would be raised for a duplicate index name?

I didn't see anything appropriate. Possibly: 42710 DUPLICATE OBJECT

thanks

--
Dan Langille - http://www.langille.org/
BSDCan - The Technical BSD Conference: http://www.bsdcan.org/
PGCon - The PostgreSQL Conference: http://www.pgcon.org/

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dan Langille (#1)
Re: SQLSTATE code for duplicate constraint

Dan Langille <dan@langille.org> writes:

What error code would be raised for a duplicate index name?

regression=# \set VERBOSITY verbose
regression=# create table t1 (f1 int);
CREATE TABLE
regression=# create index t1i on t1(f1);
CREATE INDEX
regression=# create index t1i on t1(f1);
ERROR: 42P07: relation "t1i" already exists
LOCATION: index_create, index.c:567

Evidently it's ERRCODE_DUPLICATE_TABLE.

regards, tom lane