Skip to content

Update multi-query.xml#4782

Closed
miqrogroove wants to merge 1 commit intophp:masterfrom
miqrogroove:patch-2
Closed

Update multi-query.xml#4782
miqrogroove wants to merge 1 commit intophp:masterfrom
miqrogroove:patch-2

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.

@kamil-tekiela
Copy link
Member

Sorry for the delay, I forgot about this PR. You are right, the current paragraph is misleading. However, I decided to phrase it differently. Can you check if the PR #5380 is clear enough?

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"

3 participants

Comments