sqlite3 1.7.3-x64-mingw-ucrt → 2.0.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +160 -0
  3. data/CONTRIBUTING.md +23 -1
  4. data/FAQ.md +0 -43
  5. data/INSTALLATION.md +13 -5
  6. data/LICENSE +18 -22
  7. data/README.md +75 -4
  8. data/dependencies.yml +10 -11
  9. data/ext/sqlite3/aggregator.c +142 -145
  10. data/ext/sqlite3/aggregator.h +2 -4
  11. data/ext/sqlite3/backup.c +74 -65
  12. data/ext/sqlite3/backup.h +2 -2
  13. data/ext/sqlite3/database.c +535 -482
  14. data/ext/sqlite3/database.h +7 -4
  15. data/ext/sqlite3/exception.c +111 -92
  16. data/ext/sqlite3/exception.h +3 -1
  17. data/ext/sqlite3/extconf.rb +21 -22
  18. data/ext/sqlite3/sqlite3.c +159 -115
  19. data/ext/sqlite3/sqlite3_ruby.h +2 -2
  20. data/ext/sqlite3/statement.c +516 -300
  21. data/ext/sqlite3/statement.h +3 -3
  22. data/ext/sqlite3/timespec.h +20 -0
  23. data/lib/sqlite3/3.1/sqlite3_native.so +0 -0
  24. data/lib/sqlite3/3.2/sqlite3_native.so +0 -0
  25. data/lib/sqlite3/3.3/sqlite3_native.so +0 -0
  26. data/lib/sqlite3/constants.rb +171 -47
  27. data/lib/sqlite3/database.rb +106 -166
  28. data/lib/sqlite3/errors.rb +26 -1
  29. data/lib/sqlite3/pragmas.rb +126 -136
  30. data/lib/sqlite3/resultset.rb +14 -97
  31. data/lib/sqlite3/statement.rb +58 -13
  32. data/lib/sqlite3/value.rb +17 -20
  33. data/lib/sqlite3/version.rb +1 -21
  34. data/lib/sqlite3.rb +6 -4
  35. metadata +3 -28
  36. data/API_CHANGES.md +0 -49
  37. data/ChangeLog.cvs +0 -88
  38. data/Gemfile +0 -10
  39. data/LICENSE-DEPENDENCIES +0 -20
  40. data/lib/sqlite3/translator.rb +0 -117
  41. data/test/helper.rb +0 -27
  42. data/test/test_backup.rb +0 -33
  43. data/test/test_collation.rb +0 -82
  44. data/test/test_database.rb +0 -668
  45. data/test/test_database_flags.rb +0 -95
  46. data/test/test_database_readonly.rb +0 -36
  47. data/test/test_database_readwrite.rb +0 -41
  48. data/test/test_deprecated.rb +0 -49
  49. data/test/test_encoding.rb +0 -165
  50. data/test/test_integration.rb +0 -507
  51. data/test/test_integration_aggregate.rb +0 -336
  52. data/test/test_integration_open_close.rb +0 -30
  53. data/test/test_integration_pending.rb +0 -115
  54. data/test/test_integration_resultset.rb +0 -142
  55. data/test/test_integration_statement.rb +0 -194
  56. data/test/test_pragmas.rb +0 -22
  57. data/test/test_result_set.rb +0 -47
  58. data/test/test_sqlite3.rb +0 -30
  59. data/test/test_statement.rb +0 -290
  60. data/test/test_statement_execute.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db9a3248a9834c121d12a09a93e40ad0be591b6d77a4d548654aa46ab487f9e6
4
- data.tar.gz: 26bed7922d2462936dc0ed5579da479c113feddd5363a836ad92e4b1469c2afe
3
+ metadata.gz: 59d1c85343dae799e9f748808981c5edebf9f70658151a4070121008b8938024
4
+ data.tar.gz: c5b4b35bbae8271507ce922323d03422d2b7beb51bd0322399e553e676595491
5
5
  SHA512:
