do_sqlite3 0.10.3-x86-mingw32 → 0.10.4.rc1-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/README.markdown +2 -9
- data/Rakefile +12 -45
- data/ext/do_sqlite3/do_common.c +526 -0
- data/ext/do_sqlite3/do_common.h +170 -0
- data/ext/do_sqlite3/do_sqlite3.c +171 -537
- data/ext/do_sqlite3/do_sqlite3.h +3 -49
- data/ext/do_sqlite3/do_sqlite3_extension.c +28 -29
- data/ext/do_sqlite3/error.h +30 -56
- data/lib/do_sqlite3.rb +8 -3
- 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 +2 -2
- data/spec/connection_spec.rb +9 -9
- data/spec/encoding_spec.rb +3 -3
- data/spec/error/sql_error_spec.rb +2 -2
- data/spec/reader_spec.rb +2 -2
- data/spec/result_spec.rb +4 -4
- data/spec/spec_helper.rb +14 -11
- data/spec/typecast/array_spec.rb +2 -2
- data/spec/typecast/bigdecimal_spec.rb +2 -2
- data/spec/typecast/boolean_spec.rb +2 -2
- data/spec/typecast/byte_array_spec.rb +2 -2
- data/spec/typecast/class_spec.rb +2 -2
- data/spec/typecast/date_spec.rb +2 -2
- data/spec/typecast/datetime_spec.rb +2 -2
- data/spec/typecast/float_spec.rb +3 -3
- data/spec/typecast/integer_spec.rb +2 -2
- data/spec/typecast/nil_spec.rb +5 -5
- data/spec/typecast/other_spec.rb +2 -2
- data/spec/typecast/range_spec.rb +2 -2
- data/spec/typecast/string_spec.rb +2 -2
- data/spec/typecast/time_spec.rb +2 -2
- data/tasks/compile.rake +28 -29
- data/tasks/spec.rake +8 -19
- metadata +50 -47
data/ext/do_sqlite3/do_sqlite3.h
CHANGED
@@ -9,57 +9,11 @@
|
|
9
9
|
#include <sqlite3.h>
|
10
10
|
#include "compat.h"
|
11
11
|
|
12
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
13
|
-
#include <ruby/encoding.h>
|
14
|
-
|
15
|
-
#define DO_STR_NEW2(str, encoding, internal_encoding) \
|
16
|
-
({ \
|
17
|
-
VALUE _string = rb_str_new2((const char *)str); \
|
18
|
-
if(encoding != -1) { \
|
19
|
-
rb_enc_associate_index(_string, encoding); \
|
20
|
-
} \
|
21
|
-
if(internal_encoding) { \
|
22
|
-
_string = rb_str_export_to_enc(_string, internal_encoding); \
|
23
|
-
} \
|
24
|
-
_string; \
|
25
|
-
})
|
26
|
-
|
27
|
-
#define DO_STR_NEW(str, len, encoding, internal_encoding) \
|
28
|
-
({ \
|
29
|
-
VALUE _string = rb_str_new((const char *)str, (long)len); \
|
30
|
-
if(encoding != -1) { \
|
31
|
-
rb_enc_associate_index(_string, encoding); \
|
32
|
-
} \
|
33
|
-
if(internal_encoding) { \
|
34
|
-
_string = rb_str_export_to_enc(_string, internal_encoding); \
|
35
|
-
} \
|
36
|
-
_string; \
|
37
|
-
})
|
38
|
-
|
39
|
-
#else
|
40
|
-
|
41
|
-
#define DO_STR_NEW2(str, encoding, internal_encoding) \
|
42
|
-
rb_str_new2((const char *)str)
|
43
|
-
|
44
|
-
#define DO_STR_NEW(str, len, encoding, internal_encoding) \
|
45
|
-
rb_str_new((const char *)str, (long)len)
|
46
|
-
#endif
|
47
|
-
|
48
|
-
#define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
|
49
|
-
#define DRIVER_CLASS(klass, parent) (rb_define_class_under(mSqlite3, klass, parent))
|
50
|
-
|
51
|
-
#ifdef _WIN32
|
52
|
-
#define do_int64 signed __int64
|
53
|
-
#else
|
54
|
-
#define do_int64 signed long long int
|
55
|
-
#endif
|
56
|
-
|
57
12
|
#ifndef HAVE_SQLITE3_PREPARE_V2
|
58
13
|
#define sqlite3_prepare_v2 sqlite3_prepare
|
59
14
|
#endif
|
60
15
|
|
61
|
-
|
62
|
-
|
63
|
-
void Init_do_sqlite3_extension();
|
16
|
+
extern VALUE mSqlite3;
|
17
|
+
extern void Init_do_sqlite3_extension();
|
64
18
|
|
65
|
-
#endif
|
19
|
+
#endif
|
@@ -1,22 +1,16 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include "do_common.h"
|
1
3
|
#include "do_sqlite3.h"
|
2
4
|
|
3
|
-
|
4
|
-
static VALUE mDO;
|
5
|
-
static VALUE mSqlite3;
|
6
|
-
static VALUE eConnectionError;
|
7
|
-
static VALUE cDO_Extension;
|
8
|
-
static VALUE cExtension;
|
5
|
+
VALUE cExtension;
|
9
6
|
|
10
7
|
/*****************************************************/
|
11
8
|
/* File used for providing extensions on the default */
|
12
9
|
/* API that are driver specific. */
|
13
10
|
/*****************************************************/
|
14
|
-
|
11
|
+
VALUE cExtension_enable_load_extension(VALUE self, VALUE on) {
|
15
12
|
VALUE id_connection = rb_intern("connection");
|
16
|
-
|
17
13
|
VALUE connection = rb_funcall(self, id_connection, 0);
|
18
|
-
sqlite3 *db;
|
19
|
-
int status;
|
20
14
|
|
21
15
|
if (connection == Qnil) { return Qfalse; }
|
22
16
|
|
@@ -25,26 +19,24 @@ static VALUE cExtension_enable_load_extension(VALUE self, VALUE on) {
|
|
25
19
|
|
26
20
|
if (connection == Qnil) { return Qfalse; }
|
27
21
|
|
28
|
-
db
|
22
|
+
sqlite3 *db;
|
29
23
|
|
30
|
-
if(db
|
24
|
+
if (!(db = DATA_PTR(connection))) {
|
25
|
+
return Qfalse;
|
26
|
+
}
|
31
27
|
|
32
|
-
status = sqlite3_enable_load_extension(db, on == Qtrue ? 1 : 0);
|
28
|
+
int status = sqlite3_enable_load_extension(db, on == Qtrue ? 1 : 0);
|
33
29
|
|
34
|
-
if (
|
30
|
+
if (status != SQLITE_OK) {
|
35
31
|
rb_raise(eConnectionError, "Couldn't enable extension loading");
|
36
32
|
}
|
33
|
+
|
37
34
|
return Qtrue;
|
38
35
|
}
|
39
36
|
|
40
|
-
|
37
|
+
VALUE cExtension_load_extension(VALUE self, VALUE path) {
|
41
38
|
VALUE id_connection = rb_intern("connection");
|
42
|
-
|
43
39
|
VALUE connection = rb_funcall(self, id_connection, 0);
|
44
|
-
sqlite3 *db;
|
45
|
-
const char *extension_path = rb_str_ptr_readonly(path);
|
46
|
-
char* errmsg = sqlite3_malloc(1024);
|
47
|
-
int status;
|
48
40
|
|
49
41
|
if (connection == Qnil) { return Qfalse; }
|
50
42
|
|
@@ -53,26 +45,33 @@ static VALUE cExtension_load_extension(VALUE self, VALUE path) {
|
|
53
45
|
|
54
46
|
if (connection == Qnil) { return Qfalse; }
|
55
47
|
|
56
|
-
db
|
48
|
+
sqlite3 *db;
|
49
|
+
|
50
|
+
if (!(db = DATA_PTR(connection))) {
|
51
|
+
return Qfalse;
|
52
|
+
}
|
53
|
+
|
54
|
+
const char *extension_path = rb_str_ptr_readonly(path);
|
55
|
+
char *errmsg;
|
57
56
|
|
58
|
-
if(
|
57
|
+
if (!(errmsg = sqlite3_malloc(1024))) {
|
58
|
+
return Qfalse;
|
59
|
+
}
|
59
60
|
|
60
|
-
status = sqlite3_load_extension(db, extension_path, 0, &errmsg);
|
61
|
+
int status = sqlite3_load_extension(db, extension_path, 0, &errmsg);
|
61
62
|
|
62
|
-
if (
|
63
|
+
if (status != SQLITE_OK) {
|
63
64
|
VALUE errexp = rb_exc_new2(eConnectionError, errmsg);
|
65
|
+
|
64
66
|
sqlite3_free(errmsg);
|
65
67
|
rb_exc_raise(errexp);
|
66
68
|
}
|
69
|
+
|
67
70
|
return Qtrue;
|
68
71
|
}
|
69
72
|
|
70
73
|
void Init_do_sqlite3_extension() {
|
71
|
-
|
72
|
-
mDO = CONST_GET(rb_mKernel, "DataObjects");
|
73
|
-
cDO_Extension = CONST_GET(mDO, "Extension");
|
74
|
-
mSqlite3 = rb_define_module_under(mDO, "Sqlite3");
|
75
|
-
cExtension = DRIVER_CLASS("Extension", cDO_Extension);
|
74
|
+
cExtension = rb_define_class_under(mSqlite3, "Extension", cDO_Extension);
|
76
75
|
rb_define_method(cExtension, "load_extension", cExtension_load_extension, 1);
|
77
76
|
rb_define_method(cExtension, "enable_load_extension", cExtension_enable_load_extension, 1);
|
78
77
|
}
|
data/ext/do_sqlite3/error.h
CHANGED
@@ -1,111 +1,85 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef _DO_SQLITE3_ERROR_H_
|
2
|
+
#define _DO_SQLITE3_ERROR_H_
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const char *exception;
|
8
|
-
} errors [] = {
|
4
|
+
#include "do_common.h"
|
5
|
+
|
6
|
+
static struct errcodes errors[] = {
|
9
7
|
#ifdef SQLITE_ERROR
|
10
|
-
|
11
|
-
"SQLITE_ERROR", "SyntaxError"},
|
8
|
+
ERRCODE(SQLITE_ERROR, "SyntaxError"),
|
12
9
|
#endif
|
13
10
|
#ifdef SQLITE_INTERNAL
|
14
|
-
|
15
|
-
"SQLITE_INTERNAL", "SQLError"},
|
11
|
+
ERRCODE(SQLITE_INTERNAL, "SQLError"),
|
16
12
|
#endif
|
17
13
|
#ifdef SQLITE_PERM
|
18
|
-
|
19
|
-
"SQLITE_PERM", "ConnectionError"},
|
14
|
+
ERRCODE(SQLITE_PERM, "ConnectionError"),
|
20
15
|
#endif
|
21
16
|
#ifdef SQLITE_ABORT
|
22
|
-
|
23
|
-
"SQLITE_ABORT", "ConnectionError"},
|
17
|
+
ERRCODE(SQLITE_ABORT, "ConnectionError"),
|
24
18
|
#endif
|
25
19
|
#ifdef SQLITE_BUSY
|
26
|
-
|
27
|
-
"SQLITE_BUSY", "ConnectionError"},
|
20
|
+
ERRCODE(SQLITE_BUSY, "ConnectionError"),
|
28
21
|
#endif
|
29
22
|
|
30
23
|
#ifdef SQLITE_LOCKED
|
31
|
-
|
32
|
-
"SQLITE_LOCKED", "ConnectionError"},
|
24
|
+
ERRCODE(SQLITE_LOCKED, "ConnectionError"),
|
33
25
|
#endif
|
34
26
|
#ifdef SQLITE_NOMEM
|
35
|
-
|
36
|
-
"SQLITE_NOMEM", "ConnectionError"},
|
27
|
+
ERRCODE(SQLITE_NOMEM, "ConnectionError"),
|
37
28
|
#endif
|
38
29
|
#ifdef SQLITE_READONLY
|
39
|
-
|
40
|
-
"SQLITE_READONLY", "ConnectionError"},
|
30
|
+
ERRCODE(SQLITE_READONLY, "ConnectionError"),
|
41
31
|
#endif
|
42
32
|
#ifdef SQLITE_INTERRUPT
|
43
|
-
|
44
|
-
"SQLITE_INTERRUPT", "ConnectionError"},
|
33
|
+
ERRCODE(SQLITE_INTERRUPT, "ConnectionError"),
|
45
34
|
#endif
|
46
35
|
#ifdef SQLITE_IOERR
|
47
|
-
|
48
|
-
"SQLITE_IOERR", "ConnectionError"},
|
36
|
+
ERRCODE(SQLITE_IOERR, "ConnectionError"),
|
49
37
|
#endif
|
50
38
|
#ifdef SQLITE_CORRUPT
|
51
|
-
|
52
|
-
"SQLITE_CORRUPT", "ConnectionError"},
|
39
|
+
ERRCODE(SQLITE_CORRUPT, "ConnectionError"),
|
53
40
|
#endif
|
54
41
|
#ifdef SQLITE_FULL
|
55
|
-
|
56
|
-
"SQLITE_FULL", "ConnectionError"},
|
42
|
+
ERRCODE(SQLITE_FULL, "ConnectionError"),
|
57
43
|
#endif
|
58
44
|
#ifdef SQLITE_CANTOPEN
|
59
|
-
|
60
|
-
"SQLITE_CANTOPEN", "ConnectionError"},
|
45
|
+
ERRCODE(SQLITE_CANTOPEN, "ConnectionError"),
|
61
46
|
#endif
|
62
47
|
#ifdef SQLITE_EMPTY
|
63
|
-
|
64
|
-
"SQLITE_EMPTY", "ConnectionError"},
|
48
|
+
ERRCODE(SQLITE_EMPTY, "ConnectionError"),
|
65
49
|
#endif
|
66
50
|
#ifdef SQLITE_SCHEMA
|
67
|
-
|
68
|
-
"SQLITE_SCHEMA", "DataError"},
|
51
|
+
ERRCODE(SQLITE_SCHEMA, "DataError"),
|
69
52
|
#endif
|
70
53
|
#ifdef SQLITE_TOOBIG
|
71
|
-
|
72
|
-
"SQLITE_TOOBIG", "DataError"},
|
54
|
+
ERRCODE(SQLITE_TOOBIG, "DataError"),
|
73
55
|
#endif
|
74
56
|
#ifdef SQLITE_MISMATCH
|
75
|
-
|
76
|
-
"SQLITE_MISMATCH", "DataError"},
|
57
|
+
ERRCODE(SQLITE_MISMATCH, "DataError"),
|
77
58
|
#endif
|
78
59
|
#ifdef SQLITE_CONSTRAINT
|
79
|
-
|
80
|
-
"SQLITE_CONSTRAINT", "IntegrityError"},
|
60
|
+
ERRCODE(SQLITE_CONSTRAINT, "IntegrityError"),
|
81
61
|
#endif
|
82
62
|
#ifdef SQLITE_MISUSE
|
83
|
-
|
84
|
-
"SQLITE_MISUSE", "SQLError"},
|
63
|
+
ERRCODE(SQLITE_MISUSE, "SQLError"),
|
85
64
|
#endif
|
86
65
|
|
87
66
|
#ifdef SQLITE_NOLFS
|
88
|
-
|
89
|
-
"SQLITE_NOLFS", "ConnectionError"},
|
67
|
+
ERRCODE(SQLITE_NOLFS, "ConnectionError"),
|
90
68
|
#endif
|
91
69
|
#ifdef SQLITE_FORMAT
|
92
|
-
|
93
|
-
"SQLITE_FORMAT", "SyntaxError"},
|
70
|
+
ERRCODE(SQLITE_FORMAT, "SyntaxError"),
|
94
71
|
#endif
|
95
72
|
#ifdef SQLITE_RANGE
|
96
|
-
|
97
|
-
"SQLITE_RANGE", "DataError"},
|
73
|
+
ERRCODE(SQLITE_RANGE, "DataError"),
|
98
74
|
#endif
|
99
75
|
#ifdef SQLITE_NOTADB
|
100
|
-
|
101
|
-
"SQLITE_NOTADB", "ConnectionError"},
|
76
|
+
ERRCODE(SQLITE_NOTADB, "ConnectionError"),
|
102
77
|
#endif
|
103
78
|
|
104
79
|
#ifdef SQLITE_ROW
|
105
|
-
|
106
|
-
"SQLITE_ROW", "SyntaxError"},
|
80
|
+
ERRCODE(SQLITE_ROW, "SyntaxError"),
|
107
81
|
#endif
|
108
82
|
{0, NULL, NULL}
|
109
83
|
};
|
110
84
|
|
111
|
-
#endif
|
85
|
+
#endif
|
data/lib/do_sqlite3.rb
CHANGED
@@ -3,9 +3,14 @@ if RUBY_PLATFORM =~ /java/
|
|
3
3
|
require 'do_jdbc'
|
4
4
|
require 'java'
|
5
5
|
|
6
|
-
|
6
|
+
module DataObjects
|
7
|
+
module Sqlite3
|
8
|
+
JDBC_DRIVER = 'org.sqlite.JDBC'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
7
12
|
begin
|
8
|
-
java.lang.Thread.currentThread.getContextClassLoader().loadClass(
|
13
|
+
java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Sqlite3::JDBC_DRIVER, true)
|
9
14
|
rescue
|
10
15
|
require 'jdbc/sqlite3' # the JDBC driver, packaged as a gem
|
11
16
|
end
|
@@ -15,7 +20,7 @@ if RUBY_PLATFORM =~ /java/
|
|
15
20
|
# Thread.currentThread.getContextClassLoader().loadClass() within the
|
16
21
|
# data_objects.Connection Java class, which is currently not working as
|
17
22
|
# expected.
|
18
|
-
java_import
|
23
|
+
java_import DataObjects::Sqlite3::JDBC_DRIVER
|
19
24
|
end
|
20
25
|
|
21
26
|
begin
|
Binary file
|
Binary file
|
data/lib/do_sqlite3/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/command_spec'
|
4
|
+
require 'data_objects/spec/shared/command_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Sqlite3::Command do
|
7
|
-
|
7
|
+
it_should_behave_like 'a Command'
|
8
8
|
end
|
data/spec/connection_spec.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/connection_spec'
|
4
|
+
require 'data_objects/spec/shared/connection_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Sqlite3::Connection do
|
7
7
|
|
8
|
-
before do
|
9
|
-
@driver
|
10
|
-
@user
|
8
|
+
before :all do
|
9
|
+
@driver = CONFIG.scheme
|
10
|
+
@user = CONFIG.user
|
11
11
|
@password = CONFIG.pass
|
12
|
-
@host
|
13
|
-
@port
|
12
|
+
@host = CONFIG.host
|
13
|
+
@port = CONFIG.port
|
14
14
|
@database = CONFIG.database
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it_should_behave_like 'a Connection'
|
18
|
+
it_should_behave_like 'a Connection via JDNI' if JRUBY
|
19
|
+
it_should_behave_like 'a Connection with JDBC URL support' if JRUBY
|
20
20
|
end
|
data/spec/encoding_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/encoding_spec'
|
4
|
+
require 'data_objects/spec/shared/encoding_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Sqlite3::Connection do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'returning correctly encoded strings for the default database encoding'
|
8
|
+
it_should_behave_like 'returning correctly encoded strings for the default internal encoding'
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/error/sql_error_spec'
|
4
|
+
require 'data_objects/spec/shared/error/sql_error_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Sqlite3 raising SQLError' do
|
7
7
|
# This fails for now, need to think of a query that also exposes the issue on sqlite :S
|
8
|
-
#
|
8
|
+
# it_should_behave_like 'raising a SQLError'
|
9
9
|
end
|
data/spec/reader_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/reader_spec'
|
4
|
+
require 'data_objects/spec/shared/reader_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Sqlite3::Reader do
|
7
|
-
|
7
|
+
it_should_behave_like 'a Reader'
|
8
8
|
end
|
data/spec/result_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/result_spec'
|
4
|
+
require 'data_objects/spec/shared/result_spec'
|
5
5
|
|
6
6
|
# splitting the descibe into two separate declaration avoids
|
7
|
-
# concurrent execution of the "
|
7
|
+
# concurrent execution of the "it_should_behave_like ....." calls
|
8
8
|
# which would lock the database
|
9
9
|
|
10
10
|
# TODO
|
11
11
|
# the locked database created a deadlock which is worth exploring since
|
12
12
|
# such situation could appear in the wild too
|
13
13
|
describe DataObjects::Sqlite3::Result do
|
14
|
-
|
14
|
+
it_should_behave_like 'a Result'
|
15
15
|
end
|
16
16
|
|
17
17
|
describe DataObjects::Sqlite3::Result do
|
18
|
-
|
18
|
+
it_should_behave_like 'a Result which returns inserted key with sequences'
|
19
19
|
end
|