do_mysql 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,17 @@
1
- ## 0.10.1 (unreleased, in git)
1
+ ## 0.10.2 2010-05-19
2
+ * Make sure Text is returned in the proper encoding
3
+ * Make Encoding.default_internal aware
4
+ * Fix insert_id if no incrementing key is used
5
+ * Rework logging for making callbacks possible
6
+ * Remove handling Object types directly
7
+
8
+ ## 0.10.1 2010-01-08
2
9
 
3
10
  * Support for Ruby 1.8 and 1.9 on Windows.
4
11
  * Switch to Jeweler for Gem building tasks (this change may be temporary).
5
12
  * Switch to using Bacon for running specs: This should make specs friendlier to
6
13
  new Ruby implementations that are not yet 100% MRI-compatible, and in turn,
7
- prepared the road for our own IronRuby and MacRuby support.
14
+ pave the road for our own IronRuby and MacRuby support.
8
15
  * Switch to the newly added rake-compiler `JavaExtensionTask` for compiling
9
16
  JRuby extensions, instead of our (broken) home-grown solution.
10
17
 
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ JRUBY = RUBY_PLATFORM =~ /java/
11
11
  IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
12
12
  WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
13
13
  SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
14
- BINARY_VERSION = '5.0.89'
14
+ BINARY_VERSION = '5.1.46'
15
15
 
16
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
17
 
@@ -10,9 +10,9 @@
10
10
 
11
11
  #include "compat.h"
12
12
  #include "error.h"
13
- #define RUBY_CLASS(name) rb_const_get(rb_cObject, rb_intern(name))
14
- #define DRIVER_CLASS(klass, parent) (rb_define_class_under(mDOMysql, klass, parent))
13
+
15
14
  #define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
15
+ #define DRIVER_CLASS(klass, parent) (rb_define_class_under(mMysql, klass, parent))
16
16
  #define CHECK_AND_RAISE(mysql_result_value, query) if (0 != mysql_result_value) { raise_error(self, db, query); }
17
17
 
18
18
  #ifdef _WIN32
@@ -26,49 +26,48 @@
26
26
  #ifdef HAVE_RUBY_ENCODING_H
27
27
  #include <ruby/encoding.h>
28
28
 
29
- #define DO_STR_NEW2(str, encoding) \
29
+ #define DO_STR_NEW2(str, encoding, internal_encoding) \
30
30
  ({ \
31
31
  VALUE _string = rb_str_new2((const char *)str); \
32
32
  if(encoding != -1) { \
33
33
  rb_enc_associate_index(_string, encoding); \
34
34
  } \
35
+ if(internal_encoding) { \
36
+ _string = rb_str_export_to_enc(_string, internal_encoding); \
37
+ } \
35
38
  _string; \
36
39
  })
37
40
 
38
- #define DO_STR_NEW(str, len, encoding) \
41
+ #define DO_STR_NEW(str, len, encoding, internal_encoding) \
39
42
  ({ \
40
43
  VALUE _string = rb_str_new((const char *)str, (long)len); \
41
44
  if(encoding != -1) { \
42
45
  rb_enc_associate_index(_string, encoding); \
43
46
  } \
47
+ if(internal_encoding) { \
48
+ _string = rb_str_export_to_enc(_string, internal_encoding); \
49
+ } \
44
50
  _string; \
45
51
  })
46
52
 
47
53
  #else
48
54
 
49
- #define DO_STR_NEW2(str, encoding) \
55
+ #define DO_STR_NEW2(str, encoding, internal_encoding) \
50
56
  rb_str_new2((const char *)str)
51
57
 
52
- #define DO_STR_NEW(str, len, encoding) \
58
+ #define DO_STR_NEW(str, len, encoding, internal_encoding) \
53
59
  rb_str_new((const char *)str, (long)len)
54
60
  #endif
55
61
 
56
62
 
57
63
  // To store rb_intern values
58
- static ID ID_TO_I;
59
- static ID ID_TO_F;
60
- static ID ID_TO_S;
61
- static ID ID_TO_TIME;
62
64
  static ID ID_NEW;
63
65
  static ID ID_NEW_DATE;
64
66
  static ID ID_CONST_GET;
65
67
  static ID ID_RATIONAL;
