SQLite

View Ticket
Login
2011-08-22
17:49 Ticket [b1d3a2e531] Erroneous FK constraint failure when dropping table. status still Closed with 1 other change (artifact: 796ec9784d user: drh)
10:03 Closed ticket [b1d3a2e531]. (artifact: 8bc5f804eb user: dan)
10:03 Ticket [b1d3a2e531]: 1 change (artifact: 643bfe8566 user: dan)
09:55 Ticket [b1d3a2e531]: 3 changes (artifact: 1a01bb2255 user: dan)
09:55 Closed ticket [b1d3a2e531]. (artifact: e31b399b6a user: dan)
09:54
Fix for [b1d3a2e531]. (check-in: 3f3acee465 user: dan tags: trunk)
09:37 New ticket [b1d3a2e531] Erroneous FK constraint failure when dropping table.. (artifact: 6d88e323ce user: dan)

Ticket Hash: b1d3a2e531478b4e069df3d2e847b8d4346ce4ce
Title: Erroneous FK constraint failure when dropping table.
Status: Closed Type: Code_Defect
Severity: Minor Priority: Immediate
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2011-08-22 17:49:43
13.87 years ago
Created: 2011-08-22 09:37:52
13.87 years ago
Version Found In: 3.7.7.1
Description:
The following script causes a constraint failure.
   CREATE TABLE pp(x PRIMARY KEY);
   CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
   INSERT INTO pp VALUES('a value');
   INSERT INTO cc VALUES('a value');

   BEGIN;
     DROP TABLE pp;
     DROP TABLE cc;
   COMMIT;

The problem is that SQLite sees that the "DROP TABLE pp" creates a constraint violation (since there is now an orphan row in "cc"). However it does not see that "DROP TABLE cc" corrects the violation (by deleting the orphan). This is an oversight in the implementation of foreign-keys.

The bug has been present ever since FK support was introduced, in version 3.6.19.


dan added on 2011-08-22 09:55:58:
Fixed here: [3f3acee465]