1--TEST--
2SQLite3 defensive mode ini setting
3--SKIPIF--
4<?php require_once(__DIR__ . '/skipif.inc');
5
6if (SQLite3::version()['versionNumber'] < 3026000) {
7    die("skip: sqlite3 library version < 3.26: no support for defensive mode");
8}
9
10?>
11--INI--
12sqlite3.defensive=On
13--FILE--
14<?php
15
16$db = new SQLite3(':memory:');
17var_dump($db->exec('CREATE TABLE test (a, b);'));
18
19// This does not generate an error!
20var_dump($db->exec('PRAGMA writable_schema = ON;'));
21var_dump($db->querySingle('PRAGMA writable_schema;'));
22
23// Should be 1
24var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;'));
25
26// Should generate an error!
27var_dump($db->querySingle('DELETE FROM sqlite_master;'));
28
29// Should still be 1
30var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;'));
31?>
32--EXPECTF--
33bool(true)
34bool(true)
35int(1)
36int(1)
37
38Warning: SQLite3::querySingle(): Unable to prepare statement: 1, table sqlite_master may not be modified in %s on line %d
39bool(false)
40int(1)