@@ -642,40 +642,30 @@ static VALUE rb_mysql_client_abandon_results(VALUE self) {
642
642
* Query the database with +sql+, with optional +options+. For the possible
643
643
* options, see @@default_query_options on the Mysql2::Client class.
644
644
*/
645
- static VALUE rb_mysql_client_query ( int argc , VALUE * argv , VALUE self ) {
645
+ static VALUE rb_query ( VALUE self , VALUE sql , VALUE current ) {
646
646
#ifndef _WIN32
647
647
struct async_query_args async_args ;
648
648
#endif
649
649
struct nogvl_send_query_args args ;
650
650
int async = 0 ;
651
- VALUE opts , current ;
652
651
VALUE thread_current = rb_thread_current ();
653
- #ifdef HAVE_RUBY_ENCODING_H
654
- rb_encoding * conn_enc ;
655
- #endif
656
652
GET_CLIENT (self );
657
653
658
654
REQUIRE_CONNECTED (wrapper );
659
655
args .mysql = wrapper -> client ;
660
656
661
- current = rb_hash_dup (rb_iv_get (self , "@query_options" ));
662
657
RB_GC_GUARD (current );
663
658
Check_Type (current , T_HASH );
664
659
rb_iv_set (self , "@current_query_options" , current );
665
660
666
- if (rb_scan_args (argc , argv , "11" , & args .sql , & opts ) == 2 ) {
667
- rb_funcall (current , intern_merge_bang , 1 , opts );
668
-
669
- if (rb_hash_aref (current , sym_async ) == Qtrue ) {
670
- async = 1 ;
671
- }
672
- }
661
+ async = rb_hash_aref (current , sym_async ) == Qtrue ;
673
662
674
- Check_Type (args . sql , T_STRING );
663
+ Check_Type (sql , T_STRING );
675
664
#ifdef HAVE_RUBY_ENCODING_H
676
- conn_enc = rb_to_encoding (wrapper -> encoding );
677
665
/* ensure the string is in the encoding the connection is expecting */
678
- args .sql = rb_str_export_to_enc (args .sql , conn_enc );
666
+ args .sql = rb_str_export_to_enc (sql , rb_to_encoding (wrapper -> encoding ));
667
+ #else
668
+ args .sql = sql ;
679
669
#endif
680
670
args .sql_ptr = RSTRING_PTR (args .sql );
681
671
args .sql_len = RSTRING_LEN (args .sql );
@@ -1279,7 +1269,6 @@ void init_mysql2_client() {
1279
1269
rb_define_method (cMysql2Client , "encoding" , rb_mysql_client_encoding , 0 );
1280
1270
#endif
1281
1271
1282
- rb_define_private_method (cMysql2Client , "_query" , rb_mysql_client_query , -1 );
1283
1272
rb_define_private_method (cMysql2Client , "connect_timeout=" , set_connect_timeout , 1 );
1284
1273
rb_define_private_method (cMysql2Client , "read_timeout=" , set_read_timeout , 1 );
1285
1274
rb_define_private_method (cMysql2Client , "write_timeout=" , set_write_timeout , 1 );
@@ -1292,6 +1281,7 @@ void init_mysql2_client() {
1292
1281
rb_define_private_method (cMysql2Client , "ssl_set" , set_ssl_options , 5 );
1293
1282
rb_define_private_method (cMysql2Client , "initialize_ext" , initialize_ext , 0 );
1294
1283
rb_define_private_method (cMysql2Client , "connect" , rb_connect , 7 );
1284
+ rb_define_private_method (cMysql2Client , "_query" , rb_query , 2 );
1295
1285
1296
1286
sym_id = ID2SYM (rb_intern ("id" ));
1297
1287
sym_version = ID2SYM (rb_intern ("version" ));
0 commit comments