do_sqlite3 0.10.10-x86-mswin32-60 → 0.10.11-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +4 -0
- data/ext/do_sqlite3/do_common.c +43 -43
- data/ext/do_sqlite3/do_common.h +9 -10
- data/ext/do_sqlite3/do_sqlite3.c +60 -60
- data/ext/do_sqlite3/do_sqlite3.h +1 -1
- data/ext/do_sqlite3/do_sqlite3_extension.c +7 -6
- data/lib/do_sqlite3/1.8/do_sqlite3.so +0 -0
- data/lib/do_sqlite3/1.9/do_sqlite3.so +0 -0
- data/lib/do_sqlite3/version.rb +1 -1
- data/tasks/compile.rake +1 -1
- metadata +5 -5
data/ChangeLog.markdown
CHANGED
data/ext/do_sqlite3/do_common.c
CHANGED
@@ -11,13 +11,13 @@
|
|
11
11
|
*/
|
12
12
|
|
13
13
|
// To store rb_intern values
|
14
|
-
ID
|
15
|
-
ID
|
16
|
-
ID
|
17
|
-
ID
|
18
|
-
ID
|
19
|
-
ID
|
20
|
-
ID
|
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
|
37
|
-
VALUE
|
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,
|
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,
|
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,
|
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
|
-
|
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,
|
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,
|
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,
|
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(
|
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,
|
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,
|
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,
|
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,
|
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(
|
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
|
-
|
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
|
-
|
410
|
+
DO_ID_NEW = rb_intern("new");
|
411
411
|
#ifdef RUBY_LESS_THAN_186
|
412
|
-
|
412
|
+
DO_ID_NEW_DATE = rb_intern("new0");
|
413
413
|
#else
|
414
|
-
|
414
|
+
DO_ID_NEW_DATE = rb_intern("new!");
|
415
415
|
#endif
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
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
|
-
|
438
|
-
|
437
|
+
eDO_ConnectionError = data_objects_const_get(mDO, "ConnectionError");
|
438
|
+
eDO_DataError = data_objects_const_get(mDO, "DataError");
|
439
439
|
|
440
|
-
rb_global_variable(&
|
441
|
-
rb_global_variable(&
|
442
|
-
rb_global_variable(&
|
443
|
-
rb_global_variable(&
|
444
|
-
rb_global_variable(&
|
445
|
-
rb_global_variable(&
|
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(&
|
456
|
-
rb_global_variable(&
|
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,
|
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,
|
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));
|
data/ext/do_sqlite3/do_common.h
CHANGED
@@ -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
|
58
|
-
extern ID
|
59
|
-
extern ID
|
60
|
-
extern ID
|
61
|
-
extern ID
|
62
|
-
extern ID
|
63
|
-
extern ID
|
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
|
81
|
-
extern VALUE
|
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;
|
data/ext/do_sqlite3/do_sqlite3.c
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
|
4
4
|
#include "do_common.h"
|
5
5
|
|
6
|
-
VALUE
|
7
|
-
VALUE
|
8
|
-
VALUE
|
9
|
-
VALUE
|
10
|
-
VALUE
|
11
|
-
|
12
|
-
VALUE
|
13
|
-
VALUE
|
14
|
-
VALUE
|
15
|
-
VALUE
|
16
|
-
VALUE
|
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,
|
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,
|
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,
|
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,
|
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,
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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
|
-
|
408
|
-
|
409
|
-
|
410
|
-
rb_define_method(
|
411
|
-
rb_define_method(
|
412
|
-
rb_define_method(
|
413
|
-
rb_define_method(
|
414
|
-
rb_define_method(
|
415
|
-
rb_define_method(
|
416
|
-
|
417
|
-
|
418
|
-
rb_define_method(
|
419
|
-
rb_define_method(
|
420
|
-
rb_define_method(
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
rb_define_method(
|
426
|
-
rb_define_method(
|
427
|
-
rb_define_method(
|
428
|
-
rb_define_method(
|
429
|
-
rb_define_method(
|
430
|
-
|
431
|
-
rb_global_variable(&
|
432
|
-
rb_global_variable(&
|
433
|
-
|
434
|
-
|
435
|
-
rb_global_variable(&
|
436
|
-
|
437
|
-
rb_global_variable(&
|
438
|
-
|
439
|
-
rb_global_variable(&
|
440
|
-
|
441
|
-
rb_global_variable(&
|
442
|
-
|
443
|
-
rb_global_variable(&
|
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(
|
447
|
+
data_objects_define_errors(mDO_Sqlite3, do_sqlite3_errors);
|
448
448
|
}
|
data/ext/do_sqlite3/do_sqlite3.h
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#include "do_common.h"
|
3
3
|
#include "do_sqlite3.h"
|
4
4
|
|
5
|
-
VALUE
|
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(
|
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(
|
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
|
-
|
84
|
-
|
85
|
-
rb_define_method(
|
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
|
}
|
Binary file
|
Binary file
|
data/lib/do_sqlite3/version.rb
CHANGED
data/tasks/compile.rake
CHANGED
@@ -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.
|
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
|
-
-
|
9
|
-
version: 0.10.
|
8
|
+
- 11
|
9
|
+
version: 0.10.11
|
10
10
|
platform: x86-mswin32-60
|
11
11
|
authors:
|
12
12
|
- Dirkjan Bussink
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2012-12-29 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,8 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 0
|
30
30
|
- 10
|
31
|
-
-
|
32
|
-
version: 0.10.
|
31
|
+
- 11
|
32
|
+
version: 0.10.11
|
33
33
|
requirement: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
prerelease: false
|