-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
7d28a24
commit 05c00a8
Showing
3 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |