xref: /PHP-5.6/ext/pdo_sqlite/tests/bug66033.phpt (revision e3d9e18e)
1--TEST--
2Bug #66033 (Segmentation Fault when constructor of PDO statement throws an exception)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
6?>
7--FILE--
8<?php
9class DBStatement extends PDOStatement {
10	public $dbh;
11	protected function __construct($dbh) {
12		$this->dbh = $dbh;
13		throw new Exception("Blah");
14	}
15}
16
17$pdo = new PDO('sqlite::memory:', null, null);
18$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement',
19	array($pdo)));
20$pdo->exec("CREATE TABLE IF NOT EXISTS messages (
21	id INTEGER PRIMARY KEY,
22	title TEXT,
23	message TEXT,
24	time INTEGER)");
25
26try {
27	$pdoStatement = $pdo->query("select * from messages");
28} catch (Exception $e) {
29	var_dump($e->getMessage());
30}
31?>
32--EXPECTF--
33string(4) "Blah"
34