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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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-10 23:22:39
Message-ID: 15657.1360538559@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

matti(dot)aarnio(at)methics(dot)fi writes:
> 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.

Works for me:

regression=# CREATE TABLE example (
regression(# a TIMESTAMP NOT NULL,
regression(# b VARCHAR(256) NOT NULL,
regression(# c VARCHAR(256) NOT NULL,
regression(# PRIMARY KEY(a,b,c)
regression(# );
CREATE TABLE
regression=# \set VERBOSITY verbose
regression=# insert into example values('today','today','foo');
INSERT 0 1
regression=# insert into example values('today','today','foo');
ERROR: 23505: duplicate key value violates unique constraint "example_pkey"
DETAIL: Key (a, b, c)=(2013-02-10 00:00:00, today, foo) already exists.
SCHEMA NAME: public
TABLE NAME: example
CONSTRAINT NAME: example_pkey
LOCATION: _bt_check_unique, nbtinsert.c:398

I'm guessing you have a client-side problem, but since you've said
nothing about what the client-side software is, it's hard to venture
anything more detailed.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message John R Pierce 2013-02-10 23:30:33 Re:
Previous Message Noah Misch 2013-02-10 21:02:59 Re: BUG #7493: Postmaster messages unreadable in a Windows console