mysql2 0.3.12b3 → 0.3.12b4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mysql2 (0.3.12b3)
4
+ mysql2 (0.3.12b4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -618,6 +618,11 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
618
618
  retval = &intval;
619
619
  break;
620
620
 
621
+ case MYSQL_OPT_WRITE_TIMEOUT:
622
+ intval = NUM2INT(value);
623
+ retval = &intval;
624
+ break;
625
+
621
626
  case MYSQL_OPT_LOCAL_INFILE:
622
627
  intval = (value == Qfalse ? 0 : 1);
623
628
  retval = &intval;
@@ -909,6 +914,12 @@ static VALUE set_local_infile(VALUE self, VALUE value) {
909
914
  }
910
915
 
911
916
  static VALUE set_connect_timeout(VALUE self, VALUE value) {
917
+ long int sec;
918
+ Check_Type(value, T_FIXNUM);
919
+ sec = FIX2INT(value);
920
+ if (sec < 0) {
921
+ rb_raise(cMysql2Error, "connect_timeout must be a positive integer, you passed %ld", sec);
922
+ }
912
923
  return _mysql_client_options(self, MYSQL_OPT_CONNECT_TIMEOUT, value);
913
924
  }
914
925
 
@@ -926,6 +937,16 @@ static VALUE set_read_timeout(VALUE self, VALUE value) {
926
937
  return _mysql_client_options(self, MYSQL_OPT_READ_TIMEOUT, value);
927
938
  }
928
939
 
940
+ static VALUE set_write_timeout(VALUE self, VALUE value) {
941
+ long int sec;
942
+ Check_Type(value, T_FIXNUM);
943
+ sec = FIX2INT(value);
944
+ if (sec < 0) {
945
+ rb_raise(cMysql2Error, "write_timeout must be a positive integer, you passed %ld", sec);
946
+ }
947
+ return _mysql_client_options(self, MYSQL_OPT_WRITE_TIMEOUT, value);
948
+ }
949
+
929
950
  static VALUE set_charset_name(VALUE self, VALUE value) {
930
951
  char * charset_name;
931
952
  #ifdef HAVE_RUBY_ENCODING_H
@@ -1032,6 +1053,7 @@ void init_mysql2_client() {
1032
1053
  rb_define_private_method(cMysql2Client, "reconnect=", set_reconnect, 1);
1033
1054
  rb_define_private_method(cMysql2Client, "connect_timeout=", set_connect_timeout, 1);
1034
1055
  rb_define_private_method(cMysql2Client, "read_timeout=", set_read_timeout, 1);
1056
+ rb_define_private_method(cMysql2Client, "write_timeout=", set_write_timeout, 1);
1035
1057
  rb_define_private_method(cMysql2Client, "local_infile=", set_local_infile, 1);
1036
1058
  rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1);
1037
1059
  rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
@@ -21,7 +21,7 @@ module Mysql2
21
21
  initialize_ext
22
22
 
23
23
  # Set MySQL connection options (each one is a call to mysql_options())
24
- [:reconnect, :connect_timeout, :local_infile, :read_timeout].each do |key|
24
+ [:reconnect, :connect_timeout, :local_infile, :read_timeout, :write_timeout].each do |key|
25
25
  next unless opts.key?(key)
26
26
  send(:"#{key}=", opts[key])
27
27
  end
@@ -30,7 +30,7 @@ module Mysql2
30
30
  self.charset_name = opts[:encoding] || 'utf8'
31
31
 
32
32
  ssl_set(*opts.values_at(:sslkey, :sslcert, :sslca, :sslcapath, :sslcipher))
33
-
33
+
34
34
  if [:user,:pass,:hostname,:dbname,:db,:sock].any?{|k| @query_options.has_key?(k) }
35
35
  warn "============= WARNING FROM mysql2 ============="
36
36
  warn "The options :user, :pass, :hostname, :dbname, :db, and :sock will be deprecated at some point in the future."
@@ -1,3 +1,3 @@
1
1
  module Mysql2
2
- VERSION = "0.3.12b3"
2
+ VERSION = "0.3.12b4"
3
3
  end
@@ -85,12 +85,24 @@ describe Mysql2::Client do
85
85
  @client.should respond_to(:query)
86
86
  end
87
87
 
88
+ it "should expect connect_timeout to be a positive integer" do
89
+ lambda {
90
+ Mysql2::Client.new(:connect_timeout => -1)
91
+ }.should raise_error(Mysql2::Error)
92
+ end
93
+
88
94
  it "should expect read_timeout to be a positive integer" do
89
95
  lambda {
90
96
  Mysql2::Client.new(:read_timeout => -1)
91
97
  }.should raise_error(Mysql2::Error)
92
98
  end
93
99
 
100
+ it "should expect write_timeout to be a positive integer" do
101
+ lambda {
102
+ Mysql2::Client.new(:write_timeout => -1)
103
+ }.should raise_error(Mysql2::Error)
104
+ end
105
+
94
106
  context "#query" do
95
107
  it "should let you query again if iterating is finished when streaming" do
96
108
  @client.query("SELECT 1 UNION SELECT 2", :stream => true, :cache_rows => false).each {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12b3
4
+ version: 0.3.12b4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: