Skip to content
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

Various fixes for mariadb_use_result #174

Closed
wants to merge 4 commits into from

Conversation

rovo89
Copy link

@rovo89 rovo89 commented Nov 28, 2022

No description provided.

mysql_num_rows() is 0 after mysql_use_result() until all results have
been fetched, so we can't rely on it to decide if there will be more
rows.
It isn't supported and an error is thrown when
mariadb_server_prepare_disable_fallback is set. With the fallback
enabled though there's an infinite loop because mariadb_st_fetch()
doesn't know that the fallback was used and goes into the wrong branch.
mysql_use_result() requires fetching all rows before executing the
next query, otherwise we'd get an error 2014 (Commands out of sync).

This can be relevant if the script leaves the result loop early. If it
explicitly calls $sth->finish() that would croak, if it undefines $sth
it would get a warning. If it doesn't do anything and executes another
query, it croaks. With this fix, the pending rows are fetched silently.

For multi-result sets we could use mysql_store_result() for the
remaining results, that would consume more memory to buffer all rows,
rather than just fetching and discarding each individual row.
@pali
Copy link
Member

pali commented Mar 6, 2023

@rovo89 Is there still something related to mariadb_use_result attribute which needs to be fixed?

@rovo89
Copy link
Author

rovo89 commented Mar 8, 2023

The stuff in #175 is kind of related, but in a different context. I'll close this PR.

@rovo89 rovo89 closed this Mar 8, 2023
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.

2 participants