sqlite3 2.1.0.rc1-aarch64-linux-musl → 2.1.0.rc3-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +7 -12
- data/ext/sqlite3/database.c +9 -7
- data/ext/sqlite3/database.h +4 -0
- data/ext/sqlite3/statement.c +23 -28
- data/ext/sqlite3/statement.h +1 -0
- data/lib/sqlite3/3.1/sqlite3_native.so +0 -0
- data/lib/sqlite3/3.2/sqlite3_native.so +0 -0
- data/lib/sqlite3/3.3/sqlite3_native.so +0 -0
- data/lib/sqlite3/fork_safety.rb +7 -1
- data/lib/sqlite3/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022d563fce80208b0de29ff6ba0cce6422cd0ba3d69142581a7ba2b171d81ccc
|
4
|
+
data.tar.gz: 419350fa778be055d156c57ace2b7ff4b1c159c68a43a5a0826e4ef2599a2e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e5623879a9467faa28b1547161176bbed47e1b0f214d9117c77f639ab6c4215467f2cdd168bc0f9a92c2e75cc0af302edf7566760f55bf051592adc198cc72f
|
7
|
+
data.tar.gz: 7a5b6f84c35944902926775fe0ebe6415e024f8a79e886e5cc9683c0419b86fad994fbe0a553a7c9f4a2fd04c943b4e7b8c0286690708bbbecf6ce3c9b2fdac9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# sqlite3-ruby Changelog
|
2
2
|
|
3
|
+
## prerelease 2.1.0.rc3 / 2024-09-18
|
4
|
+
|
5
|
+
### Improved
|
6
|
+
|
7
|
+
- Allow suppression of fork safety warnings. [#566] @flavorjones
|
8
|
+
|
9
|
+
|
10
|
+
## prerelease 2.1.0.rc2 / 2024-09-18
|
11
|
+
|
12
|
+
### Improved
|
13
|
+
|
14
|
+
- Address a performance regression in 2.1.0.rc1.
|
15
|
+
|
16
|
+
|
3
17
|
## prerelease 2.1.0.rc1 / 2024-09-18
|
4
18
|
|
5
19
|
### Ruby
|
data/CONTRIBUTING.md
CHANGED
@@ -16,20 +16,15 @@ please look there for additional information.
|
|
16
16
|
|
17
17
|
All statements keep pointers back to their respective database connections.
|
18
18
|
The `@connection` instance variable on the `Statement` handle keeps the database
|
19
|
-
connection alive.
|
20
|
-
two cases:
|
19
|
+
connection alive.
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
for the statement handler. The reason is because there exists a race
|
27
|
-
condition. We cannot guarantee the order in which objects will be garbage
|
28
|
-
collected. So, it is possible that a connection and a statement are up for
|
29
|
-
garbage collection. If the database connection were to be free'd before the
|
30
|
-
statement, then boom. Instead we'll be conservative and free unclosed
|
31
|
-
statements when the connection is terminated.
|
21
|
+
We use `sqlite3_close_v2` in `Database#close` since v2.1.0 which defers _actually_ closing the
|
22
|
+
connection and freeing the underlying memory until all open statments are closed; though the
|
23
|
+
`Database` object will immediately behave as though it's been fully closed. If a Database is not
|
24
|
+
explicitly closed, it will be closed when it is GCed.
|
32
25
|
|
26
|
+
`Statement#close` finalizes the underlying statement. If a Statement is not explicitly closed, it
|
27
|
+
will be closed/finalized when it is GCed.
|
33
28
|
|
34
29
|
|
35
30
|
## Building gems
|
data/ext/sqlite3/database.c
CHANGED
@@ -49,15 +49,16 @@ discard_db(sqlite3RubyPtr ctx)
|
|
49
49
|
}
|
50
50
|
|
51
51
|
ctx->db = NULL;
|
52
|
+
ctx->flags |= SQLITE3_RB_DATABASE_DISCARDED;
|
52
53
|
}
|
53
54
|
|
54
55
|
static void
|
55
56
|
close_or_discard_db(sqlite3RubyPtr ctx)
|
56
57
|
{
|
57
58
|
if (ctx->db) {
|
58
|
-
int
|
59
|
+
int is_readonly = (ctx->flags & SQLITE3_RB_DATABASE_READONLY);
|
59
60
|
|
60
|
-
if (
|
61
|
+
if (is_readonly || ctx->owner == getpid()) {
|
61
62
|
// Ordinary close.
|
62
63
|
sqlite3_close_v2(ctx->db);
|
63
64
|
ctx->db = NULL;
|
@@ -153,7 +154,9 @@ rb_sqlite3_open_v2(VALUE self, VALUE file, VALUE mode, VALUE zvfs)
|
|
153
154
|
);
|
154
155
|
|
155
156
|
CHECK(ctx->db, status);
|
156
|
-
|
157
|
+
if (flags & SQLITE_OPEN_READONLY) {
|
158
|
+
ctx->flags |= SQLITE3_RB_DATABASE_READONLY;
|
159
|
+
}
|
157
160
|
|
158
161
|
return self;
|
159
162
|
}
|
@@ -943,11 +946,10 @@ rb_sqlite3_open16(VALUE self, VALUE file)
|
|
943
946
|
#endif
|
944
947
|
#endif
|
945
948
|
|
946
|
-
|
947
|
-
|
948
|
-
// these are the perm flags used implicitly by sqlite3_open16,
|
949
|
+
// sqlite3_open16 implicitly uses flags (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)
|
949
950
|
// see https://www.sqlite.org/capi3ref.html#sqlite3_open
|
950
|
-
|
951
|
+
// so we do not ever set SQLITE3_RB_DATABASE_READONLY in ctx->flags
|
952
|
+
status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db);
|
951
953
|
|
952
954
|
CHECK(ctx->db, status)
|
953
955
|
|
data/ext/sqlite3/database.h
CHANGED
data/ext/sqlite3/statement.c
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
#include <sqlite3_ruby.h>
|
2
2
|
|
3
3
|
#define REQUIRE_OPEN_STMT(_ctxt) \
|
4
|
-
if(!_ctxt->st) \
|
4
|
+
if (!_ctxt->st) \
|
5
5
|
rb_raise(rb_path2class("SQLite3::Exception"), "cannot use a closed statement");
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
VALUE closed_p = rb_funcall(
|
11
|
-
rb_iv_get(stmt_rb, "@connection"),
|
12
|
-
rb_intern("closed?"), 0);
|
13
|
-
|
14
|
-
if (RTEST(closed_p)) {
|
15
|
-
rb_raise(rb_path2class("SQLite3::Exception"),
|
16
|
-
"cannot use a statement associated with a closed database");
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
7
|
+
#define REQUIRE_LIVE_DB(_ctxt) \
|
8
|
+
if (_ctxt->db->flags & SQLITE3_RB_DATABASE_DISCARDED) \
|
9
|
+
rb_raise(rb_path2class("SQLite3::Exception"), "cannot use a statement associated with a discarded database");
|
20
10
|
|
21
11
|
VALUE cSqlite3Statement;
|
22
12
|
|
@@ -71,6 +61,11 @@ prepare(VALUE self, VALUE db, VALUE sql)
|
|
71
61
|
|
72
62
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
73
63
|
|
64
|
+
/* Dereferencing a pointer to the database struct will be faster than accessing it through the
|
65
|
+
* instance variable @connection. The struct pointer is guaranteed to be live because instance
|
66
|
+
* variable will keep it from being GCed. */
|
67
|
+
ctx->db = db_ctx;
|
68
|
+
|
74
69
|
#ifdef HAVE_SQLITE3_PREPARE_V2
|
75
70
|
status = sqlite3_prepare_v2(
|
76
71
|
#else
|
@@ -135,7 +130,7 @@ step(VALUE self)
|
|
135
130
|
|
136
131
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
137
132
|
|
138
|
-
|
133
|
+
REQUIRE_LIVE_DB(ctx);
|
139
134
|
REQUIRE_OPEN_STMT(ctx);
|
140
135
|
|
141
136
|
if (ctx->done_p) { return Qnil; }
|
@@ -232,7 +227,7 @@ bind_param(VALUE self, VALUE key, VALUE value)
|
|
232
227
|
|
233
228
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
234
229
|
|
235
|
-
|
230
|
+
REQUIRE_LIVE_DB(ctx);
|
236
231
|
REQUIRE_OPEN_STMT(ctx);
|
237
232
|
|
238
233
|
switch (TYPE(key)) {
|
@@ -326,7 +321,7 @@ reset_bang(VALUE self)
|
|
326
321
|
|
327
322
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
328
323
|
|
329
|
-
|
324
|
+
REQUIRE_LIVE_DB(ctx);
|
330
325
|
REQUIRE_OPEN_STMT(ctx);
|
331
326
|
|
332
327
|
sqlite3_reset(ctx->st);
|
@@ -348,7 +343,7 @@ clear_bindings_bang(VALUE self)
|
|
348
343
|
|
349
344
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
350
345
|
|
351
|
-
|
346
|
+
REQUIRE_LIVE_DB(ctx);
|
352
347
|
REQUIRE_OPEN_STMT(ctx);
|
353
348
|
|
354
349
|
sqlite3_clear_bindings(ctx->st);
|
@@ -382,7 +377,7 @@ column_count(VALUE self)
|
|
382
377
|
sqlite3StmtRubyPtr ctx;
|
383
378
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
384
379
|
|
385
|
-
|
380
|
+
REQUIRE_LIVE_DB(ctx);
|
386
381
|
REQUIRE_OPEN_STMT(ctx);
|
387
382
|
|
388
383
|
return INT2NUM(sqlite3_column_count(ctx->st));
|
@@ -415,7 +410,7 @@ column_name(VALUE self, VALUE index)
|
|
415
410
|
|
416
411
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
417
412
|
|
418
|
-
|
413
|
+
REQUIRE_LIVE_DB(ctx);
|
419
414
|
REQUIRE_OPEN_STMT(ctx);
|
420
415
|
|
421
416
|
name = sqlite3_column_name(ctx->st, (int)NUM2INT(index));
|
@@ -440,7 +435,7 @@ column_decltype(VALUE self, VALUE index)
|
|
440
435
|
|
441
436
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
442
437
|
|
443
|
-
|
438
|
+
REQUIRE_LIVE_DB(ctx);
|
444
439
|
REQUIRE_OPEN_STMT(ctx);
|
445
440
|
|
446
441
|
name = sqlite3_column_decltype(ctx->st, (int)NUM2INT(index));
|
@@ -459,7 +454,7 @@ bind_parameter_count(VALUE self)
|
|
459
454
|
sqlite3StmtRubyPtr ctx;
|
460
455
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
461
456
|
|
462
|
-
|
457
|
+
REQUIRE_LIVE_DB(ctx);
|
463
458
|
REQUIRE_OPEN_STMT(ctx);
|
464
459
|
|
465
460
|
return INT2NUM(sqlite3_bind_parameter_count(ctx->st));
|
@@ -568,7 +563,7 @@ stats_as_hash(VALUE self)
|
|
568
563
|
sqlite3StmtRubyPtr ctx;
|
569
564
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
570
565
|
|
571
|
-
|
566
|
+
REQUIRE_LIVE_DB(ctx);
|
572
567
|
REQUIRE_OPEN_STMT(ctx);
|
573
568
|
|
574
569
|
VALUE arg = rb_hash_new();
|
@@ -587,7 +582,7 @@ stat_for(VALUE self, VALUE key)
|
|
587
582
|
sqlite3StmtRubyPtr ctx;
|
588
583
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
589
584
|
|
590
|
-
|
585
|
+
REQUIRE_LIVE_DB(ctx);
|
591
586
|
REQUIRE_OPEN_STMT(ctx);
|
592
587
|
|
593
588
|
if (SYMBOL_P(key)) {
|
@@ -609,7 +604,7 @@ memused(VALUE self)
|
|
609
604
|
sqlite3StmtRubyPtr ctx;
|
610
605
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
611
606
|
|
612
|
-
|
607
|
+
REQUIRE_LIVE_DB(ctx);
|
613
608
|
REQUIRE_OPEN_STMT(ctx);
|
614
609
|
|
615
610
|
return INT2NUM(sqlite3_stmt_status(ctx->st, SQLITE_STMTSTATUS_MEMUSED, 0));
|
@@ -628,7 +623,7 @@ database_name(VALUE self, VALUE index)
|
|
628
623
|
sqlite3StmtRubyPtr ctx;
|
629
624
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
630
625
|
|
631
|
-
|
626
|
+
REQUIRE_LIVE_DB(ctx);
|
632
627
|
REQUIRE_OPEN_STMT(ctx);
|
633
628
|
|
634
629
|
return SQLITE3_UTF8_STR_NEW2(
|
@@ -647,7 +642,7 @@ get_sql(VALUE self)
|
|
647
642
|
sqlite3StmtRubyPtr ctx;
|
648
643
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
649
644
|
|
650
|
-
|
645
|
+
REQUIRE_LIVE_DB(ctx);
|
651
646
|
REQUIRE_OPEN_STMT(ctx);
|
652
647
|
|
653
648
|
return rb_obj_freeze(SQLITE3_UTF8_STR_NEW2(sqlite3_sql(ctx->st)));
|
@@ -667,7 +662,7 @@ get_expanded_sql(VALUE self)
|
|
667
662
|
|
668
663
|
TypedData_Get_Struct(self, sqlite3StmtRuby, &statement_type, ctx);
|
669
664
|
|
670
|
-
|
665
|
+
REQUIRE_LIVE_DB(ctx);
|
671
666
|
REQUIRE_OPEN_STMT(ctx);
|
672
667
|
|
673
668
|
expanded_sql = sqlite3_expanded_sql(ctx->st);
|
data/ext/sqlite3/statement.h
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/lib/sqlite3/fork_safety.rb
CHANGED
@@ -17,6 +17,7 @@ module SQLite3
|
|
17
17
|
|
18
18
|
@databases = []
|
19
19
|
@mutex = Mutex.new
|
20
|
+
@suppress = false
|
20
21
|
|
21
22
|
class << self
|
22
23
|
def hook!
|
@@ -30,7 +31,7 @@ module SQLite3
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def discard
|
33
|
-
warned =
|
34
|
+
warned = @suppress
|
34
35
|
@databases.each do |db|
|
35
36
|
next unless db.weakref_alive?
|
36
37
|
|
@@ -49,6 +50,11 @@ module SQLite3
|
|
49
50
|
end
|
50
51
|
@databases.clear
|
51
52
|
end
|
53
|
+
|
54
|
+
# Call to suppress the fork-related warnings.
|
55
|
+
def suppress_warnings!
|
56
|
+
@suppress = true
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
data/lib/sqlite3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.rc3
|
5
5
|
platform: aarch64-linux-musl
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2024-09-
|
14
|
+
date: 2024-09-24 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: |
|
17
17
|
Ruby library to interface with the SQLite3 database engine (http://www.sqlite.org). Precompiled
|