SQLite Forum

iOS 14 - table sqlite_master may not be modified
Login
Hi,

I have an application which modifies the database structure by manipulating the sqlite_master table directly following the instructions on https://sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes

This has been working successfully for several years but with iOS 14 this process fails with the following exception.

```
Error Domain=FMDatabase Code=1 "table sqlite_master may not be modified" UserInfo={NSLocalizedDescription=table sqlite_master may not be modified})
sql 'UPDATE sqlite_master SET sql = replace(sql, 'cloud_file_id INT,', 'cloud_file_id INT REFERENCES cloudfile (id),') WHERE name = 'attachment' AND type = 'table'' args []}
```

I have checked that I am setting `pragma writable_schema = ON` by querying `pragma writable_schema`, it returns `1` (ON) but it still the update fails.

From scouring the documentation I was wondering if `SQLITE_DBCONFIG_DEFENSIVE` connection config property had been enabled but I can't see any way to determine this.

Are there any other reasons that `sqlite_master` cannot be written?

The version of SQLite iOS 14 is using is `3.32.3`.
I have successfully tested this process on iOS 12 & version 3.24.0 (I think), OSX & version 3.27.1 and Android & version 3.22.0

Many thanks for any help or guidance

James