diff options
| author | Vincent <vquatrevieux@b2pweb.com> | 2019-06-26 11:37:08 +0200 |
|---|---|---|
| committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-06-28 12:36:02 +0200 |
| commit | 05c00a832c7b395398ef8e60edd8a7ec25439861 (patch) | |
| tree | c370019ae42a557af143f55c3d49610b1ab2736f /ext/pdo_sqlite/tests | |
| parent | 7d28a24c6602a0cf66def582c82712408254f81d (diff) | |
| download | php-git-05c00a832c7b395398ef8e60edd8a7ec25439861.tar.gz | |
Fix bug #78192 PDO SQLite SegFault when reuse statement after schema has changed
Reset stmt->columns when column count changed on new execution of prepared statement
Diffstat (limited to 'ext/pdo_sqlite/tests')
| -rw-r--r-- | ext/pdo_sqlite/tests/bug78192.phpt | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ext/pdo_sqlite/tests/bug78192.phpt b/ext/pdo_sqlite/tests/bug78192.phpt new file mode 100644 index 0000000000..dcf4b749be --- /dev/null +++ b/ext/pdo_sqlite/tests/bug78192.phpt @@ -0,0 +1,46 @@ +--TEST-- +PDO SQLite Bug #78192 SegFault when reuse statement after schema change +--SKIPIF-- +<?php +if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; +?> +--FILE-- +<?php +$connection = new \PDO('sqlite::memory:'); +$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); +$connection->query('CREATE TABLE user (id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(255) NOT NULL)'); + +$stmt = $connection->prepare('INSERT INTO user (id, name) VALUES(:id, :name)'); +$stmt->execute([ + 'id' => 10, + 'name' => 'test', +]); + +$stmt = $connection->prepare('SELECT * FROM user WHERE id = :id'); +$stmt->execute(['id' => 10]); +var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC)); + +$connection->query('ALTER TABLE user ADD new_col VARCHAR(255)'); +$stmt->execute(['id' => 10]); +var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC)); +--EXPECT-- +array(1) { + [0]=> + array(2) { + ["id"]=> + string(2) "10" + ["name"]=> + string(4) "test" + } +} +array(1) { + [0]=> + array(3) { + ["id"]=> + string(2) "10" + ["name"]=> + string(4) "test" + ["new_col"]=> + NULL + } +} |
