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. |
| return Qnil; | ||
| } | ||
|
|
||
| // Important to duplicate the hash, will receive merge! if extra opts |
There was a problem hiding this comment.
Might be possible to duplicate only conditionally, or use merge instead?
There was a problem hiding this comment.
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.
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.
| 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.
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