mdbxmou 0.3.11 → 0.3.13
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.
- package/README.md +113 -11
- package/deps/libmdbx/ChangeLog.md +44 -0
- package/deps/libmdbx/SECURITY.md +18 -0
- package/deps/libmdbx/VERSION.json +1 -1
- package/deps/libmdbx/mdbx.c +121 -63
- package/deps/libmdbx/mdbx.c++ +2 -2
- package/deps/libmdbx/mdbx_chk.c +2 -2
- package/deps/libmdbx/mdbx_copy.c +2 -2
- package/deps/libmdbx/mdbx_drop.c +2 -2
- package/deps/libmdbx/mdbx_dump.c +5 -5
- package/deps/libmdbx/mdbx_load.c +24 -23
- package/deps/libmdbx/mdbx_stat.c +2 -3
- package/lib/async.d.mts +6 -4
- package/lib/types.d.ts +17 -2
- package/package.json +2 -1
- package/src/async/envmou_keys.cpp +1 -1
- package/src/async/envmou_query.cpp +14 -13
- package/src/convmou.cpp +17 -0
- package/src/convmou.hpp +4 -8
- package/src/cursormou.cpp +2 -1
- package/src/cursormou.hpp +1 -0
- package/src/dbimou.cpp +71 -18
- package/src/dbimou.hpp +3 -1
- package/src/modulemou.cpp +14 -0
- package/src/querymou.cpp +15 -15
- package/src/querymou.hpp +3 -1
- package/src/txnmou.cpp +3 -3
- package/src/typemou.hpp +85 -5
- package/src/valuemou.hpp +62 -83
- package/deps/libmdbx/.github/workflows/ci-android.yml +0 -38
- package/deps/libmdbx/.github/workflows/ci-mingw.yml +0 -40
- package/deps/libmdbx/.github/workflows/ci-posix.yml +0 -34
- package/deps/libmdbx/.github/workflows/ci-wincxx.yml +0 -45
- package/deps/libmdbx/.github/workflows/ci-windows.yml +0 -32
- package/deps/libmdbx/ci.sh +0 -86
- package/deps/libmdbx/packages/archlinux/.SRCINFO +0 -16
- package/deps/libmdbx/packages/archlinux/PKGBUILD +0 -38
- package/deps/libmdbx/packages/buildroot/0001-package-libmdbx.patch +0 -75
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Node.js binding for [libmdbx](https://github.com/Mithril-mine/libmdbx) — a fas
|
|
|
7
7
|
- **Synchronous API** — Direct MDBX operations in main thread
|
|
8
8
|
- **Asynchronous API** — Background operations with async/await
|
|
9
9
|
- **Transactions** — ACID transactions with read/write modes
|
|
10
|
-
- **Multiple key/value types** — String, binary, ordinal
|
|
10
|
+
- **Multiple key/value types** — String, binary, ordinal keys and ordinal duplicate values
|
|
11
11
|
- **Batch operations** — Efficient multi-key read/write
|
|
12
12
|
- **Memory-mapped** — High-performance memory-mapped I/O
|
|
13
13
|
|
|
@@ -86,6 +86,8 @@ Options:
|
|
|
86
86
|
- `keyFlag` - Default key encoding for all operations (optional, defaults to Buffer)
|
|
87
87
|
- Only `string` can be set (ordinal mode uses `number`/`bigint` separately)
|
|
88
88
|
- `valueFlag` - Default value encoding for all operations (optional, defaults to Buffer)
|
|
89
|
+
- `string` affects normal string values
|
|
90
|
+
- `number` and `bigint` are meaningful for `valueMode.multiOrdinal`
|
|
89
91
|
- `maxDbi` - Maximum number of databases (optional, default `32`)
|
|
90
92
|
- `mode` - Filesystem permissions mode (optional, default `0664`)
|
|
91
93
|
- `geometry` - Map size/geometry options (optional)
|
|
@@ -190,14 +192,21 @@ const txn = env.startRead();
|
|
|
190
192
|
```javascript
|
|
191
193
|
const result = await env.query([
|
|
192
194
|
{
|
|
193
|
-
|
|
194
|
-
keyMode: MDBX_Param.keyMode.ordinal,
|
|
195
|
+
dbi,
|
|
195
196
|
mode: MDBX_Param.queryMode.get,
|
|
196
197
|
item: [{ key: 1 }, { key: 2 }]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
dbi,
|
|
201
|
+
mode: MDBX_Param.queryMode.upsert,
|
|
202
|
+
putFlag: MDBX_Param.putFlag.noOverwrite,
|
|
203
|
+
item: [{ key: 3, value: "v3" }]
|
|
197
204
|
}
|
|
198
205
|
]);
|
|
199
206
|
```
|
|
200
207
|
|
|
208
|
+
`query()` uses the passed `dbi` and inherits key/value settings from it. `queryMode` selects the operation (`get`, `del`, or base write mode), and optional `putFlag` adds write-only MDBX flags. In `query()` only `noOverwrite`, `noDupData`, `current`, `append`, and `appendDup` are supported.
|
|
209
|
+
|
|
201
210
|
### Transaction
|
|
202
211
|
|
|
203
212
|
#### Methods
|
|
@@ -271,6 +280,8 @@ const dbi = txn.openMap({
|
|
|
271
280
|
> - `keyMode: BigInt(number)` → keys returned as `BigInt`
|
|
272
281
|
> - When you pass `keyMode.ordinal` as a positional argument (Number/BigInt), it also updates `keyFlag` to number/bigint unless a numeric keyFlag was already set in env or explicitly provided.
|
|
273
282
|
|
|
283
|
+
> **Note**: When `valueMode.multiOrdinal` is used and `valueFlag` is not specified, values are returned as `number` by default. Set `valueFlag: MDBX_Param.valueFlag.bigint` if you need `BigInt` on read.
|
|
284
|
+
|
|
274
285
|
**commit()**
|
|
275
286
|
```javascript
|
|
276
287
|
txn.commit();
|
|
@@ -285,10 +296,16 @@ txn.abort();
|
|
|
285
296
|
|
|
286
297
|
#### Methods
|
|
287
298
|
|
|
288
|
-
**put(txn, key, value)**
|
|
299
|
+
**put(txn, key, value, [flags])**
|
|
289
300
|
```javascript
|
|
290
301
|
dbi.put(txn, 123, "value");
|
|
291
302
|
dbi.put(txn, "key", Buffer.from("binary data"));
|
|
303
|
+
|
|
304
|
+
// Insert only if key does not exist
|
|
305
|
+
dbi.put(txn, 123, "value", MDBX_Param.putFlag.noOverwrite);
|
|
306
|
+
|
|
307
|
+
// Fast append for sorted inserts
|
|
308
|
+
dbi.put(txn, 124, "value", MDBX_Param.putFlag.append);
|
|
292
309
|
```
|
|
293
310
|
|
|
294
311
|
**get(txn, key) → value**
|
|
@@ -297,6 +314,8 @@ const value = dbi.get(txn, 123);
|
|
|
297
314
|
const binary = dbi.get(txn, "key");
|
|
298
315
|
```
|
|
299
316
|
|
|
317
|
+
For `valueMode.multiOrdinal`, `get()` returns the first duplicate value for the key, decoded as `number` by default.
|
|
318
|
+
|
|
300
319
|
**del(txn, key) → boolean**
|
|
301
320
|
```javascript
|
|
302
321
|
const deleted = dbi.del(txn, 123);
|
|
@@ -355,6 +374,12 @@ const rows = dbi.getRange(txn, { start: 10, end: 15 });
|
|
|
355
374
|
// ]
|
|
356
375
|
```
|
|
357
376
|
|
|
377
|
+
**getCount(txn, [options]) → number**
|
|
378
|
+
```javascript
|
|
379
|
+
const total = dbi.getCount(txn, { start: 10, end: 20 });
|
|
380
|
+
// 11
|
|
381
|
+
```
|
|
382
|
+
|
|
358
383
|
**keysRange(txn, [options]) → Array**
|
|
359
384
|
```javascript
|
|
360
385
|
const keys = dbi.keysRange(txn, { start: 10, end: 20, limit: 5 });
|
|
@@ -378,6 +403,7 @@ Range options:
|
|
|
378
403
|
- `reverse` - scan from upper bound to lower bound
|
|
379
404
|
- `limit` - maximum number of returned items
|
|
380
405
|
- `offset` - skip N items after initial positioning
|
|
406
|
+
- `getCount()` ignores `offset` and `limit` and returns the total size of the bounded range
|
|
381
407
|
|
|
382
408
|
**drop(txn, [delete_db]) → void**
|
|
383
409
|
```javascript
|
|
@@ -461,7 +487,7 @@ Insert or update a record at cursor position.
|
|
|
461
487
|
cursor.put('newKey', 'newValue');
|
|
462
488
|
|
|
463
489
|
// With flags (MDBX_NOOVERWRITE, etc.)
|
|
464
|
-
cursor.put('key', 'value', MDBX_Param.
|
|
490
|
+
cursor.put('key', 'value', MDBX_Param.putFlag.noOverwrite);
|
|
465
491
|
```
|
|
466
492
|
|
|
467
493
|
**del([flags]) → boolean**
|
|
@@ -595,12 +621,20 @@ txn.commit();
|
|
|
595
621
|
### Value Modes (MDBX_Param.valueMode)
|
|
596
622
|
|
|
597
623
|
- **single** - Single value per key (default)
|
|
598
|
-
- **multi** -
|
|
624
|
+
- **multi** - `MDBX_DUPSORT`, multiple values per key
|
|
625
|
+
- **multiReverse** - `MDBX_DUPSORT | MDBX_REVERSEDUP`
|
|
626
|
+
- **multiSamelength** - `MDBX_DUPSORT | MDBX_DUPFIXED`
|
|
627
|
+
- **multiOrdinal** - `MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERDUP`
|
|
628
|
+
- **multiReverseSamelength** - `MDBX_DUPSORT | MDBX_REVERSEDUP | MDBX_DUPFIXED`
|
|
599
629
|
|
|
600
630
|
### Value Flags (MDBX_Param.valueFlag)
|
|
601
631
|
|
|
602
|
-
- **binary** - Raw binary data (default)
|
|
632
|
+
- **binary** - Raw binary data (default, represented by `0`)
|
|
603
633
|
- **string** - UTF-8 strings
|
|
634
|
+
- **number** - Numeric decode for ordinal duplicate values
|
|
635
|
+
- **bigint** - BigInt decode for ordinal duplicate values
|
|
636
|
+
|
|
637
|
+
`valueFlag.number` and `valueFlag.bigint` matter primarily for `valueMode.multiOrdinal`. For ordinary values, use Buffer (default) or `valueFlag.string`.
|
|
604
638
|
|
|
605
639
|
## Examples
|
|
606
640
|
|
|
@@ -815,6 +849,9 @@ function rangeExample() {
|
|
|
815
849
|
// { key: 6, value: 'value_6' }
|
|
816
850
|
// ]
|
|
817
851
|
|
|
852
|
+
const total = readDbi.getCount(readTxn, { start: 3, end: 8 });
|
|
853
|
+
console.log(total); // 6
|
|
854
|
+
|
|
818
855
|
const keys = readDbi.keysRange(readTxn, {
|
|
819
856
|
start: 3,
|
|
820
857
|
end: 8,
|
|
@@ -838,6 +875,44 @@ function rangeExample() {
|
|
|
838
875
|
rangeExample();
|
|
839
876
|
```
|
|
840
877
|
|
|
878
|
+
### MultiOrdinal Values
|
|
879
|
+
|
|
880
|
+
```javascript
|
|
881
|
+
const { MDBX_Env, MDBX_Param } = require('mdbxmou');
|
|
882
|
+
|
|
883
|
+
function multiOrdinalExample() {
|
|
884
|
+
const env = new MDBX_Env();
|
|
885
|
+
env.openSync({ path: './multi-ordinal-data' });
|
|
886
|
+
|
|
887
|
+
const writeTxn = env.startWrite();
|
|
888
|
+
const dbi = writeTxn.createMap({
|
|
889
|
+
name: 'dup-ids',
|
|
890
|
+
keyMode: MDBX_Param.keyMode.ordinal,
|
|
891
|
+
valueMode: MDBX_Param.valueMode.multiOrdinal
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
dbi.put(writeTxn, 5, 30);
|
|
895
|
+
dbi.put(writeTxn, 5, 10);
|
|
896
|
+
dbi.put(writeTxn, 5, 20n);
|
|
897
|
+
writeTxn.commit();
|
|
898
|
+
|
|
899
|
+
const readTxn = env.startRead();
|
|
900
|
+
const readDbi = readTxn.openMap({
|
|
901
|
+
name: 'dup-ids',
|
|
902
|
+
keyMode: MDBX_Param.keyMode.ordinal,
|
|
903
|
+
valueMode: MDBX_Param.valueMode.multiOrdinal
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
console.log(readDbi.get(readTxn, 5)); // 10
|
|
907
|
+
console.log(readDbi.valuesRange(readTxn, { start: 5, end: 5 })); // [10, 20, 30]
|
|
908
|
+
|
|
909
|
+
readTxn.commit();
|
|
910
|
+
env.closeSync();
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
multiOrdinalExample();
|
|
914
|
+
```
|
|
915
|
+
|
|
841
916
|
### Query API (Advanced Async)
|
|
842
917
|
|
|
843
918
|
```javascript
|
|
@@ -856,7 +931,8 @@ async function queryExample() {
|
|
|
856
931
|
const results = await env.query([
|
|
857
932
|
{
|
|
858
933
|
dbi,
|
|
859
|
-
mode: MDBX_Param.queryMode.
|
|
934
|
+
mode: MDBX_Param.queryMode.upsert,
|
|
935
|
+
putFlag: MDBX_Param.putFlag.noOverwrite,
|
|
860
936
|
item: [
|
|
861
937
|
{ key: 1, value: JSON.stringify({ name: "Alice" }) },
|
|
862
938
|
{ key: 2, value: JSON.stringify({ name: "Bob" }) }
|
|
@@ -981,7 +1057,21 @@ MDBX_Param.keyFlag.number // Number type (used with ordinal mode)
|
|
|
981
1057
|
MDBX_Param.keyFlag.bigint // BigInt type (used with ordinal mode)
|
|
982
1058
|
// Default - Buffer representation
|
|
983
1059
|
|
|
1060
|
+
// Value modes
|
|
1061
|
+
MDBX_Param.valueMode.multi // MDBX_DUPSORT
|
|
1062
|
+
MDBX_Param.valueMode.multiReverse // MDBX_DUPSORT | MDBX_REVERSEDUP
|
|
1063
|
+
MDBX_Param.valueMode.multiSamelength // MDBX_DUPSORT | MDBX_DUPFIXED
|
|
1064
|
+
MDBX_Param.valueMode.multiOrdinal // MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERDUP
|
|
1065
|
+
MDBX_Param.valueMode.multiReverseSamelength // MDBX_DUPSORT | MDBX_REVERSEDUP | MDBX_DUPFIXED
|
|
1066
|
+
|
|
1067
|
+
// Value flags (optional, control value representation)
|
|
1068
|
+
MDBX_Param.valueFlag.string // UTF-8 string values
|
|
1069
|
+
MDBX_Param.valueFlag.number // Number values for multiOrdinal
|
|
1070
|
+
MDBX_Param.valueFlag.bigint // BigInt values for multiOrdinal
|
|
1071
|
+
// Default - Buffer representation
|
|
1072
|
+
|
|
984
1073
|
Note: For ordinal (integer) keys, use keyFlag.number or keyFlag.bigint to specify the data type.
|
|
1074
|
+
For `valueMode.multiOrdinal`, values are returned as `number` by default, or as `bigint` when `valueFlag.bigint` is used.
|
|
985
1075
|
```
|
|
986
1076
|
|
|
987
1077
|
### Environment Flags
|
|
@@ -1027,11 +1117,23 @@ Note: For ordinal (integer) keys, use keyFlag.number or keyFlag.bigint to specif
|
|
|
1027
1117
|
|
|
1028
1118
|
### Query Modes
|
|
1029
1119
|
- `MDBX_Param.queryMode.get` - Read operations
|
|
1030
|
-
- `MDBX_Param.queryMode.upsert` -
|
|
1031
|
-
- `MDBX_Param.queryMode.update` -
|
|
1032
|
-
- `MDBX_Param.queryMode.insertUnique` -
|
|
1120
|
+
- `MDBX_Param.queryMode.upsert` - Base write mode (insert or update)
|
|
1121
|
+
- `MDBX_Param.queryMode.update` - Base write mode with `MDBX_CURRENT`
|
|
1122
|
+
- `MDBX_Param.queryMode.insertUnique` - Base write mode with `MDBX_NOOVERWRITE`
|
|
1033
1123
|
- `MDBX_Param.queryMode.del` - Delete operations
|
|
1034
1124
|
|
|
1125
|
+
### Put Flags
|
|
1126
|
+
- `MDBX_Param.putFlag.noOverwrite` - `MDBX_NOOVERWRITE`
|
|
1127
|
+
- `MDBX_Param.putFlag.noDupData` - `MDBX_NODUPDATA`
|
|
1128
|
+
- `MDBX_Param.putFlag.current` - `MDBX_CURRENT`
|
|
1129
|
+
- `MDBX_Param.putFlag.allDups` - `MDBX_ALLDUPS`
|
|
1130
|
+
- `MDBX_Param.putFlag.reserve` - `MDBX_RESERVE`
|
|
1131
|
+
- `MDBX_Param.putFlag.append` - `MDBX_APPEND`
|
|
1132
|
+
- `MDBX_Param.putFlag.appendDup` - `MDBX_APPENDDUP`
|
|
1133
|
+
- `MDBX_Param.putFlag.multiple` - `MDBX_MULTIPLE`
|
|
1134
|
+
|
|
1135
|
+
For `env.query()` write requests, only `noOverwrite`, `noDupData`, `current`, `append`, and `appendDup` are supported.
|
|
1136
|
+
|
|
1035
1137
|
### Cursor Modes
|
|
1036
1138
|
- `MDBX_Param.cursorMode.first` - First key
|
|
1037
1139
|
- `MDBX_Param.cursorMode.last` - Last key
|
|
@@ -9,6 +9,45 @@ Donations are welcome to ETH `0xD104d8f8B2dC312aaD74899F83EBf3EEBDC1EA3A`,
|
|
|
9
9
|
BTC `bc1qzvl9uegf2ea6cwlytnanrscyv8snwsvrc0xfsu`, SOL `FTCTgbHajoLVZGr8aEFWMzx3NDMyS5wXJgfeMTmJznRi`.
|
|
10
10
|
Всё будет хорошо!
|
|
11
11
|
|
|
12
|
+
## v0.13.12 "Аврора" (Aurora) at 2026-04-30
|
|
13
|
+
|
|
14
|
+
The supporting release of a stable branch with bug fixes.
|
|
15
|
+
|
|
16
|
+
Appreciations:
|
|
17
|
+
|
|
18
|
+
- [Erigon](https://erigon.tech/) for sponsorship.
|
|
19
|
+
- [Chloe Cano](https://github.com/Segwaz) for fuzzing, bug reporting and fixes.
|
|
20
|
+
- [Weixie Cui](https://github.com/cuiweixie) for bug fixing through pull-requests.
|
|
21
|
+
- [Alexander Kelchin](https://serebrium.ru/) (Serebrium Company) for bug reporting and prototypes of exploits.
|
|
22
|
+
|
|
23
|
+
Fixes:
|
|
24
|
+
|
|
25
|
+
- Fixed the counting of nested trees in the `mdbx_chk` tool for a multi-values/dupsort hives (backport).
|
|
26
|
+
|
|
27
|
+
- Fixed swapping the shrink/growth parameters in a DB-geometry in the `mdbx_load` utility (backport).
|
|
28
|
+
|
|
29
|
+
- Fixed `SIGSEGV` in the case when all meta pages are not entirely usable (backport).
|
|
30
|
+
|
|
31
|
+
- Fixed information collection via `kstat()` for bootid on Solaris and related platforms (backport).
|
|
32
|
+
|
|
33
|
+
- Fixed a typo in the `ST_EXPORTED` processing path that broke the build on platforms where the mentioned flag is defined for `fstatvfs()` (backport).
|
|
34
|
+
|
|
35
|
+
- Fixed missing error handling of `NtUnmapViewOfSection()` and `munmap()` inside `osal_munmap()` (backport).
|
|
36
|
+
|
|
37
|
+
- Fixed `SIGSEGV` due to an attempt to clean/overwrite a corrupted meta page when opening the database in read-only mode (backport).
|
|
38
|
+
|
|
39
|
+
- Fixed returning a wrong/uninitialized `ms_psize` field when using `mdbx_enumerate_tables()` (backport).
|
|
40
|
+
|
|
41
|
+
- Fixed adjusting of neighbor nested cursors after a dupsort item deletion (backport).
|
|
42
|
+
|
|
43
|
+
Other:
|
|
44
|
+
|
|
45
|
+
- The dumps generated by the `mdbx_dump` utility no longer contains the current size of a DB and `maxreaders` parameter, so that the contents of a dump depend only on a payload data.
|
|
46
|
+
|
|
47
|
+
- Cutoff `packages/` into the separate aside repository.
|
|
48
|
+
|
|
49
|
+
--------------------------------------------------------------------------------
|
|
50
|
+
|
|
12
51
|
## v0.13.11 "A7A5" (just as Stable) at 2026-01-30
|
|
13
52
|
|
|
14
53
|
The supporting release of a stable branch with bug fixes.
|
|
@@ -59,6 +98,11 @@ Other:
|
|
|
59
98
|
|
|
60
99
|
- Added link to [`mdbxmou`](https://github.com/ikonopistsev/mdbxmou) bindings for NodeJS.
|
|
61
100
|
|
|
101
|
+
- Added in-code example of fix out-of-bounds read via corrupted leaf-node with comments.
|
|
102
|
+
See `node_read()` inside the source code.
|
|
103
|
+
|
|
104
|
+
- Refined a handling of bad/corrupted/crafted database geometry in a meta-pages, corresponding behaviour and logged messages.
|
|
105
|
+
|
|
62
106
|
--------------------------------------------------------------------------------
|
|
63
107
|
|
|
64
108
|
## v0.13.10 "Блеск Славы" (Gloss of Glory) от 2025-12-17
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
The following versions will receive security updates promptly based on the maintainers' discretion.
|
|
6
|
+
|
|
7
|
+
In fact, >80% of all kinds of bugs are fixed within 24 hours, and with rare exceptions, any issues are fixed within a week.
|
|
8
|
+
However, this should not be taken as a promise or a guarantee - we just try to do what we set out to do properly.
|
|
9
|
+
|
|
10
|
+
| Version | Supported |
|
|
11
|
+
| ------- | ------------------ |
|
|
12
|
+
| 0.14.x | :white_check_mark: |
|
|
13
|
+
| 0.13.x | :white_check_mark: |
|
|
14
|
+
| < 0.13 | :x: |
|
|
15
|
+
|
|
16
|
+
## Reporting a Vulnerability
|
|
17
|
+
|
|
18
|
+
To report a vulnerability, please email to `libmdbx-security @ dqdkfa.ru` or use the GitHub disclosure in the security tab to alert us to a security issue.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "git_describe": "v0.13.
|
|
1
|
+
{ "git_describe": "v0.13.12-0-gf619d43d", "git_timestamp": "2026-04-30T16:36:24+03:00", "git_tree": "f5574b87cc64fa7a3a6b21ba33809258498d5f17", "git_commit": "f619d43dfbc36cbc9a1832503ce43f2e5223996e", "semver": "0.13.12" }
|