sqlite3 1.6.3 → 2.10.2

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +615 -1
  3. data/CONTRIBUTING.md +103 -6
  4. data/{faq/faq.md → FAQ.md} +66 -79
  5. data/INSTALLATION.md +267 -0
  6. data/LICENSE +18 -22
  7. data/README.md +87 -124
  8. data/dependencies.yml +10 -11
  9. data/ext/sqlite3/aggregator.c +178 -178
  10. data/ext/sqlite3/aggregator.h +7 -4
  11. data/ext/sqlite3/backup.c +92 -65
  12. data/ext/sqlite3/backup.h +2 -2
  13. data/ext/sqlite3/database.c +964 -477
  14. data/ext/sqlite3/database.h +26 -4
  15. data/ext/sqlite3/exception.c +213 -94
  16. data/ext/sqlite3/exception.h +26 -1
  17. data/ext/sqlite3/extconf.rb +59 -29
  18. data/ext/sqlite3/sqlite3.c +190 -115
  19. data/ext/sqlite3/sqlite3_ruby.h +5 -2
  20. data/ext/sqlite3/statement.c +672 -297
  21. data/ext/sqlite3/statement.h +4 -3
  22. data/ext/sqlite3/timespec.h +29 -0
  23. data/lib/sqlite3/constants.rb +195 -47
  24. data/lib/sqlite3/database.rb +272 -225
  25. data/lib/sqlite3/errors.rb +54 -1
  26. data/lib/sqlite3/fork_safety.rb +66 -0
  27. data/lib/sqlite3/pragmas.rb +194 -141
  28. data/lib/sqlite3/resultset.rb +30 -111
  29. data/lib/sqlite3/statement.rb +105 -25
  30. data/lib/sqlite3/value.rb +17 -20
  31. data/lib/sqlite3/version.rb +2 -21
  32. data/lib/sqlite3/version_info.rb +17 -0
  33. data/lib/sqlite3.rb +8 -4
  34. data/ports/archives/sqlite-autoconf-3540100.tar.gz +0 -0
  35. metadata +16 -48
  36. data/API_CHANGES.md +0 -49
  37. data/ChangeLog.cvs +0 -88
  38. data/Gemfile +0 -11
  39. data/LICENSE-DEPENDENCIES +0 -20
  40. data/faq/faq.rb +0 -145
  41. data/faq/faq.yml +0 -426
  42. data/lib/sqlite3/translator.rb +0 -118
  43. data/ports/archives/sqlite-autoconf-3420000.tar.gz +0 -0
  44. data/test/helper.rb +0 -27
  45. data/test/test_backup.rb +0 -33
  46. data/test/test_collation.rb +0 -82
  47. data/test/test_database.rb +0 -569
  48. data/test/test_database_flags.rb +0 -95
  49. data/test/test_database_readonly.rb +0 -36
  50. data/test/test_database_readwrite.rb +0 -41
  51. data/test/test_deprecated.rb +0 -49
  52. data/test/test_encoding.rb +0 -165
  53. data/test/test_integration.rb +0 -507
  54. data/test/test_integration_aggregate.rb +0 -336
  55. data/test/test_integration_open_close.rb +0 -30
  56. data/test/test_integration_pending.rb +0 -115
  57. data/test/test_integration_resultset.rb +0 -142
  58. data/test/test_integration_statement.rb +0 -194
  59. data/test/test_pragmas.rb +0 -22
  60. data/test/test_result_set.rb +0 -47
  61. data/test/test_sqlite3.rb +0 -30
  62. data/test/test_statement.rb +0 -288
  63. data/test/test_statement_execute.rb +0 -39
@@ -3,15 +3,37 @@
3
3
 
4
4
  #include <sqlite3_ruby.h>
5
5
 
