sqlite3 1.3.13-x64-mingw32 → 1.5.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sqlite3 might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.gemtest +0 -0
- data/{API_CHANGES.rdoc → API_CHANGES.md} +3 -4
- data/CHANGELOG.md +425 -0
- data/CONTRIBUTING.md +24 -0
- data/Gemfile +2 -14
- data/LICENSE-DEPENDENCIES +20 -0
- data/README.md +233 -0
- data/ext/sqlite3/aggregator.c +274 -0
- data/ext/sqlite3/aggregator.h +12 -0
- data/ext/sqlite3/database.c +171 -206
- data/ext/sqlite3/database.h +2 -0
- data/ext/sqlite3/exception.c +6 -2
- data/ext/sqlite3/extconf.rb +236 -55
- data/ext/sqlite3/sqlite3.c +12 -1
- data/ext/sqlite3/sqlite3_ruby.h +3 -7
- data/ext/sqlite3/statement.c +15 -20
- data/faq/faq.md +431 -0
- data/faq/faq.yml +1 -1
- data/lib/sqlite3/2.6/sqlite3_native.so +0 -0
- data/lib/sqlite3/2.7/sqlite3_native.so +0 -0
- data/lib/sqlite3/3.0/sqlite3_native.so +0 -0
- data/lib/sqlite3/constants.rb +2 -1
- data/lib/sqlite3/database.rb +202 -52
- data/lib/sqlite3/errors.rb +1 -10
- data/lib/sqlite3/pragmas.rb +17 -10
- data/lib/sqlite3/resultset.rb +2 -10
- data/lib/sqlite3/statement.rb +2 -1
- data/lib/sqlite3/translator.rb +1 -1
- data/lib/sqlite3/version.rb +3 -5
- data/test/helper.rb +9 -0
- data/test/test_database.rb +126 -11
- data/test/test_database_flags.rb +95 -0
- data/test/test_database_readwrite.rb +41 -0
- data/test/test_integration.rb +12 -81
- data/test/test_integration_aggregate.rb +336 -0
- data/test/test_integration_resultset.rb +0 -17
- data/test/test_sqlite3.rb +9 -0
- data/test/test_statement.rb +11 -8
- metadata +54 -85
- data/CHANGELOG.rdoc +0 -292
- data/Manifest.txt +0 -52
- data/README.rdoc +0 -118
- data/Rakefile +0 -10
- data/lib/sqlite3/2.0/sqlite3_native.so +0 -0
- data/lib/sqlite3/2.1/sqlite3_native.so +0 -0
- data/lib/sqlite3/2.2/sqlite3_native.so +0 -0
- data/lib/sqlite3/2.3/sqlite3_native.so +0 -0
- data/lib/sqlite3/2.4/sqlite3_native.so +0 -0
- data/setup.rb +0 -1333
- data/tasks/faq.rake +0 -9
- data/tasks/gem.rake +0 -38
- data/tasks/native.rake +0 -52
- data/tasks/vendor_sqlite3.rake +0 -97
data/ext/sqlite3/extconf.rb
CHANGED
@@ -1,71 +1,252 @@
|
|
1
|
-
|
1
|
+
require "mkmf"
|
2
|
+
require "mini_portile2"
|
3
|
+
|
4
|
+
module Sqlite3
|
5
|
+
module ExtConf
|
6
|
+
ENV_ALLOWLIST = ["CC", "CFLAGS", "LDFLAGS", "LIBS", "CPPFLAGS", "LT_SYS_LIBRARY_PATH", "CPP"]
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def configure
|
10
|
+
configure_cross_compiler
|
11
|
+
|
12
|
+
if system_libraries?
|
13
|
+
message "Building sqlite3-ruby using system #{libname}.\n"
|
14
|
+
configure_system_libraries
|
15
|
+
else
|
16
|
+
message "Building sqlite3-ruby using packaged sqlite3.\n"
|
17
|
+
configure_packaged_libraries
|
18
|
+
end
|
19
|
+
|
20
|
+
configure_extension
|
21
|
+
|
22
|
+
create_makefile('sqlite3/sqlite3_native')
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure_cross_compiler
|
26
|
+
RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
|
27
|
+
ENV["CC"] = RbConfig::CONFIG["CC"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def system_libraries?
|
31
|
+
sqlcipher? || enable_config("system-libraries")
|
32
|
+
end
|
33
|
+
|
34
|
+
def libname
|
35
|
+
sqlcipher? ? "sqlcipher" : "sqlite3"
|
36
|
+
end
|
37
|
+
|
38
|
+
def sqlcipher?
|
39
|
+
with_config("sqlcipher") ||
|
40
|
+
with_config("sqlcipher-dir") ||
|
41
|
+
with_config("sqlcipher-include") ||
|
42
|
+
with_config("sqlcipher-lib")
|
43
|
+
end
|
44
|
+
|
45
|
+
def configure_system_libraries
|
46
|
+
pkg_config(libname)
|
47
|
+
append_cppflags("-DUSING_SQLCIPHER") if sqlcipher?
|
48
|
+
end
|
49
|
+
|
50
|
+
def configure_packaged_libraries
|
51
|
+
minimal_recipe.tap do |recipe|
|
52
|
+
recipe.configure_options += ["--enable-shared=no", "--enable-static=yes"]
|
53
|
+
ENV.to_h.tap do |env|
|
54
|
+
additional_cflags = [
|
55
|
+
"-fPIC", # needed for linking the static library into a shared library
|
56
|
+
"-O2", # see https://github.com/sparklemotion/sqlite3-ruby/issues/335 for some benchmarks
|
57
|
+
]
|
58
|
+
env["CFLAGS"] = [env["CFLAGS"], additional_cflags].flatten.join(" ")
|
59
|
+
recipe.configure_options += env.select { |k,v| ENV_ALLOWLIST.include?(k) }
|
60
|
+
.map { |key, value| "#{key}=#{value.strip}" }
|
61
|
+
end
|
62
|
+
|
63
|
+
unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
|
64
|
+
recipe.cook
|
65
|
+
end
|
66
|
+
recipe.activate
|
67
|
+
|
68
|
+
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t" # on macos, pkg-config will not return --cflags without this
|
69
|
+
pcfile = File.join(recipe.path, "lib", "pkgconfig", "sqlite3.pc")
|
70
|
+
if pkg_config(pcfile)
|
71
|
+
# see https://bugs.ruby-lang.org/issues/18490
|
72
|
+
libs = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
|
73
|
+
libs.split.each { |lib| append_ldflags(lib) } if $?.success?
|
74
|
+
else
|
75
|
+
abort("\nCould not configure the build properly. Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def configure_extension
|
81
|
+
if Gem::Requirement.new("< 2.7").satisfied_by?(Gem::Version.new(RUBY_VERSION))
|
82
|
+
append_cppflags("-DTAINTING_SUPPORT")
|
83
|
+
end
|
84
|
+
|
85
|
+
if find_header("sqlite3.h")
|
86
|
+
# noop
|
87
|
+
elsif sqlcipher? && find_header("sqlcipher/sqlite3.h")
|
88
|
+
append_cppflags("-DUSING_SQLCIPHER_INC_SUBDIR")
|
89
|
+
else
|
90
|
+
abort_could_not_find("sqlite3.h")
|
91
|
+
end
|
92
|
+
|
93
|
+
abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h")
|
94
|
+
|
95
|
+
# Functions defined in 1.9 but not 1.8
|
96
|
+
have_func('rb_proc_arity')
|
97
|
+
|
98
|
+
# Functions defined in 2.1 but not 2.0
|
99
|
+
have_func('rb_integer_pack')
|
100
|
+
|
101
|
+
# These functions may not be defined
|
102
|
+
have_func('sqlite3_initialize')
|
103
|
+
have_func('sqlite3_backup_init')
|
104
|
+
have_func('sqlite3_column_database_name')
|
105
|
+
have_func('sqlite3_enable_load_extension')
|
106
|
+
have_func('sqlite3_load_extension')
|
107
|
+
|
108
|
+
unless have_func('sqlite3_open_v2') # https://www.sqlite.org/releaselog/3_5_0.html
|
109
|
+
abort("\nPlease use a version of SQLite3 >= 3.5.0\n\n")
|
110
|
+
end
|
111
|
+
|
112
|
+
have_func('sqlite3_prepare_v2')
|
113
|
+
have_type('sqlite3_int64', 'sqlite3.h')
|
114
|
+
have_type('sqlite3_uint64', 'sqlite3.h')
|
115
|
+
end
|
116
|
+
|
117
|
+
def minimal_recipe
|
118
|
+
MiniPortile.new(libname, sqlite3_config[:version]).tap do |recipe|
|
119
|
+
recipe.files = sqlite3_config[:files]
|
120
|
+
recipe.target = File.join(package_root_dir, "ports")
|
121
|
+
recipe.patch_files = Dir[File.join(package_root_dir, "patches", "*.patch")].sort
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def package_root_dir
|
126
|
+
File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
127
|
+
end
|
128
|
+
|
129
|
+
def sqlite3_config
|
130
|
+
mini_portile_config[:sqlite3]
|
131
|
+
end
|
132
|
+
|
133
|
+
def mini_portile_config
|
134
|
+
{
|
135
|
+
sqlite3: {
|
136
|
+
# checksum verified by first checking the published sha3(256) checksum against https://sqlite.org/download.html:
|
137
|
+
#
|
138
|
+
# $ sha3sum -a 256 ports/archives/sqlite-autoconf-3390300.tar.gz
|
139
|
+
# dfa055c70724cd63f0b7da6e9f53530d8da51fe021e3f864d58c7c847d590e1d ports/archives/sqlite-autoconf-3390300.tar.gz
|
140
|
+
#
|
141
|
+
# $ sha256sum ports/archives/sqlite-autoconf-3390300.tar.gz
|
142
|
+
# 7868fb3082be3f2cf4491c6fba6de2bddcbc293a35fefb0624ee3c13f01422b9 ports/archives/sqlite-autoconf-3390300.tar.gz
|
143
|
+
#
|
144
|
+
version: "3.39.3",
|
145
|
+
files: [{
|
146
|
+
url: "https://www.sqlite.org/2022/sqlite-autoconf-3390300.tar.gz",
|
147
|
+
sha256: "7868fb3082be3f2cf4491c6fba6de2bddcbc293a35fefb0624ee3c13f01422b9",
|
148
|
+
}],
|
149
|
+
}
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
def abort_could_not_find(missing)
|
154
|
+
abort("\nCould not find #{missing}.\nPlease visit https://github.com/sparklemotion/sqlite3-ruby for installation instructions.\n\n")
|
155
|
+
end
|
156
|
+
|
157
|
+
def cross_build?
|
158
|
+
enable_config("cross-build")
|
159
|
+
end
|
160
|
+
|
161
|
+
def download
|
162
|
+
minimal_recipe.download
|
163
|
+
end
|
164
|
+
|
165
|
+
def print_help
|
166
|
+
print(<<~TEXT)
|
167
|
+
USAGE: ruby #{$PROGRAM_NAME} [options]
|
168
|
+
|
169
|
+
Flags that are always valid:
|
170
|
+
|
171
|
+
--disable-system-libraries
|
172
|
+
Use the packaged libraries, and ignore the system libraries.
|
173
|
+
(This is the default behavior.)
|
2
174
|
|
3
|
-
|
175
|
+
--enable-system-libraries
|
176
|
+
Use system libraries instead of building and using the packaged libraries.
|
4
177
|
|
5
|
-
|
178
|
+
--with-sqlcipher
|
179
|
+
Use libsqlcipher instead of libsqlite3.
|
180
|
+
(Implies `--enable-system-libraries`.)
|
6
181
|
|
7
|
-
|
182
|
+
--help
|
183
|
+
Display this message.
|
8
184
|
|
9
185
|
|
186
|
+
Flags only used when using system libraries:
|
10
187
|
|
11
|
-
|
12
|
-
if RbConfig::CONFIG["host_os"] =~ /darwin/
|
13
|
-
begin
|
14
|
-
brew_prefix = `brew --prefix sqlite3`.chomp
|
15
|
-
ldflags = "#{brew_prefix}/lib"
|
16
|
-
cppflags = "#{brew_prefix}/include"
|
17
|
-
pkg_conf = "#{brew_prefix}/lib/pkgconfig"
|
188
|
+
General (applying to all system libraries):
|
18
189
|
|
19
|
-
|
20
|
-
|
21
|
-
# in case the user doesn't have pkg-config installed
|
22
|
-
ENV['PKG_CONFIG_PATH'] ||= pkg_conf
|
23
|
-
rescue
|
24
|
-
end
|
25
|
-
end
|
190
|
+
--with-opt-dir=DIRECTORY
|
191
|
+
Look for headers and libraries in DIRECTORY.
|
26
192
|
|
27
|
-
|
193
|
+
--with-opt-lib=DIRECTORY
|
194
|
+
Look for libraries in DIRECTORY.
|
28
195
|
|
29
|
-
|
30
|
-
|
196
|
+
--with-opt-include=DIRECTORY
|
197
|
+
Look for headers in DIRECTORY.
|
31
198
|
|
32
|
-
|
33
|
-
$CFLAGS << ' -W3'
|
34
|
-
end
|
199
|
+
Related to sqlcipher:
|
35
200
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
201
|
+
--with-sqlcipher-dir=DIRECTORY
|
202
|
+
Look for sqlcipher headers and library in DIRECTORY.
|
203
|
+
(Implies `--with-sqlcipher` and `--enable-system-libraries`.)
|
204
|
+
|
205
|
+
--with-sqlcipher-lib=DIRECTORY
|
206
|
+
Look for sqlcipher library in DIRECTORY.
|
207
|
+
(Implies `--with-sqlcipher` and `--enable-system-libraries`.)
|
208
|
+
|
209
|
+
--with-sqlcipher-include=DIRECTORY
|
210
|
+
Look for sqlcipher headers in DIRECTORY.
|
211
|
+
(Implies `--with-sqlcipher` and `--enable-system-libraries`.)
|
212
|
+
|
213
|
+
|
214
|
+
Flags only used when building and using the packaged libraries:
|
215
|
+
|
216
|
+
--enable-cross-build
|
217
|
+
Enable cross-build mode. (You probably do not want to set this manually.)
|
49
218
|
|
50
|
-
asplode('sqlite3.h') unless find_header 'sqlite3.h'
|
51
|
-
find_library 'pthread', 'pthread_create' # 1.8 support. *shrug*
|
52
|
-
asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number'
|
53
219
|
|
54
|
-
|
55
|
-
have_func('rb_proc_arity')
|
220
|
+
Environment variables used for compiling the C extension:
|
56
221
|
|
57
|
-
|
58
|
-
|
222
|
+
CC
|
223
|
+
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
59
224
|
|
60
|
-
# These functions may not be defined
|
61
|
-
have_func('sqlite3_initialize')
|
62
|
-
have_func('sqlite3_backup_init')
|
63
|
-
have_func('sqlite3_column_database_name')
|
64
|
-
have_func('sqlite3_enable_load_extension')
|
65
|
-
have_func('sqlite3_load_extension')
|
66
|
-
have_func('sqlite3_open_v2')
|
67
|
-
have_func('sqlite3_prepare_v2')
|
68
|
-
have_type('sqlite3_int64', 'sqlite3.h')
|
69
|
-
have_type('sqlite3_uint64', 'sqlite3.h')
|
70
225
|
|
71
|
-
|
226
|
+
Environment variables passed through to the compilation of packaged libraries:
|
227
|
+
|
228
|
+
CC
|
229
|
+
CPPFLAGS
|
230
|
+
CFLAGS
|
231
|
+
LDFLAGS
|
232
|
+
LIBS
|
233
|
+
LT_SYS_LIBRARY_PATH
|
234
|
+
CPP
|
235
|
+
|
236
|
+
TEXT
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
if arg_config("--help")
|
243
|
+
Sqlite3::ExtConf.print_help
|
244
|
+
exit!(0)
|
245
|
+
end
|
246
|
+
|
247
|
+
if arg_config("--download-dependencies")
|
248
|
+
Sqlite3::ExtConf.download
|
249
|
+
exit!(0)
|
250
|
+
end
|
251
|
+
|
252
|
+
Sqlite3::ExtConf.configure
|
data/ext/sqlite3/sqlite3.c
CHANGED
@@ -65,6 +65,15 @@ static VALUE libversion(VALUE UNUSED(klass))
|
|
65
65
|
return INT2NUM(sqlite3_libversion_number());
|
66
66
|
}
|
67
67
|
|
68
|
+
static VALUE using_sqlcipher(VALUE UNUSED(klass))
|
69
|
+
{
|
70
|
+
#ifdef USING_SQLCIPHER
|
71
|
+
return Qtrue;
|
72
|
+
#else
|
73
|
+
return Qfalse;
|
74
|
+
#endif
|
75
|
+
}
|
76
|
+
|
68
77
|
/* Returns the compile time setting of the SQLITE_THREADSAFE flag.
|
69
78
|
* See: https://www.sqlite.org/c3ref/threadsafe.html
|
70
79
|
*/
|
@@ -144,9 +153,11 @@ void Init_sqlite3_native()
|
|
144
153
|
#ifdef HAVE_SQLITE3_BACKUP_INIT
|
145
154
|
init_sqlite3_backup();
|
146
155
|
#endif
|
147
|
-
|
156
|
+
rb_define_singleton_method(mSqlite3, "sqlcipher?", using_sqlcipher, 0);
|
148
157
|
rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
|
149
158
|
rb_define_singleton_method(mSqlite3, "threadsafe", threadsafe_p, 0);
|
150
159
|
rb_define_const(mSqlite3, "SQLITE_VERSION", rb_str_new2(SQLITE_VERSION));
|
151
160
|
rb_define_const(mSqlite3, "SQLITE_VERSION_NUMBER", INT2FIX(SQLITE_VERSION_NUMBER));
|
161
|
+
rb_define_const(mSqlite3, "SQLITE_LOADED_VERSION", rb_str_new2(sqlite3_libversion()));
|
162
|
+
|
152
163
|
}
|
data/ext/sqlite3/sqlite3_ruby.h
CHANGED
@@ -12,7 +12,6 @@
|
|
12
12
|
# define UNUSED(x) x
|
13
13
|
#endif
|
14
14
|
|
15
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
16
15
|
#include <ruby/encoding.h>
|
17
16
|
|
18
17
|
#define USASCII_P(_obj) (rb_enc_get_index(_obj) == rb_usascii_encindex())
|
@@ -22,15 +21,12 @@
|
|
22
21
|
#define SQLITE3_UTF8_STR_NEW2(_obj) \
|
23
22
|
(rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex()))
|
24
23
|
|
24
|
+
#ifdef USING_SQLCIPHER_INC_SUBDIR
|
25
|
+
# include <sqlcipher/sqlite3.h>
|
25
26
|
#else
|
26
|
-
|
27
|
-
#define SQLITE3_UTF8_STR_NEW2(_obj) (rb_str_new2(_obj))
|
28
|
-
|
27
|
+
# include <sqlite3.h>
|
29
28
|
#endif
|
30
29
|
|
31
|
-
|
32
|
-
#include <sqlite3.h>
|
33
|
-
|
34
30
|
#ifndef HAVE_TYPE_SQLITE3_INT64
|
35
31
|
typedef sqlite_int64 sqlite3_int64;
|
36
32
|
#endif
|
data/ext/sqlite3/statement.c
CHANGED
@@ -43,11 +43,9 @@ static VALUE initialize(VALUE self, VALUE db, VALUE sql)
|
|
43
43
|
if(!db_ctx->db)
|
44
44
|
rb_raise(rb_eArgError, "prepare called on a closed database");
|
45
45
|
|
46
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
47
46
|
if(!UTF8_P(sql)) {
|
48
47
|
sql = rb_str_export_to_enc(sql, rb_utf8_encoding());
|
49
48
|
}
|
50
|
-
#endif
|
51
49
|
|
52
50
|
#ifdef HAVE_SQLITE3_PREPARE_V2
|
53
51
|
status = sqlite3_prepare_v2(
|
@@ -110,9 +108,7 @@ static VALUE step(VALUE self)
|
|
110
108
|
sqlite3_stmt *stmt;
|
111
109
|
int value, length;
|
112
110
|
VALUE list;
|
113
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
114
111
|
rb_encoding * internal_encoding;
|
115
|
-
#endif
|
116
112
|
|
117
113
|
Data_Get_Struct(self, sqlite3StmtRuby, ctx);
|
118
114
|
|
@@ -120,17 +116,24 @@ static VALUE step(VALUE self)
|
|
120
116
|
|
121
117
|
if(ctx->done_p) return Qnil;
|
122
118
|
|
123
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
124
119
|
{
|
125
120
|
VALUE db = rb_iv_get(self, "@connection");
|
126
121
|
rb_funcall(db, rb_intern("encoding"), 0);
|
127
122
|
internal_encoding = rb_default_internal_encoding();
|
128
123
|
}
|
129
|
-
#endif
|
130
124
|
|
131
125
|
stmt = ctx->st;
|
132
126
|
|
133
127
|
value = sqlite3_step(stmt);
|
128
|
+
if (rb_errinfo() != Qnil) {
|
129
|
+
/* some user defined function was invoked as a callback during step and
|
130
|
+
* it raised an exception that has been suppressed until step returns.
|
131
|
+
* Now re-raise it. */
|
132
|
+
VALUE exception = rb_errinfo();
|
133
|
+
rb_set_errinfo(Qnil);
|
134
|
+
rb_exc_raise(exception);
|
135
|
+
}
|
136
|
+
|
134
137
|
length = sqlite3_column_count(stmt);
|
135
138
|
list = rb_ary_new2((long)length);
|
136
139
|
|
@@ -148,21 +151,19 @@ static VALUE step(VALUE self)
|
|
148
151
|
break;
|
149
152
|
case SQLITE_TEXT:
|
150
153
|
{
|
151
|
-
VALUE str =
|
154
|
+
VALUE str = rb_str_new(
|
152
155
|
(const char *)sqlite3_column_text(stmt, i),
|
153
156
|
(long)sqlite3_column_bytes(stmt, i)
|
154
157
|
);
|
155
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
156
158
|
rb_enc_associate_index(str, rb_utf8_encindex());
|
157
159
|
if(internal_encoding)
|
158
160
|
str = rb_str_export_to_enc(str, internal_encoding);
|
159
|
-
#endif
|
160
161
|
rb_ary_push(list, str);
|
161
162
|
}
|
162
163
|
break;
|
163
164
|
case SQLITE_BLOB:
|
164
165
|
{
|
165
|
-
VALUE str =
|
166
|
+
VALUE str = rb_str_new(
|
166
167
|
(const char *)sqlite3_column_blob(stmt, i),
|
167
168
|
(long)sqlite3_column_bytes(stmt, i)
|
168
169
|
);
|
@@ -225,9 +226,7 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
225
226
|
switch(TYPE(value)) {
|
226
227
|
case T_STRING:
|
227
228
|
if(CLASS_OF(value) == cSqlite3Blob
|
228
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
229
229
|
|| rb_enc_get_index(value) == rb_ascii8bit_encindex()
|
230
|
-
#endif
|
231
230
|
) {
|
232
231
|
status = sqlite3_bind_blob(
|
233
232
|
ctx->st,
|
@@ -239,7 +238,6 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
239
238
|
} else {
|
240
239
|
|
241
240
|
|
242
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
243
241
|
if (UTF16_LE_P(value) || UTF16_BE_P(value)) {
|
244
242
|
status = sqlite3_bind_text16(
|
245
243
|
ctx->st,
|
@@ -252,7 +250,6 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
252
250
|
if (!UTF8_P(value) || !USASCII_P(value)) {
|
253
251
|
value = rb_str_encode(value, rb_enc_from_encoding(rb_utf8_encoding()), 0, Qnil);
|
254
252
|
}
|
255
|
-
#endif
|
256
253
|
status = sqlite3_bind_text(
|
257
254
|
ctx->st,
|
258
255
|
index,
|
@@ -260,9 +257,7 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
260
257
|
(int)RSTRING_LEN(value),
|
261
258
|
SQLITE_TRANSIENT
|
262
259
|
);
|
263
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
264
260
|
}
|
265
|
-
#endif
|
266
261
|
}
|
267
262
|
break;
|
268
263
|
case T_BIGNUM: {
|
@@ -295,7 +290,7 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
295
290
|
/* call-seq: stmt.reset!
|
296
291
|
*
|
297
292
|
* Resets the statement. This is typically done internally, though it might
|
298
|
-
*
|
293
|
+
* occasionally be necessary to manually reset the statement.
|
299
294
|
*/
|
300
295
|
static VALUE reset_bang(VALUE self)
|
301
296
|
{
|
@@ -314,9 +309,9 @@ static VALUE reset_bang(VALUE self)
|
|
314
309
|
/* call-seq: stmt.clear_bindings!
|
315
310
|
*
|
316
311
|
* Resets the statement. This is typically done internally, though it might
|
317
|
-
*
|
312
|
+
* occasionally be necessary to manually reset the statement.
|
318
313
|
*/
|
319
|
-
static VALUE
|
314
|
+
static VALUE clear_bindings_bang(VALUE self)
|
320
315
|
{
|
321
316
|
sqlite3StmtRubyPtr ctx;
|
322
317
|
|
@@ -433,7 +428,7 @@ void init_sqlite3_statement()
|
|
433
428
|
rb_define_method(cSqlite3Statement, "closed?", closed_p, 0);
|
434
429
|
rb_define_method(cSqlite3Statement, "bind_param", bind_param, 2);
|
435
430
|
rb_define_method(cSqlite3Statement, "reset!", reset_bang, 0);
|
436
|
-
rb_define_method(cSqlite3Statement, "clear_bindings!",
|
431
|
+
rb_define_method(cSqlite3Statement, "clear_bindings!", clear_bindings_bang, 0);
|
437
432
|
rb_define_method(cSqlite3Statement, "step", step, 0);
|
438
433
|
rb_define_method(cSqlite3Statement, "done?", done_p, 0);
|
439
434
|
rb_define_method(cSqlite3Statement, "column_count", column_count, 0);
|