lmdb 0.7.0 → 0.7.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.
- checksums.yaml +4 -4
- data/ext/lmdb_ext/lmdb_ext.c +31 -2
- data/lib/lmdb/database.rb +21 -9
- data/lib/lmdb/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27c33b768709ded58c1414c9102a0a4024219abb305e875279b705d6d784aa68
|
|
4
|
+
data.tar.gz: 6d9b3f61f5ec981329fe42b6c310aca2760d5569f72202cbbe590258d1693591
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e1816c955d847948075046de78e382316ea599e56090bde14c669b4318cb12fc42d0c90cfed3089dded7be185c2589b99d756b343ae126c4e2c6f425e19451e
|
|
7
|
+
data.tar.gz: 2bab39420ba0d6243bf261239a1264694e8be367f2b221522b3e596acfc3697225190cd8b6ba41fc34596e73731cc7f870312e13b15f36ae66f9041186268eb0
|
data/ext/lmdb_ext/lmdb_ext.c
CHANGED
|
@@ -137,6 +137,28 @@ static VALUE transaction_is_readonly(VALUE self) {
|
|
|
137
137
|
return (transaction->flags & MDB_RDONLY) ? Qtrue : Qfalse;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* @overload finished?
|
|
142
|
+
* @note This predicate is considered *unstable*; do not get used to it.
|
|
143
|
+
* @return [false,true] whether the transaction is finished.
|
|
144
|
+
*/
|
|
145
|
+
static VALUE transaction_is_finished(VALUE self) {
|
|
146
|
+
TRANSACTION(self, transaction);
|
|
147
|
+
// MDB_TXN_FINISHED
|
|
148
|
+
return (transaction->flags & 0x01) ? Qtrue : Qfalse;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @overload error?
|
|
153
|
+
* @note This predicate is considered *unstable*; do not get used to it.
|
|
154
|
+
* @return [false,true] whether the transaction incurred an error.
|
|
155
|
+
*/
|
|
156
|
+
static VALUE transaction_is_error(VALUE self) {
|
|
157
|
+
TRANSACTION(self, transaction);
|
|
158
|
+
// MDB_TXN_ERROR
|
|
159
|
+
return (transaction->flags & 0x02) ? Qtrue : Qfalse;
|
|
160
|
+
}
|
|
161
|
+
|
|
140
162
|
|
|
141
163
|
static void transaction_finish(VALUE self, int commit) {
|
|
142
164
|
TRANSACTION(self, transaction);
|
|
@@ -312,16 +334,21 @@ static VALUE with_transaction(VALUE venv, VALUE(*fn)(VALUE), VALUE arg, int flag
|
|
|
312
334
|
*/
|
|
313
335
|
|
|
314
336
|
if (tparent && flags & MDB_RDONLY) {
|
|
337
|
+
// We are reusing the parent transaction.
|
|
338
|
+
|
|
315
339
|
int exception;
|
|
316
340
|
VALUE ret = rb_protect(fn, NIL_P(arg) ? vparent : arg, &exception);
|
|
341
|
+
|
|
317
342
|
if (exception) {
|
|
318
|
-
|
|
319
|
-
|
|
343
|
+
// this is a cargo cult; i just copied it from below
|
|
344
|
+
if (vparent == environment_active_txn(venv)) transaction_abort(vparent);
|
|
320
345
|
rb_jump_tag(exception);
|
|
321
346
|
}
|
|
322
347
|
return ret;
|
|
323
348
|
}
|
|
324
349
|
else {
|
|
350
|
+
// We are creating a new transaction.
|
|
351
|
+
|
|
325
352
|
// XXX note this is a cursed goto loop that could almost certainly
|
|
326
353
|
// be rewritten as a do-while
|
|
327
354
|
retry:
|
|
@@ -1802,6 +1829,8 @@ void Init_lmdb_ext() {
|
|
|
1802
1829
|
rb_define_method(cTransaction, "abort", transaction_abort, 0);
|
|
1803
1830
|
rb_define_method(cTransaction, "env", transaction_env, 0);
|
|
1804
1831
|
rb_define_method(cTransaction, "readonly?", transaction_is_readonly, 0);
|
|
1832
|
+
rb_define_method(cTransaction, "finished?", transaction_is_finished, 0);
|
|
1833
|
+
rb_define_method(cTransaction, "error?", transaction_is_error, 0);
|
|
1805
1834
|
|
|
1806
1835
|
/**
|
|
1807
1836
|
* Document-class: LMDB::Cursor
|
data/lib/lmdb/database.rb
CHANGED
|
@@ -126,7 +126,7 @@ module LMDB
|
|
|
126
126
|
|
|
127
127
|
ret = false
|
|
128
128
|
# read-only txn was having trouble being nested inside a read-write
|
|
129
|
-
maybe_txn
|
|
129
|
+
maybe_txn(true) do
|
|
130
130
|
# env.transaction true do
|
|
131
131
|
# env.transaction do
|
|
132
132
|
cursor { |c| ret = !!c.set(key, value) }
|
|
@@ -145,11 +145,20 @@ module LMDB
|
|
|
145
145
|
# @return [void]
|
|
146
146
|
#
|
|
147
147
|
def put?(key, value = nil, **options)
|
|
148
|
+
# early bailout
|
|
149
|
+
return if value.nil?
|
|
150
|
+
|
|
148
151
|
flags = { (dupsort? ? :nodupdata : :nooverwrite) => true }
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
|
|
153
|
+
env.transaction do |txn|
|
|
154
|
+
# begin
|
|
155
|
+
put(key, value, **options.merge(flags)) unless has?(key, value)
|
|
156
|
+
# rescue LMDB::Error::KEYEXIST
|
|
157
|
+
# # this should never be reached lol
|
|
158
|
+
# # warn 'lol'
|
|
159
|
+
# txn.abort
|
|
160
|
+
# nil
|
|
161
|
+
# end
|
|
153
162
|
end
|
|
154
163
|
end
|
|
155
164
|
|
|
@@ -163,10 +172,13 @@ module LMDB
|
|
|
163
172
|
# @return [void]
|
|
164
173
|
#
|
|
165
174
|
def delete?(key, value = nil)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
env.transaction do |txn|
|
|
176
|
+
begin
|
|
177
|
+
delete key, value
|
|
178
|
+
rescue LMDB::Error::NOTFOUND
|
|
179
|
+
txn.abort
|
|
180
|
+
nil
|
|
181
|
+
end
|
|
170
182
|
end
|
|
171
183
|
end
|
|
172
184
|
|
data/lib/lmdb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lmdb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Mendler
|
|
8
8
|
- Dorian Taylor
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
144
|
version: '0'
|
|
145
145
|
requirements: []
|
|
146
|
-
rubygems_version: 3.6.
|
|
146
|
+
rubygems_version: 3.6.7
|
|
147
147
|
specification_version: 4
|
|
148
148
|
summary: Ruby bindings to Lightning MDB
|
|
149
149
|
test_files:
|