Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: matti(dot)aarnio(at)methics(dot)fi
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key
Date: 2013-02-11 12:11:07
Message-ID: 5118DFDB.4080103@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 09.02.2013 22:25, matti(dot)aarnio(at)methics(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Matti Aarnio 2013-02-11 15:34:30 Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key
Previous Message Tom Lane 2013-02-10 23:47:30 Re: BUG #7493: Postmaster messages unreadable in a Windows console