do_mysql 0.10.0-x86-mingw32 → 0.10.1-x86-mingw32

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.
Files changed (44) hide show
  1. data/ChangeLog.markdown +27 -0
  2. data/LICENSE +1 -1
  3. data/README.markdown +104 -3
  4. data/Rakefile +56 -9
  5. data/ext/do_mysql/compat.h +55 -0
  6. data/ext/{do_mysql_ext/do_mysql_ext.c → do_mysql/do_mysql.c} +34 -57
  7. data/ext/{do_mysql_ext → do_mysql}/error.h +0 -0
  8. data/ext/{do_mysql_ext → do_mysql}/extconf.rb +15 -8
  9. data/lib/do_mysql.rb +27 -11
  10. data/lib/do_mysql/1.8/do_mysql.so +0 -0
  11. data/lib/do_mysql/1.9/do_mysql.so +0 -0
  12. data/lib/do_mysql/version.rb +1 -1
  13. data/spec/command_spec.rb +2 -2
  14. data/spec/connection_spec.rb +16 -14
  15. data/spec/encoding_spec.rb +2 -1
  16. data/spec/reader_spec.rb +1 -1
  17. data/spec/result_spec.rb +3 -3
  18. data/spec/spec_helper.rb +21 -31
  19. data/spec/typecast/array_spec.rb +1 -1
  20. data/spec/typecast/bigdecimal_spec.rb +2 -2
  21. data/spec/typecast/boolean_spec.rb +2 -2
  22. data/spec/typecast/byte_array_spec.rb +1 -1
  23. data/spec/typecast/class_spec.rb +1 -1
  24. data/spec/typecast/date_spec.rb +2 -2
  25. data/spec/typecast/datetime_spec.rb +2 -2
  26. data/spec/typecast/float_spec.rb +2 -2
  27. data/spec/typecast/integer_spec.rb +1 -1
  28. data/spec/typecast/nil_spec.rb +3 -3
  29. data/spec/typecast/other_spec.rb +8 -0
  30. data/spec/typecast/range_spec.rb +1 -1
  31. data/spec/typecast/string_spec.rb +1 -1
  32. data/spec/typecast/time_spec.rb +1 -1
  33. data/tasks/compile.rake +65 -0
  34. data/tasks/release.rake +12 -71
  35. data/tasks/retrieve.rake +1 -1
  36. data/tasks/spec.rake +19 -15
  37. metadata +65 -38
  38. data/HISTORY.markdown +0 -17
  39. data/Manifest.txt +0 -32
  40. data/lib/do_mysql_ext.so +0 -0
  41. data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -3
  42. data/tasks/gem.rake +0 -8
  43. data/tasks/install.rake +0 -15
  44. data/tasks/native.rake +0 -31
@@ -0,0 +1,27 @@
1
+ ## 0.10.1 (unreleased, in git)
2
+
3
+ * Support for Ruby 1.8 and 1.9 on Windows.
4
+ * Switch to Jeweler for Gem building tasks (this change may be temporary).
5
+ * Switch to using Bacon for running specs: This should make specs friendlier to
6
+ new Ruby implementations that are not yet 100% MRI-compatible, and in turn,
7
+ prepared the road for our own IronRuby and MacRuby support.
8
+ * Switch to the newly added rake-compiler `JavaExtensionTask` for compiling
9
+ JRuby extensions, instead of our (broken) home-grown solution.
10
+
11
+ ## 0.10.0 2009-09-15
12
+ * Improvements
13
+ * JRuby Support (using *do_jdbc*)
14
+
15
+ ## 0.9.12 2009-05-17
16
+ * Improvements
17
+ * Windows support
18
+
19
+ ## 0.9.11 2009-01-19
20
+ * Improvements
21
+ * Ruby 1.9 support
22
+ * Fixes
23
+ * Reconnecting now works properly
24
+
25
+ ## 0.9.9 2008-11-27
26
+ * Improvements
27
+ * Added initial support for Ruby 1.9 [John Harrison]
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007, 2008, 2009 Yehuda Katz, Dirkjan Bussink
1
+ Copyright (c) 2007 - 2010 Yehuda Katz, Dirkjan Bussink
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,4 +1,105 @@
1
- do_mysql
2
- ========
1
+ # do_mysql
3
2
 
