BUG #4327: Primary key not refresh after cascaded deleted - Mailing list pgsql-bugs

From Sam Wong
Subject BUG #4327: Primary key not refresh after cascaded deleted
Date
Msg-id 200807270841.m6R8fa6j043628@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #4327: Primary key not refresh after cascaded deleted  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      4327
Logged by:          Sam Wong
Email address:      sam@hellosam.net
PostgreSQL version: 8.3.1
Operating system:   Linux Debian
Description:        Primary key not refresh after cascaded deleted
Details:

Say, I have two table A and B.

That A has one column:
A_primary_col
...and keys:
PRIMARY KEY (A_primary_col)

That B has two columns:
B_primary_col, A_reference
...and keys:
PRIMARY KEY (b_primary_col)
FOREIGN KEY (A_reference) REFERENCES A(A_primary_col) ON DELETE CASCADE

Now I inserted the following records into
into A:
1
2
3

into B:
A,1
B,2
C,3

Now I delete all records from A:
DELETE FROM A;
so that both table is empty now.

Now when I try to insert the following:
into A:
4

Then when I try to insert the following into B:
A,4

Expected Behavior:
it will insert with no problem

Actual Behavior:
it will say
duplicate key value violates unique constraint "B_primary_column_pkey".

Workaround:
Analyze the table B.

I believe that's a bug that the primary key index is not updated
accordingly? Thanks.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4324: Default value for a column is not returned in select when column has not been explicitly set
Next
From: "andrew victoria"
Date:
Subject: BUG #4328: help in creating database encoded with LATIN1