On 12/08/2014 09:55 PM, Nico Williams wrote:
Ideally there would be something like DEFERRED foreign key checking
for uniqueness constraints...

You could hack SQLite to do enforce unique constraints the same way as FKs. When adding an entry to a UNIQUE index b-tree, you check for a duplicate. If one exists, increment a counter. Do the opposite when removing entries - decrement the counter if there are two or more duplicates of the entry you are removing. If your counter is greater than zero at commit time, a UNIQUE constraint has failed.

I suspect there would be a non-trivial increase in the CPU use of UPDATE statements though.





   You can get something like that by
using non-unique indexes (but there would also go your primary keys)
and then check that there are no duplicates before you COMMIT.  (Doing
this reliably would require something like transaction triggers, which
IIRC exists in a "sessions" branch.)

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

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

Reply via email to