From: | "Andrus" <kobruleht2(at)hot(dot)ee> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | delete commands fails silently to delete primary key |
Date: | 2008-11-22 19:56:27 |
Message-ID: | gg9pg9$1edv$3@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have table in 8.1.4 which tracks users logged into db
CREATE TABLE "session"
(
workplace character(16) NOT NULL,
ipaddress character(20),
logintime character(28),
loggeduser character(10),
CONSTRAINT session_pkey PRIMARY KEY (workplace)
);
Commands executed at logon in same transaction are:
delete from session where workplace=E'LIIVA' ;
insert into session (workplace,ipaddress,logintime,loggeduser) values (
E'LIIVA' , inet_client_addr()::CHAR(14),
current_timestamp::CHAR(28),CURRENT_USER)
Sometimes (during locking contention or during heavy load) those commands
cause error:
2008-11-22 11:24:26 EET INSERT 1 47433335ERROR: duplicate key violates
unique constraint "session_pkey"
2008-11-22 11:24:26 EET INSERT 2 47433335STATEMENT: delete from session
where workplace=E'LIIVA' ;insert into session
(workplace,ipaddress,logintime,loggeduser) values ( E'LIIVA' ,
inet_client_addr()::CHAR(14), current_timestamp::CHAR(28),CURRENT_USER)
No other client can add 'LIIVA' primary key.
Any idea why this error occurs and how to fix ?
Andrus.
From | Date | Subject | |
---|---|---|---|
Next Message | Ciprian Dorin Craciun | 2008-11-22 21:37:46 | Re: Using Postgres to store high volume streams of sensor readings |
Previous Message | Tom Lane | 2008-11-22 18:17:15 | Re: SQL query |