12
12
VALUE cMysql2Client ;
13
13
extern VALUE mMysql2 , cMysql2Error ;
14
14
static VALUE sym_id , sym_version , sym_async , sym_symbolize_keys , sym_as , sym_array , sym_stream ;
15
- static ID intern_merge , intern_error_number_eql , intern_sql_state_eql ;
15
+ static ID intern_merge , intern_merge_bang , intern_error_number_eql , intern_sql_state_eql ;
16
16
17
17
#ifndef HAVE_RB_HASH_DUP
18
18
static VALUE rb_hash_dup (VALUE other ) {
@@ -368,7 +368,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
368
368
return rb_raise_mysql2_error (wrapper );
369
369
}
370
370
371
- VALUE is_streaming = rb_hash_aref (rb_iv_get (self , "@query_options " ), sym_stream );
371
+ VALUE is_streaming = rb_hash_aref (rb_iv_get (self , "@current_query_options " ), sym_stream );
372
372
if (is_streaming == Qtrue ) {
373
373
result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_use_result , wrapper , RUBY_UBF_IO , 0 );
374
374
} else {
@@ -386,7 +386,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
386
386
387
387
resultObj = rb_mysql_result_to_obj (result );
388
388
/* pass-through query options for result construction later */
389
- rb_iv_set (resultObj , "@query_options" , rb_hash_dup (rb_iv_get (self , "@query_options " )));
389
+ rb_iv_set (resultObj , "@query_options" , rb_hash_dup (rb_iv_get (self , "@current_query_options " )));
390
390
391
391
#ifdef HAVE_RUBY_ENCODING_H
392
392
GetMysql2Result (resultObj , result_wrapper );
@@ -526,7 +526,7 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
526
526
#endif
527
527
struct nogvl_send_query_args args ;
528
528
int async = 0 ;
529
- VALUE opts , defaults ;
529
+ VALUE opts , current ;
530
530
VALUE thread_current = rb_thread_current ();
531
531
#ifdef HAVE_RUBY_ENCODING_H
532
532
rb_encoding * conn_enc ;
@@ -536,16 +536,14 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
536
536
REQUIRE_CONNECTED (wrapper );
537
537
args .mysql = wrapper -> client ;
538
538
539
- defaults = rb_iv_get (self , "@query_options" );
539
+ rb_iv_set (self , "@current_query_options" , rb_hash_dup (rb_iv_get (self , "@query_options" )));
540
+ current = rb_iv_get (self , "@current_query_options" );
540
541
if (rb_scan_args (argc , argv , "11" , & args .sql , & opts ) == 2 ) {
541
- opts = rb_funcall (defaults , intern_merge , 1 , opts );
542
- rb_iv_set (self , "@query_options" , opts );
542
+ opts = rb_funcall (current , intern_merge_bang , 1 , opts );
543
543
544
- if (rb_hash_aref (opts , sym_async ) == Qtrue ) {
544
+ if (rb_hash_aref (current , sym_async ) == Qtrue ) {
545
545
async = 1 ;
546
546
}
547
- } else {
548
- opts = defaults ;
549
547
}
550
548
551
549
Check_Type (args .sql , T_STRING );
@@ -937,7 +935,7 @@ static VALUE rb_mysql_client_store_result(VALUE self)
937
935
938
936
resultObj = rb_mysql_result_to_obj (result );
939
937
/* pass-through query options for result construction later */
940
- rb_iv_set (resultObj , "@query_options" , rb_hash_dup (rb_iv_get (self , "@query_options " )));
938
+ rb_iv_set (resultObj , "@query_options" , rb_hash_dup (rb_iv_get (self , "@current_query_options " )));
941
939
942
940
#ifdef HAVE_RUBY_ENCODING_H
943
941
GetMysql2Result (resultObj , result_wrapper );
@@ -1134,6 +1132,7 @@ void init_mysql2_client() {
1134
1132
sym_stream = ID2SYM (rb_intern ("stream" ));
1135
1133
1136
1134
intern_merge = rb_intern ("merge" );
1135
+ intern_merge_bang = rb_intern ("merge!" );
1137
1136
intern_error_number_eql = rb_intern ("error_number=" );
1138
1137
intern_sql_state_eql = rb_intern ("sql_state=" );
1139
1138
0 commit comments