do_sqlite3 0.10.7-x86-mswin32-60 → 0.10.8-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.8 2012-02-10
2
+
3
+ * Ruby 1.9.3 compatibility on Windows
4
+ * Fix issue with sqlite3_load_extension
5
+
1
6
  ## 0.10.7 2011-10-13
2
7
 
3
8
  * Ruby 1.9.3 compatibility
@@ -53,9 +53,10 @@ VALUE data_objects_const_get(VALUE scope, const char *constant) {
53
53
  void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
54
54
  struct timeval stop;
55
55
  VALUE message;
56
+ do_int64 duration;
56
57
 
57
58
  gettimeofday(&stop, NULL);
58
- do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
59
+ duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
59
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
62
 
@@ -65,6 +66,7 @@ void data_objects_debug(VALUE connection, VALUE string, struct timeval *start) {
65
66
  void data_objects_raise_error(VALUE self, const struct errcodes *errors, int errnum, const char *message, VALUE query, VALUE state) {
66
67
  const char *exception_type = "SQLError";
67
68
  const struct errcodes *e;
69
+ VALUE uri, exception;
68
70
 
69
71
  for (e = errors; e->error_name; e++) {
70
72
  if (e->error_no == errnum) {
@@ -74,9 +76,9 @@ void data_objects_raise_error(VALUE self, const struct errcodes *errors, int err
74
76
  }
75
77
  }
76
78
 
77
- VALUE uri = rb_funcall(rb_iv_get(self, "@connection"), rb_intern("to_s"), 0);
79
+ uri = rb_funcall(rb_iv_get(self, "@connection"), rb_intern("to_s"), 0);
78
80
 
79
- VALUE exception = rb_funcall(
81
+ exception = rb_funcall(
80
82
  data_objects_const_get(mDO, exception_type),
81
83
  ID_NEW,
82
84
  5,
@@ -116,8 +118,8 @@ void data_objects_assert_file_exists(char *file, const char *message) {
116
118
  }
117
119
 
118
120
  VALUE data_objects_build_query_from_args(VALUE klass, int count, VALUE *args) {
119
- VALUE array = rb_ary_new();
120
121
  int i;
122
+ VALUE array = rb_ary_new();
121
123
 
122
124
  for (i = 0; i < count; i++) {
123
125
  rb_ary_push(array, args[i]);
@@ -176,8 +178,6 @@ VALUE data_objects_timezone_to_offset(int hour_offset, int minute_offset) {
176
178
  VALUE data_objects_parse_date(const char *date) {
177
179
  static char const *const _fmt_date = "%4d-%2d-%2d";
178
180
  int year = 0, month = 0, day = 0;
179
- int jd, ajd;
180
- VALUE rational;
181
181
 
182
182
  switch (sscanf(date, _fmt_date, &year, &month, &day)) {
183
183
  case 0:
@@ -185,16 +185,7 @@ VALUE data_objects_parse_date(const char *date) {
185
185
  return Qnil;
186
186
  }
187
187
 
188
- #ifdef HAVE_NO_DATETIME_NEWBANG
189
188
  return rb_funcall(rb_cDate, ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
190
- #else
191
-
192
- jd = data_objects_jd_from_date(year, month, day);
193
- ajd = (jd * 2) - 1; // Math from Date.jd_to_ajd
194
- rational = rb_funcall(rb_mKernel, ID_RATIONAL, 2, INT2NUM(ajd), INT2NUM(2));
195
-
196
- return rb_funcall(rb_cDate, ID_NEW_DATE, 3, rational, INT2NUM(0), INT2NUM(2299161));
197
- #endif
198
189
  }
199
190
 
200
191
  VALUE data_objects_parse_time(const char *date) {
@@ -224,10 +215,9 @@ VALUE data_objects_parse_date_time(const char *date) {
224
215
  int tokens_read;
225
216
  const char *fmt_datetime;
226
217
 
227
- VALUE ajd, offset;
218
+ VALUE offset;
228
219
 
229
- int year, month, day, hour, min, sec, hour_offset, minute_offset, jd;
230
- do_int64 num, den;
220
+ int year, month, day, hour, min, sec, hour_offset, minute_offset;
231
221
 
232
222
  struct tm timeinfo;
233
223
  time_t target_time;
@@ -304,40 +294,9 @@ VALUE data_objects_parse_date_time(const char *date) {
304
294
  rb_raise(eDataError, "Couldn't parse date: %s", date);
305
295
  }
306
296
 
307
- #ifdef HAVE_NO_DATETIME_NEWBANG
308
297
  offset = data_objects_timezone_to_offset(hour_offset, minute_offset);
309
298
  return rb_funcall(rb_cDateTime, ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
310
299
  INT2NUM(hour), INT2NUM(min), INT2NUM(sec), offset);
311
- #else
312
- jd = data_objects_jd_from_date(year, month, day);
313
-
314
- /*
315
- * Generate ajd with fractional days for the time.
316
- * Extracted from Date#jd_to_ajd, Date#day_fraction_to_time, and Rational#+ and #-.
317
- *
318
- * TODO: These are 64bit numbers; is reduce() really necessary?
319
- */
320
-
321
- num = (hour * 1440) + (min * 24);
322
- num -= (hour_offset * 1440) + (minute_offset * 24);
323
- den = (24 * 1440);
324
- data_objects_reduce(&num, &den);
325
-
326
- num = (num * 86400) + (sec * den);
327
- den = den * 86400;
328
- data_objects_reduce(&num, &den);
329
-
330
- num += jd * den;
331
-
332
- num = (num * 2) - den;
333
- den *= 2;
334
- data_objects_reduce(&num, &den);
335
-
336
- ajd = rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ull2inum(num), rb_ull2inum(den));
337
- offset = data_objects_timezone_to_offset(hour_offset, minute_offset);
338
-
339
- return rb_funcall(rb_cDateTime, ID_NEW_DATE, 3, ajd, offset, INT2NUM(2299161));
340
- #endif
341
300
  }
342
301
 
343
302
  VALUE data_objects_cConnection_character_set(VALUE self) {
@@ -371,17 +330,15 @@ VALUE data_objects_cConnection_quote_date(VALUE self, VALUE value) {
371
330
  * into Ruby-strings so we can easily typecast later
372
331
  */
373
332
  VALUE data_objects_cCommand_set_types(int argc, VALUE *argv, VALUE self) {
333
+ VALUE entry, sub_entry;
334
+ int i, j;
374
335
  VALUE type_strings = rb_ary_new();
375
336
  VALUE array = rb_ary_new();
376
337
 
377
- int i, j;
378
-
379
338
  for (i = 0; i < argc; i++) {
380
339
  rb_ary_push(array, argv[i]);
381
340
  }
382
341
 
383
- VALUE entry, sub_entry;
384
-
385
342
  for (i = 0; i < RARRAY_LEN(array); i++) {
386
343
  entry = rb_ary_entry(array, i);
387
344
 
@@ -215,50 +215,6 @@ VALUE do_sqlite3_cConnection_quote_byte_array(VALUE self, VALUE string) {
215
215
  return rb_ary_join(array, Qnil);
216
216
  }
217
217
 
218
- VALUE do_sqlite3_cConnection_enable_load_extension(VALUE self, VALUE value) {
219
- VALUE connection = rb_iv_get(self, "@connection");
220
-
221
- if (connection == Qnil) {
222
- return Qfalse;
223
- }
224
-
225
- sqlite3 *db = DATA_PTR(connection);
226
-
227
- if (!db) {
228
- return Qfalse;
229
- }
230
-
231
- int status = sqlite3_enable_load_extension(db, value == Qtrue ? 1 : 0);
232
-
233
- if (status != SQLITE_OK) {
234
- rb_raise(eConnectionError, "Error enabling load extension.");
235
- }
236
- return Qtrue;
237
- }
238
-
239
- VALUE do_sqlite3_cConnection_load_extension(VALUE self, VALUE string) {
240
- VALUE connection = rb_iv_get(self, "@connection");
241
-
242
- if (connection == Qnil) {
243
- return Qfalse;
244
- }
245
-
246
- sqlite3 *db = DATA_PTR(connection);
247
-
248
- if (!db) {
249
- return Qfalse;
250
- }
251
-
252
- const char *extension_name = rb_str_ptr_readonly(string);
253
- char *errmsg = NULL;
254
- int status = sqlite3_load_extension(db, extension_name, 0, &errmsg);
255
-
256
- if (status != SQLITE_OK) {
257
- rb_raise(eConnectionError, "%s", errmsg);
258
- }
259
- return Qtrue;
260
- }
261
-
262
218
  VALUE do_sqlite3_cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
263
219
  VALUE query = data_objects_build_query_from_args(self, argc, argv);
264
220
  VALUE connection = rb_iv_get(self, "@connection");
@@ -363,16 +319,23 @@ VALUE do_sqlite3_cReader_close(VALUE self) {
363
319
  }
364
320
 
365
321
  VALUE do_sqlite3_cReader_next(VALUE self) {
322
+
323
+ VALUE reader = rb_iv_get(self, "@reader");
324
+
325
+ if(reader == Qnil) {
326
+ rb_raise(eConnectionError, "This result set has already been closed.");
327
+ }
328
+
366
329
  if (rb_iv_get(self, "@done") == Qtrue) {
367
330
  return Qfalse;
368
331
  }
369
332
 
370
- sqlite3_stmt *reader = NULL;
333
+ sqlite3_stmt *sqlite_reader = NULL;
371
334
  int result;
372
335
 
373
- Data_Get_Struct(rb_iv_get(self, "@reader"), sqlite3_stmt, reader);
336
+ Data_Get_Struct(reader, sqlite3_stmt, sqlite_reader);
374
337
 
375
- result = sqlite3_step(reader);
338
+ result = sqlite3_step(sqlite_reader);
376
339
  rb_iv_set(self, "@state", INT2NUM(result));
377
340
 
378
341
  if (result != SQLITE_ROW) {
@@ -399,7 +362,7 @@ VALUE do_sqlite3_cReader_next(VALUE self) {
399
362
 
400
363
  for (i = 0; i < field_count; i++) {
401
364
  field_type = rb_ary_entry(field_types, i);
402
- value = do_sqlite3_typecast(reader, i, field_type, enc);
365
+ value = do_sqlite3_typecast(sqlite_reader, i, field_type, enc);
403
366
  rb_ary_push(arr, value);
404
367
  }
405
368
 
@@ -430,8 +393,6 @@ void Init_do_sqlite3() {
430
393
  rb_define_method(cSqlite3Connection, "quote_string", do_sqlite3_cConnection_quote_string, 1);
431
394
  rb_define_method(cSqlite3Connection, "quote_byte_array", do_sqlite3_cConnection_quote_byte_array, 1);
432
395
  rb_define_method(cSqlite3Connection, "character_set", data_objects_cConnection_character_set, 0);
433
- rb_define_method(cSqlite3Connection, "enable_load_extension", do_sqlite3_cConnection_enable_load_extension, 1);
434
- rb_define_method(cSqlite3Connection, "load_extension", do_sqlite3_cConnection_load_extension, 1);
435
396
 
436
397
  cSqlite3Command = rb_define_class_under(mSqlite3, "Command", cDO_Command);
437
398
  rb_define_method(cSqlite3Command, "set_types", data_objects_cCommand_set_types, -1);
@@ -9,6 +9,7 @@ VALUE cSqlite3Extension;
9
9
  /* API that are driver specific. */
10
10
  /*****************************************************/
11
11
  VALUE do_sqlite3_cExtension_enable_load_extension(VALUE self, VALUE on) {
12
+ #ifdef HAVE_SQLITE3_ENABLE_LOAD_EXTENSION
12
13
  VALUE id_connection = rb_intern("connection");
13
14
  VALUE connection = rb_funcall(self, id_connection, 0);
14
15
 
@@ -32,9 +33,13 @@ VALUE do_sqlite3_cExtension_enable_load_extension(VALUE self, VALUE on) {
32
33
  }
33
34
 
34
35
  return Qtrue;
36
+ #else
37
+ return Qfalse;
38
+ #endif
35
39
  }
36
40
 
37
41
  VALUE do_sqlite3_cExtension_load_extension(VALUE self, VALUE path) {
42
+ #ifdef HAVE_SQLITE3_ENABLE_LOAD_EXTENSION
38
43
  VALUE id_connection = rb_intern("connection");
39
44
  VALUE connection = rb_funcall(self, id_connection, 0);
40
45
 
@@ -68,6 +73,9 @@ VALUE do_sqlite3_cExtension_load_extension(VALUE self, VALUE path) {
68
73
  }
69
74
 
70
75
  return Qtrue;
76
+ #else
77
+ return Qfalse;
78
+ #endif
71
79
  }
72
80
 
73
81
  void Init_do_sqlite3_extension() {
@@ -28,6 +28,7 @@ if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
28
28
  have_func("gmtime_r")
29
29
  have_func("sqlite3_prepare_v2")
30
30
  have_func("sqlite3_open_v2")
31
+ have_func("sqlite3_enable_load_extension")
31
32
 
32
33
  create_makefile('do_sqlite3/do_sqlite3')
33
34
  end
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Sqlite3
3
- VERSION = '0.10.7'
3
+ VERSION = '0.10.8'
4
4
  end
5
5
  end
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.7'
58
+ gem.add_dependency 'do_jdbc', '0.10.8'
59
59
  end
60
60
  end
61
61
  rescue LoadError
data/tasks/spec.rake CHANGED
@@ -2,7 +2,6 @@ require 'rspec/core/rake_task'
2
2
 
3
3
  RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec|
4
4
  spec.pattern = './spec/**/*_spec.rb'
5
- spec.skip_bundler = true
6
5
  end
7
6
 
8
7
  RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
- - 7
10
- version: 0.10.7
9
+ - 8
10
+ version: 0.10.8
11
11
  platform: x86-mswin32-60
12
12
  authors:
13
13
  - Dirkjan Bussink
@@ -18,23 +18,23 @@ cert_chain: []
18
18
  date: 2011-03-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
22
  none: false
23
23
  requirements:
24
24
  - - "="
25
25
  - !ruby/object:Gem::Version
26
- hash: 57
26
+ hash: 39
27
27
  segments:
28
28
  - 0
29
29
  - 10
30
- - 7
31
- version: 0.10.7
32
- version_requirements: *id001
30
+ - 8
31
+ version: 0.10.8
33
32
  name: data_objects
34
33
  prerelease: false
35
34
  type: :runtime
35
+ requirement: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
40
40
  - - ~>
@@ -44,12 +44,12 @@ dependencies:
44
44
  - 2
45
45
  - 5
46
46
  version: "2.5"
47
- version_requirements: *id002
48
47
  name: rspec
49
48
  prerelease: false
50
49
  type: :development
50
+ requirement: *id002
51
51
  - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
@@ -59,10 +59,10 @@ dependencies:
59
59
  - 0
60
60
  - 7
61
61
  version: "0.7"
62
- version_requirements: *id003
63
62
  name: rake-compiler
64
63
  prerelease: false
65
64
  type: :development
65
+ requirement: *id003
66
66
  description: Implements the DataObjects API for Sqlite3
67
67
  email: d.bussink@gmail.com
68
68
  executables: []
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  requirements: []
163
163
 
164
164
  rubyforge_project: dorb
165
- rubygems_version: 1.8.6
165
+ rubygems_version: 1.8.14
166
166
  signing_key:
167
167
  specification_version: 3
168
168
  summary: DataObjects Sqlite3 Driver