Running Sqlite 3.19.3, an insert failed because of a constraint violation and 
the return value from changes() was not what I would have expected.  Why did 
"select changes()" return "3" on the second call, even though nothing was 
inserted into the db?

sqlite> pragma foreign_keys=1;
sqlite> create table t1(c1 int);
sqlite> insert into t1 (c1) values (1), (2), (3);
sqlite> select changes();
3
sqlite> select count(1) from t1;
3
sqlite> create table t2 (c1 int references t1(c1) on delete restrict);
sqlite> insert into t2 (c1) values (1);
Error: foreign key mismatch - "t2" referencing "t1"
sqlite> select changes();
3
sqlite> select count(1) from t2;
0

Thank you,

Steve Friedman

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

Reply via email to