do_sqlite3 0.10.0-x86-mswin32-60 → 0.10.1-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +32 -0
- data/LICENSE +1 -1
- data/README.markdown +101 -3
- data/Rakefile +56 -9
- data/ext/do_sqlite3/compat.h +55 -0
- data/ext/{do_sqlite3_ext/do_sqlite3_ext.c → do_sqlite3/do_sqlite3.c} +46 -34
- data/ext/{do_sqlite3_ext → do_sqlite3}/error.h +0 -0
- data/ext/{do_sqlite3_ext → do_sqlite3}/extconf.rb +3 -3
- data/lib/do_sqlite3.rb +19 -11
- 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/spec/command_spec.rb +1 -1
- data/spec/connection_spec.rb +8 -6
- data/spec/reader_spec.rb +1 -1
- data/spec/result_spec.rb +3 -3
- data/spec/spec_helper.rb +19 -32
- data/spec/typecast/array_spec.rb +1 -1
- data/spec/typecast/bigdecimal_spec.rb +1 -1
- data/spec/typecast/boolean_spec.rb +1 -1
- data/spec/typecast/byte_array_spec.rb +1 -2
- data/spec/typecast/class_spec.rb +1 -1
- data/spec/typecast/date_spec.rb +1 -1
- data/spec/typecast/datetime_spec.rb +1 -1
- data/spec/typecast/float_spec.rb +2 -2
- data/spec/typecast/integer_spec.rb +1 -1
- data/spec/typecast/nil_spec.rb +4 -4
- data/spec/typecast/other_spec.rb +8 -0
- data/spec/typecast/range_spec.rb +1 -1
- data/spec/typecast/string_spec.rb +1 -1
- data/spec/typecast/time_spec.rb +1 -1
- data/tasks/compile.rake +64 -0
- data/tasks/release.rake +12 -71
- data/tasks/retrieve.rake +1 -1
- data/tasks/spec.rake +19 -15
- metadata +64 -38
- data/HISTORY.markdown +0 -22
- data/Manifest.txt +0 -31
- data/lib/do_sqlite3_ext.so +0 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -3
- data/tasks/gem.rake +0 -8
- data/tasks/install.rake +0 -15
- data/tasks/native.rake +0 -35
data/ChangeLog.markdown
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
## 0.10.1 (unreleased, in git)
|
2
|
+
|
3
|
+
* Support for Ruby 1.8 and 1.9 on Windows.
|
4
|
+
* Switch to Jeweler for Gem building tasks (this change may be temporary).
|
5
|
+
* Switch to using Bacon for running specs: This should make specs friendlier to
|
6
|
+
new Ruby implementations that are not yet 100% MRI-compatible, and in turn,
|
7
|
+
prepared the road for our own IronRuby and MacRuby support.
|
8
|
+
* Switch to the newly added rake-compiler `JavaExtensionTask` for compiling
|
9
|
+
JRuby extensions, instead of our (broken) home-grown solution.
|
10
|
+
|
11
|
+
## 0.10.0 2009-09-15
|
12
|
+
* Improvements
|
13
|
+
* JRuby Support (using *do_jdbc*)
|
14
|
+
|
15
|
+
## 0.9.12 2009-05-17
|
16
|
+
* Improvements
|
17
|
+
* rake-compiler for Windows support
|
18
|
+
|
19
|
+
## 0.9.11 2009-01-19
|
20
|
+
* Improvements
|
21
|
+
* Ruby 1.9 support
|
22
|
+
* Fixes
|
23
|
+
* Fix Windows gem
|
24
|
+
|
25
|
+
## 0.9.9 2008-11-27
|
26
|
+
* Improvements
|
27
|
+
* Added cross compile rake tasks for Windows gems [Jonathan Stott, Luis Lavena]
|
28
|
+
* Added initial support for Ruby 1.9 [John Harrison]
|
29
|
+
|
30
|
+
* Bug Fixes
|
31
|
+
* Removed sqlite3.dll from source gem [Dan Kubb]
|
32
|
+
* Removed hard coded .bundle from source [Dirkjan Bussink]
|
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -1,4 +1,102 @@
|
|
1
|
-
do_sqlite3
|
2
|
-
==========
|
1
|
+
# do_sqlite3
|
3
2
|
|
4
|
-
|
3
|
+
* <http://dataobjects.info>
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
A SQLite3 driver for DataObjects.
|
8
|
+
|
9
|
+
## Features/Problems
|
10
|
+
|
11
|
+
This driver implements the DataObjects API for the SQLite3 relational database.
|
12
|
+
|
13
|
+
## Synopsis
|
14
|
+
|
15
|
+
An example of usage:
|
16
|
+
|
17
|
+
@connection = DataObjects::Connection.new("sqlite3://employees")
|
18
|
+
@reader = @connection.create_command('SELECT * FROM users').execute_reader
|
19
|
+
@reader.next!
|
20
|
+
|
21
|
+
In the future, the `Connection` constructor will be able to be passed either a
|
22
|
+
DataObjects-style URL or JDBC style URL, when using do\_sqlite3 on JRuby.
|
23
|
+
However, this feature is not currently working reliably and is a known issue.
|
24
|
+
|
25
|
+
## Requirements
|
26
|
+
|
27
|
+
This driver is provided for the following platforms:
|
28
|
+
* Ruby MRI (1.8.6/7), 1.9: tested on Linux, Mac OS X and Windows platforms.
|
29
|
+
* JRuby 1.3.1 + (1.4+ recommended).
|
30
|
+
* Rubinius (experimental).
|
31
|
+
|
32
|
+
Additionally you should have the following prerequisites:
|
33
|
+
* `data_objects` gem
|
34
|
+
* `do_jdbc` gem (shared library), if running on JRuby.
|
35
|
+
|
36
|
+
## Install
|
37
|
+
|
38
|
+
To install the gem:
|
39
|
+
|
40
|
+
gem install do_sqlite3
|
41
|
+
|
42
|
+
To compile and install from source:
|
43
|
+
|
44
|
+
* Install rake-compiler: `gem install rake-compiler`.
|
45
|
+
|
46
|
+
* For MRI/Rubinius extensions:
|
47
|
+
* Install the `gcc` compiler. On OS X, you should install XCode tools. On
|
48
|
+
Ubuntu, run `apt-get install build-essential`.
|
49
|
+
* Install Ruby and SQLite3.
|
50
|
+
* Install the Ruby and SQLite3 development headers.
|
51
|
+
* On Debian-Linux distributions, you can install the following packages
|
52
|
+
with `apt`: `ruby-dev` `libsqlite3-dev`.
|
53
|
+
* If you want to cross-compile for Windows:
|
54
|
+
* Install MinGW:
|
55
|
+
* On Debian-Linux distributions, you can install the following package
|
56
|
+
with `apt`: `mingw32`.
|
57
|
+
* On OS X, this can install the following package with MacPorts: `i386-mingw32-gcc`.
|
58
|
+
* Run `rake-compiler cross-ruby`.
|
59
|
+
* Run `rake-compiler update-config`.
|
60
|
+
|
61
|
+
* For JRuby extensions:
|
62
|
+
* Install the Java Development Kit (provided if you are
|
63
|
+
on a recent version of Mac OS X) from <http://java.sun.com>.
|
64
|
+
* Install a recent version of JRuby. Ensure `jruby` is in your `PATH` and/or
|
65
|
+
you have configured the `JRUBY_HOME` environment variable to point to your
|
66
|
+
JRuby installation.
|
67
|
+
* Install `data_objects` and `do_jdbc` with `jruby -S rake install`.
|
68
|
+
|
69
|
+
* Then, install this driver with `(jruby -S) rake install`.
|
70
|
+
|
71
|
+
For more information, see the SQLite3 driver wiki page:
|
72
|
+
<http://wiki.github.com/datamapper/do/sqlite3>.
|
73
|
+
|
74
|
+
## Developers
|
75
|
+
|
76
|
+
Follow the above installation instructions. Additionally, you'll need:
|
77
|
+
* `bacon` gem for running specs.
|
78
|
+
* `YARD` gem for generating documentation.
|
79
|
+
|
80
|
+
See the DataObjects wiki for more comprehensive information on installing and
|
81
|
+
contributing to the JRuby-variant of this driver:
|
82
|
+
<http://wiki.github.com/datamapper/do/jruby>.
|
83
|
+
|
84
|
+
To run specs:
|
85
|
+
|
86
|
+
rake spec
|
87
|
+
|
88
|
+
To run specs without compiling extensions first:
|
89
|
+
|
90
|
+
rake spec_no_compile
|
91
|
+
|
92
|
+
To run individual specs:
|
93
|
+
|
94
|
+
rake spec TEST=spec/connection_spec.rb
|
95
|
+
|
96
|
+
(Note that the `rake` task uses a `TEST` parameter, not `SPEC`. This is because
|
97
|
+
the `Rake::TestTask` is used for executing the Bacon specs).
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
This code is licensed under an **MIT (X11) License**. Please see the
|
102
|
+
accompanying `LICENSE` file.
|
data/Rakefile
CHANGED
@@ -1,16 +1,63 @@
|
|
1
|
+
require 'pathname'
|
1
2
|
require 'rubygems'
|
2
3
|
require 'rake'
|
3
4
|
require 'rake/clean'
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
ROOT = Pathname(__FILE__).dirname.expand_path
|
7
|
+
|
8
|
+
require ROOT + 'lib/do_sqlite3/version'
|
9
|
+
|
10
|
+
JRUBY = RUBY_PLATFORM =~ /java/
|
11
|
+
IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
|
12
|
+
WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
|
13
|
+
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
|
14
|
+
BINARY_VERSION = '3_6_21'
|
15
|
+
|
16
|
+
CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_sqlite3/Makefile ext-java/target ])
|
17
|
+
|
18
|
+
begin
|
19
|
+
gem 'jeweler', '~> 1.4'
|
20
|
+
require 'jeweler'
|
21
|
+
|
22
|
+
Jeweler::Tasks.new do |gem|
|
23
|
+
gem.name = 'do_sqlite3'
|
24
|
+
gem.version = DataObjects::Sqlite3::VERSION
|
25
|
+
gem.summary = 'DataObjects Sqlite3 Driver'
|
26
|
+
gem.description = 'Implements the DataObjects API for Sqlite3'
|
27
|
+
gem.platform = Gem::Platform::RUBY
|
28
|
+
gem.files = FileList['lib/**/*.rb', 'spec/**/*.rb', 'tasks/**/*.rake',
|
29
|
+
'ext/**/*.{rb,c,h}', 'LICENSE', 'Rakefile',
|
30
|
+
'*.{markdown,rdoc,txt,yml}']
|
31
|
+
gem.extra_rdoc_files = FileList['README*', 'ChangeLog*', 'LICENSE']
|
32
|
+
gem.test_files = FileList['spec/**/*.rb']
|
33
|
+
|
34
|
+
# rake-compiler should generate gemspecs for other platforms (e.g. 'java')
|
35
|
+
# and modify dependencies and extensions appropriately
|
36
|
+
gem.extensions << 'ext/do_sqlite3/extconf.rb'
|
37
|
+
|
38
|
+
gem.add_dependency 'data_objects', DataObjects::Sqlite3::VERSION
|
39
|
+
|
40
|
+
gem.add_development_dependency 'bacon', '~>1.1'
|
41
|
+
gem.add_development_dependency 'rake-compiler', '~>0.7'
|
42
|
+
|
43
|
+
gem.has_rdoc = false
|
44
|
+
gem.rubyforge_project = 'dorb'
|
45
|
+
gem.authors = [ 'Dirkjan Bussink' ]
|
46
|
+
gem.email = 'd.bussink@gmail.com'
|
47
|
+
end
|
7
48
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
49
|
+
if JRUBY
|
50
|
+
Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build')
|
51
|
+
Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install')
|
52
|
+
task :build => [ :java, :gem ]
|
53
|
+
task :install do
|
54
|
+
sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_sqlite3-#{DataObjects::Sqlite3::VERSION}-java.gem"
|
55
|
+
end
|
56
|
+
end
|
13
57
|
|
14
|
-
|
58
|
+
Jeweler::GemcutterTasks.new
|
15
59
|
|
16
|
-
|
60
|
+
FileList['tasks/**/*.rake'].each { |task| import task }
|
61
|
+
rescue LoadError
|
62
|
+
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
|
63
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#ifndef RUBY_COMPAT_H
|
2
|
+
#define RUBY_COMPAT_H
|
3
|
+
|
4
|
+
/*
|
5
|
+
* Rules for better ruby C extensions:
|
6
|
+
*
|
7
|
+
* Never use the R<TYPE> macros directly, always use R<TYPE>_<FIELD>
|
8
|
+
*
|
9
|
+
* Never compare with RBASIC(obj)->klass, always use
|
10
|
+
* rb_obj_is_instance_of()
|
11
|
+
*
|
12
|
+
* Never use RHASH(obj)->tbl or RHASH_TBL().
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
|
16
|
+
|
17
|
+
// Array
|
18
|
+
#ifndef RARRAY_PTR
|
19
|
+
#define RARRAY_PTR(obj) RARRAY(obj)->ptr
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#ifndef RARRAY_LEN
|
23
|
+
#define RARRAY_LEN(obj) RARRAY(obj)->len
|
24
|
+
#endif
|
25
|
+
|
26
|
+
// String
|
27
|
+
#ifndef RSTRING_PTR
|
28
|
+
#define RSTRING_PTR(obj) RSTRING(obj)->ptr
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#ifndef RSTRING_LEN
|
32
|
+
#define RSTRING_LEN(obj) RSTRING(obj)->len
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#ifndef rb_str_ptr
|
36
|
+
#define rb_str_ptr(str) RSTRING_PTR(str)
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#ifndef rb_str_ptr_readonly
|
40
|
+
#define rb_str_ptr_readonly(str) RSTRING_PTR(str)
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#ifndef rb_str_flush
|
44
|
+
#define rb_str_flush(str)
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#ifndef rb_str_update
|
48
|
+
#define rb_str_update(str)
|
49
|
+
#endif
|
50
|
+
|
51
|
+
#ifndef rb_str_len
|
52
|
+
#define rb_str_len(str) RSTRING_LEN(str)
|
53
|
+
#endif
|
54
|
+
|
55
|
+
#endif
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#include <time.h>
|
5
5
|
#include <locale.h>
|
6
6
|
#include <sqlite3.h>
|
7
|
+
#include "compat.h"
|
7
8
|
#include "error.h"
|
8
9
|
|
9
10
|
#ifdef HAVE_RUBY_ENCODING_H
|
@@ -47,20 +48,6 @@
|
|
47
48
|
#define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
|
48
49
|
#define SQLITE3_CLASS(klass, parent) (rb_define_class_under(mSqlite3, klass, parent))
|
49
50
|
|
50
|
-
#define TRUE_CLASS CONST_GET(rb_mKernel, "TrueClass")
|
51
|
-
|
52
|
-
#ifndef RSTRING_PTR
|
53
|
-
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
54
|
-
#endif
|
55
|
-
|
56
|
-
#ifndef RSTRING_LEN
|
57
|
-
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
58
|
-
#endif
|
59
|
-
|
60
|
-
#ifndef RARRAY_LEN
|
61
|
-
#define RARRAY_LEN(a) RARRAY(a)->len
|
62
|
-
#endif
|
63
|
-
|
64
51
|
#ifdef _WIN32
|
65
52
|
#define do_int64 signed __int64
|
66
53
|
#else
|
@@ -130,15 +117,15 @@ static int jd_from_date(int year, int month, int day) {
|
|
130
117
|
}
|
131
118
|
a = year / 100;
|
132
119
|
b = 2 - a + (a / 4);
|
133
|
-
return floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524;
|
120
|
+
return (int) (floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524);
|
134
121
|
}
|
135
122
|
|
136
123
|
static void data_objects_debug(VALUE string, struct timeval* start) {
|
137
124
|
struct timeval stop;
|
138
125
|
char *message;
|
139
126
|
|
140
|
-
char *query =
|
141
|
-
|
127
|
+
const char *query = rb_str_ptr_readonly(string);
|
128
|
+
size_t length = rb_str_len(string);
|
142
129
|
char total_time[32];
|
143
130
|
do_int64 duration = 0;
|
144
131
|
|
@@ -274,8 +261,8 @@ static VALUE parse_date_time(char *date) {
|
|
274
261
|
if ( is_dst > 0 )
|
275
262
|
gmt_offset -= is_dst;
|
276
263
|
|
277
|
-
hour_offset = -(gmt_offset / 3600);
|
278
|
-
minute_offset = -(gmt_offset % 3600 / 60);
|
264
|
+
hour_offset = -((int)gmt_offset / 3600);
|
265
|
+
minute_offset = -((int)gmt_offset % 3600 / 60);
|
279
266
|
|
280
267
|
} else {
|
281
268
|
// Something went terribly wrong
|
@@ -383,7 +370,7 @@ static VALUE typecast(sqlite3_stmt *stmt, int i, VALUE type, int encoding) {
|
|
383
370
|
} else if (type == rb_cByteArray) {
|
384
371
|
return rb_funcall(rb_cByteArray, ID_NEW, 1, rb_str_new((char*)sqlite3_column_blob(stmt, i), length));
|
385
372
|
} else if (type == rb_cClass) {
|
386
|
-
return rb_funcall(
|
373
|
+
return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new((char*)sqlite3_column_text(stmt, i), length));
|
387
374
|
} else if (type == rb_cObject) {
|
388
375
|
return rb_marshal_load(rb_str_new((char*)sqlite3_column_text(stmt, i), length));
|
389
376
|
} else if (type == rb_cNilClass) {
|
@@ -441,9 +428,9 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
|
|
441
428
|
path = rb_funcall(uri, ID_PATH, 0);
|
442
429
|
|
443
430
|
#ifdef HAVE_SQLITE3_OPEN_V2
|
444
|
-
ret = sqlite3_open_v2(
|
431
|
+
ret = sqlite3_open_v2(rb_str_ptr_readonly(path), &db, flags_from_uri(uri), 0);
|
445
432
|
#else
|
446
|
-
ret = sqlite3_open(
|
433
|
+
ret = sqlite3_open(rb_str_ptr_readonly(path), &db);
|
447
434
|
#endif
|
448
435
|
|
449
436
|
if ( ret != SQLITE_OK ) {
|
@@ -519,7 +506,7 @@ static VALUE cConnection_quote_boolean(VALUE self, VALUE value) {
|
|
519
506
|
}
|
520
507
|
|
521
508
|
static VALUE cConnection_quote_string(VALUE self, VALUE string) {
|
522
|
-
const char *source =
|
509
|
+
const char *source = rb_str_ptr_readonly(string);
|
523
510
|
char *escaped_with_quotes;
|
524
511
|
VALUE result;
|
525
512
|
|
@@ -534,6 +521,18 @@ static VALUE cConnection_quote_string(VALUE self, VALUE string) {
|
|
534
521
|
return result;
|
535
522
|
}
|
536
523
|
|
524
|
+
static VALUE cConnection_quote_byte_array(VALUE self, VALUE string) {
|
525
|
+
VALUE source = StringValue(string);
|
526
|
+
VALUE array = rb_funcall(source, rb_intern("unpack"), 1, rb_str_new2("H*"));
|
527
|
+
rb_ary_unshift(array, rb_str_new2("X'"));
|
528
|
+
rb_ary_push(array, rb_str_new2("'"));
|
529
|
+
return rb_ary_join(array, Qnil);
|
530
|
+
}
|
531
|
+
|
532
|
+
static VALUE cConnection_character_set(VALUE self) {
|
533
|
+
return rb_iv_get(self, "@encoding");
|
534
|
+
}
|
535
|
+
|
537
536
|
static VALUE build_query_from_args(VALUE klass, int count, VALUE *args) {
|
538
537
|
VALUE query = rb_iv_get(klass, "@text");
|
539
538
|
int i;
|
@@ -550,18 +549,23 @@ static VALUE cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
|
|
550
549
|
char *error_message;
|
551
550
|
int status;
|
552
551
|
int affected_rows;
|
553
|
-
|
554
|
-
VALUE
|
552
|
+
do_int64 insert_id;
|
553
|
+
VALUE connection, sqlite3_connection;
|
555
554
|
VALUE query;
|
556
555
|
struct timeval start;
|
557
556
|
|
558
557
|
query = build_query_from_args(self, argc, argv);
|
559
558
|
|
560
|
-
|
561
|
-
|
559
|
+
connection = rb_iv_get(self, "@connection");
|
560
|
+
sqlite3_connection = rb_iv_get(connection, "@connection");
|
561
|
+
if (Qnil == sqlite3_connection) {
|
562
|
+
rb_raise(eConnectionError, "This connection has already been closed.");
|
563
|
+
}
|
564
|
+
|
565
|
+
Data_Get_Struct(sqlite3_connection, sqlite3, db);
|
562
566
|
|
563
567
|
gettimeofday(&start, NULL);
|
564
|
-
status = sqlite3_exec(db,
|
568
|
+
status = sqlite3_exec(db, rb_str_ptr_readonly(query), 0, 0, &error_message);
|
565
569
|
|
566
570
|
if ( status != SQLITE_OK ) {
|
567
571
|
raise_error(self, db, query);
|
@@ -581,18 +585,23 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
|
|
581
585
|
int field_count;
|
582
586
|
int i;
|
583
587
|
VALUE reader;
|
584
|
-
VALUE
|
588
|
+
VALUE connection, sqlite3_connection;
|
585
589
|
VALUE query;
|
586
590
|
VALUE field_names, field_types;
|
587
591
|
struct timeval start;
|
588
592
|
|
589
|
-
|
590
|
-
|
593
|
+
connection = rb_iv_get(self, "@connection");
|
594
|
+
sqlite3_connection = rb_iv_get(connection, "@connection");
|
595
|
+
if (Qnil == sqlite3_connection) {
|
596
|
+
rb_raise(eConnectionError, "This connection has already been closed.");
|
597
|
+
}
|
598
|
+
|
599
|
+
Data_Get_Struct(sqlite3_connection, sqlite3, db);
|
591
600
|
|
592
601
|
query = build_query_from_args(self, argc, argv);
|
593
602
|
|
594
603
|
gettimeofday(&start, NULL);
|
595
|
-
status = sqlite3_prepare_v2(db,
|
604
|
+
status = sqlite3_prepare_v2(db, rb_str_ptr_readonly(query), -1, &sqlite3_reader, 0);
|
596
605
|
data_objects_debug(query, &start);
|
597
606
|
|
598
607
|
if ( status != SQLITE_OK ) {
|
@@ -604,6 +613,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
|
|
604
613
|
|
605
614
|
rb_iv_set(reader, "@reader", Data_Wrap_Struct(rb_cObject, 0, 0, sqlite3_reader));
|
606
615
|
rb_iv_set(reader, "@field_count", INT2NUM(field_count));
|
616
|
+
rb_iv_set(reader, "@connection", connection);
|
607
617
|
|
608
618
|
field_names = rb_ary_new();
|
609
619
|
field_types = rb_iv_get(self, "@field_types");
|
@@ -647,7 +657,7 @@ static VALUE cReader_next(VALUE self) {
|
|
647
657
|
int field_count;
|
648
658
|
int result;
|
649
659
|
int i;
|
650
|
-
|
660
|
+
size_t ft_length;
|
651
661
|
VALUE arr = rb_ary_new();
|
652
662
|
VALUE field_types;
|
653
663
|
VALUE field_type;
|
@@ -707,7 +717,7 @@ static VALUE cReader_field_count(VALUE self) {
|
|
707
717
|
return rb_iv_get(self, "@field_count");
|
708
718
|
}
|
709
719
|
|
710
|
-
void
|
720
|
+
void Init_do_sqlite3() {
|
711
721
|
rb_require("bigdecimal");
|
712
722
|
rb_require("date");
|
713
723
|
|
@@ -752,6 +762,8 @@ void Init_do_sqlite3_ext() {
|
|
752
762
|
rb_define_method(cConnection, "dispose", cConnection_dispose, 0);
|
753
763
|
rb_define_method(cConnection, "quote_boolean", cConnection_quote_boolean, 1);
|
754
764
|
rb_define_method(cConnection, "quote_string", cConnection_quote_string, 1);
|
765
|
+
rb_define_method(cConnection, "quote_byte_array", cConnection_quote_byte_array, 1);
|
766
|
+
rb_define_method(cConnection, "character_set", cConnection_character_set, 0);
|
755
767
|
|
756
768
|
cCommand = SQLITE3_CLASS("Command", cDO_Command);
|
757
769
|
rb_define_method(cCommand, "set_types", cCommand_set_types, -1);
|