Skip to content

[4.x] Consume the remaining result sets after a stored procedure call in MySQLi - #409

Open
Hackwar wants to merge 2 commits into
joomla-framework:4.x-devfrom
Hackwar:4.x-mysqli-drain-results
Open

Hackwar wants to merge 2 commits into
joomla-framework:4.x-devfrom
Hackwar:4.x-mysqli-drain-results

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

A CALL of a stored procedure that returns rows produces more than one result set (the rows plus the status of the CALL). MysqliStatement::closeCursor() only called free_result() for the first one and never moved on with more_results()/next_result(), so the connection stayed busy and the next prepare() failed with 2014 Commands out of sync; you can't run this command now (#296). The only workaround was $db->disconnect(). The PDO MySQL driver is not affected.

closeCursor() now consumes and frees the remaining result sets.

Testing Instructions

New MysqliDriverTest::testQueryAfterCallingStoredProcedure creates a procedure SELECT 1, calls it twice and then runs another query; without the change the second statement fails with error 2014. It needs MySQL/MariaDB (MySQLi CI jobs); no server was available locally.

Documentation Changes Required

None.

Fixes #296

🤖 Generated with Claude Code

Hackwar and others added 2 commits November 12, 2026 23:48
A CALL of a stored procedure that returns rows produces several result sets.
closeCursor() only freed the first one, so the connection stayed busy and the
next statement failed with "2014 Commands out of sync" until the connection
was closed. The remaining result sets are now consumed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MySQL 5.7 and MariaDB 10.4 cannot prepare CREATE/DROP PROCEDURE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar

Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

First CI run: the new test failed on MySQL 5.7 / MariaDB 10.4 because those servers cannot prepare CREATE PROCEDURE (test setup, not the fix). Follow-up commit runs the procedure DDL on the native connection; please squash on merge.

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.

Joomla 5: MySQL Error -- 2014 - Commands out of sync; you can't run this command now

1 participant