66
- static ID ID_UTC;
67
- static ID ID_ESCAPE_SQL;
68
+ static ID ID_ESCAPE;
68
69
  static ID ID_STRFTIME;
69
- static ID ID_LOGGER;
70
- static ID ID_DEBUG;
71
- static ID ID_LEVEL;
70
+ static ID ID_LOG;
72
71
 
73
72
  // Reference to Extlib module
74
73
  static VALUE mExtlib;
@@ -81,6 +80,8 @@ static VALUE cDO_Connection;
81
80
  static VALUE cDO_Command;
82
81
  static VALUE cDO_Result;
83
82
  static VALUE cDO_Reader;
83
+ static VALUE cDO_Logger;
84
+ static VALUE cDO_Logger_Message;
84
85
 
85
86
  // References to Ruby classes that we'll need
86
87
  static VALUE rb_cDate;
@@ -89,12 +90,11 @@ static VALUE rb_cBigDecimal;
89
90
  static VALUE rb_cByteArray;
90
91
 
91
92
  // Classes that we'll build in Init
92
- static VALUE mDOMysql;
93
+ static VALUE mMysql;
93
94
  static VALUE cConnection;
94
95
  static VALUE cCommand;
95
96
  static VALUE cResult;
96
97
  static VALUE cReader;
97
- static VALUE eArgumentError;
98
98
  static VALUE eConnectionError;
99
99
  static VALUE eDataError;
100
100
 
@@ -124,11 +124,17 @@ static VALUE infer_ruby_type(MYSQL_FIELD *field) {
124
124
  case MYSQL_TYPE_DATE:
125
125
  case MYSQL_TYPE_NEWDATE:
126
126
  return rb_cDate;
127
+ case MYSQL_TYPE_STRING:
128
+ case MYSQL_TYPE_VAR_STRING:
127
129
  case MYSQL_TYPE_TINY_BLOB:
128
130
  case MYSQL_TYPE_MEDIUM_BLOB:
129
131
  case MYSQL_TYPE_LONG_BLOB:
130
132
  case MYSQL_TYPE_BLOB:
131
- return rb_cByteArray;
133
+ if(field->charsetnr == 63) {
134
+ return rb_cByteArray;
135
+ } else {
136
+ return rb_cString;
137
+ }
132
138
  default:
133
139
  return rb_cString;
134
140
  }
@@ -320,10 +326,16 @@ static VALUE typecast(const char *value, long length, const VALUE type, int enco
320
326
  return Qnil;
321
327
  }
322
328
 
329
+ #ifdef HAVE_RUBY_ENCODING_H
330
+ rb_encoding * internal_encoding = rb_default_internal_encoding();
331
+ #else
332
+ void * internal_encoding = NULL;
333
+ #endif
334
+
323
335
  if (type == rb_cInteger) {
324
336
  return rb_cstr2inum(value, 10);
325
337
  } else if (type == rb_cString) {
326
- return DO_STR_NEW(value, length, encoding);
338
+ return DO_STR_NEW(value, length, encoding, internal_encoding);
327
339
  } else if (type == rb_cFloat) {
328
340
  return rb_float_new(rb_cstr_to_dbl(value, Qfalse));
329
341
  } else if (type == rb_cBigDecimal) {
@@ -340,38 +352,24 @@ static VALUE typecast(const char *value, long length, const VALUE type, int enco
340
352
  return rb_funcall(rb_cByteArray, ID_NEW, 1, rb_str_new(value, length));
341
353
  } else if (type == rb_cClass) {
342
354
  return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new(value, length));
343
- } else if (type == rb_cObject) {
344
- return rb_marshal_load(rb_str_new(value, length));
345
355
  } else if (type == rb_cNilClass) {
346
356
  return Qnil;
347
357
  } else {
348
- return DO_STR_NEW(value, length, encoding);
358
+ return DO_STR_NEW(value, length, encoding, internal_encoding);
349
359
  }
350
360
 
351
361
  }
352
362
 
