Hi Team,
I have come across a puzzling case illustrated by
Alex Fatkulin at
Pythian whereby a Primary Key can have duplicates under certain conditions when using a deferred PK constraint. This is the URL:
https://blog.pythian.com/deferrable-constraints-in-oracle-11gr2-may-lead-to-logically-corrupted-data/ This problem he described is still reproducible in 12c (12.1.0.2.0). Please find below my reproduction:
In First Session:
SQL> create table def_bug(n number primary key deferrable initially deferred);
Table created.
SQL> insert into def_bug values (1);
1 row created.
SQL> insert into def_bug values (2);
1 row created.
SQL> commit;
Commit complete.
-- Checking to make sure constraint is working
SQL> insert into def_bug values (1);
1 row created.
SQL> commit;
commit
*
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-00001: unique constraint (AISMAILA.SYS_C0010310) violated
In Second Session:
SQL> update def_bug set n=3 where n=2;
1 row updated.
Back in First Session (This will hang)
SQL> update def_bug set n=3 where n<=2;
1 row updated.
Now Commit Second session:
SQL> commit;
Commit complete.
And Commit First Session:
SQL> commit;
Commit complete.
Now See Contents of table:
SQL> select * from def_bug;
N
----------
3
3
Your comments on this will be much appreciated.
Thanks