Skip to content

Update multi-query.xml #4782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update multi-query.xml #4782

wants to merge 1 commit into from

Conversation

miqrogroove
Copy link
Contributor

Fixes #4778 by clarifying the MySQL "wait" happens after executing all queries.

Fixes php#4778 by clarifying the MySQL "wait" happens after executing all queries.
@kamil-tekiela
Copy link
Member

I don't think that's true. What evidence do you have for the contrary? Can you please share a reproducible on https://phpize.online/

@miqrogroove
Copy link
Contributor Author

It's quite true. For my test case, I opened 2 separate connections. In PHP, I sent 3 insert queries via multi_query() and then used sleep(10) between each instance of next_result().

For simplicity, I opened the other connection on phpMyAdmin. I was able to refresh the target table immediately after starting the test in PHP, and all 3 records appeared in the database before the first sleep expired.

@kamil-tekiela
Copy link
Member

kamil-tekiela commented Jul 17, 2025

It's quite true. For my test case, I opened 2 separate connections. In PHP, I sent 3 insert queries via multi_query() and then used sleep(10) between each instance of next_result().

For simplicity, I opened the other connection on phpMyAdmin. I was able to refresh the target table immediately after starting the test in PHP, and all 3 records appeared in the database before the first sleep expired.

Isn't this just a single result though? I'd imagine you need at 2 results to see the stall. For example:

SELECT 1, SLEEP(10);
SELECT 2, SLEEP(10);
INSERT INTO test VALUE (NOW());

The sleeps are irrelevant here, but I believe that the insert should wait for next_result. I can't test it now though.

@miqrogroove
Copy link
Contributor Author

miqrogroove commented Jul 18, 2025

I tested this query and again all 3 records appeared instantly:

$sql = "
    INSERT INTO mytable SET name = 'hkjhkjh';
    SELECT * FROM mytable;
    INSERT INTO mytable SET name = 'hkjhkjh2';
    SELECT * FROM mytable;
    INSERT INTO mytable SET name = 'hkjhkjh3';
    SELECT * FROM mytable
";

This seems to support my revision. Even if I call sleep(10) and never call next_result() the server will process all of the queries.

@miqrogroove
Copy link
Contributor Author

For clarity, I see MySQL also has a SLEEP function, which I am never using. I'm calling sleep in PHP to delay the result processing.

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.

MySQL multi_query Doesn't Cause the Server to "wait"
2 participants