-
Notifications
You must be signed in to change notification settings - Fork 550
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
Accept query options on Statement#execute #912
Conversation
076bec1
to
6709b2b
Compare
Turns out this is Ruby 2.0 syntax. Supporting the extra arguments in Ruby 1.9.3 requires a different approach to parsing out a trailing Hash in the argument list. |
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.
👍 looks better than #640!
ext/mysql2/statement.c
Outdated
@@ -416,10 +421,16 @@ static VALUE rb_mysql_stmt_execute(int argc, VALUE *argv, VALUE self) { | |||
return Qnil; | |||
} | |||
|
|||
// Important to duplicate the hash, will receive merge! if extra opts |
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.
Might be possible to duplicate only conditionally, or use merge
instead?
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.
It was duplicate previously - I should actually check if it gets duplicated again in rb_mysql_result_to_obj
or if that method keeps the same options hash argument that was passed to it.
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.
Confirmed that rb_mysql_result_to_obj
uses what is passed to it, rather than duplicating its own query options hash, so the comment here (and in client.c) should reflect that.
lib/mysql2/statement.rb
Outdated
@@ -7,12 +7,14 @@ class Statement | |||
if Thread.respond_to?(:handle_interrupt) | |||
def execute(*args) | |||
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do | |||
_execute(*args) | |||
options = args.last.is_a?(Hash) ? args.pop : {} |
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.
Consider leaving a TODO that this should change when 1.9 is dropped.
8627a1e
to
b65c3a2
Compare
b65c3a2
to
45cc574
Compare
* master: GitHub is HTTPS by default (brianmario#922) Fix wrong value of type YEAR on big endian environment. (brianmario#921) Avoid 0 byte allocation call when statement takes no parameters Small spec improvement for RSpec style Travis CI for Mac OS X builds use the same steps again More specific exception classes (brianmario#911) Travis CI matrix add Ruby 2.5 and switch Mac OS X to Ruby 2.3 (ala High Sierra) README text for query options on Statement#execute Accept query options on Statement#execute (brianmario#912) Drop 1.9.3 support (brianmario#913)
This fixes a regression caused by brianmario#912 due to calling `rb_funcall` between `mysql_stmt_execute` and `mysql_stmt_store_result`, it will cause `mysql_stmt_close` to be called in wrong order. Fixes brianmario#956.
Thanks to @kamipo for diagnosing the problem and drafting the first PR. This fixes a regression caused by brianmario#912 due to calling `rb_funcall` between `mysql_stmt_execute` and `mysql_stmt_store_result`, it will cause `mysql_stmt_close` to be called in wrong order. In further testing, `rb_hash_aref` can also call `rb_funcall` if the query_options hash has a `default_proc` set, so adding a stronger comment to remind future maintainers. Fixes brianmario#956.
This commit fixes two error scenarios. The first is to avoid GC runs between `mysql_stmt_execute` and `mysql_stmt_store_result`. This fixes a regression caused by brianmario#912 due to calling `rb_funcall` between `mysql_stmt_execute` and `mysql_stmt_store_result`. The error in this case is: Commands out of sync; you can't run this command now Thanks to @kamipo for diagnosing the problem and drafting the first PR. The second problem is that in streaming mode, rows are returned to Ruby space one at a time, so garbage collection will naturally occur at any time. By requesting a cursor into the result set, other MySQL commands can be sent on the wire between row fetches. The error in this case is: Row retrieval was canceled by mysql_stmt_close Fixes brianmario#956, updates brianmario#957.
This commit fixes two error scenarios. The first is to avoid GC runs between `mysql_stmt_execute` and `mysql_stmt_store_result`. This fixes a regression caused by brianmario#912 due to calling `rb_funcall` between `mysql_stmt_execute` and `mysql_stmt_store_result`. The error in this case is: Commands out of sync; you can't run this command now Thanks to @kamipo for diagnosing the problem and drafting the first PR. The second problem is that in streaming mode, rows are returned to Ruby space one at a time, so garbage collection will naturally occur at any time. By requesting a cursor into the result set, other MySQL commands can be sent on the wire between row fetches. The error in this case is: Row retrieval was canceled by mysql_stmt_close Fixes brianmario#956, updates brianmario#957.
This commit fixes two error scenarios. The first is to avoid GC runs between `mysql_stmt_execute` and `mysql_stmt_store_result`. This fixes a regression caused by brianmario#912 due to calling `rb_funcall` between `mysql_stmt_execute` and `mysql_stmt_store_result`. The error in this case is: Commands out of sync; you can't run this command now Thanks to @kamipo for diagnosing the problem and drafting the first PR. The second problem is that in streaming mode, rows are returned to Ruby space one at a time, so garbage collection will naturally occur at any time. By requesting a cursor into the result set, other MySQL commands can be sent on the wire between row fetches. The error in this case is: Row retrieval was canceled by mysql_stmt_close Fixes brianmario#956, updates brianmario#957.
This commit fixes two error scenarios. The first is to avoid GC runs between `mysql_stmt_execute` and `mysql_stmt_store_result`. This fixes a regression caused by #912 due to calling `rb_funcall` between `mysql_stmt_execute` and `mysql_stmt_store_result`. The error in this case is: Commands out of sync; you can't run this command now Thanks to @kamipo for diagnosing the problem and drafting the first PR. The second problem is that in streaming mode, rows are returned to Ruby space one at a time, so garbage collection will naturally occur at any time. By requesting a cursor into the result set, other MySQL commands can be sent on the wire between row fetches. The error in this case is: Row retrieval was canceled by mysql_stmt_close Fixes #956, updates #957.
Instead of #640