1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/sqlite3/tests/sqlite3_defensive.phpt
Niels Dossche e6fef2944b Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12633: sqlite3_defensive.phpt fails with sqlite 3.44.0
  Fix GH-12628: The gh11374 test fails on Alpinelinux
2023-11-10 00:12:47 +01:00

41 lines
883 B
PHP

--TEST--
SQLite3 defensive mode ini setting
--EXTENSIONS--
sqlite3
--SKIPIF--
<?php
if (SQLite3::version()['versionNumber'] < 3026000) {
die("skip: sqlite3 library version < 3.26: no support for defensive mode");
}
?>
--INI--
sqlite3.defensive=On
--FILE--
<?php
$db = new SQLite3(':memory:');
var_dump($db->exec('CREATE TABLE test (a, b);'));
// This does not generate an error!
var_dump($db->exec('PRAGMA writable_schema = ON;'));
// Should be 1
var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;'));
// Should generate an error!
var_dump($db->querySingle('DELETE FROM sqlite_master;'));
// Should still be 1
var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;'));
?>
--EXPECTF--
bool(true)
bool(true)
int(1)
Warning: SQLite3::querySingle(): Unable to prepare statement: table sqlite_master may not be modified in %s on line %d
bool(false)
int(1)