|
16 | 16 |
|
17 | 17 | VALUE cMysql2Client; |
18 | 18 | extern VALUE mMysql2, cMysql2Error; |
19 | | -static VALUE sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, sym_array, sym_stream; |
| 19 | +static VALUE sym_id, sym_version, sym_header_version, sym_async, sym_symbolize_keys, sym_as, sym_array, sym_stream; |
20 | 20 | static ID intern_merge, intern_merge_bang, intern_error_number_eql, intern_sql_state_eql; |
21 | 21 | static ID intern_brackets, intern_new; |
22 | 22 |
|
@@ -824,30 +824,23 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) { |
824 | 824 | * |
825 | 825 | * Returns a string that represents the client library version. |
826 | 826 | */ |
827 | | -static VALUE rb_mysql_client_info(VALUE self) { |
828 | | - VALUE version, client_info; |
829 | | -#ifdef HAVE_RUBY_ENCODING_H |
830 | | - rb_encoding *default_internal_enc; |
831 | | - rb_encoding *conn_enc; |
832 | | - GET_CLIENT(self); |
833 | | -#endif |
834 | | - version = rb_hash_new(); |
| 827 | +static VALUE rb_mysql_client_info(RB_MYSQL_UNUSED VALUE klass) { |
| 828 | + VALUE version_info, version, header_version; |
| 829 | + version_info = rb_hash_new(); |
835 | 830 |
|
836 | | -#ifdef HAVE_RUBY_ENCODING_H |
837 | | - default_internal_enc = rb_default_internal_encoding(); |
838 | | - conn_enc = rb_to_encoding(wrapper->encoding); |
839 | | -#endif |
| 831 | + version = rb_str_new2(mysql_get_client_info()); |
| 832 | + header_version = rb_str_new2(MYSQL_LINK_VERSION); |
840 | 833 |
|
841 | | - rb_hash_aset(version, sym_id, LONG2NUM(mysql_get_client_version())); |
842 | | - client_info = rb_str_new2(mysql_get_client_info()); |
843 | 834 | #ifdef HAVE_RUBY_ENCODING_H |
844 | | - rb_enc_associate(client_info, conn_enc); |
845 | | - if (default_internal_enc) { |
846 | | - client_info = rb_str_export_to_enc(client_info, default_internal_enc); |
847 | | - } |
| 835 | + rb_enc_associate(version, rb_usascii_encoding()); |
| 836 | + rb_enc_associate(header_version, rb_usascii_encoding()); |
848 | 837 | #endif |
849 | | - rb_hash_aset(version, sym_version, client_info); |
850 | | - return version; |
| 838 | + |
| 839 | + rb_hash_aset(version_info, sym_id, LONG2NUM(mysql_get_client_version())); |
| 840 | + rb_hash_aset(version_info, sym_version, version); |
| 841 | + rb_hash_aset(version_info, sym_header_version, header_version); |
| 842 | + |
| 843 | + return version_info; |
851 | 844 | } |
852 | 845 |
|
853 | 846 | /* call-seq: |
@@ -1244,11 +1237,11 @@ void init_mysql2_client() { |
1244 | 1237 | rb_define_alloc_func(cMysql2Client, allocate); |
1245 | 1238 |
|
1246 | 1239 | rb_define_singleton_method(cMysql2Client, "escape", rb_mysql_client_escape, 1); |
| 1240 | + rb_define_singleton_method(cMysql2Client, "info", rb_mysql_client_info, 0); |
1247 | 1241 |
|
1248 | 1242 | rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0); |
1249 | 1243 | rb_define_method(cMysql2Client, "abandon_results!", rb_mysql_client_abandon_results, 0); |
1250 | 1244 | rb_define_method(cMysql2Client, "escape", rb_mysql_client_real_escape, 1); |
1251 | | - rb_define_method(cMysql2Client, "info", rb_mysql_client_info, 0); |
1252 | 1245 | rb_define_method(cMysql2Client, "server_info", rb_mysql_client_server_info, 0); |
1253 | 1246 | rb_define_method(cMysql2Client, "socket", rb_mysql_client_socket, 0); |
1254 | 1247 | rb_define_method(cMysql2Client, "async_result", rb_mysql_client_async_result, 0); |
@@ -1284,6 +1277,7 @@ void init_mysql2_client() { |
1284 | 1277 |
|
1285 | 1278 | sym_id = ID2SYM(rb_intern("id")); |
1286 | 1279 | sym_version = ID2SYM(rb_intern("version")); |
| 1280 | + sym_header_version = ID2SYM(rb_intern("header_version")); |
1287 | 1281 | sym_async = ID2SYM(rb_intern("async")); |
1288 | 1282 | sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); |
1289 | 1283 | sym_as = ID2SYM(rb_intern("as")); |
|
0 commit comments