-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Rebind row values to the statement after freeing result #2489
Conversation
@@ -335,6 +346,7 @@ public function errorInfo() | |||
public function closeCursor() | |||
{ | |||
$this->_stmt->free_result(); | |||
$this->_rowValuesAreBound = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reset rowBindedValues and hereby avoid rowValuesAreBound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kimhemsoe by "reset" you mean re-bind? We can extract the procedure of binding row values to a separate method and call it from execute()
and from here.
However, we don't know if the statement is going to be reused after closing cursor, so setting a flag saves us some CPU ticks. What do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. It is just moving store_result() scares me alot. In history it have been a very picky call to get right, with all the different drivers and such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the store_result()
part from this patch as irrelevant.
I think we should combine the 2 PR you have into one with one test. They are both very similar. |
Also we need someone to test the none pdo drivers. Adding a test for this will make some of the other drivers fail. |
@kimhemsoe the 2 PRs are fine as separate as they are (makes it easier to track what was done, too). What do you mean by |
@Ocramius All those drivers which are not PDO. Mysqli is only driver that is not PDO and is getting tested by travis. |
Ah yes, we have very few unit tests there, I fear. Can't do much about it besides adding them, but can't ask to scope-creep this PR either. |
No ofc not, just saying that we introducing failing tests for the other drivers :) |
I'd say it's better to keep them separate since these are two completely independent issues. In fact, fixing this one doesn't require calling |
Right now the test skips all drivers besides |
@morozov If you have the resources to test the other drivers afterwards, you are were much welcome. But for now lets drag them in here more then i already have done. |
a3aec83
to
d3151a1
Compare
Looks like I looked at the wrong place, since all the adapters above close the statement resource as part of
|
…her statement reuse. Emulate closing the cursor for drivers which don't support that.
cdf74cb
to
ac3b38f
Compare
So, apart from the original issue, a related issue with closing cursor and then reusing statement has been fixed for Oracle, IBM DB2 and SQL Server platforms. Can we handle them together, since they can be reproduced with a similar use case, or we should split them apart? |
If prepared statement is reused for multiple queries, and after one of the executions, the statement cursor is closed (
$stmt->closeCursor()
), all consequent executions will return the last row returned by$stmt->_fetch()
before the cursor was closed.The reason is that
mysqli_stmt::free_result()
also unbinds result variables from the statement, and they don't get bound back upon next execution.