4
- A MySQL driver for DataObjects
3
+ * <http://dataobjects.info>
4
+
5
+ ## Description
6
+
7
+ A MySQL driver for DataObjects.
8
+
9
+ ## Features/Problems
10
+
11
+ This driver implements the DataObjects API for the MySQL relational database.
12
+
13
+ ## Synopsis
14
+
15
+ An example of usage:
16
+
17
+ # default user (root, no password); default port (3306)
18
+ DataObjects::Connection.new("mysql://host/database")
19
+ # specified user, specified port
20
+ DataObjects::Connection.new("mysql://user:pass@host:8888/database")
21
+
22
+ @connection = DataObjects::Connection.new("mysql://localhost/employees")
23
+ @reader = @connection.create_command('SELECT * FROM users').execute_reader
24
+ @reader.next!
25
+
26
+ In the future, the `Connection` constructor will be able to be passed either a
27
+ DataObjects-style URL or JDBC style URL, when using do\_mysql on JRuby. However,
28
+ this feature is not currently working reliably and is a known issue.
29
+
30
+ ## Requirements
31
+
32
+ This driver is provided for the following platforms:
33
+ * Ruby MRI (1.8.6/7), 1.9: tested on Linux, Mac OS X and Windows platforms.
34
+ * JRuby 1.3.1 + (1.4+ recommended).
35
+ * Rubinius (experimental).
36
+
37
+ Additionally you should have the following prerequisites:
38
+ * `data_objects` gem
39
+ * `do_jdbc` gem (shared library), if running on JRuby.
40
+
41
+ ## Install
42
+
43
+ To install the gem:
44
+
45
+ gem install do_mysql
46
+
47
+ If installing the MRI/1.9/Rubinius extension on OS X and you install a version
48
+ of MySQL that was built for only a single architecture, you will need to set
49
+ `ARCHFLAGS` appropriately:
50
+
51
+ sudo env ARCHFLAGS="-arch i386" gem install do_mysql
52
+
53
+ To compile and install from source:
54
+
55
+ * Install rake-compiler: `gem install rake-compiler`.
56
+
57
+ * For MRI/Rubinius extensions:
58
+ * Install the `gcc` compiler. On OS X, you should install XCode tools. On
59
+ Ubuntu, run `apt-get install build-essential`.
60
+ * Install Ruby and MySQL.
61
+ * Install the Ruby and MySQL development headers.
62
+ * On Debian-Linux distributions, you can install the following packages
63
+ with `apt`: `ruby-dev` `libmysqlclient15-dev`.
64
+ * If you want to cross-compile for Windows:
65
+ * Install MinGW:
66
+ * On Debian-Linux distributions, you can install the following package
67
+ with `apt`: `mingw32`.
68
+ * On OS X, this can install the following package with MacPorts: `i386-mingw32-gcc`.
69
+ * Run `rake-compiler cross-ruby`.
70
+ * Run `rake-compiler update-config`.
71
+
72
+ * Then, install this driver with `(jruby -S) rake install`.
73
+
74
+ For more information, see the MySQL driver wiki page:
75
+ <http://wiki.github.com/datamapper/do/mysql>.
76
+
77
+ ## Developers
78
+
79
+ Follow the above installation instructions. Additionally, you'll need:
80
+ * `bacon` gem for running specs.
81
+ * `YARD` gem for generating documentation.
82
+
83
+ See the DataObjects wiki for more comprehensive information on installing and
84
+ contributing to the JRuby-variant of this driver:
85
+ <http://wiki.github.com/datamapper/do/jruby>.
86
+
87
+ To run specs:
88
+
89
+ rake spec
90
+
91
+ To run specs without compiling extensions first:
92
+
93
+ rake spec_no_compile
94
+
95
+ To run individual specs:
96
+
97
+ rake spec TEST=spec/connection_spec.rb
98
+
99
+ (Note that the `rake` task uses a `TEST` parameter, not `SPEC`. This is because
100
+ the `Rake::TestTask` is used for executing the Bacon specs).
101
+
102
+ ## License
103
+
104
+ This code is licensed under an **MIT (X11) License**. Please see the
105
+ accompanying `LICENSE` file.
data/Rakefile CHANGED
@@ -1,16 +1,63 @@
1
+ require 'pathname'
1
2
  require 'rubygems'
2
3
  require 'rake'
3
4
  require 'rake/clean'
4
5
 
5
- require 'pathname'
6
- require 'lib/do_mysql/version'
6
+ ROOT = Pathname(__FILE__).dirname.expand_path
7
+
8
+ require ROOT + 'lib/do_mysql/version'
9
+
10
+ JRUBY = RUBY_PLATFORM =~ /java/
11
+ IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
12
+ WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
13
+ SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
14
+ BINARY_VERSION = '5.0.89'
15
+
16
+ CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_mysql/Makefile ext-java/target ])
17
+
18
+ begin
19
+ gem 'jeweler', '~> 1.4'
20
+ require 'jeweler'
21
+
22
+ Jeweler::Tasks.new do |gem|
23
+ gem.name = 'do_mysql'
24
+ gem.version = DataObjects::Mysql::VERSION
25
+ gem.summary = 'DataObjects MySQL Driver'
26
+ gem.description = 'Implements the DataObjects API for MySQL'
27
+ gem.platform = Gem::Platform::RUBY
28
+ gem.files = Dir['lib/**/*.rb', 'spec/**/*.rb', 'tasks/**/*.rake',
29
+ 'ext/**/*.{rb,c,h}', 'LICENSE', 'Rakefile',
30
+ '*.{markdown,rdoc,txt,yml}']
31
+ gem.extra_rdoc_files = FileList['README*', 'ChangeLog*', 'LICENSE']
32
+ gem.test_files = FileList['spec/**/*.rb']
33
+
34
+ # rake-compiler should generate gemspecs for other platforms (e.g. 'java')
35
+ # and modify dependencies and extensions appropriately
36
+ gem.extensions << 'ext/do_mysql/extconf.rb'
37
+
38
+ gem.add_dependency 'data_objects', DataObjects::Mysql::VERSION
39
+
40
+ gem.add_development_dependency 'bacon', '~>1.1'
41
+ gem.add_development_dependency 'rake-compiler', '~>0.7'
42
+
43
+ gem.has_rdoc = false
44
+ gem.rubyforge_project = 'dorb'
45
+ gem.authors = [ 'Dirkjan Bussink' ]
46
+ gem.email = 'd.bussink@gmail.com'
47
+ end
7
48
 
8
- ROOT = Pathname(__FILE__).dirname.expand_path
9
- JRUBY = RUBY_PLATFORM =~ /java/
10
- WINDOWS = Gem.win_platform?
11
- SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
12
- BINARY_VERSION = '5.0.85'
49
+ if JRUBY
50
+ Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build')
51
+ Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install')
52
+ task :build => [ :java, :gem ]
53
+ task :install do
54
+ sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_mysql-#{DataObjects::Mysql::VERSION}-java.gem"
55
+ end
56
+ end
13
57
 
14
- Dir['tasks/*.rake'].sort.each { |f| import f }
58
+ Jeweler::GemcutterTasks.new
15
59
 
