Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: BUG #4327: Primary key not refresh after cascaded deleted


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: "Sam Wong" <sam(at)hellosam(dot)net>
  • Cc: pgsql-bugs(at)postgresql(dot)org
  • Subject: Re: BUG #4327: Primary key not refresh after cascaded deleted
  • Date: Mon, 28 Jul 2008 12:17:52 -0400
  • Message-id: <22201.1217261872@sss.pgh.pa.us> <text/plain>

"Sam Wong" <sam(at)hellosam(dot)net> writes:
> Then when I try to insert the following into B:
> A,4
> it will say
> duplicate key value violates unique constraint "B_primary_column_pkey".

Works for me:

regression=# create table a (A_primary_col int primary key);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "a_pkey" for table "a"
CREATE TABLE
regression=# insert into a values (1),(2),(3);
INSERT 0 3
regression=# create table b (B_primary_col text primary key, a_reference int references a on delete cascade);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "b_pkey" for table "b"
CREATE TABLE
regression=# insert into b values('A',1),('B',2),('C',3);
INSERT 0 3
regression=# DELETE FROM A;
DELETE 3
regression=# select * from a;
 a_primary_col 
---------------
(0 rows)

regression=# select * from b;
 b_primary_col | a_reference 
---------------+-------------
(0 rows)

regression=# insert into a values (4);        
INSERT 0 1
regression=# insert into b values('A',4);                
INSERT 0 1

I suspect a mistake on your part.  If you can actually reproduce this
problem, please show an exact test case, not hand-waving.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group