Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ext/pdo_sqlite/sqlite_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt)
return 1;

case SQLITE_ERROR:
sqlite3_reset(S->stmt);
ZEND_FALLTHROUGH;
case SQLITE_MISUSE:
case SQLITE_BUSY:
default:
sqlite3_reset(S->stmt);
pdo_sqlite_error_stmt(stmt);
return 0;
}
Expand Down
33 changes: 33 additions & 0 deletions ext/pdo_sqlite/tests/gh24990.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
GH-24990 (Statement unusable after a failed execute())
--EXTENSIONS--
pdo_sqlite
--FILE--
<?php
$db = new PDO('sqlite::memory:', options: [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$db->exec('CREATE TABLE test (k TEXT PRIMARY KEY NOT NULL)');
$db->exec("INSERT INTO test VALUES ('a')");

$stmt = $db->prepare('INSERT INTO test (k) VALUES (?)');
foreach (['a', 'b', 'b', 'c'] as $k) {
try {
var_dump($stmt->execute([$k]));
} catch (PDOException $e) {
echo $e->getMessage(), "\n";
}
}
var_dump($db->query('SELECT k FROM test ORDER BY k')->fetchAll(PDO::FETCH_COLUMN));
?>
--EXPECT--
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: test.k
bool(true)
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: test.k
bool(true)
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
Loading