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.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
No comments:
Post a Comment