Hello,

It seems that Composite Foreign Key constraint fails when it should not.  For 
example:

   PRAGMA foreign_keys=ON;
   CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER);
   CREATE UNIQUE INDEX i1 ON t1(a,b);
   INSERT INTO t1 VALUES(100,200);
   CREATE TABLE t2(w INTEGER,x INTEGER,y INTEGER,FOREIGN KEY(x,y) REFERENCES 
t1(a,b));
   INSERT INTO t2 VALUES(300,100,200);
   UPDATE t1 set b = 200 where a = 100;

The UPDATE on table t1 will fail, even if it does not violate the foreign key 
on table t2.

This is related somewhat to http://www.sqlite.org/src/info/dd08e5a988  and  
http://www.sqlite.org/src/info/636f86095e .

The real database has over 240 tables, doing CRUD, using a lot of "surrogate 
key with propagation", and each UPDATE statement always specify all fields of 
the table (except for primary key fields), so updating fields with same values 
on FK happens often.

Thanks!
George Somers

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

Reply via email to