353
- static void data_objects_debug(VALUE string, struct timeval* start) {
363
+ static void data_objects_debug(VALUE connection, VALUE string, struct timeval* start) {
354
364
  struct timeval stop;
355
- char *message;
356
-
357
- const char *query = rb_str_ptr_readonly(string);
358
- size_t length = rb_str_len(string);
359
- char total_time[32];
360
- do_int64 duration = 0;
365
+ VALUE message;
361
366
 
362
- VALUE logger = rb_funcall(mDOMysql, ID_LOGGER, 0);
363
- int log_level = NUM2INT(rb_funcall(logger, ID_LEVEL, 0));
367
+ gettimeofday(&stop, NULL);
368
+ do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
364
369
 
365
- if (0 == log_level) {
366
- gettimeofday(&stop, NULL);
370
+ message = rb_funcall(cDO_Logger_Message, ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
367
371
 
368
- duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
369
-
370
- snprintf(total_time, 32, "%.6f", duration / 1000000.0);
371
- message = (char *)calloc(length + strlen(total_time) + 4, sizeof(char));
372
- snprintf(message, length + strlen(total_time) + 4, "(%s) %s", total_time, query);
373
- rb_funcall(logger, ID_DEBUG, 1, rb_str_new(message, length + strlen(total_time) + 3));
374
- }
372
+ rb_funcall(connection, ID_LOG, 1, message);
375
373
  }
376
374
 
377
375
  static void raise_error(VALUE self, MYSQL *db, VALUE query) {
@@ -418,14 +416,14 @@ static char * get_uri_option(VALUE query_hash, const char * key) {
418
416
  static void assert_file_exists(char * file, const char * message) {
419
417
  if (file == NULL) { return; }
420
418
  if (rb_funcall(rb_cFile, rb_intern("exist?"), 1, rb_str_new2(file)) == Qfalse) {
421
- rb_raise(eArgumentError, "%s", message);
419
+ rb_raise(rb_eArgError, "%s", message);
422
420
  }
423
421
  }
424
422
 
425
423
  static void full_connect(VALUE self, MYSQL *db);
426
424
 
427
425
  #ifdef _WIN32
428
- static MYSQL_RES* cCommand_execute_sync(VALUE self, MYSQL* db, VALUE query) {
426
+ static MYSQL_RES* cCommand_execute_sync(VALUE self, VALUE connection, MYSQL* db, VALUE query) {
429
427
  int retval;
430
428
  struct timeval start;
431
429
  const char* str = rb_str_ptr_readonly(query);
@@ -438,14 +436,14 @@ static MYSQL_RES* cCommand_execute_sync(VALUE self, MYSQL* db, VALUE query) {
438
436
  }
439
437
  gettimeofday(&start, NULL);
440
438
  retval = mysql_real_query(db, str, len);
441
- data_objects_debug(query, &start);
439
+ data_objects_debug(connection, query, &start);
442
440
 
443
441
  CHECK_AND_RAISE(retval, query);
444
442
 
445
443
  return mysql_store_result(db);
446
444
  }
447
445
  #else
448
- static MYSQL_RES* cCommand_execute_async(VALUE self, MYSQL* db, VALUE query) {
446
+ static MYSQL_RES* cCommand_execute_async(VALUE self, VALUE connection, MYSQL* db, VALUE query) {
449
447
  int socket_fd;
450
448
  int retval;
451
449
  fd_set rset;
@@ -454,18 +452,16 @@ static MYSQL_RES* cCommand_execute_async(VALUE self, MYSQL* db, VALUE query) {
454
452
  size_t len = rb_str_len(query);
455
453
 
456
454
  if((retval = mysql_ping(db)) && mysql_errno(db) == CR_SERVER_GONE_ERROR) {
457
- VALUE connection = rb_iv_get(self, "@connection");
458
455
  full_connect(connection, db);
459
456
  }
457
+ gettimeofday(&start, NULL);
458
+
460
459
  retval = mysql_send_query(db, str, len);
461
460
 
462
461
  CHECK_AND_RAISE(retval, query);
463
- gettimeofday(&start, NULL);
464
462
 
465
463
  socket_fd = db->net.fd;
466
464
 
467
- data_objects_debug(query, &start);
468
-
469
465
  for(;;) {
470
466
  FD_ZERO(&rset);
471
467
  FD_SET(socket_fd, &rset);
@@ -487,6 +483,7 @@ static MYSQL_RES* cCommand_execute_async(VALUE self, MYSQL* db, VALUE query) {
487
483
 
488
484
  retval = mysql_read_query_result(db);
489
485
  CHECK_AND_RAISE(retval, query);
486
+ data_objects_debug(connection, query, &start);
490
487
 
491
488
  return mysql_store_result(db);
492
489
  }
@@ -561,7 +558,7 @@ static void full_connect(VALUE self, MYSQL* db) {
561
558
 
562
559
  mysql_ssl_set(db, ssl_client_key, ssl_client_cert, ssl_ca_cert, ssl_ca_path, ssl_cipher);
563
560
  } else if(r_ssl != Qnil) {
564
- rb_raise(eArgumentError, "ssl must be passed a hash");
561
+ rb_raise(rb_eArgError, "ssl must be passed a hash");
565
562
  }
566
563
  }
567
564
  #endif
@@ -618,11 +615,17 @@ static void full_connect(VALUE self, MYSQL* db) {
618
615
  }
619
616
 
620
617
  // Disable sql_auto_is_null
621
- cCommand_execute(self, db, rb_str_new2("SET sql_auto_is_null = 0"));
618
+ cCommand_execute(Qnil, self, db, rb_str_new2("SET sql_auto_is_null = 0"));
622
619
  // removed NO_AUTO_VALUE_ON_ZERO because of MySQL bug http://bugs.mysql.com/bug.php?id=42270
623
620
  // added NO_BACKSLASH_ESCAPES so that backslashes should not be escaped as in other databases
624
- cCommand_execute(self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'"));
625
-
621
+
622
+ //4.x versions do not support certain session parameters
623
+ if(mysql_get_server_version(db) < 50000 ){
624
+ cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_DIR_IN_CREATE,NO_UNSIGNED_SUBTRACTION'"));
625
+ }else{
626
+ cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'"));
627
+ }
628
+
626
629
  rb_iv_set(self, "@connection", Data_Wrap_Struct(rb_cObject, 0, 0, db));
627
630
  }
628
631
 
@@ -732,11 +735,11 @@ static VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self) {
732
735
  if(TYPE(sub_entry) == T_CLASS) {
733
736
  rb_ary_push(type_strings, sub_entry);
734
737
  } else {
735
- rb_raise(eArgumentError, "Invalid type given");
738
+ rb_raise(rb_eArgError, "Invalid type given");
736
739
  }
737
740
  }
738
741
  } else {
739
- rb_raise(eArgumentError, "Invalid type given");
742
+ rb_raise(rb_eArgError, "Invalid type given");
740
743
  }
741
744
  }
742
745
 
@@ -779,7 +782,9 @@ static VALUE cConnection_quote_string(VALUE self, VALUE string) {
779
782
 
780
783
  // Wrap the escaped string in single-quotes, this is DO's convention
781
784
  escaped[0] = escaped[quoted_length + 1] = '\'';
782
- result = DO_STR_NEW(escaped, quoted_length + 2, FIX2INT(rb_iv_get(self, "@encoding_id")));
785
+ // We don't want to use the internal encoding, because this needs
786
+ // to go into the database in the connection encoding
787
+ result = DO_STR_NEW(escaped, quoted_length + 2, FIX2INT(rb_iv_get(self, "@encoding_id")), NULL);
783
788
 
784
789
  free(escaped);
785
790
  return result;
@@ -793,7 +798,7 @@ static VALUE build_query_from_args(VALUE klass, int count, VALUE *args) {
793
798
  for ( i = 0; i < count; i++) {
794
799
  rb_ary_push(array, (VALUE)args[i]);
795
800
  }
796
- query = rb_funcall(klass, ID_ESCAPE_SQL, 1, array);
801
+ query = rb_funcall(klass, ID_ESCAPE, 1, array);
797
802
 
798
803
  return query;
799
804
  }
@@ -804,6 +809,7 @@ static VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
804
809
  MYSQL_RES *response = 0;
805
810
 
806
811
  my_ulonglong affected_rows;
812
+ my_ulonglong insert_id;
807
813
  VALUE connection = rb_iv_get(self, "@connection");
808
814
  VALUE mysql_connection = rb_iv_get(connection, "@connection");
809
815
  if (Qnil == mysql_connection) {
@@ -813,15 +819,17 @@ static VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
813
819
  MYSQL *db = DATA_PTR(mysql_connection);
814
820
  query = build_query_from_args(self, argc, argv);
815
821
 
816
- response = cCommand_execute(self, db, query);
822
+ response = cCommand_execute(self, connection, db, query);
817
823
 
818
824
  affected_rows = mysql_affected_rows(db);
825
+ insert_id = mysql_insert_id(db);
819
826
  mysql_free_result(response);
820
827
 
821
- if ((my_ulonglong)-1 == affected_rows)
828
+ if ((my_ulonglong)-1 == affected_rows) {
822
829
  return Qnil;
830
+ }
823
831
 
824
- return rb_funcall(cResult, ID_NEW, 3, self, INT2NUM(affected_rows), INT2NUM(mysql_insert_id(db)));
832
+ return rb_funcall(cResult, ID_NEW, 3, self, INT2NUM(affected_rows), insert_id == 0 ? Qnil : INT2NUM(insert_id));
825
833
  }
826
834
 
827
835
  static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
@@ -845,7 +853,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
845
853
 
846
854
  query = build_query_from_args(self, argc, argv);
847
855
 
848
- response = cCommand_execute(self, db, query);
856
+ response = cCommand_execute(self, connection, db, query);
849
857
 
850
858
  if (!response) {
851
859
  return Qnil;
@@ -869,7 +877,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
869
877
  // Whoops... wrong number of types passed to set_types. Close the reader and raise
870
878
  // and error
871
879
  rb_funcall(reader, rb_intern("close"), 0);
872
- rb_raise(eArgumentError, "Field-count mismatch. Expected %ld fields, but the query yielded %d", RARRAY_LEN(field_types), field_count);
880
+ rb_raise(rb_eArgError, "Field-count mismatch. Expected %ld fields, but the query yielded %d", RARRAY_LEN(field_types), field_count);
873
881
  }
874
882
 
875
883
  for(i = 0; i < field_count; i++) {
@@ -983,13 +991,15 @@ static VALUE cReader_field_count(VALUE self) {
983
991
  void Init_do_mysql() {
984
992
  rb_require("bigdecimal");
985
993
  rb_require("date");
994
+ rb_require("data_objects");
995
+
996
+ ID_CONST_GET = rb_intern("const_get");
986
997
 
987
- rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects"));
998
+ // Get references classes needed for Date/Time parsing
999
+ rb_cDate = CONST_GET(rb_mKernel, "Date");
1000
+ rb_cDateTime = CONST_GET(rb_mKernel, "DateTime");
1001
+ rb_cBigDecimal = CONST_GET(rb_mKernel, "BigDecimal");
988
1002
 
989
- ID_TO_I = rb_intern("to_i");
990
- ID_TO_F = rb_intern("to_f");
991
- ID_TO_S = rb_intern("to_s");
992
- ID_TO_TIME = rb_intern("to_time");
993
1003
  ID_NEW = rb_intern("new");
994
1004
  #ifdef RUBY_LESS_THAN_186
995
1005
  ID_NEW_DATE = rb_intern("new0");
@@ -998,17 +1008,9 @@ void Init_do_mysql() {
998
1008
  #endif
999
1009
  ID_CONST_GET = rb_intern("const_get");
1000
1010
  ID_RATIONAL = rb_intern("Rational");
1001
- ID_UTC = rb_intern("utc");
1002
- ID_ESCAPE_SQL = rb_intern("escape_sql");
1011
+ ID_ESCAPE = rb_intern("escape_sql");
1003
1012
  ID_STRFTIME = rb_intern("strftime");
1004
- ID_LOGGER = rb_intern("logger");
1005
- ID_DEBUG = rb_intern("debug");
1006
- ID_LEVEL = rb_intern("level");
1007
-
1008
- // Store references to a few helpful clases that aren't in Ruby Core
1009
- rb_cDate = RUBY_CLASS("Date");
1010
- rb_cDateTime = RUBY_CLASS("DateTime");
1011
- rb_cBigDecimal = RUBY_CLASS("BigDecimal");
1013
+ ID_LOG = rb_intern("log");
1012
1014
 
1013
1015
  // Get references to the Extlib module
1014
1016
  mExtlib = CONST_GET(rb_mKernel, "Extlib");
@@ -1021,14 +1023,14 @@ void Init_do_mysql() {
1021
1023
  cDO_Command = CONST_GET(mDO, "Command");
1022
1024
  cDO_Result = CONST_GET(mDO, "Result");
1023
1025
  cDO_Reader = CONST_GET(mDO, "Reader");
1026
+ cDO_Logger = CONST_GET(mDO, "Logger");
1027
+ cDO_Logger_Message = CONST_GET(cDO_Logger, "Message");
1024
1028
 
1025
1029
  // Top Level Module that all the classes live under
1026
- mDOMysql = rb_define_module_under(mDO, "Mysql");
1027
-
1028
- eArgumentError = CONST_GET(rb_mKernel, "ArgumentError");
1030
+ mMysql = rb_define_module_under(mDO, "Mysql");
1029
1031
  eConnectionError = CONST_GET(mDO, "ConnectionError");
1030
1032
  eDataError = CONST_GET(mDO, "DataError");
1031
- mEncoding = rb_define_module_under(mDOMysql, "Encoding");
1033
+ mEncoding = rb_define_module_under(mMysql, "Encoding");
1032
1034
 
1033
1035
  cConnection = DRIVER_CLASS("Connection", cDO_Connection);
1034
1036
  rb_define_method(cConnection, "initialize", cConnection_initialize, 1);
@@ -1057,9 +1059,30 @@ void Init_do_mysql() {
1057
1059
  rb_define_method(cReader, "fields", cReader_fields, 0);
1058
1060
  rb_define_method(cReader, "field_count", cReader_field_count, 0);
1059
1061
 
1062
+ rb_global_variable(&ID_NEW_DATE);
1063
+ rb_global_variable(&ID_RATIONAL);
1064
+ rb_global_variable(&ID_CONST_GET);
1065
+ rb_global_variable(&ID_ESCAPE);
1066
+ rb_global_variable(&ID_LOG);
1067
+ rb_global_variable(&ID_NEW);
1068
+
1069
+ rb_global_variable(&rb_cDate);
1070
+ rb_global_variable(&rb_cDateTime);
1071
+ rb_global_variable(&rb_cBigDecimal);
1072
+ rb_global_variable(&rb_cByteArray);
1073
+
1074
+ rb_global_variable(&mDO);
1075
+ rb_global_variable(&cDO_Logger_Message);
1076
+
1077
+ rb_global_variable(&cResult);
1078
+ rb_global_variable(&cReader);
1079
+
1080
+ rb_global_variable(&eConnectionError);
1081
+ rb_global_variable(&eDataError);
1082
+
1060
1083
  struct errcodes *errs;
1061
1084
 
1062
1085
  for (errs = errors; errs->error_name; errs++) {
1063
- rb_const_set(mDOMysql, rb_intern(errs->error_name), INT2NUM(errs->error_no));
1086
+ rb_const_set(mMysql, rb_intern(errs->error_name), INT2NUM(errs->error_no));
1064
1087
  }
1065
1088
  }
@@ -35,9 +35,9 @@ end
35
35
  if RUBY_PLATFORM =~ /mswin|mingw/
36
36
  dir_config('mysql')
37
37
  have_header 'my_global.h'
38
- have_header 'mysql.h' || exit(1)
39
- have_library 'libmysql' || exit(1)
40
- have_func('mysql_query', 'mysql.h') || exit(1)
38
+ have_header 'mysql.h'
39
+ have_library 'libmysql'
40
+ have_func('mysql_query', 'mysql.h')
41
41
  have_func('mysql_ssl_set', 'mysql.h')
42
42
  elsif mc = with_config('mysql-config', default_mysql_config_path)
43
43
  includes = mysql_config('include').split(/\s+/).map do |dir|
@@ -46,7 +46,15 @@ elsif mc = with_config('mysql-config', default_mysql_config_path)
46
46
  libs = mysql_config('libs').split(/\s+/).select {|lib| lib =~ /^-L/}.map do |dir|
47
47
  dir.gsub(/^-L/, "")
48
48
  end.uniq
49
+
50
+ linked = mysql_config('libs').split(/\s+/).select {|lib| lib =~ /^-l/}.map do |dir|
51
+ dir.gsub(/^-l/, "")
52
+ end.uniq
53
+
49
54
  dir_config('mysql', includes, libs)
55
+ linked.each do |link|
56
+ have_library link
57
+ end
50
58
  else
51
59
  inc, lib = dir_config('mysql', default_prefix)
52
60
  libs = ['m', 'z', 'socket', 'nsl']
@@ -60,8 +68,7 @@ end
60
68
 
61
69
  unless RUBY_PLATFORM =~ /mswin|mingw/
62
70
  have_header 'mysql.h'
63
- have_library 'mysqlclient' || exit(1)
64
- have_func 'mysql_query' || exit(1)
71
+ have_func 'mysql_query'
65
72
  have_func 'mysql_ssl_set'
66
73
  end
67
74
 
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Mysql
3
- VERSION = '0.10.1'.freeze
3
+ VERSION = '0.10.2'
4
4
  end
5
5
  end
@@ -5,5 +5,6 @@ require 'data_objects/spec/encoding_spec'
5
5
 
6
6
  describe DataObjects::Mysql::Connection do
7
7
  behaves_like 'a driver supporting different encodings'
8
- behaves_like 'returning correctly encoded strings for the default encoding'
8
+ behaves_like 'returning correctly encoded strings for the default database encoding'
9
+ behaves_like 'returning correctly encoded strings for the default internal encoding'
9
10
  end
@@ -12,5 +12,6 @@ describe DataObjects::Mysql::Result do
12
12
  end
13
13
 
14
14
  describe DataObjects::Mysql::Result do
15
- behaves_like 'a Result which returns inserted keys'
15
+ behaves_like 'a Result which returns inserted key with sequences'
16
+ behaves_like 'a Result which returns nil without sequences'
16
17
  end
@@ -71,9 +71,8 @@ module DataObjectsSpecHelpers
71
71
 
72
72
  conn.create_command(<<-EOF).execute_non_query
73
73
  CREATE TABLE `invoices` (
74
- `id` int(11) NOT NULL auto_increment,
75
74
  `invoice_number` varchar(50) NOT NULL,
76
- PRIMARY KEY (`id`)
75
+ PRIMARY KEY (`invoice_number`)
77
76
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
78
77
  EOF
79
78
 
@@ -57,7 +57,7 @@ begin
57
57
  ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
58
58
  ext.java_compiling do |gem|
59
59
  gem.add_dependency 'jdbc-mysql', '>=5.0.4'
60
- gem.add_dependency 'do_jdbc', '0.10.1'
60
+ gem.add_dependency 'do_jdbc', '0.10.2'
61
61
  end
62
62
  end
63
63
  rescue LoadError
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 10
8
+ - 2
9
+ version: 0.10.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Dirkjan Bussink
@@ -9,39 +14,49 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-09 00:00:00 +01:00
17
+ date: 2010-05-19 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: data_objects
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - "="
22
26
  - !ruby/object:Gem::Version
23
- version: 0.10.1
24
- version:
27
+ segments:
28
+ - 0
29
+ - 10
30
+ - 2
31
+ version: 0.10.2
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: bacon
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ~>
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 1
33
44
  version: "1.1"
34
- version:
45
+ type: :development
46
+ version_requirements: *id002
35
47
  - !ruby/object:Gem::Dependency
36
48
  name: rake-compiler
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
40
51
  requirements:
41
52
  - - ~>
42
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ - 7
43
57
  version: "0.7"
44
- version:
58
+ type: :development
59
+ version_requirements: *id003
45
60
  description: Implements the DataObjects API for MySQL
46
61
  email: d.bussink@gmail.com
47
62
  executables: []
@@ -103,18 +118,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
118
  requirements:
104
119
  - - ">="
105
120
  - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
106
123
  version: "0"
107
- version:
108
124
  required_rubygems_version: !ruby/object:Gem::Requirement
109
125
  requirements:
110
126
  - - ">="
111
127
  - !ruby/object:Gem::Version
128
+ segments:
129
+ - 0
112
130
  version: "0"
113
- version:
114
131
  requirements: []
115
132
 
116
133
  rubyforge_project: dorb
117
- rubygems_version: 1.3.5
134
+ rubygems_version: 1.3.6
118
135
  signing_key:
119
136
  specification_version: 3
120
137
  summary: DataObjects MySQL Driver