A way to verify the constraint integrety would be great.

Some thoughts:

- Introduce a boolean 'all_foreign_key_constraits_are_known_valid' (default
false) that is stored in the database header
- A new PRAGMA foreign_key_check checks the foreign key constraints
- If it finds invalid constraints and the new boolean was set true it
reports a corrupted database
- If it finds no invalid constraints it sets the new boolean to true
- When there is any update to the database while PRAGMA foreign_keys is off
the boolean is set to false
- When the database is first opened check if the last SQLite library to
write the database was a version that is aware of the new boolean. If not,
set the boolean false.

This way a well behaved application (always immediate set PRAGMA
foreign_keys true after opening the database) will always have the new
boolean set to true and any invalid constraint can be reported as true
corruption.

On the other hand, a 'light' version of PRAGMA foreign_key_check would first
evaluate the new boolean and skip all checks if it is already true.

Jos

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to