do_sqlite3 0.10.10 → 0.10.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 0.10.11 2012-12-29
2
+
3
+ * Rename C symbols to prevent name collitions
4
+
1
5
  ## 0.10.10 2012-10-11
2
6
 
3
7
  * Add support to C driver for busy\_timeout
@@ -11,13 +11,13 @@
11
11
  */
12
12
 
13
13
  // To store rb_intern values
14
- ID ID_NEW;
15
- ID ID_NEW_DATE;
16
- ID ID_CONST_GET;
17
- ID ID_RATIONAL;
18
- ID ID_ESCAPE;
19
- ID ID_STRFTIME;
20
- ID ID_LOG;
14
+ ID DO_ID_NEW;
15
+ ID DO_ID_NEW_DATE;
16
+ ID DO_ID_CONST_GET;
17
+ ID DO_ID_RATIONAL;
18
+ ID DO_ID_ESCAPE;
19
+ ID DO_ID_STRFTIME;
20
+ ID DO_ID_LOG;
21
21
 
22
22
  // Reference to Extlib module
23
23
  VALUE mExtlib;
@@ -33,8 +33,8 @@ VALUE cDO_Reader;
33
33
  VALUE cDO_Logger;
34
34
  VALUE cDO_Logger_Message;
35
35
  VALUE cDO_Extension;
36
- VALUE eConnectionError;
37
- VALUE eDataError;
36
+ VALUE eDO_ConnectionError;
37
+ VALUE eDO_DataError;
38
38
 
39
39
  // References to Ruby classes that we'll need
40
40
  VALUE rb_cDate;
@@ -47,7 +47,7 @@ VALUE rb_cBigDecimal;
47
47
 
48
48
 
49
49
  VALUE data_objects_const_get(VALUE scope, const char *constant) {
50
- return rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant));
50
+ return rb_funcall(scope, DO_ID_CONST_GET, 1, rb_str_new2(constant));
51
51
  }
52
52
 
53
53
  void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
@@ -58,9 +58,9 @@ void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
58
58
  gettimeofday(&stop, NULL);
59
59
  duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
60
60
 
