Skip to content

Fix sqlite3 fetchArray #64531 #5137

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

Closed
wants to merge 2 commits into from
Closed

Conversation

frikiluser
Copy link

Fix #64531 SQLite3 SQLite3Result::fetchArray()
Avoid sqlite3_step() call when result contains no columns (ie non-select-like query).

sqlite3_column_count() described here https://sqlite.org/c3ref/column_count.html
A SELECT statement will always have a positive sqlite3_column_count()

Patch uploaded: https://bugs.php.net/patch-display.php?bug_id=64531&patch=fix64531-sqlite3-fetchArray-skipNoColumns&revision=1580516014

@frikiluser frikiluser requested a review from cmb69 February 1, 2020 06:34
@frikiluser frikiluser removed the request for review from cmb69 February 7, 2020 19:00
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! According to your comment in the bugtracker, this should probably target PHP-7.3, so please rebase onto that branch.

Anyhow, while this is not a general fix for bug #64531, it seems that it still makes sense to have this patched.

Please address my comment below, and also please add test cases which show what is fixed, and what is not yet fixed with this patch. Thanks.

@frikiluser
Copy link
Author

Pushed again to force travis-ci tests rerun. Network problems...

@frikiluser
Copy link
Author

Thanks for the PR! According to your comment in the bugtracker, this should probably target PHP-7.3, so please rebase onto that branch.

Note I've rebased from 7.3 branch and renamed as master in my repo. The pull request still points to php/master branch (should be changed to 7.3).

Let me know if I should open a new PR to the correct branch.

Regards

@cmb69
Copy link
Member

cmb69 commented Feb 19, 2020

Let me know if I should open a new PR to the correct branch.

Nope, not necessary. I'll currently investigate on some not directly related issues I've stumbled upon while having a closer look at this PR. Will come back to this PR afterwards. Thanks for the added test case, anyway. :)

@cmb69
Copy link
Member

cmb69 commented Feb 24, 2020

I'm not sure if this solution would really be helpful. While it certainly catches some cases, it wouldn't work for the ALTER TABLE query mentioned in bug #78813, and I'm not even sure if sqlite3_column_count() may be called after sqlite3_reset(), but that would happen for the first ::fetchArray().

PR #5204 would be a cleaner solution, but has issues on its own (error code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants