Skip to content

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

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

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

Conversation

@iliaal

@iliaal iliaal commented Oct 16, 2026

Copy link
Copy Markdown
Member

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 #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

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but I think the name of the new field could be better, it actually means "no successful completion since last attempted execution"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.6.0RC3: crash in pecl pdo_oci when doing execute()+fetch_all() twice using the same prepared statement

2 participants