6
+ /* bits in the `flags` field */
7
+ #define SQLITE3_RB_DATABASE_READONLY 0x01
8
+ #define SQLITE3_RB_DATABASE_DISCARDED 0x02
9
+
6
10
  struct _sqlite3Ruby {
7
- sqlite3 *db;
11
+ sqlite3 *db;
12
+ VALUE busy_handler;
13
+ /* sqlite holds raw pointers to everything in these arrays. functions and
14
+ * aggregators are append-only, so redefining a name keeps the old object
15
+ * for the life of the connection: sqlite keys them by name and arity, and
16
+ * releasing on name alone was GHSA-28hh-pr2h-2w89. collations is rebuilt
17
+ * from a private hash keyed by name without regard to ASCII case, as
18
+ * sqlite keys them, so it releases a replaced comparator. */
19
+ VALUE functions;
20
+ VALUE collations;
21
+ VALUE aggregators;
22
+ VALUE trace_handler;
23
+ VALUE authorizer;
24
+ int stmt_timeout;
25
+ struct timespec stmt_deadline;
26
+ rb_pid_t owner;
27
+ int flags;
8
28
  };
9
29
 
10
30
  typedef struct _sqlite3Ruby sqlite3Ruby;
11
- typedef sqlite3Ruby * sqlite3RubyPtr;
31
+ typedef sqlite3Ruby *sqlite3RubyPtr;
12
32
 
13
33
  void init_sqlite3_database();
14
- void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result);
15
- VALUE sqlite3val2rb(sqlite3_value * val);
34
+ void set_sqlite3_func_result(sqlite3_context *ctx, VALUE result);
35
+
36
+ sqlite3RubyPtr sqlite3_database_unwrap(VALUE database);
37
+ VALUE sqlite3val2rb(sqlite3_value *val);
16
38
 
17
39
  #endif
@@ -1,98 +1,217 @@
1
1
  #include <sqlite3_ruby.h>
2
2
 
3
- void rb_sqlite3_raise(sqlite3 * db, int status)
3
+ static VALUE
4
+ status2klass(int status)
4
5
  {
5
- VALUE klass = Qnil;
6
-
7
- /* Consider only lower 8 bits, to work correctly when
8
- extended result codes are enabled. */
9
- switch(status & 0xff) {
10
- case SQLITE_OK:
11
- return;
12
- break;
13
- case SQLITE_ERROR:
14
- klass = rb_path2class("SQLite3::SQLException");
15
- break;
16
- case SQLITE_INTERNAL:
17
- klass = rb_path2class("SQLite3::InternalException");
18
- break;
19
- case SQLITE_PERM:
20
- klass = rb_path2class("SQLite3::PermissionException");
21
- break;
22
- case SQLITE_ABORT:
23
- klass = rb_path2class("SQLite3::AbortException");
24
- break;
25
- case SQLITE_BUSY:
26
- klass = rb_path2class("SQLite3::BusyException");
27
- break;
28
- case SQLITE_LOCKED:
29
- klass = rb_path2class("SQLite3::LockedException");
30
- break;
31
- case SQLITE_NOMEM:
32
- klass = rb_path2class("SQLite3::MemoryException");
33
- break;
34
- case SQLITE_READONLY:
35
- klass = rb_path2class("SQLite3::ReadOnlyException");
36
- break;
37
- case SQLITE_INTERRUPT:
38
- klass = rb_path2class("SQLite3::InterruptException");
39
- break;
40
- case SQLITE_IOERR:
41
- klass = rb_path2class("SQLite3::IOException");
42
- break;
43
- case SQLITE_CORRUPT:
44
- klass = rb_path2class("SQLite3::CorruptException");
45
- break;
46
- case SQLITE_NOTFOUND:
47
- klass = rb_path2class("SQLite3::NotFoundException");
48
- break;
49
- case SQLITE_FULL:
50
- klass = rb_path2class("SQLite3::FullException");
51
- break;
52
- case SQLITE_CANTOPEN:
53
- klass = rb_path2class("SQLite3::CantOpenException");
54
- break;
55
- case SQLITE_PROTOCOL:
56
- klass = rb_path2class("SQLite3::ProtocolException");
57
- break;
58
- case SQLITE_EMPTY:
59
- klass = rb_path2class("SQLite3::EmptyException");
60
- break;
61
- case SQLITE_SCHEMA:
62
- klass = rb_path2class("SQLite3::SchemaChangedException");
63
- break;
64
- case SQLITE_TOOBIG:
65
- klass = rb_path2class("SQLite3::TooBigException");
66
- break;
67
- case SQLITE_CONSTRAINT:
68
- klass = rb_path2class("SQLite3::ConstraintException");
69
- break;
70
- case SQLITE_MISMATCH:
71
- klass = rb_path2class("SQLite3::MismatchException");
72
- break;
73
- case SQLITE_MISUSE:
74
- klass = rb_path2class("SQLite3::MisuseException");
75
- break;
76
- case SQLITE_NOLFS:
77
- klass = rb_path2class("SQLite3::UnsupportedException");
78
- break;
79
- case SQLITE_AUTH:
80
- klass = rb_path2class("SQLite3::AuthorizationException");
81
- break;
82
- case SQLITE_FORMAT:
83
- klass = rb_path2class("SQLite3::FormatException");
84
- break;
85
- case SQLITE_RANGE:
86
- klass = rb_path2class("SQLite3::RangeException");
87
- break;
88
- case SQLITE_NOTADB:
89
- klass = rb_path2class("SQLite3::NotADatabaseException");
90
- break;
91
- default:
92
- klass = rb_eRuntimeError;
93
- }
94
-
95
- klass = rb_exc_new2(klass, sqlite3_errmsg(db));
96
- rb_iv_set(klass, "@code", INT2FIX(status));
97
- rb_exc_raise(klass);
6
+ /* Consider only lower 8 bits, to work correctly when
7
+ extended result codes are enabled. */
8
+ switch (status & 0xff) {
9
+ case SQLITE_OK:
10
+ return Qnil;
11
+ case SQLITE_ERROR:
12
+ return rb_path2class("SQLite3::SQLException");
13
+ case SQLITE_INTERNAL:
14
+ return rb_path2class("SQLite3::InternalException");
15
+ case SQLITE_PERM:
16
+ return rb_path2class("SQLite3::PermissionException");
17
+ case SQLITE_ABORT:
18
+ return rb_path2class("SQLite3::AbortException");
19
+ case SQLITE_BUSY:
20
+ return rb_path2class("SQLite3::BusyException");
21
+ case SQLITE_LOCKED:
22
+ return rb_path2class("SQLite3::LockedException");
23
+ case SQLITE_NOMEM:
24
+ return rb_path2class("SQLite3::MemoryException");
25
+ case SQLITE_READONLY:
26
+ return rb_path2class("SQLite3::ReadOnlyException");
27
+ case SQLITE_INTERRUPT:
28
+ return rb_path2class("SQLite3::InterruptException");
29
+ case SQLITE_IOERR:
30
+ return rb_path2class("SQLite3::IOException");
31
+ case SQLITE_CORRUPT:
32
+ return rb_path2class("SQLite3::CorruptException");
33
+ case SQLITE_NOTFOUND:
34
+ return rb_path2class("SQLite3::NotFoundException");
35
+ case SQLITE_FULL:
36
+ return rb_path2class("SQLite3::FullException");
37
+ case SQLITE_CANTOPEN:
38
+ return rb_path2class("SQLite3::CantOpenException");
39
+ case SQLITE_PROTOCOL:
40
+ return rb_path2class("SQLite3::ProtocolException");
41
+ case SQLITE_EMPTY:
42
+ return rb_path2class("SQLite3::EmptyException");
43
+ case SQLITE_SCHEMA:
44
+ return rb_path2class("SQLite3::SchemaChangedException");
45
+ case SQLITE_TOOBIG:
46
+ return rb_path2class("SQLite3::TooBigException");
47
+ case SQLITE_CONSTRAINT:
48
+ return rb_path2class("SQLite3::ConstraintException");
49
+ case SQLITE_MISMATCH:
50
+ return rb_path2class("SQLite3::MismatchException");
51
+ case SQLITE_MISUSE:
52
+ return rb_path2class("SQLite3::MisuseException");
53
+ case SQLITE_NOLFS:
54
+ return rb_path2class("SQLite3::UnsupportedException");
55
+ case SQLITE_AUTH:
56
+ return rb_path2class("SQLite3::AuthorizationException");
57
+ case SQLITE_FORMAT:
58
+ return rb_path2class("SQLite3::FormatException");
59
+ case SQLITE_RANGE:
60
+ return rb_path2class("SQLite3::RangeException");
61
+ case SQLITE_NOTADB:
62
+ return rb_path2class("SQLite3::NotADatabaseException");
63
+ default:
64
+ return rb_path2class("SQLite3::Exception");
65
+ }
66
+ }
67
+
68
+ void
69
+ rb_sqlite3_raise(sqlite3 *db, int status)
70
+ {
71
+ VALUE klass = status2klass(status);
72
+ if (NIL_P(klass)) {
73
+ return;
74
+ }
75
+
76
+ VALUE exception = rb_exc_new2(klass, sqlite3_errmsg(db));
77
+ rb_iv_set(exception, "@code", INT2FIX(status));
78
+
79
+ rb_exc_raise(exception);
80
+ }
81
+
82
+ /*
83
+ * accepts a sqlite3 error message as the final argument, which will be `sqlite3_free`d
84
+ */
85
+ void
86
+ rb_sqlite3_raise_msg(sqlite3 *db, int status, const char *msg)
87
+ {
88
+ VALUE klass = status2klass(status);
89
+ if (NIL_P(klass)) {
90
+ return;
91
+ }
92
+
93
+ VALUE exception = rb_exc_new2(klass, msg);
94
+ rb_iv_set(exception, "@code", INT2FIX(status));
95
+ sqlite3_free((void *)msg);
96
+
97
+ rb_exc_raise(exception);
98
+ }
99
+
100
+ void
101
+ rb_sqlite3_raise_with_sql(sqlite3 *db, int status, const char *sql)
102
+ {
103
+ VALUE klass = status2klass(status);
104
+ if (NIL_P(klass)) {
105
+ return;
106
+ }
107
+
108
+ const char *error_msg = sqlite3_errmsg(db);
109
+ int error_offset = -1;
110
+ #ifdef HAVE_SQLITE3_ERROR_OFFSET
111
+ error_offset = sqlite3_error_offset(db);
112
+ #endif
113
+
114
+ VALUE exception = rb_exc_new2(klass, error_msg);
115
+ rb_iv_set(exception, "@code", INT2FIX(status));
116
+ if (sql) {
117
+ rb_iv_set(exception, "@sql", rb_str_new2(sql));
118
+ rb_iv_set(exception, "@sql_offset", INT2FIX(error_offset));
119
+ }
120
+
121
+ rb_exc_raise(exception);
122
+ }
123
+
124
+ /* Each call into sqlite that can run callbacks pushes a frame on the current
125
+ * fiber's chain. A callback that fails records its rb_protect state in the top
126
+ * frame, and the call resumes Ruby's pending jump once sqlite returns. Ruby
127
+ * code that runs in between, such as a finalizer during an allocation, pushes
128
+ * its own frame for any nested call, so it never takes the outer call's jump.
129
+ * The chain is fiber-local because Ruby code inside a callback can switch
130
+ * threads or fibers, and a Ruby thread can move between native threads inside
131
+ * rb_protect. */
132
+ typedef struct {
133
+ rb_sqlite3_callback_frame_t *top;
134
+ } callback_frames_t;
135
+
136
+ static const rb_data_type_t callback_frames_type = {
137
+ .wrap_struct_name = "SQLite3::CallbackFrames",
138
+ .function = {
139
+ .dfree = RUBY_TYPED_DEFAULT_FREE,
140
+ },
141
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
142
+ };
143
+
144
+ static ID id_callback_frames;
145
+
146
+ /* Ruby code can overwrite or delete the fiber-local, so check its type. */
147
+ static VALUE
148
+ current_callback_frames_holder(void)
149
+ {
150
+ VALUE holder = rb_thread_local_aref(rb_thread_current(), id_callback_frames);
151
+ return rb_typeddata_is_kind_of(holder, &callback_frames_type) ? holder : Qnil;
152
+ }
153
+
154
+ static callback_frames_t *
155
+ current_callback_frames(void)
156
+ {
157
+ VALUE holder = current_callback_frames_holder();
158
+ return NIL_P(holder) ? NULL : (callback_frames_t *)RTYPEDDATA_DATA(holder);
159
+ }
160
+
161
+ void
162
+ rb_sqlite3_push_callback_frame(rb_sqlite3_callback_frame_t *frame)
163
+ {
164
+ VALUE holder = current_callback_frames_holder();
165
+ callback_frames_t *frames;
166
+
167
+ if (NIL_P(holder)) {
168
+ holder = TypedData_Make_Struct(rb_cObject, callback_frames_t, &callback_frames_type, frames);
169
+ rb_thread_local_aset(rb_thread_current(), id_callback_frames, holder);
170
+ }
171
+ frames = (callback_frames_t *)RTYPEDDATA_DATA(holder);
172
+
173
+ frame->state = 0;
174
+ frame->prev = frames->top;
175
+ frame->holder = holder;
176
+ frames->top = frame;
177
+ }
178
+
179
+ int
180
+ rb_sqlite3_pop_callback_frame(rb_sqlite3_callback_frame_t *frame)
181
+ {
182
+ ((callback_frames_t *)RTYPEDDATA_DATA(frame->holder))->top = frame->prev;
183
+ return frame->state;
184
+ }
185
+
186
+ VALUE
187
+ rb_sqlite3_protect_callback(VALUE (*body)(VALUE), VALUE data, int *failed)
188
+ {
189
+ callback_frames_t *frames = current_callback_frames();
190
+ rb_sqlite3_callback_frame_t *frame = frames ? frames->top : NULL;
191
+ VALUE result;
192
+ int state;
193
+
194
+ if (frame && frame->state) {
195
+ *failed = 1;
196
+ return Qnil;
197
+ }
198
+
199
+ result = rb_protect(body, data, &state);
200
+ *failed = state != 0;
201
+
202
+ if (frame) {
203
+ frame->state = state;
204
+ } else if (state) {
205
+ /* sqlite ran the callback from a call that cannot resume the jump, such
206
+ * as Statement#reset!, so the error is dropped */
207
+ rb_set_errinfo(Qnil);
208
+ }
209
+
210
+ return result;
211
+ }
212
+
213
+ void
214
+ init_sqlite3_exception(void)
215
+ {
216
+ id_callback_frames = rb_intern("__sqlite3_callback_frames__");
98
217
  }
@@ -2,7 +2,32 @@
2
2
  #define SQLITE3_EXCEPTION_RUBY
3
3
 
4
4
  #define CHECK(_db, _status) rb_sqlite3_raise(_db, _status);
5
+ #define CHECK_MSG(_db, _status, _msg) rb_sqlite3_raise_msg(_db, _status, _msg);
6
+ #define CHECK_PREPARE(_db, _status, _sql) rb_sqlite3_raise_with_sql(_db, _status, _sql)
5
7
 
6
- void rb_sqlite3_raise(sqlite3 * db, int status);
8
+ void rb_sqlite3_raise(sqlite3 *db, int status);
9
+ void rb_sqlite3_raise_msg(sqlite3 *db, int status, const char *msg);
10
+ void rb_sqlite3_raise_with_sql(sqlite3 *db, int status, const char *sql);
11
+
12
+ typedef struct rb_sqlite3_callback_frame {
13
+ int state;
14
+ struct rb_sqlite3_callback_frame *prev;
15
+ /* the frame lives on the C stack, so GC marks and pins this */
16
+ VALUE holder;
17
+ } rb_sqlite3_callback_frame_t;
18
+
19
+ /* A call into sqlite that can run callbacks is wrapped in a frame. sqlite
20
+ * cannot carry a raise or a throw, so a failed callback records its rb_protect
21
+ * state in the frame, and later callbacks skip their Ruby code. Pop the frame
22
+ * when sqlite returns, then resume the jump with rb_jump_tag if the returned
23
+ * state is nonzero. Run nothing but the sqlite call in between, because a
24
+ * raise there would skip the pop. */
25
+ void rb_sqlite3_push_callback_frame(rb_sqlite3_callback_frame_t *frame);
26
+ int rb_sqlite3_pop_callback_frame(rb_sqlite3_callback_frame_t *frame);
27
+
28
+ /* Runs a callback's Ruby code for sqlite. Sets *failed if it did not complete. */
29
+ VALUE rb_sqlite3_protect_callback(VALUE (*body)(VALUE), VALUE data, int *failed);
30
+
31
+ void init_sqlite3_exception(void);
7
32
 
