extralite 2.8 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/examples/pubsub_store_polyphony.rb +5 -5
- data/ext/extralite/database.c +6 -0
- data/lib/extralite/version.rb +1 -1
- data/test/test_database.rb +45 -3
- 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: 49fbb44a887747091953d2ec2239050036dd1c5c37290d9f651521b47a84fdfb
|
4
|
+
data.tar.gz: 5200205e84f47abad1a9e3c936999edd77defa53e187941d81d50a91926cd520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd77a5ebe191923ba6159eb79b6c60ac5c8311280a5a8513262e6ff6accf2020422a9394df25308718971b98ff25ab50409f50bf81c931cb41274f7401334e4
|
7
|
+
data.tar.gz: 0dde4d327858617ae1b3ad88432a705593303a312e93177a91c2fc25029cf505eaf952ce98a2cbbd4cced57d733a5a2c045cbf9d7909899c42972ca2c59e1cbd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,7 @@ databases.
|
|
32
32
|
Extralite comes in two flavors: the `extralite` gem which uses the
|
33
33
|
system-installed sqlite3 library, and the `extralite-bundle` gem which bundles
|
34
34
|
the latest version of SQLite
|
35
|
-
([3.45.
|
35
|
+
([3.45.3](https://sqlite.org/releaselog/3_45_3.html)), offering access to the
|
36
36
|
latest features and enhancements.
|
37
37
|
|
38
38
|
## Features
|
@@ -103,9 +103,9 @@ db2.pragma(journal_mode: :wal, synchronous: 1)
|
|
103
103
|
db3 = Extralite::Database.new(fn)
|
104
104
|
db3.pragma(journal_mode: :wal, synchronous: 1)
|
105
105
|
|
106
|
-
db1.on_progress
|
107
|
-
db2.on_progress
|
108
|
-
db3.on_progress
|
106
|
+
db1.on_progress { |b| b ? sleep(0.0001) : snooze }
|
107
|
+
db2.on_progress { |b| b ? sleep(0.0001) : snooze }
|
108
|
+
db3.on_progress { |b| b ? sleep(0.0001) : snooze }
|
109
109
|
|
110
110
|
producer = PubSub.new(db1)
|
111
111
|
producer.setup
|
@@ -163,7 +163,7 @@ end
|
|
163
163
|
|
164
164
|
db4 = Extralite::Database.new(fn)
|
165
165
|
db4.pragma(journal_mode: :wal, synchronous: 1)
|
166
|
-
db4.on_progress
|
166
|
+
db4.on_progress { |busy| busy ? sleep(0.05) : snooze }
|
167
167
|
|
168
168
|
last_t = Time.now
|
169
169
|
last_publish_count = 0
|
@@ -175,7 +175,7 @@ while true
|
|
175
175
|
d_publish = publish_count - last_publish_count
|
176
176
|
d_receive = receive_count - last_receive_count
|
177
177
|
pending = db4.query_single_splat('select count(*) from messages')
|
178
|
-
puts "#{Time.now} publish: #{d_publish/elapsed}/s receive: #{d_receive/elapsed}/s pending: #{pending}"
|
178
|
+
puts "#{Time.now} publish: #{(d_publish/elapsed).round}/s receive: #{(d_receive/elapsed).round}/s pending: #{pending} latency: #{pending / (d_receive/elapsed)}"
|
179
179
|
last_t = now
|
180
180
|
last_publish_count = publish_count
|
181
181
|
last_receive_count = receive_count
|
data/ext/extralite/database.c
CHANGED
@@ -294,6 +294,8 @@ static inline VALUE Database_perform_query(int argc, VALUE *argv, VALUE self, VA
|
|
294
294
|
prepare_multi_stmt(DB_GVL_MODE(db), db->sqlite3_db, &stmt, sql);
|
295
295
|
RB_GC_GUARD(sql);
|
296
296
|
|
297
|
+
if (stmt == NULL) return Qnil;
|
298
|
+
|
297
299
|
bind_all_parameters(stmt, argc - 1, argv + 1);
|
298
300
|
query_ctx ctx = QUERY_CTX(
|
299
301
|
self, sql, db, stmt, Qnil, transform,
|
@@ -485,6 +487,10 @@ VALUE Database_query_single_array(int argc, VALUE *argv, VALUE self) {
|
|
485
487
|
* specified using keyword arguments:
|
486
488
|
*
|
487
489
|
* db.execute('update foo set x = :bar', bar: 42)
|
490
|
+
*
|
491
|
+
* @param sql [String] query SQL
|
492
|
+
* @param parameters [Array, Hash] parameters to run query with
|
493
|
+
* @return [Integer, nil] Total number of changes effected or `nil` if the query ends with a comment.
|
488
494
|
*/
|
489
495
|
VALUE Database_execute(int argc, VALUE *argv, VALUE self) {
|
490
496
|
return Database_perform_query(argc, argv, self, safe_query_changes, QUERY_HASH);
|
data/lib/extralite/version.rb
CHANGED
data/test/test_database.rb
CHANGED
@@ -948,7 +948,7 @@ class DatabaseTest < Minitest::Test
|
|
948
948
|
|
949
949
|
db.execute('insert into foo values (43)')
|
950
950
|
assert_equal [42, 43], db.query_splat('select x from foo')
|
951
|
-
|
951
|
+
|
952
952
|
db.savepoint(:b)
|
953
953
|
|
954
954
|
db.execute('insert into foo values (44)')
|
@@ -1046,6 +1046,48 @@ class DatabaseTest < Minitest::Test
|
|
1046
1046
|
assert File.size(wal_fn) == 0
|
1047
1047
|
assert_equal [0, 0], r
|
1048
1048
|
end
|
1049
|
+
|
1050
|
+
def test_execute_with_comments
|
1051
|
+
result = @db.execute(<<~SQL)
|
1052
|
+
-- this is a comment
|
1053
|
+
SQL
|
1054
|
+
assert_nil result
|
1055
|
+
|
1056
|
+
result = @db.execute(<<~SQL)
|
1057
|
+
DELETE FROM t;
|
1058
|
+
INSERT INTO t (x, y, z) VALUES (1, 1, 1);
|
1059
|
+
INSERT INTO t (x, y, z) VALUES (2, 2, 2);
|
1060
|
+
SQL
|
1061
|
+
assert_equal 1, result
|
1062
|
+
assert_equal [1, 2], @db.query_splat('SELECT x FROM t ORDER BY x')
|
1063
|
+
|
1064
|
+
result = @db.execute(<<~SQL)
|
1065
|
+
-- this is a comment at the beginning
|
1066
|
+
DELETE FROM t;
|
1067
|
+
INSERT INTO t (x, y, z) VALUES (3, 3, 3);
|
1068
|
+
INSERT INTO t (x, y, z) VALUES (4, 4, 4);
|
1069
|
+
SQL
|
1070
|
+
assert_equal 1, result
|
1071
|
+
assert_equal [3, 4], @db.query_splat('SELECT x FROM t ORDER BY x')
|
1072
|
+
|
1073
|
+
result = @db.execute(<<~SQL)
|
1074
|
+
DELETE FROM t;
|
1075
|
+
INSERT INTO t (x, y, z) VALUES (5, 5, 5);
|
1076
|
+
-- this is a comment in the middle
|
1077
|
+
INSERT INTO t (x, y, z) VALUES (6, 6, 6);
|
1078
|
+
SQL
|
1079
|
+
assert_equal 1, result
|
1080
|
+
assert_equal [5, 6], @db.query_splat('SELECT x FROM t ORDER BY x')
|
1081
|
+
|
1082
|
+
result = @db.execute(<<~SQL)
|
1083
|
+
DELETE FROM t;
|
1084
|
+
INSERT INTO t (x, y, z) VALUES (7, 7, 7);
|
1085
|
+
INSERT INTO t (x, y, z) VALUES (8, 8, 8);
|
1086
|
+
-- this is a comment at the end
|
1087
|
+
SQL
|
1088
|
+
assert_nil result
|
1089
|
+
assert_equal [7, 8], @db.query_splat('SELECT x FROM t ORDER BY x')
|
1090
|
+
end
|
1049
1091
|
end
|
1050
1092
|
|
1051
1093
|
class ScenarioTest < Minitest::Test
|
@@ -1438,7 +1480,7 @@ class ConcurrencyTest < Minitest::Test
|
|
1438
1480
|
|
1439
1481
|
def test_progress_handler_invalid_arg
|
1440
1482
|
db = Extralite::Database.new(':memory:')
|
1441
|
-
|
1483
|
+
|
1442
1484
|
assert_raises(TypeError) { db.on_progress(period: :foo) }
|
1443
1485
|
assert_raises(TypeError) { db.on_progress(tick: :foo) }
|
1444
1486
|
assert_raises(ArgumentError) { db.on_progress(mode: :foo) }
|
@@ -1635,7 +1677,7 @@ end
|
|
1635
1677
|
class RactorTest < Minitest::Test
|
1636
1678
|
def test_ractor_simple
|
1637
1679
|
skip if SKIP_RACTOR_TESTS
|
1638
|
-
|
1680
|
+
|
1639
1681
|
fn = Tempfile.new('extralite_test_database_in_ractor').path
|
1640
1682
|
|
1641
1683
|
r = Ractor.new do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extralite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|