SQLite Forum

Recursive Triggers documentation
Login

Recursive Triggers documentation

(1.1) By Keith Medcalf (kmedcalf) on 2020-07-09 06:49:00 edited from 1.0 [source]

There appears to be a discrepancy between the documentation and the code regarding the default for recursive triggers. The documentation https://sqlite.org/limits.html in para 10 states:

10. Maximum Depth Of Trigger Recursion

SQLite limits the depth of recursion of triggers in order to prevent a statement involving recursive triggers from using an unbounded amount of memory.

Prior to SQLite version 3.6.18 (2009-09-11), triggers were not recursive and so this limit was meaningless. Beginning with version 3.6.18, recursive triggers were supported but had to be explicitly enabled using the PRAGMA recursive_triggers statement. Beginning with version 3.7.0 (2009-09-11), recursive triggers are enabled by default but can be manually disabled using PRAGMA recursive_triggers. The SQLITE_MAX_TRIGGER_DEPTH is only meaningful if recursive triggers are enabled.

The default maximum trigger recursion depth is 1000.

Which would seem to indicate that since version 3.7.0 the default for recursive triggers is enabled, however, sqliteInt.h at about line 626 in the current trunk reads:

/*
** Determine whether triggers are recursive by default.  This can be
** changed at run-time using a pragma.
*/
#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS
# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0
#endif

which sets the default to disabled.

Which one is correct and the intended default?

Note that the documentation for pragma recursive_triggers seems to indicate that the default is off but may be turned on in the future https://sqlite.org/pragma.html#pragma_recursive_triggers