Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key
Date
Msg-id 5118DFDB.4080103@vmware.com
Whole thread Raw
In response to BUG #7865: Unexpected error code on insert of duplicate to composite primary key  (matti.aarnio@methics.fi)
Responses Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key  (Matti Aarnio <matti.aarnio@methics.fi>)
List pgsql-bugs
On 09.02.2013 22:25, matti.aarnio@methics.fi wrote:
> CREATE TABLE example (
>     a   TIMESTAMP    NOT NULL,
>     b   VARCHAR(256) NOT NULL,
>     c   VARCHAR(256) NOT NULL,
>     PRIMARY KEY(a,b,c)
> );
>
> Inserting a duplicate record on this is returning an SQL Error, but the
> status code is 0 instead of expected 23505.
>
> This used to work fine in 8.x series, but is now causing trouble in 9.1.7,
> and 9.2.3.

Works for me:

postgres=# do $$
begin
   insert into example values ('2001-01-01', 'foo', 'bar');
   insert into example values ('2001-01-01', 'foo', 'bar');
exception
   when others then raise notice 'caught %', sqlstate;
end;
$$;
NOTICE:  caught 23505
DO

How exactly are you seeing the wrong status code? What client are you using?

- Heikki

pgsql-bugs by date:

Previous
From: John R Pierce
Date:
Subject: Re:
Next
From: Heikki Linnakangas
Date:
Subject: Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key