61
- message = rb_funcall(cDO_Logger_Message, ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
61
+ message = rb_funcall(cDO_Logger_Message, DO_ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
62
62
 
63
- rb_funcall(connection, ID_LOG, 1, message);
63
+ rb_funcall(connection, DO_ID_LOG, 1, message);
64
64
  }
65
65
 
66
66
  void data_objects_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state) {
@@ -80,7 +80,7 @@ void data_objects_raise_error(VALUE self, const struct errcodes *errors, int err
80
80
 
81
81
  exception = rb_funcall(
82
82
  data_objects_const_get(mDO, exception_type),
83
- ID_NEW,
83
+ DO_ID_NEW,
84
84
  5,
85
85
  rb_str_new2(message),
86
86
  INT2NUM(errnum),
@@ -125,7 +125,7 @@ VALUE data_objects_build_query_from_args(VALUE klass, int count, VALUE *args) {
125
125
  rb_ary_push(array, args[i]);
126
126
  }
127
127
 
128
- return rb_funcall(klass, ID_ESCAPE, 1, array);
128
+ return rb_funcall(klass, DO_ID_ESCAPE, 1, array);
129
129
  }
130
130
 
131
131
  // Find the greatest common denominator and reduce the provided numerator and denominator.
@@ -163,7 +163,7 @@ VALUE data_objects_seconds_to_offset(long seconds_offset) {
163
163
  do_int64 den = 86400;
164
164
 
165
165
  data_objects_reduce(&num, &den);
166
- return rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ll2inum(num), rb_ll2inum(den));
166
+ return rb_funcall(rb_mKernel, DO_ID_RATIONAL, 2, rb_ll2inum(num), rb_ll2inum(den));
167
167
  }
168
168
 
169
169
  VALUE data_objects_timezone_to_offset(int hour_offset, int minute_offset) {
@@ -189,7 +189,7 @@ VALUE data_objects_parse_date(const char *date) {
189
189
  return Qnil;
190
190
  }
191
191
 
192
- return rb_funcall(rb_cDate, ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
192
+ return rb_funcall(rb_cDate, DO_ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
193
193
  }
194
194
 
195
195
  VALUE data_objects_parse_time(const char *date) {
@@ -299,11 +299,11 @@ VALUE data_objects_parse_date_time(const char *date) {
299
299
  break;
300
300
 
301
301
  default: /* Any other combo of missing tokens and we can't do anything */
302
- rb_raise(eDataError, "Couldn't parse date: %s", date);
302
+ rb_raise(eDO_DataError, "Couldn't parse date: %s", date);
303
303
  }
304
304
 
305
305
  offset = data_objects_timezone_to_offset(hour_offset, minute_offset);
306
- return rb_funcall(rb_cDateTime, ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
306
+ return rb_funcall(rb_cDateTime, DO_ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
307
307
  INT2NUM(hour), INT2NUM(min), INT2NUM(sec), offset);
308
308
  }
309
309
 
@@ -320,17 +320,17 @@ VALUE data_objects_cConnection_ssl_cipher(VALUE self) {
320
320
  }
321
321
 
322
322
  VALUE data_objects_cConnection_quote_time(VALUE self, VALUE value) {
323
- return rb_funcall(value, ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d %H:%M:%S'"));
323
+ return rb_funcall(value, DO_ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d %H:%M:%S'"));
324
324
  }
325
325
 
326
326
  VALUE data_objects_cConnection_quote_date_time(VALUE self, VALUE value) {
327
327
  // TODO: Support non-local dates. we need to call #new_offset on the date to be
328
328
  // quoted and pass in the current locale's date offset (self.new_offset((hours * 3600).to_r / 86400)
329
- return rb_funcall(value, ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d %H:%M:%S'"));
329
+ return rb_funcall(value, DO_ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d %H:%M:%S'"));
330
330
  }
331
331
 
332
332
  VALUE data_objects_cConnection_quote_date(VALUE self, VALUE value) {
333
- return rb_funcall(value, ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d'"));
333
+ return rb_funcall(value, DO_ID_STRFTIME, 1, rb_str_new2("'%Y-%m-%d'"));
334
334
  }
335
335
 
336
336
  /*
@@ -379,7 +379,7 @@ VALUE data_objects_cReader_values(VALUE self) {
379
379
  VALUE values = rb_iv_get(self, "@values");
380
380
 
381
381
  if (state == Qnil || state == Qfalse || values == Qnil) {
382
- rb_raise(eDataError, "Reader is not initialized");
382
+ rb_raise(eDO_DataError, "Reader is not initialized");
383
383
  }
384
384
 
385
385
  return rb_iv_get(self, "@values");
@@ -400,24 +400,24 @@ void data_objects_common_init(void) {
400
400
  rb_require("data_objects");
401
401
 
402
402
  // Needed by data_objects_const_get
403
- ID_CONST_GET = rb_intern("const_get");
403
+ DO_ID_CONST_GET = rb_intern("const_get");
404
404
 
405
405
  // Get references classes needed for Date/Time parsing
406
406
  rb_cDate = data_objects_const_get(rb_mKernel, "Date");
407
407
  rb_cDateTime = data_objects_const_get(rb_mKernel, "DateTime");
408
408
  rb_cBigDecimal = data_objects_const_get(rb_mKernel, "BigDecimal");
409
409
 
410
- ID_NEW = rb_intern("new");
410
+ DO_ID_NEW = rb_intern("new");
411
411
  #ifdef RUBY_LESS_THAN_186
412
- ID_NEW_DATE = rb_intern("new0");
412
+ DO_ID_NEW_DATE = rb_intern("new0");
413
413
  #else
414
- ID_NEW_DATE = rb_intern("new!");
414
+ DO_ID_NEW_DATE = rb_intern("new!");
415
415
  #endif
416
- ID_CONST_GET = rb_intern("const_get");
417
- ID_RATIONAL = rb_intern("Rational");
418
- ID_ESCAPE = rb_intern("escape_sql");
419
- ID_STRFTIME = rb_intern("strftime");
420
- ID_LOG = rb_intern("log");
416
+ DO_ID_CONST_GET = rb_intern("const_get");
417
+ DO_ID_RATIONAL = rb_intern("Rational");
418
+ DO_ID_ESCAPE = rb_intern("escape_sql");
419
+ DO_ID_STRFTIME = rb_intern("strftime");
420
+ DO_ID_LOG = rb_intern("log");
421
421
 
422
422
  // Get references to the Extlib module
423
423
  mExtlib = data_objects_const_get(rb_mKernel, "Extlib");
@@ -434,15 +434,15 @@ void data_objects_common_init(void) {
434
434
  cDO_Logger_Message = data_objects_const_get(cDO_Logger, "Message");
435
435
  cDO_Extension = data_objects_const_get(mDO, "Extension");
436
436
 
437
- eConnectionError = data_objects_const_get(mDO, "ConnectionError");
438
- eDataError = data_objects_const_get(mDO, "DataError");
437
+ eDO_ConnectionError = data_objects_const_get(mDO, "ConnectionError");
438
+ eDO_DataError = data_objects_const_get(mDO, "DataError");
439
439
 
440
- rb_global_variable(&ID_NEW_DATE);
441
- rb_global_variable(&ID_RATIONAL);
442
- rb_global_variable(&ID_CONST_GET);
443
- rb_global_variable(&ID_ESCAPE);
444
- rb_global_variable(&ID_LOG);
445
- rb_global_variable(&ID_NEW);
440
+ rb_global_variable(&DO_ID_NEW_DATE);
441
+ rb_global_variable(&DO_ID_RATIONAL);
442
+ rb_global_variable(&DO_ID_CONST_GET);
443
+ rb_global_variable(&DO_ID_ESCAPE);
444
+ rb_global_variable(&DO_ID_LOG);
445
+ rb_global_variable(&DO_ID_NEW);
446
446
 
447
447
  rb_global_variable(&rb_cDate);
448
448
  rb_global_variable(&rb_cDateTime);
@@ -452,8 +452,8 @@ void data_objects_common_init(void) {
452
452
  rb_global_variable(&mDO);
453
453
  rb_global_variable(&cDO_Logger_Message);
454
454
 
455
- rb_global_variable(&eConnectionError);
456
- rb_global_variable(&eDataError);
455
+ rb_global_variable(&eDO_ConnectionError);
456
+ rb_global_variable(&eDO_DataError);
457
457
 
458
458
  tzset();
459
459
  }
@@ -478,7 +478,7 @@ extern VALUE data_objects_typecast(const char *value, long length, const VALUE t
478
478
  return rb_float_new(rb_cstr_to_dbl(value, Qfalse));
479
479
  }
480
480
  else if (type == rb_cBigDecimal) {
481
- return rb_funcall(rb_cBigDecimal, ID_NEW, 1, rb_str_new(value, length));
481
+ return rb_funcall(rb_cBigDecimal, DO_ID_NEW, 1, rb_str_new(value, length));
482
482
  }
483
483
  else if (type == rb_cDate) {
484
484
  return data_objects_parse_date(value);
@@ -493,7 +493,7 @@ extern VALUE data_objects_typecast(const char *value, long length, const VALUE t
493
493
  return (!value || strcmp("0", value) == 0) ? Qfalse : Qtrue;
494
494
  }
495
495
  else if (type == rb_cByteArray) {
496
- return rb_funcall(rb_cByteArray, ID_NEW, 1, rb_str_new(value, length));
496
+ return rb_funcall(rb_cByteArray, DO_ID_NEW, 1, rb_str_new(value, length));
497
497
  }
498
498
  else if (type == rb_cClass) {
499
499
  return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new(value, length));
@@ -54,13 +54,13 @@ typedef signed long long int do_int64;
54
54
  #endif
55
55
 
56
56
  // To store rb_intern values
57
- extern ID ID_NEW;
58
- extern ID ID_NEW_DATE;
59
- extern ID ID_CONST_GET;
60
- extern ID ID_RATIONAL;
61
- extern ID ID_ESCAPE;
62
- extern ID ID_STRFTIME;
63
- extern ID ID_LOG;
57
+ extern ID DO_ID_NEW;
58
+ extern ID DO_ID_NEW_DATE;
59
+ extern ID DO_ID_CONST_GET;
60
+ extern ID DO_ID_RATIONAL;
61
+ extern ID DO_ID_ESCAPE;
62
+ extern ID DO_ID_STRFTIME;
63
+ extern ID DO_ID_LOG;
64
64
 
65
65
  // Reference to Extlib module
66
66
  extern VALUE mExtlib;
@@ -68,7 +68,6 @@ extern VALUE rb_cByteArray;
68
68
 
69
69
  // References to DataObjects base classes
70
70
  extern VALUE mDO;
71
- extern VALUE mEncoding;
72
71
  extern VALUE cDO_Quoting;
73
72
  extern VALUE cDO_Connection;
74
73
  extern VALUE cDO_Command;
@@ -77,8 +76,8 @@ extern VALUE cDO_Reader;
77
76
  extern VALUE cDO_Logger;
78
77
  extern VALUE cDO_Logger_Message;
79
78
  extern VALUE cDO_Extension;
80
- extern VALUE eConnectionError;
81
- extern VALUE eDataError;
79
+ extern VALUE eDO_ConnectionError;
80
+ extern VALUE eDO_DataError;
82
81
 
83
82
  // References to Ruby classes that we'll need
84
83
  extern VALUE rb_cDate;
@@ -3,17 +3,17 @@
3
3
 
4
4
  #include "do_common.h"
5
5
 
6
- VALUE mSqlite3;
7
- VALUE cSqlite3Connection;
8
- VALUE cSqlite3Command;
9
- VALUE cSqlite3Result;
10
- VALUE cSqlite3Reader;
11
-
12
- VALUE OPEN_FLAG_READONLY;
13
- VALUE OPEN_FLAG_READWRITE;
14
- VALUE OPEN_FLAG_CREATE;
15
- VALUE OPEN_FLAG_NO_MUTEX;
16
- VALUE OPEN_FLAG_FULL_MUTEX;
6
+ VALUE mDO_Sqlite3;
7
+ VALUE cDO_Sqlite3Connection;
8
+ VALUE cDO_Sqlite3Command;
9
+ VALUE cDO_Sqlite3Result;
10
+ VALUE cDO_Sqlite3Reader;
11
+
12
+ VALUE DO_OPEN_FLAG_READONLY;
13
+ VALUE DO_OPEN_FLAG_READWRITE;
14
+ VALUE DO_OPEN_FLAG_CREATE;
15
+ VALUE DO_OPEN_FLAG_NO_MUTEX;
16
+ VALUE DO_OPEN_FLAG_FULL_MUTEX;
17
17
 
18
18
  void do_sqlite3_raise_error(VALUE self, sqlite3 *result, VALUE query) {
19
19
  int errnum = sqlite3_errcode(result);
@@ -67,7 +67,7 @@ VALUE do_sqlite3_typecast(sqlite3_stmt *stmt, int i, VALUE type, int encoding) {
67
67
  return rb_float_new(sqlite3_column_double(stmt, i));
68
68
  }
69
69
  else if (type == rb_cBigDecimal) {
70
- return rb_funcall(rb_cBigDecimal, ID_NEW, 1, rb_str_new((char*)sqlite3_column_text(stmt, i), length));
70
+ return rb_funcall(rb_cBigDecimal, DO_ID_NEW, 1, rb_str_new((char*)sqlite3_column_text(stmt, i), length));
71
71
  }
72
72
  else if (type == rb_cDate) {
73
73
  return data_objects_parse_date((char*)sqlite3_column_text(stmt, i));
@@ -82,7 +82,7 @@ VALUE do_sqlite3_typecast(sqlite3_stmt *stmt, int i, VALUE type, int encoding) {
82
82
  return strcmp((char*)sqlite3_column_text(stmt, i), "t") == 0 ? Qtrue : Qfalse;
83
83
  }
84
84
  else if (type == rb_cByteArray) {
85
- return rb_funcall(rb_cByteArray, ID_NEW, 1, rb_str_new((char*)sqlite3_column_blob(stmt, i), length));
85
+ return rb_funcall(rb_cByteArray, DO_ID_NEW, 1, rb_str_new((char*)sqlite3_column_blob(stmt, i), length));
86
86
  }
87
87
  else if (type == rb_cClass) {
88
88
  return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new((char*)sqlite3_column_text(stmt, i), length));
@@ -106,7 +106,7 @@ int do_sqlite3_flags_from_uri(VALUE uri) {
106
106
  if (!NIL_P(query_values) && TYPE(query_values) == T_HASH) {
107
107
  /// scan for flags
108
108
  #ifdef SQLITE_OPEN_READONLY
109
- if (FLAG_PRESENT(query_values, OPEN_FLAG_READONLY)) {
109
+ if (FLAG_PRESENT(query_values, DO_OPEN_FLAG_READONLY)) {
110
110
  flags |= SQLITE_OPEN_READONLY;
111
111
  }
112
112
  else {
@@ -115,13 +115,13 @@ int do_sqlite3_flags_from_uri(VALUE uri) {
115
115
  #endif
116
116
 
117
117
  #ifdef SQLITE_OPEN_NOMUTEX
118
- if (FLAG_PRESENT(query_values, OPEN_FLAG_NO_MUTEX)) {
118
+ if (FLAG_PRESENT(query_values, DO_OPEN_FLAG_NO_MUTEX)) {
119
119
  flags |= SQLITE_OPEN_NOMUTEX;
120
120
  }
121
121
  #endif
122
122
 
123
123
  #ifdef SQLITE_OPEN_FULLMUTEX
124
- if (FLAG_PRESENT(query_values, OPEN_FLAG_FULL_MUTEX)) {
124
+ if (FLAG_PRESENT(query_values, DO_OPEN_FLAG_FULL_MUTEX)) {
125
125
  flags |= SQLITE_OPEN_FULLMUTEX;
126
126
  }
127
127
  #endif
@@ -241,7 +241,7 @@ VALUE do_sqlite3_cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
241
241
  VALUE sqlite3_connection = rb_iv_get(connection, "@connection");
242
242
 
243
243
  if (sqlite3_connection == Qnil) {
244
- rb_raise(eConnectionError, "This connection has already been closed.");
244
+ rb_raise(eDO_ConnectionError, "This connection has already been closed.");
245
245
  }
246
246
 
247
247
  sqlite3 *db = NULL;
@@ -264,7 +264,7 @@ VALUE do_sqlite3_cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
264
264
  int affected_rows = sqlite3_changes(db);
265
265
  do_int64 insert_id = sqlite3_last_insert_rowid(db);
266
266
 
267
- return rb_funcall(cSqlite3Result, ID_NEW, 3, self, INT2NUM(affected_rows), INT2NUM(insert_id));
267
+ return rb_funcall(cDO_Sqlite3Result, DO_ID_NEW, 3, self, INT2NUM(affected_rows), INT2NUM(insert_id));
268
268
  }
269
269
 
270
270
  VALUE do_sqlite3_cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
@@ -273,7 +273,7 @@ VALUE do_sqlite3_cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
273
273
  VALUE sqlite3_connection = rb_iv_get(connection, "@connection");
274
274
 
275
275
  if (sqlite3_connection == Qnil) {
276
- rb_raise(eConnectionError, "This connection has already been closed.");
276
+ rb_raise(eDO_ConnectionError, "This connection has already been closed.");
277
277
  }
278
278
 
279
279
  sqlite3 *db = NULL;
@@ -293,7 +293,7 @@ VALUE do_sqlite3_cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
293
293
  }
294
294
 
295
295
  int field_count = sqlite3_column_count(sqlite3_reader);
296
- VALUE reader = rb_funcall(cSqlite3Reader, ID_NEW, 0);
296
+ VALUE reader = rb_funcall(cDO_Sqlite3Reader, DO_ID_NEW, 0);
297
297
 
298
298
  rb_iv_set(reader, "@reader", Data_Wrap_Struct(rb_cObject, 0, 0, sqlite3_reader));
299
299
  rb_iv_set(reader, "@field_count", INT2NUM(field_count));
@@ -343,7 +343,7 @@ VALUE do_sqlite3_cReader_next(VALUE self) {
343
343
  VALUE reader = rb_iv_get(self, "@reader");
344
344
 
345
345
  if(reader == Qnil) {
346
- rb_raise(eConnectionError, "This result set has already been closed.");
346
+ rb_raise(eDO_ConnectionError, "This result set has already been closed.");
347
347
  }
348
348
 
349
349
  if (rb_iv_get(self, "@done") == Qtrue) {
@@ -394,7 +394,7 @@ VALUE do_sqlite3_cReader_values(VALUE self) {
394
394
  VALUE state = rb_iv_get(self, "@state");
395
395
 
396
396
  if (state == Qnil || NUM2INT(state) != SQLITE_ROW) {
397
- rb_raise(eDataError, "Reader is not initialized");
397
+ rb_raise(eDO_DataError, "Reader is not initialized");
398
398
  return Qnil;
399
399
  }
400
400
 
@@ -404,45 +404,45 @@ VALUE do_sqlite3_cReader_values(VALUE self) {
404
404
  void Init_do_sqlite3() {
405
405
  data_objects_common_init();
406
406
 
407
- mSqlite3 = rb_define_module_under(mDO, "Sqlite3");
408
-
409
- cSqlite3Connection = rb_define_class_under(mSqlite3, "Connection", cDO_Connection);
410
- rb_define_method(cSqlite3Connection, "initialize", do_sqlite3_cConnection_initialize, 1);
411
- rb_define_method(cSqlite3Connection, "dispose", do_sqlite3_cConnection_dispose, 0);
412
- rb_define_method(cSqlite3Connection, "quote_boolean", do_sqlite3_cConnection_quote_boolean, 1);
413
- rb_define_method(cSqlite3Connection, "quote_string", do_sqlite3_cConnection_quote_string, 1);
414
- rb_define_method(cSqlite3Connection, "quote_byte_array", do_sqlite3_cConnection_quote_byte_array, 1);
415
- rb_define_method(cSqlite3Connection, "character_set", data_objects_cConnection_character_set, 0);
416
-
417
- cSqlite3Command = rb_define_class_under(mSqlite3, "Command", cDO_Command);
418
- rb_define_method(cSqlite3Command, "set_types", data_objects_cCommand_set_types, -1);
419
- rb_define_method(cSqlite3Command, "execute_non_query", do_sqlite3_cCommand_execute_non_query, -1);
420
- rb_define_method(cSqlite3Command, "execute_reader", do_sqlite3_cCommand_execute_reader, -1);
421
-
422
- cSqlite3Result = rb_define_class_under(mSqlite3, "Result", cDO_Result);
423
-
424
- cSqlite3Reader = rb_define_class_under(mSqlite3, "Reader", cDO_Reader);
425
- rb_define_method(cSqlite3Reader, "close", do_sqlite3_cReader_close, 0);
426
- rb_define_method(cSqlite3Reader, "next!", do_sqlite3_cReader_next, 0);
427
- rb_define_method(cSqlite3Reader, "values", do_sqlite3_cReader_values, 0); // TODO: DRY?
428
- rb_define_method(cSqlite3Reader, "fields", data_objects_cReader_fields, 0);
429
- rb_define_method(cSqlite3Reader, "field_count", data_objects_cReader_field_count, 0);
430
-
431
- rb_global_variable(&cSqlite3Result);
432
- rb_global_variable(&cSqlite3Reader);
433
-
434
- OPEN_FLAG_READONLY = rb_str_new2("read_only");
435
- rb_global_variable(&OPEN_FLAG_READONLY);
436
- OPEN_FLAG_READWRITE = rb_str_new2("read_write");
437
- rb_global_variable(&OPEN_FLAG_READWRITE);
438
- OPEN_FLAG_CREATE = rb_str_new2("create");
439
- rb_global_variable(&OPEN_FLAG_CREATE);
440
- OPEN_FLAG_NO_MUTEX = rb_str_new2("no_mutex");
441
- rb_global_variable(&OPEN_FLAG_NO_MUTEX);
442
- OPEN_FLAG_FULL_MUTEX = rb_str_new2("full_mutex");
443
- rb_global_variable(&OPEN_FLAG_FULL_MUTEX);
407
+ mDO_Sqlite3 = rb_define_module_under(mDO, "Sqlite3");
408
+
409
+ cDO_Sqlite3Connection = rb_define_class_under(mDO_Sqlite3, "Connection", cDO_Connection);
410
+ rb_define_method(cDO_Sqlite3Connection, "initialize", do_sqlite3_cConnection_initialize, 1);
411
+ rb_define_method(cDO_Sqlite3Connection, "dispose", do_sqlite3_cConnection_dispose, 0);
412
+ rb_define_method(cDO_Sqlite3Connection, "quote_boolean", do_sqlite3_cConnection_quote_boolean, 1);
413
+ rb_define_method(cDO_Sqlite3Connection, "quote_string", do_sqlite3_cConnection_quote_string, 1);
414
+ rb_define_method(cDO_Sqlite3Connection, "quote_byte_array", do_sqlite3_cConnection_quote_byte_array, 1);
415
+ rb_define_method(cDO_Sqlite3Connection, "character_set", data_objects_cConnection_character_set, 0);
416
+
417
+ cDO_Sqlite3Command = rb_define_class_under(mDO_Sqlite3, "Command", cDO_Command);
418
+ rb_define_method(cDO_Sqlite3Command, "set_types", data_objects_cCommand_set_types, -1);
419
+ rb_define_method(cDO_Sqlite3Command, "execute_non_query", do_sqlite3_cCommand_execute_non_query, -1);
420
+ rb_define_method(cDO_Sqlite3Command, "execute_reader", do_sqlite3_cCommand_execute_reader, -1);
421
+
422
+ cDO_Sqlite3Result = rb_define_class_under(mDO_Sqlite3, "Result", cDO_Result);
423
+
424
+ cDO_Sqlite3Reader = rb_define_class_under(mDO_Sqlite3, "Reader", cDO_Reader);
425
+ rb_define_method(cDO_Sqlite3Reader, "close", do_sqlite3_cReader_close, 0);
426
+ rb_define_method(cDO_Sqlite3Reader, "next!", do_sqlite3_cReader_next, 0);
427
+ rb_define_method(cDO_Sqlite3Reader, "values", do_sqlite3_cReader_values, 0); // TODO: DRY?
428
+ rb_define_method(cDO_Sqlite3Reader, "fields", data_objects_cReader_fields, 0);
429
+ rb_define_method(cDO_Sqlite3Reader, "field_count", data_objects_cReader_field_count, 0);
430
+
431
+ rb_global_variable(&cDO_Sqlite3Result);
432
+ rb_global_variable(&cDO_Sqlite3Reader);
433
+
434
+ DO_OPEN_FLAG_READONLY = rb_str_new2("read_only");
435
+ rb_global_variable(&DO_OPEN_FLAG_READONLY);
436
+ DO_OPEN_FLAG_READWRITE = rb_str_new2("read_write");
437
+ rb_global_variable(&DO_OPEN_FLAG_READWRITE);
438
+ DO_OPEN_FLAG_CREATE = rb_str_new2("create");
439
+ rb_global_variable(&DO_OPEN_FLAG_CREATE);
440
+ DO_OPEN_FLAG_NO_MUTEX = rb_str_new2("no_mutex");
441
+ rb_global_variable(&DO_OPEN_FLAG_NO_MUTEX);
442
+ DO_OPEN_FLAG_FULL_MUTEX = rb_str_new2("full_mutex");
443
+ rb_global_variable(&DO_OPEN_FLAG_FULL_MUTEX);
444
444
 
445
445
  Init_do_sqlite3_extension();
446
446
 
447
- data_objects_define_errors(mSqlite3, do_sqlite3_errors);
447
+ data_objects_define_errors(mDO_Sqlite3, do_sqlite3_errors);
448
448
  }
@@ -13,7 +13,7 @@
13
13
  #define sqlite3_prepare_v2 sqlite3_prepare
14
14
  #endif
15
15
 
16
- extern VALUE mSqlite3;
16
+ extern VALUE mDO_Sqlite3;
17
17
  extern void Init_do_sqlite3_extension();
18
18
 
19
19
  #endif
@@ -2,7 +2,7 @@
2
2
  #include "do_common.h"
3
3
  #include "do_sqlite3.h"
4
4
 
5
- VALUE cSqlite3Extension;
5
+ VALUE cDO_Sqlite3Extension;
6
6
 
7
7
  /*****************************************************/
8
8
  /* File used for providing extensions on the default */
@@ -32,7 +32,7 @@ VALUE do_sqlite3_cExtension_enable_load_extension(VALUE self, VALUE on) {
32
32
  int status = sqlite3_enable_load_extension(db, on == Qtrue ? 1 : 0);
33
33
 
34
34
  if (status != SQLITE_OK) {
35
- rb_raise(eConnectionError, "Couldn't enable extension loading");
35
+ rb_raise(eDO_ConnectionError, "Couldn't enable extension loading");
36
36
  }
37
37
 
38
38
  return Qtrue;
@@ -66,7 +66,7 @@ VALUE do_sqlite3_cExtension_load_extension(VALUE self, VALUE path) {
66
66
  int status = sqlite3_load_extension(db, extension_path, 0, &errmsg);
67
67
 
68
68
  if (status != SQLITE_OK) {
69
- VALUE errexp = rb_exc_new2(eConnectionError, errmsg);
69
+ VALUE errexp = rb_exc_new2(eDO_ConnectionError, errmsg);
70
70
 
71
71
  sqlite3_free(errmsg);
72
72
  rb_exc_raise(errexp);
@@ -80,7 +80,8 @@ VALUE do_sqlite3_cExtension_load_extension(VALUE self, VALUE path) {
80
80
  }
81
81
 
82
82
  void Init_do_sqlite3_extension() {
83
- cSqlite3Extension = rb_define_class_under(mSqlite3, "Extension", cDO_Extension);
84
- rb_define_method(cSqlite3Extension, "load_extension", do_sqlite3_cExtension_load_extension, 1);
85
- rb_define_method(cSqlite3Extension, "enable_load_extension", do_sqlite3_cExtension_enable_load_extension, 1);
83
+ cDO_Sqlite3Extension = rb_define_class_under(mDO_Sqlite3, "Extension", cDO_Extension);
84
+ rb_global_variable(&cDO_Sqlite3Extension);
85
+ rb_define_method(cDO_Sqlite3Extension, "load_extension", do_sqlite3_cExtension_load_extension, 1);
86
+ rb_define_method(cDO_Sqlite3Extension, "enable_load_extension", do_sqlite3_cExtension_enable_load_extension, 1);
86
87
  }
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Sqlite3
3
- VERSION = '0.10.10'
3
+ VERSION = '0.10.11'
4
4
  end
5
5
  end
@@ -55,7 +55,7 @@ begin
55
55
  ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
56
56
  ext.java_compiling do |gem|
57
57
  gem.add_dependency 'jdbc-sqlite3', '>=3.5.8'
58
- gem.add_dependency 'do_jdbc', '0.10.10'
58
+ gem.add_dependency 'do_jdbc', '0.10.11'
59
59
  end
60
60
  end
61
61
  rescue LoadError
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 10
8
- - 10
9
- version: 0.10.10
8
+ - 11
9
+ version: 0.10.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dirkjan Bussink
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-29 00:00:00 +02:00
17
+ date: 2012-12-29 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 10
30
- - 10
31
- version: 0.10.10
30
+ - 11
31
+ version: 0.10.11
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency