make sure the query string is converted to the connection's encoding before it's handed to libmysql

This commit is contained in:
Brian Lopez 2010-07-08 22:51:19 -07:00
parent e385e7cf6b
commit ab032b99db

View File

@ -221,6 +221,12 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
} }
} }
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding"));
// ensure the string is in the encoding the connection is expecting
args.sql = rb_str_export_to_enc(args.sql, conn_enc);
#endif
Check_Type(args.sql, T_STRING); Check_Type(args.sql, T_STRING);
Data_Get_Struct(self, MYSQL, client); Data_Get_Struct(self, MYSQL, client);