Re: primary key error message - Mailing list pgsql-hackers

From Tom Lane
Subject Re: primary key error message
Date
Msg-id 14168.1264109352@sss.pgh.pa.us
Whole thread Raw
In response to Re: primary key error message  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: primary key error message  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> On tor, 2010-01-21 at 15:51 -0500, Tom Lane wrote:
>> This patch fails to cover all cases (index build being the obvious
>> omission, but I think there might be other paths as well where the
>> information is not so readily available).

> This is the user-visible error message, and that's the only place it's
> generated.

Hardly ...

regression=# create table foo (f1 int);
CREATE TABLE
regression=# insert into foo values(1),(1);
INSERT 0 2
regression=# alter table foo add primary key (f1);
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
ERROR:  could not create unique index "foo_pkey"
DETAIL:  Key (f1)=(1) is duplicated.

>> And I agree with Robert that the usefulness is at best highly debatable.

> The usefulness is that they are different kinds of objects that are
> defined and listed in different ways and it would be slightly helpful if
> the error message pointed in the righter direction.

It is not incorrect to refer to a primary key as a unique constraint.
Will you next be wanting the error messages about null values to
distinguish whether the NOT NULL constraint came from a primary key?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: primary key error message
Next
From: Rafael Martinez
Date:
Subject: Re: PITR backup history files with identical 2nd part file names