Skip to content

Fix GH-24372: Keep stmt->executed set across PDOStatement::execute() - #436

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-24372-pdo-executed-flag
Closed

iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-24372-pdo-executed-flag

Conversation

@iliaal

@iliaal iliaal commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

11690db clears stmt->executed on re-execute. pdo_oci reads that as a first execution and reallocates its column buffers while PDO core keeps the old descriptions, so the second fetch crashes; pdo_ibm leaks instead. A failed execute() is now tracked in a separate bit and executed is left alone. closeCursor() followed by execute() crashes pdo_oci the same way on every version; that needs a pdo_oci fix (php/pecl-database-pdo_oci#46).

This is a much more simplified approach, personally I think this is much cleaner than the original

Fixes php#24372

11690db cleared stmt->executed on entry to execute() so a failed
execute() could not leave the previous result fetchable. Drivers read that
flag as "executed successfully at least once": pdo_oci reallocates its
column buffers when it is clear, while PDO core skips describing the
columns again because they are still set, so the OCI defines keep writing
into the freed buffers; pdo_ibm leaks its column descriptors. Record the
failed execute() in a separate bit instead. The cursor closer still runs
on entry, but drivers without one are no longer drained, which also made
them fetch every remaining row on each re-execute.

Fixes phpGH-24372
@iliaal

iliaal commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#24379

@iliaal iliaal closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant