lmdb 0.7.3 → 0.7.5
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/README.md +12 -4
- data/Rakefile +48 -0
- data/ext/lmdb_ext/extconf.rb +27 -10
- data/ext/lmdb_ext/lmdb_ext.c +22 -8
- data/lib/lmdb/database.rb +2 -1
- data/lib/lmdb/version.rb +1 -1
- data/lmdb.gemspec +4 -1
- data/spec/lmdb_spec.rb +9 -0
- data/vendor/liblmdb/VERSION +1 -0
- data/vendor/{libraries/liblmdb → liblmdb}/lmdb.h +18 -63
- data/vendor/{libraries/liblmdb → liblmdb}/mdb.c +583 -1480
- data/vendor/{libraries/liblmdb → liblmdb}/midl.c +0 -62
- data/vendor/{libraries/liblmdb → liblmdb}/midl.h +4 -16
- metadata +7 -34
- data/CONTRIBUTORS +0 -8
- data/behaviour.org +0 -35
- data/ext/lmdb_ext/prototypes.sh +0 -4
- data/vendor/libraries/liblmdb/.gitignore +0 -24
- data/vendor/libraries/liblmdb/COPYRIGHT +0 -20
- data/vendor/libraries/liblmdb/Doxyfile +0 -1631
- data/vendor/libraries/liblmdb/LICENSE +0 -47
- data/vendor/libraries/liblmdb/Makefile +0 -118
- data/vendor/libraries/liblmdb/intro.doc +0 -192
- data/vendor/libraries/liblmdb/mdb_copy.1 +0 -61
- data/vendor/libraries/liblmdb/mdb_copy.c +0 -84
- data/vendor/libraries/liblmdb/mdb_drop.1 +0 -40
- data/vendor/libraries/liblmdb/mdb_drop.c +0 -135
- data/vendor/libraries/liblmdb/mdb_dump.1 +0 -81
- data/vendor/libraries/liblmdb/mdb_dump.c +0 -319
- data/vendor/libraries/liblmdb/mdb_load.1 +0 -84
- data/vendor/libraries/liblmdb/mdb_load.c +0 -492
- data/vendor/libraries/liblmdb/mdb_stat.1 +0 -70
- data/vendor/libraries/liblmdb/mdb_stat.c +0 -264
- data/vendor/libraries/liblmdb/mtest.c +0 -177
- data/vendor/libraries/liblmdb/mtest2.c +0 -124
- data/vendor/libraries/liblmdb/mtest3.c +0 -133
- data/vendor/libraries/liblmdb/mtest4.c +0 -168
- data/vendor/libraries/liblmdb/mtest5.c +0 -135
- data/vendor/libraries/liblmdb/mtest6.c +0 -141
- data/vendor/libraries/liblmdb/sample-bdb.txt +0 -73
- data/vendor/libraries/liblmdb/sample-mdb.txt +0 -62
- data/vendor/libraries/liblmdb/tooltag +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0bdc2e97f5353c0b63346ff01f45bbdefbecdc9846528a14c787c62155a7ad34
|
|
4
|
+
data.tar.gz: da28bdf61332f08e234d6562999f4dcbba5c35b02b5af33e21dc87e8238598df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3ffb3eba78a9c59b5e7dd357492a837c73e6cadd0d09da00399ffc7f1bf470056fed6b280ae326712b59c47ce032c890ff73a33c25a697668432cf1cb162e13
|
|
7
|
+
data.tar.gz: 96521beef4abb44b5ee3abea5c7a2d79dafa4b49a9a88d9d2fe77d0584b8a62fee9140431cbcc51ca17d9c5a92d70e9281d42fb9cad2cbb6c14cb8802bc3c865
|
data/README.md
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
# LMDB
|
|
2
2
|
|
|
3
|
-
Ruby bindings
|
|
3
|
+
These are Ruby bindings [OpenLDAP's excellent Lightning Memory-Mapped
|
|
4
|
+
Database (LMDB)](https://www.symas.com/lmdb/).
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
7
|
-
Install via rubygems:
|
|
8
|
+
Install via [RubyGems](https://rubygems.org/gems/lmdb/):
|
|
8
9
|
|
|
9
|
-
```
|
|
10
|
-
gem install lmdb
|
|
10
|
+
```bash
|
|
11
|
+
$ gem install lmdb
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
If you want to force the bundled LMDB over your system version
|
|
15
|
+
(assuming one is present, along with headers):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ gem install lmdb -- --vendor-lmdb
|
|
11
19
|
```
|
|
12
20
|
|
|
13
21
|
## Links
|
data/Rakefile
CHANGED
|
@@ -76,3 +76,51 @@ namespace :release do
|
|
|
76
76
|
abort "#{tag} exists; update version!" unless `git tag -l #{tag}`.empty?
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
|
+
|
|
80
|
+
# all this business is to download actual releases of lmdb instead of using
|
|
81
|
+
# git submodules
|
|
82
|
+
|
|
83
|
+
require 'open-uri'
|
|
84
|
+
require 'json'
|
|
85
|
+
require 'fileutils'
|
|
86
|
+
require 'rubygems/package'
|
|
87
|
+
require 'zlib'
|
|
88
|
+
|
|
89
|
+
LMDB_VENDOR_DIR = File.expand_path('vendor/liblmdb', __dir__)
|
|
90
|
+
LMDB_NEEDED = %w[mdb.c midl.c lmdb.h midl.h].freeze
|
|
91
|
+
|
|
92
|
+
namespace :lmdb do
|
|
93
|
+
desc 'Fetch the latest LMDB C source into vendor/liblmdb'
|
|
94
|
+
task :fetch do
|
|
95
|
+
tags_url = 'https://api.github.com/repos/LMDB/lmdb/tags?per_page=20'
|
|
96
|
+
headers = { 'User-Agent' => 'rb-lmdb-gem-fetch' }
|
|
97
|
+
|
|
98
|
+
tags = JSON.parse(URI.open(tags_url, headers).read)
|
|
99
|
+
# warn tags.inspect
|
|
100
|
+
# Tags are like "LMDB_0_9_32" — pick the highest numeric one
|
|
101
|
+
tag = tags
|
|
102
|
+
.map { |t| t['name'] }
|
|
103
|
+
.select { |n| n.match?(/\ALMDB_\d+[_.]\d+[_.]\d+\z/) }
|
|
104
|
+
.max_by { |n| n.scan(/\d+/).map(&:to_i) }
|
|
105
|
+
|
|
106
|
+
abort 'Could not determine latest LMDB tag' unless tag
|
|
107
|
+
puts "Fetching LMDB #{tag}..."
|
|
108
|
+
|
|
109
|
+
tarball_url = "https://github.com/LMDB/lmdb/archive/refs/tags/#{tag}.tar.gz"
|
|
110
|
+
FileUtils.mkdir_p(LMDB_VENDOR_DIR)
|
|
111
|
+
|
|
112
|
+
# Stream the tarball, extract only the liblmdb source files we need
|
|
113
|
+
URI.open(tarball_url, headers) do |gz|
|
|
114
|
+
Gem::Package::TarReader.new(Zlib::GzipReader.new(gz)).each do |entry|
|
|
115
|
+
base = File.basename(entry.full_name)
|
|
116
|
+
next unless entry.file? && LMDB_NEEDED.include?(base)
|
|
117
|
+
dest = File.join(LMDB_VENDOR_DIR, base)
|
|
118
|
+
File.write(dest, entry.read)
|
|
119
|
+
puts " -> #{dest}"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
File.write(File.join(LMDB_VENDOR_DIR, 'VERSION'), "#{tag}\n")
|
|
124
|
+
puts "Done. LMDB #{tag} vendored in #{LMDB_VENDOR_DIR}."
|
|
125
|
+
end
|
|
126
|
+
end
|
data/ext/lmdb_ext/extconf.rb
CHANGED
|
@@ -3,18 +3,35 @@ require 'mkmf'
|
|
|
3
3
|
$CFLAGS << ' -std=c99 -Wall -g '
|
|
4
4
|
$CFLAGS << ' -fdeclspec' if /darwin/.match? RUBY_PLATFORM
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
dir_config('lmdb')
|
|
7
|
+
|
|
8
|
+
# --vendor flag: skip system lmdb and always build from vendored source
|
|
9
|
+
vendor_forced = arg_config('--vendor-lmdb', false)
|
|
10
|
+
|
|
11
|
+
have_system_lmdb = false
|
|
12
|
+
|
|
13
|
+
unless vendor_forced
|
|
14
|
+
have_system_lmdb =
|
|
15
|
+
have_header('lmdb.h') && have_library('lmdb', 'mdb_env_create')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
unless have_system_lmdb
|
|
19
|
+
vendor_dir = File.expand_path('../../vendor/liblmdb', __dir__)
|
|
20
|
+
abort <<~MSG unless File.exist?(File.join(vendor_dir, 'mdb.c'))
|
|
21
|
+
Could not find system lmdb and no vendored source found.
|
|
22
|
+
Run `rake lmdb:fetch` to download the LMDB C source, then retry.
|
|
23
|
+
MSG
|
|
24
|
+
|
|
25
|
+
warn "Building from vendored LMDB source in #{vendor_dir}"
|
|
26
|
+
$INCFLAGS << " -I#{vendor_dir}"
|
|
27
|
+
$srcs = Dir[File.join(__dir__, '*.c')] +
|
|
28
|
+
[File.join(vendor_dir, 'mdb.c'),
|
|
29
|
+
File.join(vendor_dir, 'midl.c')]
|
|
30
|
+
$VPATH << vendor_dir
|
|
16
31
|
end
|
|
17
32
|
|
|
33
|
+
|
|
34
|
+
|
|
18
35
|
have_header 'limits.h'
|
|
19
36
|
have_header 'string.h'
|
|
20
37
|
have_header 'stdlib.h'
|
data/ext/lmdb_ext/lmdb_ext.c
CHANGED
|
@@ -268,6 +268,11 @@ static void stop_txn_begin(void *arg)
|
|
|
268
268
|
txn_args->stop = 1;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
// adding the break so we can commit on break
|
|
272
|
+
#ifndef TAG_BREAK
|
|
273
|
+
#define TAG_BREAK 0x2
|
|
274
|
+
#endif
|
|
275
|
+
|
|
271
276
|
/**
|
|
272
277
|
* This is the code that opens transactions. Read-write transactions
|
|
273
278
|
* have to be called outside the GVL because they will block otherwise.
|
|
@@ -336,12 +341,13 @@ static VALUE with_transaction(VALUE venv, VALUE(*fn)(VALUE), VALUE arg, int flag
|
|
|
336
341
|
if (tparent && flags & MDB_RDONLY) {
|
|
337
342
|
// We are reusing the parent transaction.
|
|
338
343
|
|
|
339
|
-
int exception;
|
|
344
|
+
int exception = 0;
|
|
340
345
|
VALUE ret = rb_protect(fn, NIL_P(arg) ? vparent : arg, &exception);
|
|
341
346
|
|
|
342
347
|
if (exception) {
|
|
343
|
-
//
|
|
344
|
-
if (vparent == environment_active_txn(venv)
|
|
348
|
+
// we only abort if there is a bona fide exception, ie not an early break
|
|
349
|
+
if (vparent == environment_active_txn(venv) && exception != TAG_BREAK)
|
|
350
|
+
transaction_abort(vparent);
|
|
345
351
|
rb_jump_tag(exception);
|
|
346
352
|
}
|
|
347
353
|
return ret;
|
|
@@ -414,17 +420,20 @@ static VALUE with_transaction(VALUE venv, VALUE(*fn)(VALUE), VALUE arg, int flag
|
|
|
414
420
|
environment_set_active_txn(venv, transaction->thread, vtxn);
|
|
415
421
|
|
|
416
422
|
// now we run the function in the transaction
|
|
417
|
-
int exception;
|
|
423
|
+
int exception = 0;
|
|
418
424
|
VALUE ret = rb_protect(fn, NIL_P(arg) ? vtxn : arg, &exception);
|
|
419
425
|
|
|
420
426
|
if (exception) {
|
|
421
427
|
// rb_warn("lol got exception");
|
|
422
|
-
if (vtxn == environment_active_txn(venv))
|
|
423
|
-
|
|
428
|
+
if (vtxn == environment_active_txn(venv)) {
|
|
429
|
+
exception == TAG_BREAK ?
|
|
430
|
+
transaction_commit(vtxn) : transaction_abort(vtxn);
|
|
431
|
+
}
|
|
424
432
|
rb_jump_tag(exception);
|
|
425
433
|
}
|
|
426
|
-
|
|
427
|
-
|
|
434
|
+
|
|
435
|
+
// no-exception behaviour is to commit the transaction
|
|
436
|
+
if (vtxn == environment_active_txn(venv)) transaction_commit(vtxn);
|
|
428
437
|
return ret;
|
|
429
438
|
}
|
|
430
439
|
}
|
|
@@ -846,9 +855,14 @@ static MDB_txn* need_txn(VALUE self) {
|
|
|
846
855
|
* transaction. A transaction commits when it exits the block successfully.
|
|
847
856
|
* A transaction aborts when it raises an exception or calls
|
|
848
857
|
* {Transaction#abort}.
|
|
858
|
+
*
|
|
849
859
|
* @param [Boolean] readonly This transaction will not perform any
|
|
850
860
|
* write operations
|
|
861
|
+
*
|
|
851
862
|
* @note Transactions can be nested.
|
|
863
|
+
* @note do a `break txn.commit` if you want to exit from the block
|
|
864
|
+
* early without aborting.
|
|
865
|
+
*
|
|
852
866
|
* @yield [txn] The block to be executed with the body of the transaction.
|
|
853
867
|
* @yieldparam txn [Transaction] An optional transaction argument
|
|
854
868
|
* @example
|
data/lib/lmdb/database.rb
CHANGED
|
@@ -126,7 +126,8 @@ 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(true) { cursor { |c| ret = !!c.set(key, value) } }
|
|
129
|
+
# maybe_txn(true) { cursor { |c| ret = !!c.set(key, value) } }
|
|
130
|
+
env.transaction(true) { cursor { |c| ret = !!c.set(key, value) } }
|
|
130
131
|
|
|
131
132
|
ret
|
|
132
133
|
end
|
data/lib/lmdb/version.rb
CHANGED
data/lmdb.gemspec
CHANGED
|
@@ -16,7 +16,10 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.authors = ['Daniel Mendler', 'Dorian Taylor']
|
|
17
17
|
s.extensions = Dir['ext/**/extconf.rb']
|
|
18
18
|
|
|
19
|
-
s.files = `git ls-files --recurse-submodules -- *`.split("\n")
|
|
19
|
+
#s.files = `git ls-files --recurse-submodules -- *`.split("\n")
|
|
20
|
+
s.files = Dir[*%w[lib/**/*.rb ext/**/*.{c,h,rb}
|
|
21
|
+
vendor/liblmdb/{mdb.c,midl.c,lmdb.h,midl.h,VERSION}
|
|
22
|
+
README.md CHANGES LICENSE lmdb.gemspec Rakefile Gemfile]]
|
|
20
23
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
21
24
|
s.require_paths = ['lib']
|
|
22
25
|
|
data/spec/lmdb_spec.rb
CHANGED
|
@@ -279,6 +279,15 @@ describe LMDB do
|
|
|
279
279
|
end
|
|
280
280
|
end
|
|
281
281
|
|
|
282
|
+
it 'should not complain when you break out of a transaction' do
|
|
283
|
+
env.transaction do |txn|
|
|
284
|
+
db.put 'key4', 'value4'
|
|
285
|
+
break
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
db.get('key4').should eq('value4')
|
|
289
|
+
end
|
|
290
|
+
|
|
282
291
|
it 'should return stat' do
|
|
283
292
|
db.stat.should be_instance_of(Hash)
|
|
284
293
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
LMDB_0.9.35
|
|
@@ -53,15 +53,14 @@
|
|
|
53
53
|
*
|
|
54
54
|
* Fix: Check for stale readers periodically, using the
|
|
55
55
|
* #mdb_reader_check function or the \ref mdb_stat_1 "mdb_stat" tool.
|
|
56
|
-
* Stale writers will be cleared automatically on
|
|
56
|
+
* Stale writers will be cleared automatically on some systems:
|
|
57
57
|
* - Windows - automatic
|
|
58
|
-
* - BSD, systems using SysV semaphores - automatic
|
|
59
58
|
* - Linux, systems using POSIX mutexes with Robust option - automatic
|
|
59
|
+
* - not on BSD, systems using POSIX semaphores.
|
|
60
60
|
* Otherwise just make all programs using the database close it;
|
|
61
61
|
* the lockfile is always reset on first open of the environment.
|
|
62
62
|
*
|
|
63
|
-
* - On BSD systems or others configured with
|
|
64
|
-
* MDB_USE_POSIX_SEM,
|
|
63
|
+
* - On BSD systems or others configured with MDB_USE_POSIX_SEM,
|
|
65
64
|
* startup can fail due to semaphores owned by another userid.
|
|
66
65
|
*
|
|
67
66
|
* Fix: Open and close the database as the user which owns the
|
|
@@ -167,8 +166,6 @@
|
|
|
167
166
|
#define _LMDB_H_
|
|
168
167
|
|
|
169
168
|
#include <sys/types.h>
|
|
170
|
-
#include <inttypes.h>
|
|
171
|
-
#include <limits.h>
|
|
172
169
|
|
|
173
170
|
#ifdef __cplusplus
|
|
174
171
|
extern "C" {
|
|
@@ -181,32 +178,6 @@ typedef int mdb_mode_t;
|
|
|
181
178
|
typedef mode_t mdb_mode_t;
|
|
182
179
|
#endif
|
|
183
180
|
|
|
184
|
-
#ifdef _WIN32
|
|
185
|
-
# define MDB_FMT_Z "I"
|
|
186
|
-
#else
|
|
187
|
-
# define MDB_FMT_Z "z" /**< printf/scanf format modifier for size_t */
|
|
188
|
-
#endif
|
|
189
|
-
|
|
190
|
-
#ifndef MDB_VL32
|
|
191
|
-
/** Unsigned type used for mapsize, entry counts and page/transaction IDs.
|
|
192
|
-
*
|
|
193
|
-
* It is normally size_t, hence the name. Defining MDB_VL32 makes it
|
|
194
|
-
* uint64_t, but do not try this unless you know what you are doing.
|
|
195
|
-
*/
|
|
196
|
-
typedef size_t mdb_size_t;
|
|
197
|
-
# define MDB_SIZE_MAX SIZE_MAX /**< max #mdb_size_t */
|
|
198
|
-
/** #mdb_size_t printf formats, \b t = one of [diouxX] without quotes */
|
|
199
|
-
# define MDB_PRIy(t) MDB_FMT_Z #t
|
|
200
|
-
/** #mdb_size_t scanf formats, \b t = one of [dioux] without quotes */
|
|
201
|
-
# define MDB_SCNy(t) MDB_FMT_Z #t
|
|
202
|
-
#else
|
|
203
|
-
typedef uint64_t mdb_size_t;
|
|
204
|
-
# define MDB_SIZE_MAX UINT64_MAX
|
|
205
|
-
# define MDB_PRIy(t) PRI##t##64
|
|
206
|
-
# define MDB_SCNy(t) SCN##t##64
|
|
207
|
-
# define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */
|
|
208
|
-
#endif
|
|
209
|
-
|
|
210
181
|
/** An abstraction for a file handle.
|
|
211
182
|
* On POSIX systems file handles are small integers. On Windows
|
|
212
183
|
* they're opaque pointers.
|
|
@@ -229,7 +200,7 @@ typedef int mdb_filehandle_t;
|
|
|
229
200
|
/** Library minor version */
|
|
230
201
|
#define MDB_VERSION_MINOR 9
|
|
231
202
|
/** Library patch version */
|
|
232
|
-
#define MDB_VERSION_PATCH
|
|
203
|
+
#define MDB_VERSION_PATCH 35
|
|
233
204
|
|
|
234
205
|
/** Combine args a,b,c into a single integer for easy version comparisons */
|
|
235
206
|
#define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
|
|
@@ -239,7 +210,7 @@ typedef int mdb_filehandle_t;
|
|
|
239
210
|
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
|
|
240
211
|
|
|
241
212
|
/** The release date of this library version */
|
|
242
|
-
#define MDB_VERSION_DATE "
|
|
213
|
+
#define MDB_VERSION_DATE "Jan 27, 2026"
|
|
243
214
|
|
|
244
215
|
/** A stringifier for the version info */
|
|
245
216
|
#define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")"
|
|
@@ -332,8 +303,6 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
|
|
|
332
303
|
#define MDB_NORDAHEAD 0x800000
|
|
333
304
|
/** don't initialize malloc'd memory before writing to datafile */
|
|
334
305
|
#define MDB_NOMEMINIT 0x1000000
|
|
335
|
-
/** use the previous snapshot rather than the latest one */
|
|
336
|
-
#define MDB_PREVSNAPSHOT 0x2000000
|
|
337
306
|
/** @} */
|
|
338
307
|
|
|
339
308
|
/** @defgroup mdb_dbi_open Database Flags
|
|
@@ -343,8 +312,7 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
|
|
|
343
312
|
#define MDB_REVERSEKEY 0x02
|
|
344
313
|
/** use sorted duplicates */
|
|
345
314
|
#define MDB_DUPSORT 0x04
|
|
346
|
-
/** numeric keys in native byte order
|
|
347
|
-
* (lmdb expects 32-bit int <= size_t <= 32/64-bit mdb_size_t.)
|
|
315
|
+
/** numeric keys in native byte order: either unsigned int or size_t.
|
|
348
316
|
* The keys must all be of the same size. */
|
|
349
317
|
#define MDB_INTEGERKEY 0x08
|
|
350
318
|
/** with #MDB_DUPSORT, sorted dup items have fixed size */
|
|
@@ -480,10 +448,8 @@ typedef enum MDB_cursor_op {
|
|
|
480
448
|
#define MDB_BAD_VALSIZE (-30781)
|
|
481
449
|
/** The specified DBI was changed unexpectedly */
|
|
482
450
|
#define MDB_BAD_DBI (-30780)
|
|
483
|
-
/** Unexpected problem - txn should abort */
|
|
484
|
-
#define MDB_PROBLEM (-30779)
|
|
485
451
|
/** The last defined error code */
|
|
486
|
-
#define MDB_LAST_ERRCODE
|
|
452
|
+
#define MDB_LAST_ERRCODE MDB_BAD_DBI
|
|
487
453
|
/** @} */
|
|
488
454
|
|
|
489
455
|
/** @brief Statistics for a database in the environment */
|
|
@@ -491,18 +457,18 @@ typedef struct MDB_stat {
|
|
|
491
457
|
unsigned int ms_psize; /**< Size of a database page.
|
|
492
458
|
This is currently the same for all databases. */
|
|
493
459
|
unsigned int ms_depth; /**< Depth (height) of the B-tree */
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
460
|
+
size_t ms_branch_pages; /**< Number of internal (non-leaf) pages */
|
|
461
|
+
size_t ms_leaf_pages; /**< Number of leaf pages */
|
|
462
|
+
size_t ms_overflow_pages; /**< Number of overflow pages */
|
|
463
|
+
size_t ms_entries; /**< Number of data items */
|
|
498
464
|
} MDB_stat;
|
|
499
465
|
|
|
500
466
|
/** @brief Information about the environment */
|
|
501
467
|
typedef struct MDB_envinfo {
|
|
502
468
|
void *me_mapaddr; /**< Address of map, if fixed */
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
469
|
+
size_t me_mapsize; /**< Size of the data memory map */
|
|
470
|
+
size_t me_last_pgno; /**< ID of the last used page */
|
|
471
|
+
size_t me_last_txnid; /**< ID of the last committed transaction */
|
|
506
472
|
unsigned int me_maxreaders; /**< max reader slots in the environment */
|
|
507
473
|
unsigned int me_numreaders; /**< max reader slots used in the environment */
|
|
508
474
|
} MDB_envinfo;
|
|
@@ -648,12 +614,6 @@ int mdb_env_create(MDB_env **env);
|
|
|
648
614
|
* caller is expected to overwrite all of the memory that was
|
|
649
615
|
* reserved in that case.
|
|
650
616
|
* This flag may be changed at any time using #mdb_env_set_flags().
|
|
651
|
-
* <li>#MDB_PREVSNAPSHOT
|
|
652
|
-
* Open the environment with the previous snapshot rather than the latest
|
|
653
|
-
* one. This loses the latest transaction, but may help work around some
|
|
654
|
-
* types of corruption. If opened with write access, this must be the
|
|
655
|
-
* only process using the environment. This flag is automatically reset
|
|
656
|
-
* after a write transaction is successfully committed.
|
|
657
617
|
* </ul>
|
|
658
618
|
* @param[in] mode The UNIX permissions to set on created files and semaphores.
|
|
659
619
|
* This parameter is ignored on Windows.
|
|
@@ -882,7 +842,7 @@ int mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *fd);
|
|
|
882
842
|
* an active write transaction.
|
|
883
843
|
* </ul>
|
|
884
844
|
*/
|
|
885
|
-
int mdb_env_set_mapsize(MDB_env *env,
|
|
845
|
+
int mdb_env_set_mapsize(MDB_env *env, size_t size);
|
|
886
846
|
|
|
887
847
|
/** @brief Set the maximum number of threads/reader slots for the environment.
|
|
888
848
|
*
|
|
@@ -995,10 +955,6 @@ int mdb_env_set_assert(MDB_env *env, MDB_assert_func *func);
|
|
|
995
955
|
* <ul>
|
|
996
956
|
* <li>#MDB_RDONLY
|
|
997
957
|
* This transaction will not perform any write operations.
|
|
998
|
-
* <li>#MDB_NOSYNC
|
|
999
|
-
* Don't flush system buffers to disk when committing this transaction.
|
|
1000
|
-
* <li>#MDB_NOMETASYNC
|
|
1001
|
-
* Flush system buffers but omit metadata flush when committing this transaction.
|
|
1002
958
|
* </ul>
|
|
1003
959
|
* @param[out] txn Address where the new #MDB_txn handle will be stored
|
|
1004
960
|
* @return A non-zero error value on failure and 0 on success. Some possible
|
|
@@ -1031,7 +987,7 @@ MDB_env *mdb_txn_env(MDB_txn *txn);
|
|
|
1031
987
|
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
|
|
1032
988
|
* @return A transaction ID, valid if input is an active transaction.
|
|
1033
989
|
*/
|
|
1034
|
-
|
|
990
|
+
size_t mdb_txn_id(MDB_txn *txn);
|
|
1035
991
|
|
|
1036
992
|
/** @brief Commit all the operations of a transaction into the database.
|
|
1037
993
|
*
|
|
@@ -1141,8 +1097,7 @@ int mdb_txn_renew(MDB_txn *txn);
|
|
|
1141
1097
|
* keys must be unique and may have only a single data item.
|
|
1142
1098
|
* <li>#MDB_INTEGERKEY
|
|
1143
1099
|
* Keys are binary integers in native byte order, either unsigned int
|
|
1144
|
-
* or
|
|
1145
|
-
* (lmdb expects 32-bit int <= size_t <= 32/64-bit mdb_size_t.)
|
|
1100
|
+
* or size_t, and will be sorted as such.
|
|
1146
1101
|
* The keys must all be of the same size.
|
|
1147
1102
|
* <li>#MDB_DUPFIXED
|
|
1148
1103
|
* This flag may only be used in combination with #MDB_DUPSORT. This option
|
|
@@ -1587,7 +1542,7 @@ int mdb_cursor_del(MDB_cursor *cursor, unsigned int flags);
|
|
|
1587
1542
|
* <li>EINVAL - cursor is not initialized, or an invalid parameter was specified.
|
|
1588
1543
|
* </ul>
|
|
1589
1544
|
*/
|
|
1590
|
-
int mdb_cursor_count(MDB_cursor *cursor,
|
|
1545
|
+
int mdb_cursor_count(MDB_cursor *cursor, size_t *countp);
|
|
1591
1546
|
|
|
1592
1547
|
/** @brief Compare two data items according to a particular database.
|
|
1593
1548
|
*
|