sqlite3-ffi 0.1.5 → 0.1.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/lib/sqlite3/database.rb +5 -1
- data/lib/sqlite3/ffi/c_api.rb +12 -2
- data/lib/sqlite3/ffi/database.rb +30 -7
- data/lib/sqlite3/ffi/statement.rb +7 -3
- data/lib/sqlite3/ffi/version.rb +1 -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: '0099c7235d3e7b13c26861041a474d279952101488139c9b11c40053658bb095'
|
|
4
|
+
data.tar.gz: e809f4772c73162b7417c79ae56674606c689e2a1fddb3181ac637d958066f04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 916507cb952494f227d6182cf92d9e910cf3534f01995706efff64523eb86750fe7601238b9e4d6c32813cff3a097a073b541bad0632dc74f87e2b35e589ccca
|
|
7
|
+
data.tar.gz: 78586b3eb030fdcb58e4afbcace803efcf78c3e02d3939d73524186148f55cc6b7699c5f15b42df774f6007681ac22bbf82a434887874b1092b3a72ec66efadf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 0.1.7 (2026-06-07)
|
|
2
|
+
|
|
3
|
+
- Synced with sqlite3-ruby 2.9.5
|
|
4
|
+
- Fixed [GHSA-28hh-pr2h-2w89](https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-28hh-pr2h-2w89) and [GHSA-j7fr-3v8c-3qc3](https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-j7fr-3v8c-3qc3)
|
|
5
|
+
|
|
6
|
+
## 0.1.6 (2026-02-19)
|
|
7
|
+
|
|
8
|
+
- Fixed memory leaks
|
|
9
|
+
|
|
1
10
|
## 0.1.5 (2026-01-02)
|
|
2
11
|
|
|
3
12
|
- Synced with sqlite3-ruby 2.9.0
|
data/LICENSE.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Copyright (c) 2004-2024, Jamis Buck, Luis Lavena, Aaron Patterson, Mike Dalessio, et al.
|
|
2
|
-
Copyright (c) 2025, Andrew Kane.
|
|
2
|
+
Copyright (c) 2025-2026, Andrew Kane.
|
|
3
3
|
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
5
5
|
provided that the following conditions are met:
|
data/lib/sqlite3/database.rb
CHANGED
|
@@ -175,7 +175,7 @@ module SQLite3
|
|
|
175
175
|
@authorizer = nil
|
|
176
176
|
@progress_handler = nil
|
|
177
177
|
@collations = {}
|
|
178
|
-
@functions =
|
|
178
|
+
@functions = []
|
|
179
179
|
@results_as_hash = options[:results_as_hash]
|
|
180
180
|
@readonly = mode & Constants::Open::READONLY != 0
|
|
181
181
|
@default_transaction_mode = options[:default_transaction_mode] || :deferred
|
|
@@ -398,6 +398,8 @@ module SQLite3
|
|
|
398
398
|
# the FunctionProxy#result= method on the +func+ parameter and
|
|
399
399
|
# indicate the return value that way.
|
|
400
400
|
#
|
|
401
|
+
# A reference to the block will be kept for the lifetime of the database object.
|
|
402
|
+
#
|
|
401
403
|
# Example:
|
|
402
404
|
#
|
|
403
405
|
# db.create_function( "maim", 1 ) do |func, value|
|
|
@@ -437,6 +439,8 @@ module SQLite3
|
|
|
437
439
|
# function invocation. It should invoke FunctionProxy#result= to
|
|
438
440
|
# store the result of the function.
|
|
439
441
|
#
|
|
442
|
+
# A reference to the block will be kept for the lifetime of the database object.
|
|
443
|
+
#
|
|
440
444
|
# Example:
|
|
441
445
|
#
|
|
442
446
|
# db.create_aggregate( "lengths", 1 ) do
|
data/lib/sqlite3/ffi/c_api.rb
CHANGED
|
@@ -129,6 +129,9 @@ module SQLite3
|
|
|
129
129
|
SQLITE_TRACE_ROW = 0x04
|
|
130
130
|
SQLITE_TRACE_CLOSE = 0x08
|
|
131
131
|
|
|
132
|
+
SQLITE_FCNTL_FILE_POINTER = 7
|
|
133
|
+
SQLITE_FCNTL_JOURNAL_POINTER = 28
|
|
134
|
+
|
|
132
135
|
attach_function :sqlite3_aggregate_context, [:pointer, :int], :pointer
|
|
133
136
|
attach_function :sqlite3_backup_finish, [:pointer], :int
|
|
134
137
|
attach_function :sqlite3_backup_init, [:pointer, :string, :pointer, :string], :pointer
|
|
@@ -169,9 +172,9 @@ module SQLite3
|
|
|
169
172
|
attach_function :sqlite3_errmsg, [:pointer], :string
|
|
170
173
|
attach_function :sqlite3_error_offset, [:pointer], :int
|
|
171
174
|
attach_function :sqlite3_exec, [:pointer, :string, :pointer, :pointer, :pointer], :int
|
|
172
|
-
attach_function :sqlite3_expanded_sql, [:pointer], :
|
|
175
|
+
attach_function :sqlite3_expanded_sql, [:pointer], :pointer
|
|
173
176
|
attach_function :sqlite3_extended_result_codes, [:pointer, :int], :int
|
|
174
|
-
attach_function :sqlite3_file_control, [:pointer, :
|
|
177
|
+
attach_function :sqlite3_file_control, [:pointer, :pointer, :int, :pointer], :int
|
|
175
178
|
attach_function :sqlite3_finalize, [:pointer], :int
|
|
176
179
|
attach_function :sqlite3_free, [:pointer], :void
|
|
177
180
|
attach_function :sqlite3_get_autocommit, [:pointer], :int
|
|
@@ -205,6 +208,13 @@ module SQLite3
|
|
|
205
208
|
attach_function :sqlite3_value_text, [:pointer], :pointer
|
|
206
209
|
attach_function :sqlite3_value_type, [:pointer], :int
|
|
207
210
|
|
|
211
|
+
HAVE_SQLITE3_DB_NAME = begin
|
|
212
|
+
attach_function :sqlite3_db_name, [:pointer, :int], :pointer
|
|
213
|
+
true
|
|
214
|
+
rescue ::FFI::NotFoundError
|
|
215
|
+
false
|
|
216
|
+
end
|
|
217
|
+
|
|
208
218
|
HAVE_SQLITE3_ENABLE_LOAD_EXTENSION = begin
|
|
209
219
|
attach_function :sqlite3_enable_load_extension, [:pointer, :int], :int
|
|
210
220
|
true
|
data/lib/sqlite3/ffi/database.rb
CHANGED
|
@@ -2,7 +2,6 @@ module SQLite3
|
|
|
2
2
|
class Database
|
|
3
3
|
def close
|
|
4
4
|
close_or_discard_db
|
|
5
|
-
@aggregators = nil
|
|
6
5
|
self
|
|
7
6
|
end
|
|
8
7
|
|
|
@@ -53,7 +52,7 @@ module SQLite3
|
|
|
53
52
|
|
|
54
53
|
status = FFI::CApi.sqlite3_create_function(@db, FFI.string_value(name), block.arity, flags, FFI.wrap(block), FFI::FUNC, nil, nil)
|
|
55
54
|
FFI.check(@db, status)
|
|
56
|
-
@functions
|
|
55
|
+
@functions << block
|
|
57
56
|
self
|
|
58
57
|
end
|
|
59
58
|
|
|
@@ -169,8 +168,31 @@ module SQLite3
|
|
|
169
168
|
end
|
|
170
169
|
|
|
171
170
|
def discard_db
|
|
171
|
+
sfile = ::FFI::MemoryPointer.new(:pointer)
|
|
172
|
+
|
|
172
173
|
FFI::CApi.sqlite3_db_release_memory(@db)
|
|
173
|
-
|
|
174
|
+
|
|
175
|
+
if FFI::CApi::HAVE_SQLITE3_DB_NAME
|
|
176
|
+
j_db = 0
|
|
177
|
+
while !(db_name = FFI::CApi.sqlite3_db_name(@db, j_db)).null?
|
|
178
|
+
status = FFI::CApi.sqlite3_file_control(@db, db_name, FFI::CApi::SQLITE_FCNTL_FILE_POINTER, sfile)
|
|
179
|
+
if status == 0
|
|
180
|
+
# TODO
|
|
181
|
+
end
|
|
182
|
+
j_db += 1
|
|
183
|
+
end
|
|
184
|
+
else
|
|
185
|
+
status = FFI::CApi.sqlite3_file_control(@db, nil, FFI::CApi::SQLITE_FCNTL_FILE_POINTER, sfile)
|
|
186
|
+
if status == 0
|
|
187
|
+
# TODO
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
status = FFI::CApi.sqlite3_file_control(@db, nil, FFI::CApi::SQLITE_FCNTL_JOURNAL_POINTER, sfile)
|
|
192
|
+
if status == 0
|
|
193
|
+
# TODO
|
|
194
|
+
end
|
|
195
|
+
|
|
174
196
|
@db = nil
|
|
175
197
|
@discarded = true
|
|
176
198
|
end
|
|
@@ -178,7 +200,7 @@ module SQLite3
|
|
|
178
200
|
def close_or_discard_db
|
|
179
201
|
unless @db.nil?
|
|
180
202
|
if @readonly || @owner == Process.pid
|
|
181
|
-
|
|
203
|
+
@db.free
|
|
182
204
|
@db = nil
|
|
183
205
|
else
|
|
184
206
|
discard_db
|
|
@@ -191,14 +213,15 @@ module SQLite3
|
|
|
191
213
|
end
|
|
192
214
|
|
|
193
215
|
def open_v2(file, flags, zvfs)
|
|
216
|
+
@owner = Process.pid
|
|
194
217
|
db = ::FFI::MemoryPointer.new(:pointer)
|
|
195
218
|
status = FFI::CApi.sqlite3_open_v2(FFI.string_value(file), db, flags, zvfs)
|
|
196
219
|
@db = db.read_pointer
|
|
220
|
+
@db = ::FFI::AutoPointer.new(db.read_pointer, FFI::CApi.method(:sqlite3_close_v2))
|
|
197
221
|
FFI.check(@db, status)
|
|
198
222
|
if (flags & FFI::CApi::SQLITE_OPEN_READONLY) != 0
|
|
199
223
|
@readonly = true
|
|
200
224
|
end
|
|
201
|
-
@owner = Process.pid
|
|
202
225
|
self
|
|
203
226
|
end
|
|
204
227
|
|
|
@@ -212,7 +235,6 @@ module SQLite3
|
|
|
212
235
|
|
|
213
236
|
def discard
|
|
214
237
|
discard_db
|
|
215
|
-
@aggregators = nil
|
|
216
238
|
self
|
|
217
239
|
end
|
|
218
240
|
|
|
@@ -228,9 +250,10 @@ module SQLite3
|
|
|
228
250
|
end
|
|
229
251
|
|
|
230
252
|
def open16(file)
|
|
253
|
+
@owner = Process.pid
|
|
231
254
|
db = ::FFI::MemoryPointer.new(:pointer)
|
|
232
255
|
status = FFI::CApi.sqlite3_open16(utf16_string_value_ptr(file), db)
|
|
233
|
-
@db = db.read_pointer
|
|
256
|
+
@db = ::FFI::AutoPointer.new(db.read_pointer, FFI::CApi.method(:sqlite3_close_v2))
|
|
234
257
|
FFI.check(@db, status)
|
|
235
258
|
status
|
|
236
259
|
end
|
|
@@ -10,7 +10,7 @@ module SQLite3
|
|
|
10
10
|
status = FFI::CApi.sqlite3_prepare_v2(db, sql, sql.bytesize, stmt, tail)
|
|
11
11
|
FFI.check_prepare(db, status, sql)
|
|
12
12
|
|
|
13
|
-
@stmt = stmt.read_pointer
|
|
13
|
+
@stmt = ::FFI::AutoPointer.new(stmt.read_pointer, FFI::CApi.method(:sqlite3_finalize))
|
|
14
14
|
@db.instance_variable_set(:@stmt_deadline, nil)
|
|
15
15
|
|
|
16
16
|
tail.read_pointer.read_string.force_encoding(Encoding::UTF_8)
|
|
@@ -19,7 +19,7 @@ module SQLite3
|
|
|
19
19
|
def close
|
|
20
20
|
require_open_stmt
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
@stmt.free
|
|
23
23
|
@stmt = nil
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -239,7 +239,11 @@ module SQLite3
|
|
|
239
239
|
require_live_db
|
|
240
240
|
require_open_stmt
|
|
241
241
|
|
|
242
|
-
FFI::CApi.sqlite3_expanded_sql(@stmt)
|
|
242
|
+
expanded_sql = FFI::CApi.sqlite3_expanded_sql(@stmt)
|
|
243
|
+
rb_expanded_sql = expanded_sql.read_string.force_encoding(Encoding::UTF_8).freeze
|
|
244
|
+
FFI::CApi.sqlite3_free(expanded_sql)
|
|
245
|
+
|
|
246
|
+
rb_expanded_sql
|
|
243
247
|
end
|
|
244
248
|
|
|
245
249
|
private
|
data/lib/sqlite3/ffi/version.rb
CHANGED
data/lib/sqlite3/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sqlite3-ffi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jamis Buck
|
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
78
|
version: '0'
|
|
79
79
|
requirements: []
|
|
80
|
-
rubygems_version: 4.0.
|
|
80
|
+
rubygems_version: 4.0.13
|
|
81
81
|
specification_version: 4
|
|
82
82
|
summary: A drop-in replacement for the sqlite3 gem for JRuby
|
|
83
83
|
test_files: []
|