16
- CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_mysql_ext/Makefile ext-java/target ])
60
+ FileList['tasks/**/*.rake'].each { |task| import task }
61
+ rescue LoadError
62
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
63
+ end
@@ -0,0 +1,55 @@
1
+ #ifndef RUBY_COMPAT_H
2
+ #define RUBY_COMPAT_H
3
+
4
+ /*
5
+ * Rules for better ruby C extensions:
6
+ *
7
+ * Never use the R<TYPE> macros directly, always use R<TYPE>_<FIELD>
8
+ *
9
+ * Never compare with RBASIC(obj)->klass, always use
10
+ * rb_obj_is_instance_of()
11
+ *
12
+ * Never use RHASH(obj)->tbl or RHASH_TBL().
13
+ *
14
+ */
15
+
16
+
17
+ // Array
18
+ #ifndef RARRAY_PTR
19
+ #define RARRAY_PTR(obj) RARRAY(obj)->ptr
20
+ #endif
21
+
22
+ #ifndef RARRAY_LEN
23
+ #define RARRAY_LEN(obj) RARRAY(obj)->len
24
+ #endif
25
+
26
+ // String
27
+ #ifndef RSTRING_PTR
28
+ #define RSTRING_PTR(obj) RSTRING(obj)->ptr
29
+ #endif
30
+
31
+ #ifndef RSTRING_LEN
32
+ #define RSTRING_LEN(obj) RSTRING(obj)->len
33
+ #endif
34
+
35
+ #ifndef rb_str_ptr
36
+ #define rb_str_ptr(str) RSTRING_PTR(str)
37
+ #endif
38
+
39
+ #ifndef rb_str_ptr_readonly
40
+ #define rb_str_ptr_readonly(str) RSTRING_PTR(str)
41
+ #endif
42
+
43
+ #ifndef rb_str_flush
44
+ #define rb_str_flush(str)
45
+ #endif
46
+
47
+ #ifndef rb_str_update
48
+ #define rb_str_update(str)
49
+ #endif
50
+
51
+ #ifndef rb_str_len
52
+ #define rb_str_len(str) RSTRING_LEN(str)
53
+ #endif
54
+
55
+ #endif
@@ -3,28 +3,18 @@
3
3
  #include <math.h>
4
4
  #include <ctype.h>
5
5
  #include <time.h>
6
+
6
7
  #include <mysql.h>
7
8
  #include <errmsg.h>
8
9
  #include <mysqld_error.h>
9
- #include "error.h"
10
10
 
11
+ #include "compat.h"
12
+ #include "error.h"
11
13
  #define RUBY_CLASS(name) rb_const_get(rb_cObject, rb_intern(name))
12
14
  #define DRIVER_CLASS(klass, parent) (rb_define_class_under(mDOMysql, klass, parent))
13
15
  #define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
14
16
  #define CHECK_AND_RAISE(mysql_result_value, query) if (0 != mysql_result_value) { raise_error(self, db, query); }
15
17
 
16
- #ifndef RSTRING_PTR
17
- #define RSTRING_PTR(s) (RSTRING(s)->ptr)
18
- #endif
19
-
20
- #ifndef RSTRING_LEN
21
- #define RSTRING_LEN(s) (RSTRING(s)->len)
22
- #endif
23
-
24
- #ifndef RARRAY_LEN
25
- #define RARRAY_LEN(a) RARRAY(a)->len
26
- #endif
27
-
28
18
  #ifdef _WIN32
29
19
  #define cCommand_execute cCommand_execute_sync
30
20
  #define do_int64 signed __int64
@@ -166,7 +156,7 @@ static int jd_from_date(int year, int month, int day) {
166
156
  }
167
157
  a = year / 100;
168
158
  b = 2 - a + (a / 4);
169
- return floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524;
159
+ return (int) (floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524);
170
160
  }
171
161
 
