Skip to content

Fixed PDO::CURSOR_SCROLL statements closing a cursor that was never declared - #23490

Open
KentarouTakeda wants to merge 1 commit into
php:masterfrom
KentarouTakeda:fix-pdo-pgsql-cursor-dtor
Open

Fixed PDO::CURSOR_SCROLL statements closing a cursor that was never declared#23490
KentarouTakeda wants to merge 1 commit into
php:masterfrom
KentarouTakeda:fix-pdo-pgsql-cursor-dtor

Conversation

@KentarouTakeda

Copy link
Copy Markdown
Contributor

The destructor of a statement created with [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL] tries to close the cursor even when it has not been declared. This fixes that.

The attempted close causes an error on the database server, but the destructor discards its result, so the error cannot be observed by the user. Apart from polluting the server's log, this is mostly harmless, but when it happens inside a transaction, it causes a strange situation where subsequent statements fail for a reason that cannot be observed.

The same implementation as the one added here already exists in pgsql_stmt_execute(). This change makes the condition for issuing CLOSE on a cursor consistent within pgsql_statement.c.

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.

1 participant