Re: [sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-12 Thread David Raymond
lback; Error: cannot rollback - no transaction is active -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Richard Hipp Sent: Friday, January 12, 2018 8:37 AM To: SQLite mailing list Subject: Re: [sqlite] Is foreign key support disable

Re: [sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-12 Thread Richard Hipp
On 1/12/18, Shane Dev wrote: > Does that mean FK constraints are only checked > if processing reaches the end of the trigger? FKs are checked at the end of the entire statement. If multiple triggers fire, then they all run to completion before any FKs are checked. -- D.

Re: [sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-12 Thread Shane Dev
Thanks for the explanation. Does that mean FK constraints are only checked if processing reaches the end of the trigger? On 12 January 2018 at 13:29, Richard Hipp wrote: > Test 1 makes the changes, the checks the FK constraints, sees that the > FK constraints are violated and

Re: [sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-12 Thread Richard Hipp
Test 1 makes the changes, the checks the FK constraints, sees that the FK constraints are violated and hence runs ABORT, which backs out the change. Test 2 makes the change, then runs FAIL, which stops all further processing. The FK constraints are never checked, and the changes are not backed

Re: [sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-12 Thread Shane Dev
Hello, Perhaps it would be clearer if I ask the question in a different way. Why does the following statement - insert into vtrig select 5; fail to insert a record in Test 1 below (as expected) but succeeds in Test 2 (despite the foreign key constraint)? sqlite> CREATE TABLE reftab(id integer

Re: [sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-11 Thread Richard Hipp
On 1/11/18, Shane Dev wrote: > > CREATE VIEW vtrig as select 1; > CREATE TRIGGER ttrig instead of insert on vtrig begin > delete from deptab; > delete from reftab; > insert into deptab(ref) select 2; > select raise(FAIL, 'this statement seems to temporarily disable

[sqlite] Is foreign key support disabled within triggers with raise functions?

2018-01-11 Thread Shane Dev
om deptab); end; sqlite> insert into vtrig select 5; Error: this statement seems to temporarily disable foreign support sqlite> select * from reftab; sqlite> select * from deptab; id ref 1 2 sqlite> pragma foreign_keys; foreign_keys 1 Can we conclude foreign key support is