On 01/07/2011 09:19 PM, BareFeetWare wrote:

>> pragma foreign_keys = no;

On 08/01/2011, at 1:26 AM, Dan Kennedy wrote:

> The command above should have disabled all foreign-key constraint checks 
> (including cascades etc.). Check it for typos perhaps.

I thought it would too, but when my particular test wasn't working, I thought I 
had misunderstood what this pragma does. Thanks for confirming that it is 
supposed to do what I originally thought.

Upon further investigation, my particular test failed for another reason. I was 
testing the result of sqlite_prepare for errors, but I didn't allow for some 
errors that don't occur until "runtime", so they don't occur until sqlite3_step 
or similar is called. On of these errors is:

SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */

which was the case here because I was adding a unique constraint to my table 
schema, then inserting the old data, which contains some non unique rows. 
Because I wasn't trapping this runtime error, the transaction proceeded 
through: dropped the old table, created a new table, didn't complain when it 
failed to insert the old data, thus no rows in the new table.

Once I trapped the runtime error and forced a rollback, all is good.

Anyway, problem solved. Thanks for the input.

Thanks,
Tom
BareFeetWare

 --
Comparison of SQLite GUI tools:
http://www.barefeetware.com/sqlite/compare/?ml

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to