do_mysql 0.10.5-x86-mswin32-60 → 0.10.6-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.10.6 2011-05-22
2
+
3
+ Bugfixes
4
+ * Fix an issue on some platforms when multiple DO drivers are loaded
5
+
1
6
  ## 0.10.5 2011-05-03
2
7
 
3
8
  No changes
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'rubygems'
2
3
  require 'bundler'
3
4
  Bundler::GemHelper.install_tasks
4
5
 
@@ -45,6 +45,11 @@ VALUE rb_cBigDecimal;
45
45
  * Common Functions
46
46
  */
47
47
 
48
+
49
+ VALUE data_objects_const_get(VALUE scope, const char *constant) {
50
+ return rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant));
51
+ }
52
+
48
53
  void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
49
54
  struct timeval stop;
50
55
  VALUE message;
@@ -57,7 +62,7 @@ void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
57
62
  rb_funcall(connection, ID_LOG, 1, message);
58
63
  }
59
64
 
60
- void do_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state) {
65
+ void data_objects_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state) {
61
66
  const char *exception_type = "SQLError";
62
67
  const struct errcodes *e;
63
68
 
@@ -72,7 +77,7 @@ void do_raise_error(VALUE self, const struct errcodes *errors, int errnum, const
72
77
  VALUE uri = rb_funcall(rb_iv_get(self, "@connection"), rb_intern("to_s"), 0);
73
78
 
74
79
  VALUE exception = rb_funcall(
75
- do_const_get(mDO, exception_type),
80
+ data_objects_const_get(mDO, exception_type),
76
81
  ID_NEW,
77
82
  5,
78
83
  rb_str_new2(message),
@@ -85,7 +90,7 @@ void do_raise_error(VALUE self, const struct errcodes *errors, int errnum, const
85
90
  rb_exc_raise(exception);
86
91
  }
87
92
 
88
- char *get_uri_option(VALUE query_hash, const char *key) {
93
+ char *data_objects_get_uri_option(VALUE query_hash, const char *key) {
89
94
  VALUE query_value;
90
95
  char *value = NULL;
91
96
 
@@ -102,7 +107,7 @@ char *get_uri_option(VALUE query_hash, const char *key) {
102
107
  return value;
103
108
  }
104
109
 
105
- void assert_file_exists(char *file, const char *message) {
110
+ void data_objects_assert_file_exists(char *file, const char *message) {
106
111
  if (file) {
107
112
  if (rb_funcall(rb_cFile, rb_intern("exist?"), 1, rb_str_new2(file)) == Qfalse) {
108
113
  rb_raise(rb_eArgError, "%s", message);
@@ -110,7 +115,7 @@ void assert_file_exists(char *file, const char *message) {
110
115
  }
111
116
  }
112
117
 
113
- VALUE build_query_from_args(VALUE klass, int count, VALUE *args) {
118
+ VALUE data_objects_build_query_from_args(VALUE klass, int count, VALUE *args) {
114
119
  VALUE array = rb_ary_new();
115
120
  int i;
116
121
 
@@ -123,7 +128,7 @@ VALUE build_query_from_args(VALUE klass, int count, VALUE *args) {
123
128
 
124
129
  // Find the greatest common denominator and reduce the provided numerator and denominator.
125
130
  // This replaces calles to Rational.reduce! which does the same thing, but really slowly.
126
- void reduce(do_int64 *numerator, do_int64 *denominator) {
131
+ void data_objects_reduce(do_int64 *numerator, do_int64 *denominator) {
127
132
  do_int64 a = *numerator, b = *denominator, c;
128
133
 
129
134
  while (a != 0) {
@@ -137,7 +142,7 @@ void reduce(do_int64 *numerator, do_int64 *denominator) {
137
142
  }
138
143
 
139
144
  // Generate the date integer which Date.civil_to_jd returns
140
- int jd_from_date(int year, int month, int day) {
145
+ int data_objects_jd_from_date(int year, int month, int day) {
141
146
  int a, b;
142
147
 
143
148
  if (month <= 2) {
@@ -151,24 +156,24 @@ int jd_from_date(int year, int month, int day) {
151
156
  return (int)(floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524);
152
157
  }
153
158
 
154
- VALUE seconds_to_offset(long seconds_offset) {
159
+ VALUE data_objects_seconds_to_offset(long seconds_offset) {
155
160
  do_int64 num = seconds_offset;
156
161
  do_int64 den = 86400;
157
162
 
158
- reduce(&num, &den);
163
+ data_objects_reduce(&num, &den);
159
164
  return rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ll2inum(num), rb_ll2inum(den));
160
165
  }
161
166
 
162
- VALUE timezone_to_offset(int hour_offset, int minute_offset) {
167
+ VALUE data_objects_timezone_to_offset(int hour_offset, int minute_offset) {
163
168
  do_int64 seconds = 0;
164
169
 
165
170
  seconds += hour_offset * 3600;
166
171
  seconds += minute_offset * 60;
167
172
 
168
- return seconds_to_offset(seconds);
173
+ return data_objects_seconds_to_offset(seconds);
169
174
  }
170
175
 
171
- VALUE parse_date(const char *date) {
176
+ VALUE data_objects_parse_date(const char *date) {
172
177
  static char const *const _fmt_date = "%4d-%2d-%2d";
173
178
  int year = 0, month = 0, day = 0;
174
179
  int jd, ajd;
@@ -180,14 +185,14 @@ VALUE parse_date(const char *date) {
180
185
  return Qnil;
181
186
  }
182
187
 
183
- jd = jd_from_date(year, month, day);
188
+ jd = data_objects_jd_from_date(year, month, day);
184
189
  ajd = (jd * 2) - 1; // Math from Date.jd_to_ajd
185
190
  rational = rb_funcall(rb_mKernel, ID_RATIONAL, 2, INT2NUM(ajd), INT2NUM(2));
186
191
 
187
192
  return rb_funcall(rb_cDate, ID_NEW_DATE, 3, rational, INT2NUM(0), INT2NUM(2299161));
188
193
  }
189
194
 
190
- VALUE parse_time(const char *date) {
195
+ VALUE data_objects_parse_time(const char *date) {
191
196
  static char const* const _fmt_datetime = "%4d-%2d-%2d %2d:%2d:%2d%7lf";
192
197
  int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0, usec = 0;
193
198
  double subsec = 0;
@@ -208,7 +213,7 @@ VALUE parse_time(const char *date) {
208
213
  return rb_funcall(rb_cTime, rb_intern("local"), 7, INT2NUM(year), INT2NUM(month), INT2NUM(day), INT2NUM(hour), INT2NUM(min), INT2NUM(sec), INT2NUM(usec));
209
214
  }
210
215
 
211
- VALUE parse_date_time(const char *date) {
216
+ VALUE data_objects_parse_date_time(const char *date) {
212
217
  static char const* const _fmt_datetime_tz_normal = "%4d-%2d-%2d%*c%2d:%2d:%2d%3d:%2d";
213
218
  static char const* const _fmt_datetime_tz_subsec = "%4d-%2d-%2d%*c%2d:%2d:%2d.%*d%3d:%2d";
214
219
  int tokens_read;
@@ -294,7 +299,7 @@ VALUE parse_date_time(const char *date) {
294
299
  rb_raise(eDataError, "Couldn't parse date: %s", date);
295
300
  }
296
301
 
297
- jd = jd_from_date(year, month, day);
302
+ jd = data_objects_jd_from_date(year, month, day);
298
303
 
299
304
  /*
300
305
  * Generate ajd with fractional days for the time.
@@ -306,47 +311,47 @@ VALUE parse_date_time(const char *date) {
306
311
  num = (hour * 1440) + (min * 24);
307
312
  num -= (hour_offset * 1440) + (minute_offset * 24);
308
313
  den = (24 * 1440);
309
- reduce(&num, &den);
314
+ data_objects_reduce(&num, &den);
310
315
 
311
316
  num = (num * 86400) + (sec * den);
312
317
  den = den * 86400;
313
- reduce(&num, &den);
318
+ data_objects_reduce(&num, &den);
314
319
 
315
320
  num += jd * den;
316
321
 
317
322
  num = (num * 2) - den;
318
323
  den *= 2;
319
- reduce(&num, &den);
324
+ data_objects_reduce(&num, &den);
320
325
 
321
326
  ajd = rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ull2inum(num), rb_ull2inum(den));
322
- offset = timezone_to_offset(hour_offset, minute_offset);
327
+ offset = data_objects_timezone_to_offset(hour_offset, minute_offset);
323
328
 
324
329
  return rb_funcall(rb_cDateTime, ID_NEW_DATE, 3, ajd, offset, INT2NUM(2299161));
325
330
  }
326
331
 
327
- VALUE cConnection_character_set(VALUE self) {
332
+ VALUE data_objects_cConnection_character_set(VALUE self) {
328
333
  return rb_iv_get(self, "@encoding");
329
334
  }
330
335
 
331
- VALUE cConnection_is_using_socket(VALUE self) {
336
+ VALUE data_objects_cConnection_is_using_socket(VALUE self) {
332
337
  return rb_iv_get(self, "@using_socket");
333
338
  }
334
339
 
335
- VALUE cConnection_ssl_cipher(VALUE self) {
340
+ VALUE data_objects_cConnection_ssl_cipher(VALUE self) {
336
341
  return rb_iv_get(self, "@ssl_cipher");
337
342
  }
338
343
 
339
- VALUE cConnection_quote_time(VALUE self, VALUE value) {
344
+ VALUE data_objects_cConnection_quote_time(VALUE self, VALUE value) {
340
345
  return rb_funcall(value, ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d %H:%M:%S'"));
341
346
  }
342
347
 
343
- VALUE cConnection_quote_date_time(VALUE self, VALUE value) {
348
+ VALUE data_objects_cConnection_quote_date_time(VALUE self, VALUE value) {
344
349
  // TODO: Support non-local dates. we need to call #new_offset on the date to be
345
350
  // quoted and pass in the current locale's date offset (self.new_offset((hours * 3600).to_r / 86400)
346
351
  return rb_funcall(value, ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d %H:%M:%S'"));
347
352
  }
348
353
 
349
- VALUE cConnection_quote_date(VALUE self, VALUE value) {
354
+ VALUE data_objects_cConnection_quote_date(VALUE self, VALUE value) {
350
355
  return rb_funcall(value, ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d'"));
351
356
  }
352
357
 
@@ -354,7 +359,7 @@ VALUE cConnection_quote_date(VALUE self, VALUE value) {
354
359
  * Accepts an array of Ruby types (Fixnum, Float, String, etc...) and turns them
355
360
  * into Ruby-strings so we can easily typecast later
356
361
  */
357
- VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self) {
362
+ VALUE data_objects_cCommand_set_types(int argc, VALUE *argv, VALUE self) {
358
363
  VALUE type_strings = rb_ary_new();
359
364
  VALUE array = rb_ary_new();
360
365
 
@@ -393,7 +398,7 @@ VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self) {
393
398
  return array;
394
399
  }
395
400
 
396
- VALUE cReader_values(VALUE self) {
401
+ VALUE data_objects_cReader_values(VALUE self) {
397
402
  VALUE state = rb_iv_get(self, "@opened");
398
403
  VALUE values = rb_iv_get(self, "@values");
399
404
 
@@ -404,27 +409,27 @@ VALUE cReader_values(VALUE self) {
404
409
  return rb_iv_get(self, "@values");
405
410
  }
406
411
 
407
- VALUE cReader_fields(VALUE self) {
412
+ VALUE data_objects_cReader_fields(VALUE self) {
408
413
  return rb_iv_get(self, "@fields");
409
414
  }
410
415
 
411
- VALUE cReader_field_count(VALUE self) {
416
+ VALUE data_objects_cReader_field_count(VALUE self) {
412
417
  return rb_iv_get(self, "@field_count");
413
418
  }
414
419
 
415
- void common_init(void) {
420
+ void data_objects_common_init(void) {
416
421
  rb_require("bigdecimal");
417
422
  rb_require("rational");
418
423
  rb_require("date");
419
424
  rb_require("data_objects");
420
425
 
421
- // Needed by do_const_get
426
+ // Needed by data_objects_const_get
422
427
  ID_CONST_GET = rb_intern("const_get");
423
428
 
424
429
  // Get references classes needed for Date/Time parsing
425
- rb_cDate = do_const_get(rb_mKernel, "Date");
426
- rb_cDateTime = do_const_get(rb_mKernel, "DateTime");
427
- rb_cBigDecimal = do_const_get(rb_mKernel, "BigDecimal");
430
+ rb_cDate = data_objects_const_get(rb_mKernel, "Date");
431
+ rb_cDateTime = data_objects_const_get(rb_mKernel, "DateTime");
432
+ rb_cBigDecimal = data_objects_const_get(rb_mKernel, "BigDecimal");
428
433
 
429
434
  ID_NEW = rb_intern("new");
430
435
  #ifdef RUBY_LESS_THAN_186
@@ -439,22 +444,22 @@ void common_init(void) {
439
444
  ID_LOG = rb_intern("log");
440
445
 
441
446
  // Get references to the Extlib module
442
- mExtlib = do_const_get(rb_mKernel, "Extlib");
443
- rb_cByteArray = do_const_get(mExtlib, "ByteArray");
447
+ mExtlib = data_objects_const_get(rb_mKernel, "Extlib");
448
+ rb_cByteArray = data_objects_const_get(mExtlib, "ByteArray");
444
449
 
445
450
  // Get references to the DataObjects module and its classes
446
- mDO = do_const_get(rb_mKernel, "DataObjects");
447
- cDO_Quoting = do_const_get(mDO, "Quoting");
448
- cDO_Connection = do_const_get(mDO, "Connection");
449
- cDO_Command = do_const_get(mDO, "Command");
450
- cDO_Result = do_const_get(mDO, "Result");
451
- cDO_Reader = do_const_get(mDO, "Reader");
452
- cDO_Logger = do_const_get(mDO, "Logger");
453
- cDO_Logger_Message = do_const_get(cDO_Logger, "Message");
454
- cDO_Extension = do_const_get(mDO, "Extension");
455
-
456
- eConnectionError = do_const_get(mDO, "ConnectionError");
457
- eDataError = do_const_get(mDO, "DataError");
451
+ mDO = data_objects_const_get(rb_mKernel, "DataObjects");
452
+ cDO_Quoting = data_objects_const_get(mDO, "Quoting");
453
+ cDO_Connection = data_objects_const_get(mDO, "Connection");
454
+ cDO_Command = data_objects_const_get(mDO, "Command");
455
+ cDO_Result = data_objects_const_get(mDO, "Result");
456
+ cDO_Reader = data_objects_const_get(mDO, "Reader");
457
+ cDO_Logger = data_objects_const_get(mDO, "Logger");
458
+ cDO_Logger_Message = data_objects_const_get(cDO_Logger, "Message");
459
+ cDO_Extension = data_objects_const_get(mDO, "Extension");
460
+
461
+ eConnectionError = data_objects_const_get(mDO, "ConnectionError");
462
+ eDataError = data_objects_const_get(mDO, "DataError");
458
463
 
459
464
  rb_global_variable(&ID_NEW_DATE);
460
465
  rb_global_variable(&ID_RATIONAL);
@@ -480,7 +485,7 @@ void common_init(void) {
480
485
  /*
481
486
  * Common typecasting logic that can be used or overriden by Adapters.
482
487
  */
483
- extern VALUE do_typecast(const char *value, long length, const VALUE type, int encoding) {
488
+ extern VALUE data_objects_typecast(const char *value, long length, const VALUE type, int encoding) {
484
489
  #ifdef HAVE_RUBY_ENCODING_H
485
490
  rb_encoding *internal_encoding = rb_default_internal_encoding();
486
491
  #else
@@ -491,7 +496,7 @@ extern VALUE do_typecast(const char *value, long length, const VALUE type, int e
491
496
  return rb_cstr2inum(value, 10);
492
497
  }
493
498
  else if (type == rb_cString) {
494
- return do_str_new(value, length, encoding, internal_encoding);
499
+ return DATA_OBJECTS_STR_NEW(value, length, encoding, internal_encoding);
495
500
  }
496
501
  else if (type == rb_cFloat) {
497
502
  return rb_float_new(rb_cstr_to_dbl(value, Qfalse));
@@ -500,13 +505,13 @@ extern VALUE do_typecast(const char *value, long length, const VALUE type, int e
500
505
  return rb_funcall(rb_cBigDecimal, ID_NEW, 1, rb_str_new(value, length));
501
506
  }
502
507
  else if (type == rb_cDate) {
503
- return parse_date(value);
508
+ return data_objects_parse_date(value);
504
509
  }
505
510
  else if (type == rb_cDateTime) {
506
- return parse_date_time(value);
511
+ return data_objects_parse_date_time(value);
507
512
  }
508
513
  else if (type == rb_cTime) {
509
- return parse_time(value);
514
+ return data_objects_parse_time(value);
510
515
  }
511
516
  else if (type == rb_cTrueClass) {
512
517
  return (!value || strcmp("0", value) == 0) ? Qfalse : Qtrue;
@@ -521,6 +526,6 @@ extern VALUE do_typecast(const char *value, long length, const VALUE type, int e
521
526
  return Qnil;
522
527
  }
523
528
  else {
524
- return DO_STR_NEW(value, length, encoding, internal_encoding);
529
+ return DATA_OBJECTS_STR_NEW(value, length, encoding, internal_encoding);
525
530
  }
526
531
  }
@@ -3,18 +3,24 @@
3
3
 
4
4
  #include <ruby.h>
5
5
 
6
+ // Needed for defining error.h
7
+ struct errcodes {
8
+ int error_no;
9
+ const char *error_name;
10
+ const char *exception;
11
+ };
12
+
13
+ #define ERRCODE(name,message) {name, #name, message}
14
+
6
15
  #ifdef _WIN32
7
- #define cCommand_execute cCommand_execute_sync
8
16
  typedef signed __int64 do_int64;
9
17
  #else
10
- #define cCommand_execute cCommand_execute_async
11
18
  typedef signed long long int do_int64;
12
19
  #endif
13
20
 
14
21
  #ifdef HAVE_RUBY_ENCODING_H
15
22
  #include <ruby/encoding.h>
16
-
17
- #define DO_STR_NEW2(str, encoding, internal_encoding) \
23
+ #define DATA_OBJECTS_STR_NEW2(str, encoding, internal_encoding) \
18
24
  ({ \
19
25
  VALUE _string = rb_str_new2((const char *)str); \
20
26
  if(encoding != -1) { \
@@ -26,7 +32,7 @@ typedef signed long long int do_int64;
26
32
  _string; \
27
33
  })
28
34
 
29
- #define DO_STR_NEW(str, len, encoding, internal_encoding) \
35
+ #define DATA_OBJECTS_STR_NEW(str, len, encoding, internal_encoding) \
30
36
  ({ \
31
37
  VALUE _string = rb_str_new((const char *)str, (long)len); \
32
38
  if(encoding != -1) { \
@@ -38,24 +44,15 @@ typedef signed long long int do_int64;
38
44
  _string; \
39
45
  })
40
46
 
41
- # else
47
+ #else
42
48
 
43
- #define DO_STR_NEW2(str, encoding, internal_encoding) \
49
+ #define DATA_OBJECTS_STR_NEW2(str, encoding, internal_encoding) \
44
50
  rb_str_new2((const char *)str)
45
51
 
46
- #define DO_STR_NEW(str, len, encoding, internal_encoding) \
52
+ #define DATA_OBJECTS_STR_NEW(str, len, encoding, internal_encoding) \
47
53
  rb_str_new((const char *)str, (long)len)
48
54
  #endif
49
55
 
50
- // Needed for defining error.h
51
- struct errcodes {
52
- int error_no;
53
- const char *error_name;
54
- const char *exception;
55
- };
56
-
57
- #define ERRCODE(name,message) {name, #name, message}
58
-
59
56
  // To store rb_intern values
60
57
  extern ID ID_NEW;
61
58
  extern ID ID_NEW_DATE;
@@ -89,71 +86,37 @@ extern VALUE rb_cDateTime;
89
86
  extern VALUE rb_cBigDecimal;
90
87
 
91
88
  extern void data_objects_debug(VALUE connection, VALUE string, struct timeval *start);
92
- extern char *get_uri_option(VALUE query_hash, const char *key);
93
- extern void assert_file_exists(char *file, const char *message);
94
- extern VALUE build_query_from_args(VALUE klass, int count, VALUE *args);
95
-
96
- extern void reduce(do_int64 *numerator, do_int64 *denominator);
97
- extern int jd_from_date(int year, int month, int day);
98
- extern VALUE seconds_to_offset(long seconds_offset);
99
- extern VALUE timezone_to_offset(int hour_offset, int minute_offset);
100
-
101
- extern VALUE parse_date(const char *date);
102
- extern VALUE parse_time(const char *date);
103
- extern VALUE parse_date_time(const char *date);
104
-
105
- extern VALUE cConnection_character_set(VALUE self);
106
- extern VALUE cConnection_is_using_socket(VALUE self);
107
- extern VALUE cConnection_ssl_cipher(VALUE self);
108
- extern VALUE cConnection_quote_time(VALUE self, VALUE value);
109
- extern VALUE cConnection_quote_date_time(VALUE self, VALUE value);
110
- extern VALUE cConnection_quote_date(VALUE self, VALUE value);
111
-
112
- extern VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self);
113
-
114
- extern VALUE cReader_values(VALUE self);
115
- extern VALUE cReader_fields(VALUE self);
116
- extern VALUE cReader_field_count(VALUE self);
117
-
118
- extern void common_init(void);
119
-
120
- static inline VALUE do_const_get(VALUE scope, const char *constant) {
121
- return rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant));
122
- }
89
+ extern char *data_objects_get_uri_option(VALUE query_hash, const char *key);
90
+ extern void data_objects_assert_file_exists(char *file, const char *message);
91
+ extern VALUE data_objects_build_query_from_args(VALUE klass, int count, VALUE *args);
123
92
 
124
- static inline VALUE do_str_new(const void *string, long length, int encoding, void *internal_encoding) {
125
- VALUE new_string = rb_str_new(string, length);
93
+ extern void data_objects_reduce(do_int64 *numerator, do_int64 *denominator);
94
+ extern int data_objects_jd_from_date(int year, int month, int day);
95
+ extern VALUE data_objects_seconds_to_offset(long seconds_offset);
96
+ extern VALUE data_objects_timezone_to_offset(int hour_offset, int minute_offset);
126
97
 
127
- #ifdef HAVE_RUBY_ENCODING_H
128
- if(encoding != -1) {
129
- rb_enc_associate_index(new_string, encoding);
130
- }
98
+ extern VALUE data_objects_parse_date(const char *date);
99
+ extern VALUE data_objects_parse_time(const char *date);
100
+ extern VALUE data_objects_parse_date_time(const char *date);
131
101
 
132
- if(internal_encoding) {
133
- new_string = rb_str_export_to_enc(new_string, internal_encoding);
134
- }
135
- #endif
102
+ extern VALUE data_objects_cConnection_character_set(VALUE self);
103
+ extern VALUE data_objects_cConnection_is_using_socket(VALUE self);
104
+ extern VALUE data_objects_cConnection_ssl_cipher(VALUE self);
105
+ extern VALUE data_objects_cConnection_quote_time(VALUE self, VALUE value);
106
+ extern VALUE data_objects_cConnection_quote_date_time(VALUE self, VALUE value);
107
+ extern VALUE data_objects_cConnection_quote_date(VALUE self, VALUE value);
136
108
 
137
- return new_string;
138
- }
109
+ extern VALUE data_objects_cCommand_set_types(int argc, VALUE *argv, VALUE self);
139
110
 
140
- static inline VALUE do_str_new2(const void *string, int encoding, void *internal_encoding) {
141
- VALUE new_string = rb_str_new2(string);
111
+ extern VALUE data_objects_cReader_values(VALUE self);
112
+ extern VALUE data_objects_cReader_fields(VALUE self);
113
+ extern VALUE data_objects_cReader_field_count(VALUE self);
142
114
 
143
- #ifdef HAVE_RUBY_ENCODING_H
144
- if(encoding != -1) {
145
- rb_enc_associate_index(new_string, encoding);
146
- }
147
-
148
- if(internal_encoding) {
149
- new_string = rb_str_export_to_enc(new_string, internal_encoding);
150
- }
151
- #endif
115
+ extern void data_objects_common_init(void);
152
116
 
153
- return new_string;
154
- }
117
+ extern VALUE data_objects_const_get(VALUE scope, const char *constant);
155
118
 
156
- static inline void do_define_errors(VALUE scope, const struct errcodes *errors) {
119
+ static inline void data_objects_define_errors(VALUE scope, const struct errcodes *errors) {
157
120
  const struct errcodes *e;
158
121
 
159
122
  for (e = errors; e->error_name; e++) {
@@ -161,9 +124,9 @@ static inline void do_define_errors(VALUE scope, const struct errcodes *errors)
161
124
  }
162
125
  }
163
126
 
164
- extern void do_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state);
127
+ extern void data_objects_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state);
165
128
 
166
- extern VALUE do_typecast(const char *value, long length, const VALUE type, int encoding);
129
+ extern VALUE data_objects_typecast(const char *value, long length, const VALUE type, int encoding);
167
130
 
168
131
  #define RSTRING_NOT_MODIFIED
169
132
 
@@ -8,28 +8,34 @@
8
8
 
9
9
  #include "mysql_compat.h"
10
10
  #include "compat.h"
11
- #include "error.h"
12
11
 
12
+ #include "error.h"
13
13
  #include "do_common.h"
14
14
 
15
15
  #ifndef HAVE_CONST_MYSQL_TYPE_STRING
16
16
  #define HAVE_OLD_MYSQL_VERSION
17
17
  #endif
18
18
 
19
- #define CHECK_AND_RAISE(mysql_result_value, query) if (0 != mysql_result_value) { raise_error(self, db, query); }
19
+ #ifdef _WIN32
20
+ #define do_mysql_cCommand_execute do_mysql_cCommand_execute_sync
21
+ #else
22
+ #define do_mysql_cCommand_execute do_mysql_cCommand_execute_async
23
+ #endif
20
24
 
21
- void full_connect(VALUE self, MYSQL *db);
25
+ #define CHECK_AND_RAISE(mysql_result_value, query) if (0 != mysql_result_value) { do_mysql_raise_error(self, db, query); }
26
+
27
+ void do_mysql_full_connect(VALUE self, MYSQL *db);
22
28
 
23
29
  // Classes that we'll build in Init
24
30
  VALUE mMysql;
25
31
  VALUE mEncoding;
26
- VALUE cConnection;
27
- VALUE cCommand;
28
- VALUE cResult;
29
- VALUE cReader;
32
+ VALUE cMysqlConnection;
33
+ VALUE cMysqlCommand;
34
+ VALUE cMysqlResult;
35
+ VALUE cMysqlReader;
30
36
 
31
37
  // Figures out what we should cast a given mysql field type to
32
- VALUE infer_ruby_type(const MYSQL_FIELD *field) {
38
+ VALUE do_mysql_infer_ruby_type(const MYSQL_FIELD *field) {
33
39
  switch (field->type) {
34
40
  case MYSQL_TYPE_NULL:
35
41
  return Qnil;
@@ -81,7 +87,7 @@ VALUE infer_ruby_type(const MYSQL_FIELD *field) {
81
87
  }
82
88
 
83
89
  // Convert C-string to a Ruby instance of Ruby type "type"
84
- VALUE typecast(const char *value, long length, const VALUE type, int encoding) {
90
+ VALUE do_mysql_typecast(const char *value, long length, const VALUE type, int encoding) {
85
91
  if (!value) {
86
92
  return Qnil;
87
93
  }
@@ -93,11 +99,11 @@ VALUE typecast(const char *value, long length, const VALUE type, int encoding) {
93
99
  return rb_funcall(rb_cByteArray, ID_NEW, 1, rb_str_new(value, length));
94
100
  }
95
101
  else {
96
- return do_typecast(value, length, type, encoding);
102
+ return data_objects_typecast(value, length, type, encoding);
97
103
  }
98
104
  }
99
105
 
100
- void raise_error(VALUE self, MYSQL *db, VALUE query) {
106
+ void do_mysql_raise_error(VALUE self, MYSQL *db, VALUE query) {
101
107
  int errnum = mysql_errno(db);
102
108
  const char *message = mysql_error(db);
103
109
  VALUE sql_state = Qnil;
@@ -106,11 +112,11 @@ void raise_error(VALUE self, MYSQL *db, VALUE query) {
106
112
  sql_state = rb_str_new2(mysql_sqlstate(db));
107
113
  #endif
108
114
 
109
- do_raise_error(self, errors, errnum, message, query, sql_state);
115
+ data_objects_raise_error(self, do_mysql_errors, errnum, message, query, sql_state);
110
116
  }
111
117
 
112
118
  #ifdef _WIN32
113
- MYSQL_RES *cCommand_execute_sync(VALUE self, VALUE connection, MYSQL *db, VALUE query) {
119
+ MYSQL_RES *do_mysql_cCommand_execute_sync(VALUE self, VALUE connection, MYSQL *db, VALUE query) {
114
120
  int retval;
115
121
  struct timeval start;
116
122
  const char *str = rb_str_ptr_readonly(query);
@@ -119,7 +125,7 @@ MYSQL_RES *cCommand_execute_sync(VALUE self, VALUE connection, MYSQL *db, VALUE
119
125
  if (mysql_ping(db) && mysql_errno(db) == CR_SERVER_GONE_ERROR) {
120
126
  // Ok, we do one more try here by doing a full connect
121
127
  VALUE connection = rb_iv_get(self, "@connection");
122
- full_connect(connection, db);
128
+ do_mysql_full_connect(connection, db);
123
129
  }
124
130
 
125
131
  gettimeofday(&start, NULL);
@@ -131,11 +137,11 @@ MYSQL_RES *cCommand_execute_sync(VALUE self, VALUE connection, MYSQL *db, VALUE
131
137
  return mysql_store_result(db);
132
138
  }
133
139
  #else
134
- MYSQL_RES *cCommand_execute_async(VALUE self, VALUE connection, MYSQL *db, VALUE query) {
140
+ MYSQL_RES *do_mysql_cCommand_execute_async(VALUE self, VALUE connection, MYSQL *db, VALUE query) {
135
141
  int retval;
136
142
 
137
143
  if ((retval = mysql_ping(db)) && mysql_errno(db) == CR_SERVER_GONE_ERROR) {
138
- full_connect(connection, db);
144
+ do_mysql_full_connect(connection, db);
139
145
  }
140
146
 
141
147
  struct timeval start;
@@ -183,7 +189,7 @@ MYSQL_RES *cCommand_execute_async(VALUE self, VALUE connection, MYSQL *db, VALUE
183
189
  }
184
190
  #endif
185
191
 
186
- void full_connect(VALUE self, MYSQL *db) {
192
+ void do_mysql_full_connect(VALUE self, MYSQL *db) {
187
193
  VALUE r_host = rb_iv_get(self, "@host");
188
194
  const char *host = "localhost";
189
195
 
@@ -230,7 +236,7 @@ void full_connect(VALUE self, MYSQL *db) {
230
236
 
231
237
  // Check to see if we're on the db machine. If so, try to use the socket
232
238
  if (strcasecmp(host, "localhost") == 0) {
233
- socket = get_uri_option(r_query, "socket");
239
+ socket = data_objects_get_uri_option(r_query, "socket");
234
240
 
235
241
  if (socket) {
236
242
  rb_iv_set(self, "@using_socket", Qtrue);
@@ -245,15 +251,15 @@ void full_connect(VALUE self, MYSQL *db) {
245
251
  r_ssl = rb_hash_aref(r_query, rb_str_new2("ssl"));
246
252
 
247
253
  if (rb_obj_is_kind_of(r_ssl, rb_cHash)) {
248
- ssl_client_key = get_uri_option(r_ssl, "client_key");
249
- ssl_client_cert = get_uri_option(r_ssl, "client_cert");
250
- ssl_ca_cert = get_uri_option(r_ssl, "ca_cert");
251
- ssl_ca_path = get_uri_option(r_ssl, "ca_path");
252
- ssl_cipher = get_uri_option(r_ssl, "cipher");
254
+ ssl_client_key = data_objects_get_uri_option(r_ssl, "client_key");
255
+ ssl_client_cert = data_objects_get_uri_option(r_ssl, "client_cert");
256
+ ssl_ca_cert = data_objects_get_uri_option(r_ssl, "ca_cert");
257
+ ssl_ca_path = data_objects_get_uri_option(r_ssl, "ca_path");
258
+ ssl_cipher = data_objects_get_uri_option(r_ssl, "cipher");
253
259
 
254
- assert_file_exists(ssl_client_key, "client_key doesn't exist");
255
- assert_file_exists(ssl_client_cert, "client_cert doesn't exist");
256
- assert_file_exists(ssl_ca_cert, "ca_cert doesn't exist");
260
+ data_objects_assert_file_exists(ssl_client_key, "client_key doesn't exist");
261
+ data_objects_assert_file_exists(ssl_client_cert, "client_cert doesn't exist");
262
+ data_objects_assert_file_exists(ssl_ca_cert, "ca_cert doesn't exist");
257
263
 
258
264
  mysql_ssl_set(db, ssl_client_key, ssl_client_cert, ssl_ca_cert, ssl_ca_path, ssl_cipher);
259
265
  }
@@ -277,7 +283,7 @@ void full_connect(VALUE self, MYSQL *db) {
277
283
  );
278
284
 
279
285
  if (!result) {
280
- raise_error(self, db, Qnil);
286
+ do_mysql_raise_error(self, db, Qnil);
281
287
  }
282
288
 
283
289
  #ifdef HAVE_MYSQL_GET_SSL_CIPHER
@@ -302,13 +308,13 @@ void full_connect(VALUE self, MYSQL *db) {
302
308
  #ifdef HAVE_MYSQL_SET_CHARACTER_SET
303
309
  // Set the connections character set
304
310
  VALUE encoding = rb_iv_get(self, "@encoding");
305
- VALUE my_encoding = rb_hash_aref(do_const_get(mEncoding, "MAP"), encoding);
311
+ VALUE my_encoding = rb_hash_aref(data_objects_const_get(mEncoding, "MAP"), encoding);
306
312
 
307
313
  if (my_encoding != Qnil) {
308
314
  int encoding_error = mysql_set_character_set(db, rb_str_ptr_readonly(my_encoding));
309
315
 
310
316
  if (encoding_error != 0) {
311
- raise_error(self, db, Qnil);
317
+ do_mysql_raise_error(self, db, Qnil);
312
318
  }
313
319
  else {
314
320
  #ifdef HAVE_RUBY_ENCODING_H
@@ -329,7 +335,7 @@ void full_connect(VALUE self, MYSQL *db) {
329
335
  #endif
330
336
 
331
337
  // Disable sql_auto_is_null
332
- cCommand_execute(Qnil, self, db, rb_str_new2("SET sql_auto_is_null = 0"));
338
+ do_mysql_cCommand_execute(Qnil, self, db, rb_str_new2("SET sql_auto_is_null = 0"));
333
339
  // removed NO_AUTO_VALUE_ON_ZERO because of MySQL bug http://bugs.mysql.com/bug.php?id=42270
334
340
  // added NO_BACKSLASH_ESCAPES so that backslashes should not be escaped as in other databases
335
341
 
@@ -337,17 +343,17 @@ void full_connect(VALUE self, MYSQL *db) {
337
343
  #ifdef HAVE_MYSQL_GET_SERVER_VERSION
338
344
  //4.x versions do not support certain session parameters
339
345
  if (mysql_get_server_version(db) < 50000) {
340
- cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_DIR_IN_CREATE,NO_UNSIGNED_SUBTRACTION'"));
346
+ do_mysql_cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_DIR_IN_CREATE,NO_UNSIGNED_SUBTRACTION'"));
341
347
  }
342
348
  else {
343
- 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'"));
349
+ do_mysql_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'"));
344
350
  }
345
351
  #endif
346
352
 
347
353
  rb_iv_set(self, "@connection", Data_Wrap_Struct(rb_cObject, 0, 0, db));
348
354
  }
349
355
 
350
- VALUE cConnection_initialize(VALUE self, VALUE uri) {
356
+ VALUE do_mysql_cConnection_initialize(VALUE self, VALUE uri) {
351
357
  rb_iv_set(self, "@using_socket", Qfalse);
352
358
  rb_iv_set(self, "@ssl_cipher", Qnil);
353
359
 
@@ -386,10 +392,10 @@ VALUE cConnection_initialize(VALUE self, VALUE uri) {
386
392
 
387
393
  rb_iv_set(self, "@query", r_query);
388
394
 
389
- const char *encoding = get_uri_option(r_query, "encoding");
395
+ const char *encoding = data_objects_get_uri_option(r_query, "encoding");
390
396
 
391
397
  if (!encoding) {
392
- encoding = get_uri_option(r_query, "charset");
398
+ encoding = data_objects_get_uri_option(r_query, "charset");
393
399
 
394
400
  if (!encoding) { encoding = "UTF-8"; }
395
401
  }
@@ -398,12 +404,12 @@ VALUE cConnection_initialize(VALUE self, VALUE uri) {
398
404
 
399
405
  MYSQL *db = mysql_init(NULL);
400
406
 
401
- full_connect(self, db);
407
+ do_mysql_full_connect(self, db);
402
408
  rb_iv_set(self, "@uri", uri);
403
409
  return Qtrue;
404
410
  }
405
411
 
406
- VALUE cConnection_dispose(VALUE self) {
412
+ VALUE do_mysql_cConnection_dispose(VALUE self) {
407
413
  VALUE connection_container = rb_iv_get(self, "@connection");
408
414
 
409
415
  MYSQL *db;
@@ -423,7 +429,8 @@ VALUE cConnection_dispose(VALUE self) {
423
429
  return Qtrue;
424
430
  }
425
431
 
426
- VALUE cConnection_quote_string(VALUE self, VALUE string) {
432
+ VALUE do_mysql_cConnection_quote_string(VALUE self, VALUE string) {
433
+
427
434
  MYSQL *db = DATA_PTR(rb_iv_get(self, "@connection"));
428
435
  const char *source = rb_str_ptr_readonly(string);
429
436
  long source_len = rb_str_len(string);
@@ -453,13 +460,15 @@ VALUE cConnection_quote_string(VALUE self, VALUE string) {
453
460
  escaped[0] = escaped[quoted_length + 1] = '\'';
454
461
  // We don't want to use the internal encoding, because this needs
455
462
  // to go into the database in the connection encoding
456
- result = DO_STR_NEW(escaped, quoted_length + 2, FIX2INT(rb_iv_get(self, "@encoding_id")), NULL);
463
+
464
+ result = DATA_OBJECTS_STR_NEW(escaped, quoted_length + 2, FIX2INT(rb_iv_get(self, "@encoding_id")), NULL);
457
465
 
458
466
  free(escaped);
467
+
459
468
  return result;
460
469
  }
461
470
 
462
- VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
471
+ VALUE do_mysql_cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
463
472
  VALUE connection = rb_iv_get(self, "@connection");
464
473
  VALUE mysql_connection = rb_iv_get(connection, "@connection");
465
474
 
@@ -468,8 +477,8 @@ VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
468
477
  }
469
478
 
470
479
  MYSQL *db = DATA_PTR(mysql_connection);
471
- VALUE query = build_query_from_args(self, argc, argv);
472
- MYSQL_RES *response = cCommand_execute(self, connection, db, query);
480
+ VALUE query = data_objects_build_query_from_args(self, argc, argv);
481
+ MYSQL_RES *response = do_mysql_cCommand_execute(self, connection, db, query);
473
482
 
474
483
  my_ulonglong affected_rows = mysql_affected_rows(db);
475
484
  my_ulonglong insert_id = mysql_insert_id(db);
@@ -480,10 +489,10 @@ VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
480
489
  return Qnil;
481
490
  }
482
491
 
483
- return rb_funcall(cResult, ID_NEW, 3, self, INT2NUM(affected_rows), insert_id == 0 ? Qnil : INT2NUM(insert_id));
492
+ return rb_funcall(cMysqlResult, ID_NEW, 3, self, INT2NUM(affected_rows), insert_id == 0 ? Qnil : INT2NUM(insert_id));
484
493
  }
485
494
 
486
- VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
495
+ VALUE do_mysql_cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
487
496
  VALUE connection = rb_iv_get(self, "@connection");
488
497
  VALUE mysql_connection = rb_iv_get(connection, "@connection");
489
498
 
@@ -491,16 +500,16 @@ VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
491
500
  rb_raise(eConnectionError, "This connection has already been closed.");
492
501
  }
493
502
 
494
- VALUE query = build_query_from_args(self, argc, argv);
503
+ VALUE query = data_objects_build_query_from_args(self, argc, argv);
495
504
  MYSQL *db = DATA_PTR(mysql_connection);
496
- MYSQL_RES *response = cCommand_execute(self, connection, db, query);
505
+ MYSQL_RES *response = do_mysql_cCommand_execute(self, connection, db, query);
497
506
 
498
507
  if (!response) {
499
508
  rb_raise(eConnectionError, "No result set received for a query that should yield one.");
500
509
  }
501
510
 
502
511
  unsigned int field_count = mysql_field_count(db);
503
- VALUE reader = rb_funcall(cReader, ID_NEW, 0);
512
+ VALUE reader = rb_funcall(cMysqlReader, ID_NEW, 0);
504
513
 
505
514
  rb_iv_set(reader, "@connection", connection);
506
515
  rb_iv_set(reader, "@reader", Data_Wrap_Struct(rb_cObject, 0, 0, response));
@@ -531,7 +540,7 @@ VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
531
540
  rb_ary_push(field_names, rb_str_new2(field->name));
532
541
 
533
542
  if (guess_default_field_types == 1) {
534
- rb_ary_push(field_types, infer_ruby_type(field));
543
+ rb_ary_push(field_types, do_mysql_infer_ruby_type(field));
535
544
  }
536
545
  }
537
546
 
@@ -547,7 +556,7 @@ VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
547
556
  }
548
557
 
549
558
  // This should be called to ensure that the internal result reader is freed
550
- VALUE cReader_close(VALUE self) {
559
+ VALUE do_mysql_cReader_close(VALUE self) {
551
560
  // Get the reader from the instance variable, maybe refactor this?
552
561
  VALUE reader_container = rb_iv_get(self, "@reader");
553
562
 
@@ -569,7 +578,7 @@ VALUE cReader_close(VALUE self) {
569
578
  }
570
579
 
571
580
  // Retrieve a single row
572
- VALUE cReader_next(VALUE self) {
581
+ VALUE do_mysql_cReader_next(VALUE self) {
573
582
  // Get the reader from the instance variable, maybe refactor this?
574
583
  VALUE reader_container = rb_iv_get(self, "@reader");
575
584
 
@@ -606,7 +615,7 @@ VALUE cReader_next(VALUE self) {
606
615
  for (i = 0; i < reader->field_count; i++) {
607
616
  // The field_type data could be cached in a c-array
608
617
  field_type = rb_ary_entry(field_types, i);
609
- rb_ary_push(row, typecast(result[i], lengths[i], field_type, enc));
618
+ rb_ary_push(row, do_mysql_typecast(result[i], lengths[i], field_type, enc));
610
619
  }
611
620
 
612
621
  rb_iv_set(self, "@values", row);
@@ -614,41 +623,41 @@ VALUE cReader_next(VALUE self) {
614
623
  }
615
624
 
616
625
  void Init_do_mysql() {
617
- common_init();
626
+ data_objects_common_init();
618
627
 
619
628
  // Top Level Module that all the classes live under
620
629
  mMysql = rb_define_module_under(mDO, "Mysql");
621
630
  mEncoding = rb_define_module_under(mMysql, "Encoding");
622
631
 
623
- cConnection = rb_define_class_under(mMysql, "Connection", cDO_Connection);
624
- rb_define_method(cConnection, "initialize", cConnection_initialize, 1);
625
- rb_define_method(cConnection, "using_socket?", cConnection_is_using_socket, 0);
626
- rb_define_method(cConnection, "ssl_cipher", cConnection_ssl_cipher, 0);
627
- rb_define_method(cConnection, "character_set", cConnection_character_set , 0);
628
- rb_define_method(cConnection, "dispose", cConnection_dispose, 0);
629
- rb_define_method(cConnection, "quote_string", cConnection_quote_string, 1);
630
- rb_define_method(cConnection, "quote_date", cConnection_quote_date, 1);
631
- rb_define_method(cConnection, "quote_time", cConnection_quote_time, 1);
632
- rb_define_method(cConnection, "quote_datetime", cConnection_quote_date_time, 1);
633
-
634
- cCommand = rb_define_class_under(mMysql, "Command", cDO_Command);
635
- rb_define_method(cCommand, "set_types", cCommand_set_types, -1);
636
- rb_define_method(cCommand, "execute_non_query", cCommand_execute_non_query, -1);
637
- rb_define_method(cCommand, "execute_reader", cCommand_execute_reader, -1);
632
+ cMysqlConnection = rb_define_class_under(mMysql, "Connection", cDO_Connection);
633
+ rb_define_method(cMysqlConnection, "initialize", do_mysql_cConnection_initialize, 1);
634
+ rb_define_method(cMysqlConnection, "using_socket?", data_objects_cConnection_is_using_socket, 0);
635
+ rb_define_method(cMysqlConnection, "ssl_cipher", data_objects_cConnection_ssl_cipher, 0);
636
+ rb_define_method(cMysqlConnection, "character_set", data_objects_cConnection_character_set , 0);
637
+ rb_define_method(cMysqlConnection, "dispose", do_mysql_cConnection_dispose, 0);
638
+ rb_define_method(cMysqlConnection, "quote_string", do_mysql_cConnection_quote_string, 1);
639
+ rb_define_method(cMysqlConnection, "quote_date", data_objects_cConnection_quote_date, 1);
640
+ rb_define_method(cMysqlConnection, "quote_time", data_objects_cConnection_quote_time, 1);
641
+ rb_define_method(cMysqlConnection, "quote_datetime", data_objects_cConnection_quote_date_time, 1);
642
+
643
+ cMysqlCommand = rb_define_class_under(mMysql, "Command", cDO_Command);
644
+ rb_define_method(cMysqlCommand, "set_types", data_objects_cCommand_set_types, -1);
645
+ rb_define_method(cMysqlCommand, "execute_non_query", do_mysql_cCommand_execute_non_query, -1);
646
+ rb_define_method(cMysqlCommand, "execute_reader", do_mysql_cCommand_execute_reader, -1);
638
647
 
639
648
  // Non-Query result
640
- cResult = rb_define_class_under(mMysql, "Result", cDO_Result);
649
+ cMysqlResult = rb_define_class_under(mMysql, "Result", cDO_Result);
641
650
 
642
651
  // Query result
643
- cReader = rb_define_class_under(mMysql, "Reader", cDO_Reader);
644
- rb_define_method(cReader, "close", cReader_close, 0);
645
- rb_define_method(cReader, "next!", cReader_next, 0);
646
- rb_define_method(cReader, "values", cReader_values, 0);
647
- rb_define_method(cReader, "fields", cReader_fields, 0);
648
- rb_define_method(cReader, "field_count", cReader_field_count, 0);
652
+ cMysqlReader = rb_define_class_under(mMysql, "Reader", cDO_Reader);
653
+ rb_define_method(cMysqlReader, "close", do_mysql_cReader_close, 0);
654
+ rb_define_method(cMysqlReader, "next!", do_mysql_cReader_next, 0);
655
+ rb_define_method(cMysqlReader, "values", data_objects_cReader_values, 0);
656
+ rb_define_method(cMysqlReader, "fields", data_objects_cReader_fields, 0);
657
+ rb_define_method(cMysqlReader, "field_count", data_objects_cReader_field_count, 0);
649
658
 
650
- rb_global_variable(&cResult);
651
- rb_global_variable(&cReader);
659
+ rb_global_variable(&cMysqlResult);
660
+ rb_global_variable(&cMysqlReader);
652
661
 
653
- do_define_errors(mMysql, errors);
662
+ data_objects_define_errors(mMysql, do_mysql_errors);
654
663
  }
data/ext/do_mysql/error.h CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "do_common.h"
5
5
 
6
- static struct errcodes errors[] = {
6
+ static struct errcodes do_mysql_errors[] = {
7
7
  #ifdef ER_ABORTING_CONNECTION
8
8
  ERRCODE(ER_ABORTING_CONNECTION, "ConnectionError"),
9
9
  #endif
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Mysql
3
- VERSION = '0.10.5'
3
+ VERSION = '0.10.6'
4
4
  end
5
5
  end
data/tasks/compile.rake CHANGED
@@ -56,7 +56,7 @@ begin
56
56
  ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
57
57
  ext.java_compiling do |gem|
58
58
  gem.add_dependency 'jdbc-mysql', '>=5.0.4'
59
- gem.add_dependency 'do_jdbc', '0.10.5'
59
+ gem.add_dependency 'do_jdbc', '0.10.6'
60
60
  end
61
61
  end
62
62
  rescue LoadError
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_mysql
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
5
- prerelease: false
4
+ hash: 59
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 5
10
- version: 0.10.5
9
+ - 6
10
+ version: 0.10.6
11
11
  platform: x86-mswin32-60
12
12
  authors:
13
13
  - Dirkjan Bussink
@@ -19,22 +19,23 @@ date: 2011-03-29 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ type: :runtime
22
23
  requirement: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
25
26
  - - "="
26
27
  - !ruby/object:Gem::Version
27
- hash: 61
28
+ hash: 59
28
29
  segments:
29
30
  - 0
30
31
  - 10
31
- - 5
32
- version: 0.10.5
33
- type: :runtime
32
+ - 6
33
+ version: 0.10.6
34
34
  name: data_objects
35
- prerelease: false
36
35
  version_requirements: *id001
36
+ prerelease: false
37
37
  - !ruby/object:Gem::Dependency
38
+ type: :development
38
39
  requirement: &id002 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
@@ -45,11 +46,11 @@ dependencies:
45
46
  - 2
46
47
  - 5
47
48
  version: "2.5"
48
- type: :development
49
49
  name: rspec
50
- prerelease: false
51
50
  version_requirements: *id002
51
+ prerelease: false
52
52
  - !ruby/object:Gem::Dependency
53
+ type: :development
53
54
  requirement: &id003 !ruby/object:Gem::Requirement
54
55
  none: false
55
56
  requirements:
@@ -60,10 +61,9 @@ dependencies:
60
61
  - 0
61
62
  - 7
62
63
  version: "0.7"
63
- type: :development
64
64
  name: rake-compiler
65
- prerelease: false
66
65
  version_requirements: *id003
66
+ prerelease: false
67
67
  description: Implements the DataObjects API for MySQL
68
68
  email: d.bussink@gmail.com
69
69
  executables: []
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  requirements: []
166
166
 
167
167
  rubyforge_project: dorb
168
- rubygems_version: 1.3.7
168
+ rubygems_version: 1.5.2
169
169
  signing_key:
170
170
  specification_version: 3
171
171
  summary: DataObjects MySQL Driver