Skip to content

Query *always executes twice* when calling SQLite3Result.fetcharray() #8386

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 1 commit into from

Conversation

HochMartinez
Copy link

In SQLite3.query() and SQLite3Stmt.execute(), if success and SQLITE_ROW is true or SQLITE_DONE is true, do not reset the statement, otherwise when you execute SQLite3Result.fetcharray() the sqlite 'step' instruction executes the query again. Imagine an expensive query being executed two times... Please, please patch this. Thank you and keep up the good work! :-)

In SQLite3.query() and SQLite3Stmt.execute(), if success and SQLITE_ROW is true or SQLITE_DONE is true, *do not reset the statement*, otherwise when you execute SQLite3Result.fetcharray() the sqlite 'step' instruction executes the query again. Imagine an expensive query being executed *two times*... Please, please patch this. Thank you! :-)
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.

This simple approach causes a lot of test failures. Note that this bug is known for years, but appears hard, if not impossible to solve without seriously breaking BC.

@HochMartinez
Copy link
Author

Hi,

It's not impossible to solve, and IMHO, nor hard. I have a version of the code with a few more changes that the ones I first proposed, that solves the bug in a simple way (just addeded an int and four lines of code).

I'm using it right now on my php build with no compilation or execution issues.

No more double execution of queries when using SQLite3Result->fetcharray() afer a call to SQlite3->query() or SQLite3Stmt->execute().

What should I do to have those changes reviewed? I'm new to github.

Thank you! :-)

@cmb69
Copy link
Member

cmb69 commented Apr 21, 2022

Just push the changes to your branch HochMartinez:patch-1. Then CI should be triggered again.

@HochMartinez
Copy link
Author

Hi Christoph,

I just pushed the new fix here:

HochMartinez:patch-2

It affects two files, Sqlite3.c and php_sqlite3_structs.h.

As I commented, the patch does not affect the error logic. It's a very simple fix, so all should work fine.

Thanks and greetings from Barcelona... :-)

@cmb69
Copy link
Member

cmb69 commented Apr 22, 2022

Thank you! So I'm closing this PR in favor of #8415.

@cmb69 cmb69 closed this Apr 22, 2022
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