xref: /PHP-8.0/ext/pdo_sqlite/tests/gh9032.phpt (revision 8ed21a89)
1--TEST--
2SQLite3 authorizer crashes on NULL values
3--SKIPIF--
4<?php
5if (!extension_loaded("pdo_sqlite")) die("skip pdo_sqlite extension not available");
6?>
7--INI--
8open_basedir=.
9--FILE--
10<?php
11$db = new PDO("sqlite::memory:", null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
12
13$db->exec('attach database \':memory:\' AS "db1"');
14var_dump($db->exec('create table db1.r (id int)'));
15
16try {
17$st = $db->prepare('attach database :a AS "db2"');
18$st->execute([':a' => ':memory:']);
19var_dump($db->exec('create table db2.r (id int)'));
20} catch (PDOException $ex) {
21    echo $ex->getMessage(), PHP_EOL;
22}
23?>
24--EXPECT--
25int(0)
26SQLSTATE[HY000]: General error: 23 not authorized
27