6
- metadata.gz: 7970000d1164c103bcced824dfeaa20626480eaa08472233835abdd93a6277d44cef0985eded6e22e3cac8dc391aeab2ba1a45ac79001764449441e22cead282
7
- data.tar.gz: 4a62283554d625eb7ca0ce9e5cbc55e3d8ef74db6852ca2288df7e4ea897dbc0b28613f2ca635f2a75f3d92863152f900536b95fbdfb9c6bc51c92812f75425e
6
+ metadata.gz: d74f9b7086a2e71a82936e6998df52c4d42a0388fca93f0ec3b26d410c74e639cc0454bccb904b3a8eb9b6f79150749e398e6ef42d180991aef9c971b368e741
7
+ data.tar.gz: 178c6acf165628a40640a52092b29aad83972287c2cf7d598b573710c40f9ef20bdc6f03be7709c7e91545d5859fbae132618b12a6c6296c93c45f063312b778
data/CHANGELOG.md CHANGED
@@ -1,5 +1,165 @@
1
1
  # sqlite3-ruby Changelog
2
2
 
3
+ ## 2.0.1 / 2024-04-20
4
+
5
+ ### Fixed
6
+
7
+ - Raise `ArgumentError` if `Database#execute`, `#execute_batch`, or `#query` are passed multiple bind parameters that are not in an Array. In v2.0.0 these methods would silently swallow additional arguments, and this change makes the failure explicit. See the CHANGELOG notes for v2.0.0 for examples on how to update your code. [#527] @flavorjones
8
+ - Fixed a regression in v2.0.0 that caused `Database#execute_batch` to raise an encoding exception when passed some non-ascii strings. As a result of this fix, `Database#prepare` now ensures the "remainder" string will always be encoded as UTF-8. [#524] @flavorjones
9
+
10
+
11
+ ## 2.0.0 / 2024-04-17
12
+
13
+ This is a major release which contains some breaking changes, primarily the removal of
14
+ long-deprecated functionality. Before upgrading, please make sure to address deprecation warnings
15
+ emitted from your application using sqlite3-ruby v1.7.x.
16
+
17
+
18
+ ### Ruby
19
+
20
+ - This release drops support for Ruby 2.7. [#453] @flavorjones
21
+
22
+
23
+ ### Packaging
24
+
25
+ Native (precompiled) gems are now available for Linux Musl. [#442] @flavorjones
26
+
27
+ Here are the platforms for which native gems are shipped:
28
+
29
+ - `aarch64-linux-gnu` (requires: glibc >= 2.29)
30
+ - `aarch64-linux-musl`
31
+ - `arm-linux-gnu` (requires: glibc >= 2.29)
32
+ - `arm-linux-musl`
33
+ - `arm64-darwin`
34
+ - `x64-mingw32` / `x64-mingw-ucrt`
35
+ - `x86-linux-gnu` (requires: glibc >= 2.17)
36
+ - `x86-linux-musl`
37
+ - `x86_64-darwin`
38
+ - `x86_64-linux-gnu` (requires: glibc >= 2.17)
39
+ - `x86_64-linux-musl`
40
+
41
+ ⚠ Ruby 3.0 linux users must use Rubygems >= 3.3.22 in order to use these gems.
42
+
43
+ ⚠ Musl linux users should update to Bundler >= 2.5.6 to avoid https://github.com/rubygems/rubygems/issues/7432
44
+
45
+ See [the INSTALLATION doc](https://github.com/sparklemotion/sqlite3-ruby/blob/main/INSTALLATION.md) for more information.
46
+
47
+
48
+ ### Dependencies
49
+
50
+ - Vendored sqlite is updated to [v3.45.3](https://sqlite.org/releaselog/3_45_3.html). @flavorjones
51
+
52
+
53
+ ### Added
54
+
55
+ - `Database#busy_handler_timeout=` introduced as an alternative to `#busy_timeout=` that can be used when it's desired to release the GVL between retries. [#443, #456] @fractaledmind
56
+ - Support the `SUPER_JOURNAL` flag which is an alias for `MASTER_JOURNAL` as of sqlite 3.33.0. [#467] @flavorjones
57
+ - `Statement#stat` and `Statement#memused` introduced to report statistics. [#461] @fractaledmind
58
+ - `Statement#sql` and `Statement#expanded_sql` introduced to retrieve the SQL statement associated with the `Statement` object. [#293, #498] @tenderlove
59
+ - `SQLite3.status` introduced to return run-time status and reset high-water marks. See `SQLite3::Constants::Status` for details. [#520] @wjlroe
60
+
61
+
62
+ ### Improved
63
+
64
+ - Avoid leaking memory for statements that are not closed properly. [#392] @haileys
65
+ - Moved some C code into Ruby. [#451, #455] @tenderlove
66
+ - Improve performance of `ResultSet` hashes. [#154, #484, #468] @tenderlove
67
+ - Fix a GC compaction issue with `busy_handler`. [#466] @byroot
68
+ - Remove unused `ResultSet` instance variable. [#469] @tenderlove
69
+ - Fix encoding for values passed to custom functions. [#218, #488] @tenderlove
70
+
71
+
72
+ ### Changed
73
+
74
+ - Consistently use `SQLite3::Exception` or subclasses. Previously some `Pragmas` methods raised `Exception`, and `Database#execute_batch2` and `Database#load_extension` raised `RuntimeError`. [#467, #490] @flavorjones
75
+ - `Database#columns` returns a list of internal frozen strings. [#155, #474, #486] @tenderlove
76
+ - Freeze results that come from the database. [#480] @tenderlove
77
+ - The encoding of a Database is no longer cached. [#485] @tenderlove
78
+ - `Database#transaction` returns the result of the block when used with a block. [#508] @alexcwatt
79
+ - `Database#execute_batch` returns the result of the last statement executed. [#512] @alexcwatt
80
+
81
+
82
+ ### Removed
83
+
84
+ - Removed class `SQLite3::Translator` and all related type translation methods which have been deprecated since v1.3.2. [#470] @tenderlove
85
+
86
+ If you need to do type translation on values returned from the statement object, please wrap it
87
+ with a delegate object. Here is an example of using a delegate class to implement type
88
+ translation:
89
+
90
+ ```ruby
91
+ require "sqlite3"
92
+ require "delegate"
93
+
94
+ db = SQLite3::Database.new(":memory:")
95
+
96
+ return_value = db.execute_batch2 <<-EOSQL
97
+ CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT, name string);
98
+ INSERT INTO items (name) VALUES ("foo");
99
+ INSERT INTO items (name) VALUES ("bar");
100
+ EOSQL
101
+
102
+ class MyTranslator < DelegateClass(SQLite3::Statement)
103
+ def step
104
+ row = super
105
+ return if done?
106
+
107
+ row.map.with_index do |item, i|
108
+ case types[i]
109
+ when "integer" # turn all integers to floats
110
+ item.to_f
111
+ when "string" # add "hello" to all strings
112
+ item + "hello"
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ db.prepare("SELECT * FROM items") do |stmt|
119
+ stmt = MyTranslator.new(stmt)
120
+ while row = stmt.step
121
+ p row
122
+ end
123
+ end
124
+ ```
125
+
126
+ - Removed `types` and `fields` readers on row objects, which have been deprecated since
127
+ v1.3.6. [#471] @tenderlove
128
+
129
+ Deprecated code looks like this:
130
+
131
+ ```ruby
132
+ row = @db.execute("select * from foo")
133
+ assert_equal ["blob"], row.first.types
134
+ ```
135
+
136
+ If you would like to access the "types" associated with a returned query,
137
+ use a prepared statement like this:
138
+
139
+ ```ruby
140
+ @db.prepare("select * from foo") do |v|
141
+ assert_equal ["blob"], v.types
142
+ end
143
+ ```
144
+
145
+ - Removed support for non-Array bind parameters to methods `Database#execute`, `#execute_batch`, and `#query`, which has been deprecated since v1.3.0. [#511] @flavorjones
146
+
147
+ Deprecated code looks like this:
148
+
149
+ ``` ruby
150
+ @db.query("select * from foo where a = ? and b = ? and c = ?", 1, 2, 3)
151
+ ```
152
+
153
+ For these cases, pass the bind parameters as an array:
154
+
155
+ ``` ruby
156
+ @db.query("select * from foo where a = ? and b = ? and c = ?", [1, 2, 3])
157
+ ```
158
+
159
+ - Removed class `SQLite3::VersionProxy` which has been deprecated since v1.3.2. [#453] @flavorjones
160
+ - Removed methods `SQLite3::Database::FunctionProxy#count` and `#set_error` which have been broken since at least v1.3.13. [#164, #509, #510] @alexcwatt @flavorjones
161
+
162
+
3
163
  ## 1.7.3 / 2024-03-15
4
164
 
5
165
  ### Dependencies
data/CONTRIBUTING.md CHANGED
@@ -5,6 +5,28 @@
5
5
  This doc is a short introduction on how to modify and maintain the sqlite3-ruby gem.
6
6
 
7
7
 
8
+ ## Architecture notes
9
+
10
+ ### Garbage collection
11
+
12
+ All statements keep pointers back to their respective database connections.
13
+ The `@connection` instance variable on the `Statement` handle keeps the database
14
+ connection alive. Memory allocated for a statement handler will be freed in
15
+ two cases:
16
+
17
+ 1. `#close` is called on the statement
18
+ 2. The `SQLite3::Database` object gets garbage collected
19
+
20
+ We can't free the memory for the statement in the garbage collection function
21
+ for the statement handler. The reason is because there exists a race
22
+ condition. We cannot guarantee the order in which objects will be garbage
23
+ collected. So, it is possible that a connection and a statement are up for
24
+ garbage collection. If the database connection were to be free'd before the
25
+ statement, then boom. Instead we'll be conservative and free unclosed
26
+ statements when the connection is terminated.
27
+
28
+
29
+
8
30
  ## Building gems
9
31
 
10
32
  As a prerequisite please make sure you have `docker` correctly installed, so that you're able to cross-compile the native gems.
@@ -26,7 +48,7 @@ Update `/dependencies.yml` to reflect:
26
48
  A quick checklist:
27
49
 
28
50
  - [ ] make sure CI is green!
29
- - [ ] update `CHANGELOG.md` and `lib/sqlite3/version.rb` including `VersionProxy::{MINOR,TINY}`
51
+ - [ ] update `CHANGELOG.md` and `lib/sqlite3/version.rb`
30
52
  - [ ] run `bin/build-gems` and make sure it completes and all the tests pass
31
53
  - [ ] create a git tag using a format that matches the pattern `v\d+\.\d+\.\d+`, e.g. `v1.3.13`
32
54
  - [ ] `git push && git push --tags`
data/FAQ.md CHANGED
@@ -289,49 +289,6 @@ by column name, even though they are still arrays!
289
289
  end
290
290
  ```
291
291
 
292
- ## I'd like the values from a query to be the correct types, instead of String.
293
-
294
- You can turn on "type translation" by setting `Database#type_translation` to
295
- true:
296
-
297
-
298
- ```ruby
299
- db.type_translation = true
300
- db.execute( "select * from table" ) do |row|
301
- p row
302
- end
303
- ```
304
-
305
-
306
- By doing this, each return value for each row will be translated to its
307
- correct type, based on its declared column type.
308
-
309
-
310
- You can even declare your own translation routines, if (for example) you are
311
- using an SQL type that is not handled by default:
312
-
313
-
314
- ```ruby
315
- # assume "objects" table has the following schema:
316
- # create table objects (
317
- # name varchar2(20),
318
- # thing object
319
- # )
320
-
321
- db.type_translation = true
322
- db.translator.add_translator( "object" ) do |type, value|
323
- db.decode( value )
324
- end
325
-
326
- h = { :one=>:two, "three"=>"four", 5=>6 }
327
- dump = db.encode( h )
328
-
329
- db.execute( "insert into objects values ( ?, ? )", "bob", dump )
330
-
331
- obj = db.get_first_value( "select thing from objects where name='bob'" )
332
- p obj == h
333
- ```
334
-
335
292
  ## How do I insert binary data into the database?
336
293
 
337
294
  Use blobs. Blobs are new features of SQLite3. You have to use bind
data/INSTALLATION.md CHANGED
@@ -7,15 +7,23 @@ This document will help you install the `sqlite3` ruby gem. It also contains ins
7
7
 
8
8
  ### Native Gems (recommended)
9
9
 
10
- In v1.5.0 and later, native (precompiled) gems are available for recent Ruby versions on these platforms:
10
+ In v2.0.0 and later, native (precompiled) gems are available for recent Ruby versions on these platforms:
11
11
 
12
- - `aarch64-linux` (requires: glibc >= 2.29)
13
- - `arm-linux` (requires: glibc >= 2.29)
12
+ - `aarch64-linux-gnu` (requires: glibc >= 2.29)
13
+ - `aarch64-linux-musl`
14
+ - `arm-linux-gnu` (requires: glibc >= 2.29)
15
+ - `arm-linux-musl`
14
16
  - `arm64-darwin`
15
17
  - `x64-mingw32` / `x64-mingw-ucrt`
16
- - `x86-linux` (requires: glibc >= 2.17)
18
+ - `x86-linux-gnu` (requires: glibc >= 2.17)
19
+ - `x86-linux-musl`
17
20
  - `x86_64-darwin`
18
- - `x86_64-linux` (requires: glibc >= 2.17)
21
+ - `x86_64-linux-gnu` (requires: glibc >= 2.17)
22
+ - `x86_64-linux-musl`
23
+
24
+ ⚠ Ruby 3.0 linux users must use Rubygems >= 3.3.22 in order to use these gems.
25
+
26
+ ⚠ Musl linux users should update to Bundler >= 2.5.6 to avoid https://github.com/rubygems/rubygems/issues/7432
19
27
 
20
28
  If you are using one of these Ruby versions on one of these platforms, the native gem is the recommended way to install sqlite3-ruby.
21
29
 
data/LICENSE CHANGED
@@ -1,27 +1,23 @@
1
- Copyright (c) 2004, Jamis Buck (jamis@jamisbuck.org)
2
- All rights reserved.
1
+ Copyright (c) 2004-2024, Jamis Buck, Luis Lavena, Aaron Patterson, Mike Dalessio, et al.
3
2
 
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted
4
+ provided that the following conditions are met:
6
5
 
7
- * Redistributions of source code must retain the above copyright notice,
8
- this list of conditions and the following disclaimer.
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions
7
+ and the following disclaimer.
9
8
 
10
- * Redistributions in binary form must reproduce the above copyright
11
- notice, this list of conditions and the following disclaimer in the
12
- documentation and/or other materials provided with the distribution.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of
10
+ conditions and the following disclaimer in the documentation and/or other materials provided with
11
+ the distribution.
13
12
 
14
- * The names of its contributors may not be used to endorse or promote
15
- products derived from this software without specific prior written
16
- permission.
13
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to
14
+ endorse or promote products derived from this software without specific prior written permission.
17
15
 
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
23
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -11,8 +11,7 @@ Note that this module is only compatible with SQLite 3.6.16 or newer.
11
11
  * Download: http://rubygems.org/gems/sqlite3
12
12
  * Documentation: http://www.rubydoc.info/gems/sqlite3
13
13
 
14
- [![Unit tests](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/sqlite3-ruby.yml/badge.svg)](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/sqlite3-ruby.yml)
15
- [![Native packages](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/gem-install.yml/badge.svg)](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/gem-install.yml)
14
+ [![Test suite](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/ci.yml)
16
15
 
17
16
 
18
17
  ## Quick start
@@ -77,6 +76,78 @@ end
77
76
  # => ["Jane", "me@janedoe.com", "A", "http://blog.janedoe.com"]
78
77
  ```
79
78
 
79
+ ## Thread Safety
80
+
81
+ When `SQLite3.threadsafe?` returns `true`, then SQLite3 has been compiled to
82
+ support running in a multithreaded environment. However, this doesn't mean
83
+ that all classes in the SQLite3 gem can be considered "thread safe".
84
+
85
+ When `SQLite3.threadsafe?` returns `true`, it is safe to share only
86
+ `SQLite3::Database` instances among threads without providing your own locking
87
+ mechanism. For example, the following code is fine because only the database
88
+ instance is shared among threads:
89
+
90
+ ```ruby
91
+ require 'sqlite3'
92
+
93
+ db = SQLite3::Database.new ":memory:"
94
+
95
+ latch = Queue.new
96
+
97
+ ts = 10.times.map {
98
+ Thread.new {
99
+ latch.pop
100
+ db.execute "SELECT '#{Thread.current.inspect}'"
101
+ }
102
+ }
103
+ 10.times { latch << nil }
104
+
105
+ p ts.map(&:value)
106
+ ```
107
+
108
+ Other instances can be shared among threads, but they require that you provide
109
+ your own locking for thread safety. For example, `SQLite3::Statement` objects
110
+ (prepared statements) are mutable, so applications must take care to add
111
+ appropriate locks to avoid data race conditions when sharing these objects
112
+ among threads.
113
+
114
+ Lets rewrite the above example but use a prepared statement and safely share
115
+ the prepared statement among threads:
116
+
117
+ ```ruby
118
+ db = SQLite3::Database.new ":memory:"
119
+
120
+ # Prepare a statement
121
+ stmt = db.prepare "SELECT :inspect"
122
+ stmt_lock = Mutex.new
123
+
124
+ latch = Queue.new
125
+
126
+ ts = 10.times.map {
127
+ Thread.new {
128
+ latch.pop
129
+
130
+ # Add a lock when using the prepared statement.
131
+ # Binding values, and walking over results will mutate the statement, so
132
+ # in order to prevent other threads from "seeing" this thread's data, we
133
+ # must lock when using the statement object
134
+ stmt_lock.synchronize do
135
+ stmt.execute(Thread.current.inspect).to_a
136
+ end
137
+ }
138
+ }
139
+
140
+ 10.times { latch << nil }
141
+
142
+ p ts.map(&:value)
143
+
144
+ stmt.close
145
+ ```
146
+
147
+ It is generally recommended that if applications want to share a database among
148
+ threads, they _only_ share the database instance object. Other objects are
149
+ fine to share, but may require manual locking for thread safety.
150
+
80
151
  ## Support
81
152
 
82
153
  ### Installation or database extensions
@@ -104,7 +175,7 @@ See [`CONTRIBUTING.md`](./CONTRIBUTING.md).
104
175
 
105
176
  This library is licensed under `BSD-3-Clause`, see [`LICENSE`](./LICENSE).
106
177
 
107
-
108
178
  ### Dependencies
109
179
 
110
- The source code of `sqlite` is distributed in the "ruby platform" gem. This code is public domain, see [`LICENSE-DEPENDENCIES`](./LICENSE-DEPENDENCIES) for details.
180
+ The source code of `sqlite` is distributed in the "ruby platform" gem. This code is public domain,
181
+ see https://www.sqlite.org/copyright.html for details.
data/dependencies.yml CHANGED
@@ -1,14 +1,13 @@
1
- # TODO: stop using symbols here once we no longer support Ruby 2.7 and can rely on symbolize_names
2
- :sqlite3:
1
+ sqlite3:
3
2
  # checksum verified by first checking the published sha3(256) checksum against https://sqlite.org/download.html:
4
- # 1b02c58a711d15b50da8a1089e0f8807ebbdf3e674c714100eda9a03a69ac758
3
+ # cc1050780e0266de4d91b31c8deaf4638336908c12c21898e9f1fcae1e2ac303
5
4
  #
6
- # $ sha3sum -a 256 ports/archives/sqlite-autoconf-3450200.tar.gz
7
- # 1b02c58a711d15b50da8a1089e0f8807ebbdf3e674c714100eda9a03a69ac758 ports/archives/sqlite-autoconf-3450200.tar.gz
5
+ # $ sha3sum -a 256 ports/archives/sqlite-autoconf-3450300.tar.gz
6
+ # cc1050780e0266de4d91b31c8deaf4638336908c12c21898e9f1fcae1e2ac303 ports/archives/sqlite-autoconf-3450300.tar.gz
8
7
  #
9
- # $ sha256sum ports/archives/sqlite-autoconf-3450200.tar.gz
10
- # bc9067442eedf3dd39989b5c5cfbfff37ae66cc9c99274e0c3052dc4d4a8f6ae ports/archives/sqlite-autoconf-3450200.tar.gz
11
- :version: "3.45.2"
12
- :files:
13
- - :url: "https://sqlite.org/2024/sqlite-autoconf-3450200.tar.gz"
14
- :sha256: "bc9067442eedf3dd39989b5c5cfbfff37ae66cc9c99274e0c3052dc4d4a8f6ae"
8
+ # $ sha256sum ports/archives/sqlite-autoconf-3450300.tar.gz
9
+ # b2809ca53124c19c60f42bf627736eae011afdcc205bb48270a5ee9a38191531 ports/archives/sqlite-autoconf-3450300.tar.gz
10
+ version: "3.45.3"
11
+ files:
12
+ - url: "https://sqlite.org/2024/sqlite-autoconf-3450300.tar.gz"
13
+ sha256: "b2809ca53124c19c60f42bf627736eae011afdcc205bb48270a5ee9a38191531"