Weird message when creating PK constraint named like table - Mailing list pgsql-bugs

From r d
Subject Weird message when creating PK constraint named like table
Date
Msg-id CALtFtELrOJ-V0wuke++S7C1_XvDiJ9irBtnuecjLMq4d7zhhTg@mail.gmail.com
Whole thread Raw
Responses Re: Weird message when creating PK constraint named like table  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: Weird message when creating PK constraint named like table  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Weird message when creating PK constraint named like table  (Pavel Golub <pavel@microolap.com>)
List pgsql-bugs
When I do this

CREATE TABLE "*T1*"
> (
>   "T1_ID" bigint NOT NULL,
>   CONSTRAINT "*T1*" PRIMARY KEY ("T1_ID" )
> );


I get the following message:

NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "T1" for
> table "T1"
> ERROR:  relation "T1" already exists
> ********** Error **********
> ERROR: relation "T1" already exists
> SQL state: 42P07


It does NOT create either the table or the constraint, and the message is
confusing because there is no relation by that name.

The SQLSTATE 42P07 is described in the manual as only as "table undefined",
and it is not clear if the intent is to allow or
disallow the creation of a constraint called the same as the table in
Postgresql. Oracle 11g allows this, but my feeling is that
doing this should not be allowed, just as Postgresql handles it.

*I am complaining about the confusing error message which IMO is off-topic,
not about how the DB handles this.*

Seen on Postgresql 9.1.2 Linux 64bit.

pgsql-bugs by date:

Previous
From: John Udick
Date:
Subject: Re: BUG #6391: insert does not insert correct value
Next
From: Andres Freund
Date:
Subject: Botched estimation in eqjoinsel_semi for cases without reliable ndistinct