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