8
33
  #endif
@@ -19,7 +19,7 @@ module Sqlite3
19
19
 
20
20
  configure_extension
21
21
 
22
- create_makefile('sqlite3/sqlite3_native')
22
+ create_makefile("sqlite3/sqlite3_native")
23
23
  end
24
24
 
25
25
  def configure_cross_compiler
@@ -49,16 +49,28 @@ module Sqlite3
49
49
 
50
50
  def configure_packaged_libraries
51
51
  minimal_recipe.tap do |recipe|
52
- recipe.configure_options += ["--enable-shared=no", "--enable-static=yes"]
52
+ recipe.configure_options += [
53
+ "--disable-shared",
54
+ "--enable-static",
55
+ "--enable-fts5"
56
+ ]
53
57
  ENV.to_h.tap do |env|
54
- additional_cflags = [
58
+ user_cflags = with_config("sqlite-cflags")
59
+ more_cflags = [
55
60
  "-fPIC", # needed for linking the static library into a shared library
56
61
  "-O2", # see https://github.com/sparklemotion/sqlite3-ruby/issues/335 for some benchmarks
57
62
  "-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
63
+ "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1",
64
+ "-DSQLITE_USE_URI=1",
65
+ "-DSQLITE_ENABLE_DBPAGE_VTAB=1",
66
+ "-DSQLITE_ENABLE_DBSTAT_VTAB=1"
58
67
  ]
59
- env["CFLAGS"] = [env["CFLAGS"], additional_cflags].flatten.join(" ")
60
- recipe.configure_options += env.select { |k,v| ENV_ALLOWLIST.include?(k) }
61
- .map { |key, value| "#{key}=#{value.strip}" }
68
+ # sqlite >= 3.54 requires Vista APIs, same as ruby's default target. Placed first so a
69
+ # user-defined _WIN32_WINNT takes precedence.
70
+ windows_cflags = windows? ? ["-D_WIN32_WINNT=0x0600"] : []
71
+ env["CFLAGS"] = [windows_cflags, user_cflags, env["CFLAGS"], more_cflags].flatten.join(" ")
72
+ recipe.configure_options += env.slice(*ENV_ALLOWLIST)
73
+ .map { |key, value| "#{key}=#{value.strip}" }
62
74
  end
63
75
 
64
76
  unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
@@ -87,46 +99,55 @@ module Sqlite3
87
99
  end
88
100
 
89
101
  ldflags.each { |ldflag| append_ldflags(ldflag) }
102
+
103
+ append_cppflags("-DUSING_PACKAGED_LIBRARIES")
104
+ append_cppflags("-DUSING_PRECOMPILED_LIBRARIES") if cross_build?
90
105
  end
91
106
  end
92
107
 
93
108
  def configure_extension
94
- if Gem::Requirement.new("< 2.7").satisfied_by?(Gem::Version.new(RUBY_VERSION))
95
- append_cppflags("-DTAINTING_SUPPORT")
96
- end
97
-
98
109
  append_cflags("-fvisibility=hidden") # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
99
110
 
100
- if find_header("sqlite3.h")
101
- # noop
102
- elsif sqlcipher? && find_header("sqlcipher/sqlite3.h")
111
+ if sqlcipher? && find_header("sqlcipher/sqlite3.h")
103
112
  append_cppflags("-DUSING_SQLCIPHER_INC_SUBDIR")
113
+ elsif find_header("sqlite3.h")
114
+ # noop
104
115
  else
105
116
  abort_could_not_find("sqlite3.h")
106
117
  end
107
118
 
108
119
  abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h")
109
120
 
121
+ # Ruby 3.0+, but not on every implementation:
122
+ # https://github.com/oracle/truffleruby/issues/3408
123
+ have_func("rb_enc_interned_str_cstr")
124
+ have_func("rb_enc_interned_str")
125
+
110
126
  # Functions defined in 1.9 but not 1.8
111
- have_func('rb_proc_arity')
127
+ have_func("rb_proc_arity")
112
128
 
113
129
  # Functions defined in 2.1 but not 2.0
114
- have_func('rb_integer_pack')
130
+ have_func("rb_integer_pack")
115
131
 
116
132
  # These functions may not be defined
117
- have_func('sqlite3_initialize')
118
- have_func('sqlite3_backup_init')
119
- have_func('sqlite3_column_database_name')
120
- have_func('sqlite3_enable_load_extension')
121
- have_func('sqlite3_load_extension')
133
+ have_func("sqlite3_initialize")
134
+ have_func("sqlite3_backup_init")
135
+ have_func("sqlite3_column_database_name")
136
+ have_func("sqlite3_enable_load_extension")
137
+ have_func("sqlite3_load_extension")
122
138
 
123
- unless have_func('sqlite3_open_v2') # https://www.sqlite.org/releaselog/3_5_0.html
139
+ unless have_func("sqlite3_open_v2") # https://www.sqlite.org/releaselog/3_5_0.html
124
140
  abort("\nPlease use a version of SQLite3 >= 3.5.0\n\n")
125
141
  end
126
142
 
127
- have_func('sqlite3_prepare_v2')
128
- have_type('sqlite3_int64', 'sqlite3.h')
129
- have_type('sqlite3_uint64', 'sqlite3.h')
143
+ have_func("sqlite3_prepare_v2")
144
+ have_func("sqlite3_db_name", "sqlite3.h") # v3.39.0
145
+ have_func("sqlite3_error_offset", "sqlite3.h") # v3.38.0
146
+ have_func("sqlite3_serialize", "sqlite3.h") # v3.23.0
147
+ have_func("sqlite3_deserialize", "sqlite3.h") # v3.23.0
148
+
149
+ have_type("sqlite3_int64", "sqlite3.h")
150
+ have_type("sqlite3_uint64", "sqlite3.h")
130
151
  end
131
152
 
132
153
  def minimal_recipe
@@ -152,8 +173,7 @@ module Sqlite3
152
173
  end
153
174
 
154
175
  def mini_portile_config
155
- # TODO: once Ruby 2.7 is no longer supported, use symbolize_names: true
156
- YAML.load_file(File.join(package_root_dir, "dependencies.yml"))
176
+ YAML.load_file(File.join(package_root_dir, "dependencies.yml"), symbolize_names: true)
157
177
  end
158
178
 
159
179
  def abort_could_not_find(missing)
@@ -161,7 +181,7 @@ module Sqlite3
161
181
  end
162
182
 
163
183
  def abort_pkg_config(id)
164
- abort("\nCould not configure the build properly (#{id}). Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
184
+ abort("\nCould not configure the build properly (#{id}). Please install the `pkg-config` utility.\n\n")
165
185
  end
166
186
 
167
187
  def cross_build?
@@ -180,6 +200,10 @@ module Sqlite3
180
200
  RbConfig::CONFIG["target_os"].include?("darwin")
181
201
  end
182
202
 
203
+ def windows?
204
+ RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
205
+ end
206
+
183
207
  def print_help
184
208
  print(<<~TEXT)
185
209
  USAGE: ruby #{$PROGRAM_NAME} [options]
@@ -234,17 +258,23 @@ module Sqlite3
234
258
 
235
259
  Flags only used when building and using the packaged libraries:
236
260
 
261
+ --with-sqlite-cflags=CFLAGS
262
+ Explicitly pass compiler flags to the sqlite library build. These flags will
263
+ appear on the commandline before any flags set in the CFLAGS environment
264
+ variable. This is useful for setting compilation options in your project's
265
+ bundler config. See INSTALLATION.md for more information.
266
+
237
267
  --enable-cross-build
238
268
  Enable cross-build mode. (You probably do not want to set this manually.)
239
269
 
240
270
 
241
- Environment variables used for compiling the C extension:
271
+ Environment variables used for compiling the gem's C extension:
242
272
 
243
273
  CC
244
274
  Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
245
275
 
246
276
 
247
- Environment variables passed through to the compilation of packaged libraries:
277
+ Environment variables passed through to the compilation of sqlite:
248
278
 
249
279
  CC
250
280
  CPPFLAGS