|
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 |
|
22 | 22 | #ifndef HAVE_RB_HASH_DUP |
@@ -843,30 +843,23 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) { |
843 | 843 | * |
844 | 844 | * Returns a string that represents the client library version. |
845 | 845 | */ |
846 | | -static VALUE rb_mysql_client_info(VALUE self) { |
847 | | - VALUE version, client_info; |
848 | | -#ifdef HAVE_RUBY_ENCODING_H |
849 | | - rb_encoding *default_internal_enc; |
850 | | - rb_encoding *conn_enc; |
851 | | - GET_CLIENT(self); |
852 | | -#endif |
853 | | - version = rb_hash_new(); |
| 846 | +static VALUE rb_mysql_client_info(RB_MYSQL_UNUSED VALUE klass) { |
| 847 | + VALUE version_info, version, header_version; |
| 848 | + version_info = rb_hash_new(); |
854 | 849 |
|
855 | | -#ifdef HAVE_RUBY_ENCODING_H |
856 | | - default_internal_enc = rb_default_internal_encoding(); |
857 | | - conn_enc = rb_to_encoding(wrapper->encoding); |
858 | | -#endif |
| 850 | + version = rb_str_new2(mysql_get_client_info()); |
| 851 | + header_version = rb_str_new2(MYSQL_LINK_VERSION); |
859 | 852 |
|
860 | | - rb_hash_aset(version, sym_id, LONG2NUM(mysql_get_client_version())); |
861 | | - client_info = rb_str_new2(mysql_get_client_info()); |
862 | 853 | #ifdef HAVE_RUBY_ENCODING_H |
863 | | - rb_enc_associate(client_info, conn_enc); |
864 | | - if (default_internal_enc) { |
865 | | - client_info = rb_str_export_to_enc(client_info, default_internal_enc); |
866 | | - } |
| 854 | + rb_enc_associate(version, rb_usascii_encoding()); |
| 855 | + rb_enc_associate(header_version, rb_usascii_encoding()); |
867 | 856 | #endif |
868 | | - rb_hash_aset(version, sym_version, client_info); |
869 | | - return version; |
| 857 | + |
| 858 | + rb_hash_aset(version_info, sym_id, LONG2NUM(mysql_get_client_version())); |
| 859 | + rb_hash_aset(version_info, sym_version, version); |
| 860 | + rb_hash_aset(version_info, sym_header_version, header_version); |
| 861 | + |
| 862 | + return version_info; |
870 | 863 | } |
871 | 864 |
|
872 | 865 | /* call-seq: |
@@ -1250,12 +1243,12 @@ void init_mysql2_client() { |
1250 | 1243 | rb_define_alloc_func(cMysql2Client, allocate); |
1251 | 1244 |
|
1252 | 1245 | rb_define_singleton_method(cMysql2Client, "escape", rb_mysql_client_escape, 1); |
| 1246 | + rb_define_singleton_method(cMysql2Client, "info", rb_mysql_client_info, 0); |
1253 | 1247 |
|
1254 | 1248 | rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0); |
1255 | 1249 | rb_define_method(cMysql2Client, "query", rb_mysql_client_query, -1); |
1256 | 1250 | rb_define_method(cMysql2Client, "abandon_results!", rb_mysql_client_abandon_results, 0); |
1257 | 1251 | rb_define_method(cMysql2Client, "escape", rb_mysql_client_real_escape, 1); |
1258 | | - rb_define_method(cMysql2Client, "info", rb_mysql_client_info, 0); |
1259 | 1252 | rb_define_method(cMysql2Client, "server_info", rb_mysql_client_server_info, 0); |
1260 | 1253 | rb_define_method(cMysql2Client, "socket", rb_mysql_client_socket, 0); |
1261 | 1254 | rb_define_method(cMysql2Client, "async_result", rb_mysql_client_async_result, 0); |
@@ -1289,6 +1282,7 @@ void init_mysql2_client() { |
1289 | 1282 |
|
1290 | 1283 | sym_id = ID2SYM(rb_intern("id")); |
1291 | 1284 | sym_version = ID2SYM(rb_intern("version")); |
| 1285 | + sym_header_version = ID2SYM(rb_intern("header_version")); |
1292 | 1286 | sym_async = ID2SYM(rb_intern("async")); |
1293 | 1287 | sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); |
1294 | 1288 | sym_as = ID2SYM(rb_intern("as")); |
|
0 commit comments