sqlitetransactionspragma

Are pragma statements undone by rolling back transactions?


Would pragmas such as foreign_keys = OFF and VACUUM be undone if included in a transaction which gets rolled back? The documentation doesn't seem to cover this.


Solution

  • It is different for different pragma statements.

    SQLite version 3.7.15.2 includes the pragma user_version in transactions and will COMMIT and ROLLBACK the value. However, it excludes (in documentation and testing) foreign_keys from transactions. It appears that pragmas not documented as invalid during transactions will participate in a transaction.