172
162
  static VALUE seconds_to_offset(long seconds_offset) {
@@ -233,7 +223,7 @@ static VALUE parse_date_time(const char *date) {
233
223
  do_int64 num, den;
234
224
 
235
225
 
236
- long int gmt_offset;
226
+ time_t gmt_offset;
237
227
  int is_dst;
238
228
 
239
229
  time_t rawtime;
@@ -285,8 +275,8 @@ static VALUE parse_date_time(const char *date) {
285
275
  if ( is_dst > 0 )
286
276
  gmt_offset -= is_dst;
287
277
 
288
- hour_offset = -(gmt_offset / 3600);
289
- minute_offset = -(gmt_offset % 3600 / 60);
278
+ hour_offset = -((int)gmt_offset / 3600);
279
+ minute_offset = -((int)gmt_offset % 3600 / 60);
290
280
 
291
281
  } else {
292
282
  // Something went terribly wrong
@@ -349,7 +339,7 @@ static VALUE typecast(const char *value, long length, const VALUE type, int enco
349
339
  } else if (type == rb_cByteArray) {
350
340
  return rb_funcall(rb_cByteArray, ID_NEW, 1, rb_str_new(value, length));
351
341
  } else if (type == rb_cClass) {
352
- return rb_funcall(rb_cObject, rb_intern("full_const_get"), 1, rb_str_new(value, length));
342
+ return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new(value, length));
353
343
  } else if (type == rb_cObject) {
354
344
  return rb_marshal_load(rb_str_new(value, length));
355
345
  } else if (type == rb_cNilClass) {
@@ -364,8 +354,8 @@ static void data_objects_debug(VALUE string, struct timeval* start) {
364
354
  struct timeval stop;
365
355
  char *message;
366
356
 
367
- char *query = RSTRING_PTR(string);
368
- int length = RSTRING_LEN(string);
357
+ const char *query = rb_str_ptr_readonly(string);
358
+ size_t length = rb_str_len(string);
369
359
  char total_time[32];
370
360
  do_int64 duration = 0;
371
361
 
@@ -410,7 +400,7 @@ static void raise_error(VALUE self, MYSQL *db, VALUE query) {
410
400
  rb_exc_raise(exception);
411
401
  }
412
402
 
413
- static char * get_uri_option(VALUE query_hash, char * key) {
403
+ static char * get_uri_option(VALUE query_hash, const char * key) {
414
404
  VALUE query_value;
415
405
  char * value = NULL;
416
406
 
@@ -425,10 +415,10 @@ static char * get_uri_option(VALUE query_hash, char * key) {
425
415
  return value;
426
416
  }
427
417
 
428
- static void assert_file_exists(char * file, char * message) {
418
+ static void assert_file_exists(char * file, const char * message) {
429
419
  if (file == NULL) { return; }
430
420
  if (rb_funcall(rb_cFile, rb_intern("exist?"), 1, rb_str_new2(file)) == Qfalse) {
431
- rb_raise(eArgumentError, message);
421
+ rb_raise(eArgumentError, "%s", message);
432
422
  }
433
423
  }
434
424
 
@@ -438,8 +428,8 @@ static void full_connect(VALUE self, MYSQL *db);
438
428
  static MYSQL_RES* cCommand_execute_sync(VALUE self, MYSQL* db, VALUE query) {
439
429
  int retval;
440
430
  struct timeval start;
441
- char* str = RSTRING_PTR(query);
442
- int len = RSTRING_LEN(query);
431
+ const char* str = rb_str_ptr_readonly(query);
432
+ int len = rb_str_len(query);
443
433
 
444
434
  if(mysql_ping(db) && mysql_errno(db) == CR_SERVER_GONE_ERROR) {
445
435
  // Ok, we do one more try here by doing a full connect
@@ -448,10 +438,10 @@ static MYSQL_RES* cCommand_execute_sync(VALUE self, MYSQL* db, VALUE query) {
448
438
  }
449
439
  gettimeofday(&start, NULL);
450
440
  retval = mysql_real_query(db, str, len);
451
- CHECK_AND_RAISE(retval, query);
452
-
453
441
  data_objects_debug(query, &start);
454
442
 
443
+ CHECK_AND_RAISE(retval, query);
444
+
455
445
  return mysql_store_result(db);
456
446
  }
457
447
  #else
@@ -460,8 +450,8 @@ static MYSQL_RES* cCommand_execute_async(VALUE self, MYSQL* db, VALUE query) {
460
450
  int retval;
461
451
  fd_set rset;
462
452
  struct timeval start;
463
- char* str = RSTRING_PTR(query);
464
- int len = RSTRING_LEN(query);
453
+ const char* str = rb_str_ptr_readonly(query);
454
+ size_t len = rb_str_len(query);
465
455
 
466
456
  if((retval = mysql_ping(db)) && mysql_errno(db) == CR_SERVER_GONE_ERROR) {
467
457
  VALUE connection = rb_iv_get(self, "@connection");
@@ -474,6 +464,8 @@ static MYSQL_RES* cCommand_execute_async(VALUE self, MYSQL* db, VALUE query) {
474
464
 
475
465
  socket_fd = db->net.fd;
476
466
 
467
+ data_objects_debug(query, &start);
468
+
477
469
  for(;;) {
478
470
  FD_ZERO(&rset);
479
471
  FD_SET(socket_fd, &rset);
@@ -496,8 +488,6 @@ static MYSQL_RES* cCommand_execute_async(VALUE self, MYSQL* db, VALUE query) {
496
488
  retval = mysql_read_query_result(db);
497
489
  CHECK_AND_RAISE(retval, query);
498
490
 
499
- data_objects_debug(query, &start);
500
-
501
491
  return mysql_store_result(db);
502
492
  }
503
493
  #endif
@@ -507,8 +497,8 @@ static void full_connect(VALUE self, MYSQL* db) {
507
497
  // Check to see if we're on the db machine. If so, try to use the socket
508
498
  VALUE r_host, r_user, r_password, r_path, r_query, r_port;
509
499
 
510
- char *host = "localhost", *user = "root", *password = NULL, *path;
511
- char *database = "", *socket = NULL;
500
+ const char *host = "localhost", *user = "root";
501
+ char *database = NULL, *socket = NULL, *password = NULL, *path = NULL;
512
502
  VALUE encoding = Qnil;
513
503
 
514
504
  MYSQL *result;
@@ -609,17 +599,17 @@ static void full_connect(VALUE self, MYSQL* db) {
609
599
 
610
600
  VALUE my_encoding = rb_hash_aref(CONST_GET(mEncoding, "MAP"), encoding);
611
601
  if(my_encoding != Qnil) {
612
- encoding_error = mysql_set_character_set(db, RSTRING_PTR(my_encoding));
602
+ encoding_error = mysql_set_character_set(db, rb_str_ptr_readonly(my_encoding));
613
603
  if (0 != encoding_error) {
614
604
  raise_error(self, db, Qnil);
615
605
  } else {
616
606
  #ifdef HAVE_RUBY_ENCODING_H
617
- rb_iv_set(self, "@encoding_id", INT2FIX(rb_enc_find_index(RSTRING_PTR(encoding))));
607
+ rb_iv_set(self, "@encoding_id", INT2FIX(rb_enc_find_index(rb_str_ptr_readonly(encoding))));
618
608
  #endif
619
609
  rb_iv_set(self, "@my_encoding", my_encoding);
620
610
  }
621
611
  } else {
622
- rb_warn("Encoding %s is not a known Ruby encoding for MySQL\n", RSTRING_PTR(encoding));
612
+ rb_warn("Encoding %s is not a known Ruby encoding for MySQL\n", rb_str_ptr_readonly(encoding));
623
613
  rb_iv_set(self, "@encoding", rb_str_new2("UTF-8"));
624
614
  #ifdef HAVE_RUBY_ENCODING_H
625
615
  rb_iv_set(self, "@encoding_id", INT2FIX(rb_enc_find_index("UTF-8")));
@@ -699,16 +689,6 @@ static VALUE cConnection_ssl_cipher(VALUE self) {
699
689
  return rb_iv_get(self, "@ssl_cipher");
700
690
  }
701
691
 
702
- static VALUE cConnection_secure(VALUE self) {
703
- VALUE blank_cipher = rb_funcall(rb_iv_get(self, "@ssl_cipher"), rb_intern("blank?"), 0);
704
-
705
- if (blank_cipher == Qtrue) {
706
- return Qfalse;
707
- } else {
708
- return Qtrue;
709
- }
710
- }
711
-
712
692
  static VALUE cConnection_dispose(VALUE self) {
713
693
  VALUE connection_container = rb_iv_get(self, "@connection");
714
694
 
@@ -782,12 +762,12 @@ VALUE cConnection_quote_date(VALUE self, VALUE value) {
782
762
 
783
763
  static VALUE cConnection_quote_string(VALUE self, VALUE string) {
784
764
  MYSQL *db = DATA_PTR(rb_iv_get(self, "@connection"));
785
- const char *source = RSTRING_PTR(string);
786
- int source_len = RSTRING_LEN(string);
765
+ const char *source = rb_str_ptr_readonly(string);
766
+ size_t source_len = rb_str_len(string);
787
767
  char *escaped;
788
768
  VALUE result;
789
769
 
790
- int quoted_length = 0;
770
+ size_t quoted_length = 0;
791
771
 
792
772
  // Allocate space for the escaped version of 'string'. Use + 3 allocate space for null term.
793
773
  // and the leading and trailing single-quotes.
@@ -838,7 +818,7 @@ static VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
838
818
  affected_rows = mysql_affected_rows(db);
839
819
  mysql_free_result(response);
840
820
 
841
- if (-1 == affected_rows)
821
+ if ((my_ulonglong)-1 == affected_rows)
842
822
  return Qnil;
843
823
 
844
824
  return rb_funcall(cResult, ID_NEW, 3, self, INT2NUM(affected_rows), INT2NUM(mysql_insert_id(db)));
@@ -849,7 +829,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
849
829
  VALUE field_names, field_types;
850
830
 
851
831
  unsigned int field_count;
852
- int i;
832
+ unsigned int i;
853
833
 
854
834
  char guess_default_field_types = 0;
855
835
  VALUE connection = rb_iv_get(self, "@connection");
@@ -945,7 +925,7 @@ static VALUE cReader_next(VALUE self) {
945
925
  MYSQL_ROW result;
946
926
  unsigned long *lengths;
947
927
 
948
- int i;
928
+ unsigned int i;
949
929
 
950
930
  if (Qnil == reader_container) {
951
931
  return Qfalse;
@@ -989,9 +969,7 @@ static VALUE cReader_values(VALUE self) {
989
969
  if ( state == Qnil || state == Qfalse ) {
990
970
  rb_raise(eDataError, "Reader is not initialized");
991
971
  }
992
- else {
993
- return rb_iv_get(self, "@values");
994
- }
972
+ return rb_iv_get(self, "@values");
995
973
  }
996
974
 
997
975
  static VALUE cReader_fields(VALUE self) {
@@ -1002,7 +980,7 @@ static VALUE cReader_field_count(VALUE self) {
1002
980
  return rb_iv_get(self, "@field_count");
1003
981
  }
1004
982
 
1005
- void Init_do_mysql_ext() {
983
+ void Init_do_mysql() {
1006
984
  rb_require("bigdecimal");
1007
985
  rb_require("date");
1008
986
 
@@ -1056,7 +1034,6 @@ void Init_do_mysql_ext() {
1056
1034
  rb_define_method(cConnection, "initialize", cConnection_initialize, 1);
1057
1035
  rb_define_method(cConnection, "using_socket?", cConnection_is_using_socket, 0);
1058
1036
  rb_define_method(cConnection, "ssl_cipher", cConnection_ssl_cipher, 0);
1059
- rb_define_method(cConnection, "secure?", cConnection_secure, 0);
1060
1037
  rb_define_method(cConnection, "character_set", cConnection_character_set , 0);
1061
1038
  rb_define_method(cConnection, "dispose", cConnection_dispose, 0);
1062
1039
  rb_define_method(cConnection, "quote_string", cConnection_quote_string, 1);