SQLite Forum

Statement that fires trigger is not executed when the trigger causes an error
> Why is the original statement that caused the trigger to fire, not executed when there is an error on the trigger?

The error occurs during the prepare stage of processing.  Since no execution plan (VDBE code) is generated, it is not executed.  It is like a C program (for example) that has a fatal error during compilation which aborts the compilation.  Since no compilation has occurred, there is nothing to execute.

 > Is it rolling back the changes by default?

No.  There is nothing to roll back since there was nothing done.

 > Or does SQLite parse the trigger's actions before executing anything?

Of course.  When you issue, in this case, a DELETE statement, then all applicable DELETE triggers must be parsed (compiled into) the executable code.  When that compilation fails (due to an error such as a reference to a non-existent table in the present case) there is nothing to execute and the compiler emits an error message.

 > If so, why wasn't this parsing done when the trigger was created?

The trigger was parsed as being semantically correct when it was created.  However at compilation time (when you sought to prepare to execute it) the trigger was discovered to contain errors thus preventing successful compilation and execution in the context in which it was sought to be executed.