feat(db): switch to reth-libmdbx-rs, bump reth-mdbx-sys to 0.12.1 (#133)

* feat(db): Add mdbx-rs apache licenced code 55e234

* feat(db): replace mdbx with reth-mdbx, metadata changes

* chore(db): bump mdbx-sys to 0.12.1
This commit is contained in:
rakita
2022-10-25 11:50:02 +02:00
committed by GitHub
parent 4d2e67e9f5
commit 5c55c57c5e
39 changed files with 11740 additions and 9411 deletions

61
Cargo.lock generated
View File

@ -196,9 +196,9 @@ dependencies = [
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.60.1" version = "0.61.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cexpr", "cexpr",
@ -211,6 +211,7 @@ dependencies = [
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
"syn",
] ]
[[package]] [[package]]
@ -1797,19 +1798,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "libmdbx" name = "lifetimed-bytes"
version = "0.1.8" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc9c535ae90a96067a09087672f6eac8a7f010ab7d577037cf2e99714c2dceb1" checksum = "4c970c8ea4c7b023a41cfa4af4c785a16694604c2f2a3b0d1f20a9bcb73fa550"
dependencies = [ dependencies = [
"bitflags", "bytes",
"byteorder",
"derive_more",
"indexmap",
"libc",
"mdbx-sys",
"parking_lot",
"thiserror",
] ]
[[package]] [[package]]
@ -1843,17 +1837,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "mdbx-sys"
version = "0.12.1-0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dd34990bd2d486fb7dda34ce57cbcd393d46afebb985a39c8ad84f6c70220aa"
dependencies = [
"bindgen",
"cc",
"libc",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.5.0"
@ -2485,11 +2468,11 @@ dependencies = [
"criterion", "criterion",
"eyre", "eyre",
"iai", "iai",
"libmdbx",
"page_size", "page_size",
"parity-scale-codec", "parity-scale-codec",
"postcard", "postcard",
"reth-interfaces", "reth-interfaces",
"reth-libmdbx",
"reth-primitives", "reth-primitives",
"serde", "serde",
"tempfile", "tempfile",
@ -2604,6 +2587,34 @@ dependencies = [
"tokio-stream", "tokio-stream",
] ]
[[package]]
name = "reth-libmdbx"
version = "0.1.6"
dependencies = [
"bitflags",
"byteorder",
"criterion",
"derive_more",
"indexmap",
"libc",
"lifetimed-bytes",
"parking_lot",
"rand",
"rand_xorshift",
"reth-mdbx-sys",
"tempfile",
"thiserror",
]
[[package]]
name = "reth-mdbx-sys"
version = "0.12.1-0"
dependencies = [
"bindgen",
"cc",
"libc",
]
[[package]] [[package]]
name = "reth-p2p" name = "reth-p2p"
version = "0.1.0" version = "0.1.0"

View File

@ -17,6 +17,8 @@ members = [
"crates/primitives", "crates/primitives",
"crates/stages", "crates/stages",
"crates/transaction-pool", "crates/transaction-pool",
"crates/db" "crates/db",
"crates/libmdbx-rs",
"crates/libmdbx-rs/mdbx-sys"
] ]
default-members = ["bin/reth"] default-members = ["bin/reth"]

View File

@ -11,6 +11,7 @@ description = "Staged syncing primitives used in reth."
# reth # reth
reth-primitives = { path = "../primitives" } reth-primitives = { path = "../primitives" }
reth-interfaces = { path = "../interfaces" } reth-interfaces = { path = "../interfaces" }
reth-libmdbx = { path = "../libmdbx-rs" }
# codecs # codecs
serde = { version = "1.0.*", default-features = false } serde = { version = "1.0.*", default-features = false }
@ -19,7 +20,6 @@ parity-scale-codec = { version = "3.2.1", features = ["bytes"] }
# misc # misc
bytes = "1.2.1" bytes = "1.2.1"
libmdbx = "0.1.8"
page_size = "0.4.2" page_size = "0.4.2"
thiserror = "1.0.37" thiserror = "1.0.37"
tempfile = { version = "3.3.0", optional = true } tempfile = { version = "3.3.0", optional = true }

View File

@ -3,7 +3,7 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::utils::*; use crate::utils::*;
use libmdbx::{self, TransactionKind, WriteFlags, RO, RW}; use reth_libmdbx::{self, TransactionKind, WriteFlags, RO, RW};
use reth_interfaces::db::{ use reth_interfaces::db::{
DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW, DupSort, DupWalker, Encode, Error, Table, DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW, DupSort, DupWalker, Encode, Error, Table,
Walker, Walker,
@ -25,7 +25,7 @@ pub type CursorRW<'tx, T> = Cursor<'tx, RW, T>;
#[derive(Debug)] #[derive(Debug)]
pub struct Cursor<'tx, K: TransactionKind, T: Table> { pub struct Cursor<'tx, K: TransactionKind, T: Table> {
/// Inner `libmdbx` cursor. /// Inner `libmdbx` cursor.
pub inner: libmdbx::Cursor<'tx, K>, pub inner: reth_libmdbx::Cursor<'tx, K>,
/// Table name as is inside the database. /// Table name as is inside the database.
pub table: &'static str, pub table: &'static str,
/// Phantom data to enforce encoding/decoding. /// Phantom data to enforce encoding/decoding.

View File

@ -1,7 +1,7 @@
//! Module that interacts with MDBX. //! Module that interacts with MDBX.
use crate::utils::default_page_size; use crate::utils::default_page_size;
use libmdbx::{ use reth_libmdbx::{
DatabaseFlags, Environment, EnvironmentFlags, EnvironmentKind, Geometry, Mode, PageSize, DatabaseFlags, Environment, EnvironmentFlags, EnvironmentKind, Geometry, Mode, PageSize,
SyncMode, RO, RW, SyncMode, RO, RW,
}; };
@ -99,7 +99,7 @@ impl<E: EnvironmentKind> Env<E> {
} }
impl<E: EnvironmentKind> Deref for Env<E> { impl<E: EnvironmentKind> Deref for Env<E> {
type Target = libmdbx::Environment<E>; type Target = reth_libmdbx::Environment<E>;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.inner &self.inner
@ -134,7 +134,7 @@ pub mod test_utils {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{test_utils, Env, EnvKind}; use super::{test_utils, Env, EnvKind};
use libmdbx::{NoWriteMap, WriteMap}; use reth_libmdbx::{NoWriteMap, WriteMap};
use reth_interfaces::db::{ use reth_interfaces::db::{
tables::{Headers, PlainAccountState, PlainStorageState}, tables::{Headers, PlainAccountState, PlainStorageState},
Database, DbCursorRO, DbDupCursorRO, DbTx, DbTxMut, Database, DbCursorRO, DbDupCursorRO, DbTx, DbTxMut,

View File

@ -1,7 +1,7 @@
//! Transaction wrapper for libmdbx-sys. //! Transaction wrapper for libmdbx-sys.
use crate::{kv::cursor::Cursor, utils::decode_one}; use crate::{kv::cursor::Cursor, utils::decode_one};
use libmdbx::{EnvironmentKind, Transaction, TransactionKind, WriteFlags, RW}; use reth_libmdbx::{EnvironmentKind, Transaction, TransactionKind, WriteFlags, RW};
use reth_interfaces::db::{DbTx, DbTxGAT, DbTxMut, DbTxMutGAT, DupSort, Encode, Error, Table}; use reth_interfaces::db::{DbTx, DbTxGAT, DbTxMut, DbTxMutGAT, DupSort, Encode, Error, Table};
use std::marker::PhantomData; use std::marker::PhantomData;

View File

@ -9,7 +9,7 @@
/// Rust bindings for [MDBX](https://libmdbx.dqdkfa.ru/). /// Rust bindings for [MDBX](https://libmdbx.dqdkfa.ru/).
pub mod mdbx { pub mod mdbx {
pub use libmdbx::*; pub use reth_libmdbx::*;
} }
pub mod kv; pub mod kv;

1012
crates/libmdbx-rs/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,14 @@
[package] [package]
name = "libmdbx" name = "reth-libmdbx"
version = "0.1.6" version = "0.1.6"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Idiomatic and safe MDBX wrapper." description = "Idiomatic and safe MDBX wrapper with good licence"
documentation = "https://docs.rs/libmdbx" repository = "https://github.com/foundry-rs/reth"
homepage = "https://github.com/vorot93/libmdbx-rs"
repository = "https://github.com/vorot93/libmdbx-rs"
readme = "README.md" readme = "README.md"
keywords = ["LMDB", "MDBX", "database", "storage-engine", "bindings"]
categories = ["database"]
[lib] [lib]
name = "libmdbx" name = "reth_libmdbx"
[workspace]
members = ["mdbx-sys"]
[dependencies] [dependencies]
bitflags = "1" bitflags = "1"
@ -26,12 +19,12 @@ libc = "0.2"
parking_lot = "0.12" parking_lot = "0.12"
thiserror = "1" thiserror = "1"
ffi = { package = "mdbx-sys", version = "=0.11.8-0", path = "./mdbx-sys" } ffi = { package = "reth-mdbx-sys", path = "./mdbx-sys" }
lifetimed-bytes = { version = "0.1", optional = true } lifetimed-bytes = { version = "0.1", optional = true }
[dev-dependencies] [dev-dependencies]
criterion = "0.3" criterion = "0.4"
rand = "0.8" rand = "0.8"
rand_xorshift = "0.3" rand_xorshift = "0.3"
tempfile = "3" tempfile = "3"

View File

@ -2,7 +2,7 @@ mod utils;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ffi::*; use ffi::*;
use libmdbx::*; use reth_libmdbx::*;
use std::ptr; use std::ptr;
use utils::*; use utils::*;

View File

@ -3,7 +3,7 @@ mod utils;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ffi::*; use ffi::*;
use libc::size_t; use libc::size_t;
use libmdbx::{ObjectLength, WriteFlags}; use reth_libmdbx::{ObjectLength, WriteFlags};
use rand::{prelude::SliceRandom, SeedableRng}; use rand::{prelude::SliceRandom, SeedableRng};
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;
use std::ptr; use std::ptr;

View File

@ -1,4 +1,4 @@
use libmdbx::{Environment, NoWriteMap, WriteFlags}; use reth_libmdbx::{Environment, NoWriteMap, WriteFlags};
use tempfile::{tempdir, TempDir}; use tempfile::{tempdir, TempDir};
pub fn get_key(n: u32) -> String { pub fn get_key(n: u32) -> String {

View File

@ -1,22 +1,18 @@
[package] [package]
name = "mdbx-sys" name = "reth-mdbx-sys"
version = "0.11.8-0" version = "0.12.1-0"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Rust bindings for libmdbx." description = "Rust bindings for libmdbx with good licence."
documentation = "https://docs.rs/mdbx-sys" repository = "https://github.com/foundry-rs/reth"
homepage = "https://github.com/vorot93/libmdbx-rs" readme = "README.md"
repository = "https://github.com/vorot93/libmdbx-rs"
readme = "../README.md"
keywords = ["MDBX", "database", "storage-engine", "bindings", "library"]
categories = ["database", "external-ffi-bindings"]
[lib] [lib]
name = "mdbx_sys" name = "reth_mdbx_sys"
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"
[build-dependencies] [build-dependencies]
cc = "1.0" cc = "1.0"
bindgen = { version = "0.60", default-features = false, features = ["runtime"] } bindgen = { version = "0.61", default-features = false, features = ["runtime"] }

View File

@ -233,6 +233,7 @@ if(SUBPROJECT)
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)" ON) option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)" ON)
endif() endif()
set(MDBX_MANAGE_BUILD_FLAGS_DEFAULT OFF)
else() else()
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)" ON) option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)" ON) option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)" ON)
@ -341,9 +342,14 @@ else()
endif() endif()
endif(NOT MDBX_AMALGAMATED_SOURCE) endif(NOT MDBX_AMALGAMATED_SOURCE)
setup_compile_flags() set(MDBX_MANAGE_BUILD_FLAGS_DEFAULT ON)
endif(SUBPROJECT) endif(SUBPROJECT)
option(MDBX_MANAGE_BUILD_FLAGS "Allow libmdbx to configure/manage/override its own build flags" ${MDBX_MANAGE_BUILD_FLAGS_DEFAULT})
if(MDBX_MANAGE_BUILD_FLAGS)
setup_compile_flags()
endif()
list(FIND CMAKE_C_COMPILE_FEATURES c_std_11 HAS_C11) list(FIND CMAKE_C_COMPILE_FEATURES c_std_11 HAS_C11)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 HAS_CXX11)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14)
@ -497,7 +503,7 @@ mark_as_advanced(MDBX_LOCKING)
add_mdbx_option(MDBX_TRUST_RTC "Does a system have battery-backed Real-Time Clock or just a fake" AUTO) add_mdbx_option(MDBX_TRUST_RTC "Does a system have battery-backed Real-Time Clock or just a fake" AUTO)
mark_as_advanced(MDBX_TRUST_RTC) mark_as_advanced(MDBX_TRUST_RTC)
option(MDBX_FORCE_ASSERTIONS "Force enable assertion checking" OFF) option(MDBX_FORCE_ASSERTIONS "Force enable assertion checking" OFF)
option(MDBX_DISABLE_PAGECHECKS "Disable some checks to reduce an overhead and detection probability of database corruption to a values closer to the LMDB" OFF) option(MDBX_DISABLE_VALIDATION "Disable some checks to reduce an overhead and detection probability of database corruption to a values closer to the LMDB" OFF)
if(NOT MDBX_AMALGAMATED_SOURCE) if(NOT MDBX_AMALGAMATED_SOURCE)
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG") if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG")
@ -569,7 +575,10 @@ else()
"${MDBX_SOURCE_DIR}/options.h" "${MDBX_SOURCE_DIR}/base.h" "${MDBX_SOURCE_DIR}/options.h" "${MDBX_SOURCE_DIR}/base.h"
"${MDBX_SOURCE_DIR}/internals.h" "${MDBX_SOURCE_DIR}/osal.h" "${MDBX_SOURCE_DIR}/internals.h" "${MDBX_SOURCE_DIR}/osal.h"
"${MDBX_SOURCE_DIR}/core.c" "${MDBX_SOURCE_DIR}/osal.c" "${MDBX_SOURCE_DIR}/core.c" "${MDBX_SOURCE_DIR}/osal.c"
"${MDBX_SOURCE_DIR}/lck-posix.c" "${MDBX_SOURCE_DIR}/lck-windows.c") "${MDBX_SOURCE_DIR}/lck-posix.c")
if(NOT APPLE)
list(APPEND LIBMDBX_SOURCES "${MDBX_SOURCE_DIR}/lck-windows.c")
endif()
include_directories("${MDBX_SOURCE_DIR}") include_directories("${MDBX_SOURCE_DIR}")
endif() endif()
endif(MDBX_AMALGAMATED_SOURCE) endif(MDBX_AMALGAMATED_SOURCE)

View File

@ -1,7 +1,128 @@
ChangeLog ChangeLog
--------- ---------
## v0.11.8 at 2022-06-12 ## v0.12.1 (Positive Proxima) at 2022-08-24
The planned frontward release with new superior features on the day of 20 anniversary of [Positive Technologies](https://ptsecurty.com).
```
37 files changed, 7604 insertions(+), 7417 deletions(-)
Signed-off-by: Леонид Юрьев (Leonid Yuriev) <leo@yuriev.ru>
```
New:
- The `Big Foot` feature which significantly reduces GC overhead for processing large lists of retired pages from huge transactions.
Now _libmdbx_ avoid creating large chunks of PNLs (page number lists) which required a long sequences of free pages, aka large/overflow pages.
Thus avoiding searching, allocating and storing such sequences inside GC.
- Improved hot/online validation and checking of database pages both for more robustness and performance.
- New solid and fast method to latch meta-pages called `Troika`.
The minimum of memory barriers, reads, comparisons and conditional transitions are used.
- New `MDBX_VALIDATION` environment options to extra validation of DB structure and pages content for carefully/safe handling damaged or untrusted DB.
- Accelerated ×16/×8/×4 by AVX512/AVX2/SSE2/Neon implementations of search page sequences.
- Added the `gcrtime_seconds16dot16` counter to the "Page Operation Statistics" that accumulates time spent for GC searching and reclaiming.
- Copy-with-compactification now clears/zeroes unused gaps inside database pages.
- The `C` and `C++` APIs has been extended and/or refined to simplify using `wchar_t` pathnames.
On Windows the `mdbx_env_openW()`, ``mdbx_env_get_pathW()`()`, `mdbx_env_copyW()`, `mdbx_env_open_for_recoveryW()` are available for now,
but the `mdbx_env_get_path()` has been replaced in favor of `mdbx_env_get_pathW()`.
- Added explicit error message for Buildroot's Microblaze toolchain maintainers.
- Added `MDBX_MANAGE_BUILD_FLAGS` build options for CMake.
- Speed-up internal `bsearch`/`lower_bound` implementation using branchless tactic, including workaround for CLANG x86 optimiser bug.
- A lot internal refinement and micro-optimisations.
- Internally counted volume of dirty pages (unused for now but for coming features).
Fixes:
- Never use modern `__cxa_thread_atexit()` on Apple's OSes.
- Don't check owner for finished transactions.
- Fixed typo in `MDBX_EINVAL` which breaks MingGW builds with CLANG.
## v0.12.0 at 2022-06-19
Not a release but preparation for changing feature set and API.
-------------------------------------------------------------------------------
## v0.11.10 (the TriColor) at 2022-08-22
The stable bugfix release.
It is planned that this will be the last release of the v0.11 branch.
```
14 files changed, 263 insertions(+), 252 deletions(-)
Signed-off-by: Леонид Юрьев (Leonid Yuriev) <leo@yuriev.ru>
```
New:
- The C++ API has been refined to simplify support for `wchar_t` in path names.
- Added explicit error message for Buildroot's Microblaze toolchain maintainers.
Fixes:
- Never use modern `__cxa_thread_atexit()` on Apple's OSes.
- Use `MultiByteToWideChar(CP_THREAD_ACP)` instead of `mbstowcs()`.
- Don't check owner for finished transactions.
- Fixed typo in `MDBX_EINVAL` which breaks MingGW builds with CLANG.
Minors:
- Fixed variable name typo.
- Using `ldd` to check used dso.
- Added `MDBX_WEAK_IMPORT_ATTRIBUTE` macro.
- Use current transaction geometry for untouched parameters when `env_set_geometry()` called within a write transaction.
- Minor clarified `iov_page()` failure case.
-------------------------------------------------------------------------------
## v0.11.9 (Чирчик-1992) at 2022-08-02
The stable bugfix release.
```
18 files changed, 318 insertions(+), 178 deletions(-)
Signed-off-by: Леонид Юрьев (Leonid Yuriev) <leo@yuriev.ru>
```
Acknowledgements:
- [Alex Sharov](https://github.com/AskAlexSharov) and Erigon team for reporting and testing.
- [Andrew Ashikhmin](https://gitflic.ru/user/yperbasis) for contributing.
New:
- Ability to customise `MDBX_LOCK_SUFFIX`, `MDBX_DATANAME`, `MDBX_LOCKNAME` just by predefine ones during build.
- Added to [`mdbx::env_managed`](https://libmdbx.dqdkfa.ru/group__cxx__api.html#classmdbx_1_1env__managed)'s methods a few overloads with `const char* pathname` parameter (C++ API).
Fixes:
- Fixed hang copy-with-compactification of a corrupted DB
or in case the volume of output pages is a multiple of `MDBX_ENVCOPY_WRITEBUF`.
- Fixed standalone non-CMake build on MacOS (`#include AvailabilityMacros.h>`).
- Fixed unexpected `MDBX_PAGE_FULL` error in rare cases with large database page sizes.
Minors:
- Minor fixes Doxygen references, comments, descriptions, etc.
- Fixed copy&paste typo inside `meta_checktxnid()`.
- Minor fix `meta_checktxnid()` to avoid assertion in debug mode.
- Minor fix `mdbx_env_set_geometry()` to avoid returning `EINVAL` in particular rare cases.
- Minor refine/fix batch-get testcase for large page size.
- Added `--pagesize NN` option to long-stotastic test script.
- Updated Valgrind-suppressions file for modern GCC.
- Fixed `has no symbols` warning from Apple's ranlib.
-------------------------------------------------------------------------------
## v0.11.8 (Baked Apple) at 2022-06-12
The stable release with an important fixes and workaround for the critical macOS thread-local-storage issue.
Acknowledgements: Acknowledgements:
@ -25,6 +146,7 @@ Fixes:
- Fixed `mdbx_check_fs_local()` for CDROM case on Windows. - Fixed `mdbx_check_fs_local()` for CDROM case on Windows.
- Fixed nasty typo of typename which caused false `MDBX_CORRUPTED` error in a rare execution path, - Fixed nasty typo of typename which caused false `MDBX_CORRUPTED` error in a rare execution path,
when the size of the thread-ID type not equal to 8. when the size of the thread-ID type not equal to 8.
- Fixed Elbrus/E2K LCC 1.26 compiler warnings (memory model for atomic operations, etc).
- Fixed write-after-free memory corruption on latest `macOS` during finalization/cleanup of thread(s) that executed read transaction(s). - Fixed write-after-free memory corruption on latest `macOS` during finalization/cleanup of thread(s) that executed read transaction(s).
> The issue was suddenly discovered by a [CI](https://en.wikipedia.org/wiki/Continuous_integration) > The issue was suddenly discovered by a [CI](https://en.wikipedia.org/wiki/Continuous_integration)
> after adding an iteration with macOS 11 "Big Sur", and then reproduced on recent release of macOS 12 "Monterey". > after adding an iteration with macOS 11 "Big Sur", and then reproduced on recent release of macOS 12 "Monterey".
@ -36,7 +158,6 @@ Fixes:
> This is unexpected crazy-like behavior since the order of resources releasing/destroying > This is unexpected crazy-like behavior since the order of resources releasing/destroying
> is not the reverse of ones acquiring/construction order. Nonetheless such surprise > is not the reverse of ones acquiring/construction order. Nonetheless such surprise
> is now workarounded by using atomic compare-and-swap operations on a 64-bit signatures/cookies. > is now workarounded by using atomic compare-and-swap operations on a 64-bit signatures/cookies.
- Fixed Elbrus/E2K LCC 1.26 compiler warnings (memory model for atomic operations, etc).
Minors: Minors:
@ -51,7 +172,8 @@ Minors:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
## v0.11.7 at 2022-04-22
## v0.11.7 (Resurrected Sarmat) at 2022-04-22
The stable risen release after the Github's intentional malicious disaster. The stable risen release after the Github's intentional malicious disaster.

View File

@ -53,8 +53,9 @@ CFLAGS_EXTRA ?=
LD ?= ld LD ?= ld
# build options # build options
MDBX_BUILD_OPTIONS ?=-DNDEBUG=1 MDBX_BUILD_OPTIONS ?=-DNDEBUG=1
MDBX_BUILD_TIMESTAMP ?=$(shell date +%Y-%m-%dT%H:%M:%S%z) MDBX_BUILD_TIMESTAMP ?=$(shell date +%Y-%m-%dT%H:%M:%S%z)
MDBX_BUILD_CXX ?= YES
# probe and compose common compiler flags with variable expansion trick (seems this work two times per session for GNU Make 3.81) # probe and compose common compiler flags with variable expansion trick (seems this work two times per session for GNU Make 3.81)
CFLAGS ?= $(strip $(eval CFLAGS := -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes $$(shell for opt in -fno-semantic-interposition -Wno-unused-command-line-argument -Wno-tautological-compare; do [ -z "$$$$($(CC) '-DMDBX_BUILD_FLAGS="probe"' $$$${opt} -c $(SRC_PROBE_C) -o /dev/null >/dev/null 2>&1 || echo failed)" ] && echo "$$$${opt} "; done)$(CFLAGS_EXTRA))$(CFLAGS)) CFLAGS ?= $(strip $(eval CFLAGS := -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes $$(shell for opt in -fno-semantic-interposition -Wno-unused-command-line-argument -Wno-tautological-compare; do [ -z "$$$$($(CC) '-DMDBX_BUILD_FLAGS="probe"' $$$${opt} -c $(SRC_PROBE_C) -o /dev/null >/dev/null 2>&1 || echo failed)" ] && echo "$$$${opt} "; done)$(CFLAGS_EXTRA))$(CFLAGS))
@ -127,6 +128,9 @@ TIP := // TIP:
.PHONY: all help options lib libs tools clean install uninstall check_buildflags_tag tools-static .PHONY: all help options lib libs tools clean install uninstall check_buildflags_tag tools-static
.PHONY: install-strip install-no-strip strip libmdbx mdbx show-options lib-static lib-shared .PHONY: install-strip install-no-strip strip libmdbx mdbx show-options lib-static lib-shared
boolean = $(if $(findstring $(strip $($1)),YES Yes yes y ON On on 1 true True TRUE),1,$(if $(findstring $(strip $($1)),NO No no n OFF Off off 0 false False FALSE),,$(error Wrong value `$($1)` of $1 for YES/NO option)))
select_by = $(if $(call boolean,$(1)),$(2),$(3))
ifeq ("$(origin V)", "command line") ifeq ("$(origin V)", "command line")
MDBX_BUILD_VERBOSE := $(V) MDBX_BUILD_VERBOSE := $(V)
endif endif
@ -134,7 +138,7 @@ ifndef MDBX_BUILD_VERBOSE
MDBX_BUILD_VERBOSE := 0 MDBX_BUILD_VERBOSE := 0
endif endif
ifeq ($(MDBX_BUILD_VERBOSE),1) ifeq ($(call boolean,MDBX_BUILD_VERBOSE),1)
QUIET := QUIET :=
HUSH := HUSH :=
$(info $(TIP) Use `make V=0` for quiet.) $(info $(TIP) Use `make V=0` for quiet.)
@ -169,12 +173,12 @@ help:
show-options: show-options:
@echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)" @echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)"
@echo " MDBX_BUILD_CXX = $(MDBX_BUILD_CXX)"
@echo " MDBX_BUILD_TIMESTAMP = $(MDBX_BUILD_TIMESTAMP)" @echo " MDBX_BUILD_TIMESTAMP = $(MDBX_BUILD_TIMESTAMP)"
@echo '$(TIP) Use `make options` to listing available build options.' @echo '$(TIP) Use `make options` to listing available build options.'
@echo " CC =`which $(CC)` | `$(CC) --version | head -1`" @echo $(call select_by,MDBX_BUILD_CXX," CXX =`which $(CXX)` | `$(CXX) --version | head -1`"," CC =`which $(CC)` | `$(CC) --version | head -1`")
@echo " CFLAGS =$(CFLAGS)" @echo $(call select_by,MDBX_BUILD_CXX," CXXFLAGS =$(CXXFLAGS)"," CFLAGS =$(CFLAGS)")
@echo " CXXFLAGS =$(CXXFLAGS)" @echo $(call select_by,MDBX_BUILD_CXX," LDFLAGS =$(LDFLAGS) $(LIB_STDCXXFS) $(LIBS) $(EXE_LDFLAGS)"," LDFLAGS =$(LDFLAGS) $(LIBS) $(EXE_LDFLAGS)")
@echo " LDFLAGS =$(LDFLAGS) $(LIB_STDCXXFS) $(LIBS) $(EXE_LDFLAGS)"
@echo '$(TIP) Use `make help` to listing available targets.' @echo '$(TIP) Use `make help` to listing available targets.'
options: options:
@ -221,7 +225,7 @@ clean:
config.h src/config.h src/version.c *.tar* buildflags.tag \ config.h src/config.h src/version.c *.tar* buildflags.tag \
mdbx_*.static mdbx_*.static-lto mdbx_*.static mdbx_*.static-lto
MDBX_BUILD_FLAGS =$(strip $(MDBX_BUILD_OPTIONS) $(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)) MDBX_BUILD_FLAGS =$(strip MDBX_BUILD_CXX=$(MDBX_BUILD_CXX) $(MDBX_BUILD_OPTIONS) $(call select_by,MDBX_BUILD_CXX,$(CXXFLAGS) $(LDFLAGS) $(LIB_STDCXXFS) $(LIBS),$(CFLAGS) $(LDFLAGS) $(LIBS)))
check_buildflags_tag: check_buildflags_tag:
$(QUIET)if [ "$(MDBX_BUILD_FLAGS)" != "$$(cat buildflags.tag 2>&1)" ]; then \ $(QUIET)if [ "$(MDBX_BUILD_FLAGS)" != "$$(cat buildflags.tag 2>&1)" ]; then \
echo -n " CLEAN for build with specified flags..." && \ echo -n " CLEAN for build with specified flags..." && \
@ -231,13 +235,13 @@ check_buildflags_tag:
buildflags.tag: check_buildflags_tag buildflags.tag: check_buildflags_tag
lib-static libmdbx.a: mdbx-static.o mdbx++-static.o lib-static libmdbx.a: mdbx-static.o $(call select_by,MDBX_BUILD_CXX,mdbx++-static.o)
@echo ' AR $@' @echo ' AR $@'
$(QUIET)$(AR) rcs $@ $? $(HUSH) $(QUIET)$(AR) rcs $@ $? $(HUSH)
lib-shared libmdbx.$(SO_SUFFIX): mdbx-dylib.o mdbx++-dylib.o lib-shared libmdbx.$(SO_SUFFIX): mdbx-dylib.o $(call select_by,MDBX_BUILD_CXX,mdbx++-dylib.o)
@echo ' LD $@' @echo ' LD $@'
$(QUIET)$(CXX) $(CXXFLAGS) $^ -pthread -shared $(LDFLAGS) $(LIB_STDCXXFS) $(LIBS) -o $@ $(QUIET)$(call select_by,MDBX_BUILD_CXX,$(CXX) $(CXXFLAGS),$(CC) $(CFLAGS)) $^ -pthread -shared $(LDFLAGS) $(call select_by,MDBX_BUILD_CXX,$(LIB_STDCXXFS)) $(LIBS) -o $@
################################################################################ ################################################################################
@ -340,13 +344,13 @@ else
define bench-rule define bench-rule
bench-$(1)_$(2).txt: $(3) $(IOARENA) $(lastword $(MAKEFILE_LIST)) bench-$(1)_$(2).txt: $(3) $(IOARENA) $(lastword $(MAKEFILE_LIST))
@echo ' RUNNING ioarena for $1/$2...' @echo ' RUNNING ioarena for $1/$2...'
$(QUIET)LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}" \ $(QUIET)(export LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}"; \
ldd $(IOARENA) && \
$(IOARENA) -D $(1) -B crud -m $(BENCH_CRUD_MODE) -n $(2) \ $(IOARENA) -D $(1) -B crud -m $(BENCH_CRUD_MODE) -n $(2) \
| tee $$@ | grep throughput && \ | tee $$@ | grep throughput && \
LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}" \ $(IOARENA) -D $(1) -B iterate,get,iterate,get,iterate -m $(BENCH_CRUD_MODE) -r 4 -n $(2) \
$(IOARENA) -D $(1) -B get,iterate -m $(BENCH_CRUD_MODE) -r 4 -n $(2) \ | tee -a $$@ | grep throughput \
| tee -a $$@ | grep throughput \ ) || mv -f $$@ $$@.error
|| mv -f $$@ $$@.error
endef endef

View File

@ -97,6 +97,24 @@ _MithrilDB_ is a rightly relevant name.
<!-- section-end --> <!-- section-end -->
```
$ objdump -f -h -j .text libmdbx.so
libmdbx.so: формат файла elf64-e2k
архитектура: elbrus-v6:64, флаги 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
начальный адрес 0x0000000000021680
Разделы:
Idx Name Разм VMA LMA Фа смещ. Выр.
10 .text 000ddd28 0000000000021680 0000000000021680 00021680 2**3
CONTENTS, ALLOC, LOAD, READONLY, CODE
$ cc --version
lcc:1.26.12:Jun-05-2022:e2k-v6-linux
gcc (GCC) 9.3.0 compatible
```
----- -----
## Table of Contents ## Table of Contents
@ -376,20 +394,20 @@ since release the version 1.0.
_libmdbx_ provides two official ways for integration in source code form: _libmdbx_ provides two official ways for integration in source code form:
1. Using the amalgamated source code. 1. Using an amalgamated source code which available in the [releases section](https://gitflic.ru/project/erthink/libmdbx/release) on GitFlic.
> The amalgamated source code includes all files required to build and > An amalgamated source code includes all files required to build and
> use _libmdbx_, but not for testing _libmdbx_ itself. > use _libmdbx_, but not for testing _libmdbx_ itself.
> Beside the releases an amalgamated sources could be created any time from the original clone of git
> repository on Linux by executing `make dist`. As a result, the desired
> set of files will be formed in the `dist` subdirectory.
2. Adding the complete original source code as a `git submodule`. 2. Adding the complete source code as a `git submodule` from the [origin git repository](https://gitflic.ru/project/erthink/libmdbx) on GitFlic.
> This allows you to build as _libmdbx_ and testing tool. > This allows you to build as _libmdbx_ and testing tool.
> On the other hand, this way requires you to pull git tags, and use C++11 compiler for test tool. > On the other hand, this way requires you to pull git tags, and use C++11 compiler for test tool.
_**Please, avoid using any other techniques.**_ Otherwise, at least _**Please, avoid using any other techniques.**_ Otherwise, at least
don't ask for support and don't name such chimeras `libmdbx`. don't ask for support and don't name such chimeras `libmdbx`.
The amalgamated source code could be created from the original clone of git
repository on Linux by executing `make dist`. As a result, the desired
set of files will be formed in the `dist` subdirectory.
## Building and Testing ## Building and Testing

View File

@ -1 +1 @@
0.11.8.0 0.12.1.0

View File

@ -26,7 +26,7 @@
#ifndef MDBX_TRUST_RTC_AUTO #ifndef MDBX_TRUST_RTC_AUTO
#cmakedefine01 MDBX_TRUST_RTC #cmakedefine01 MDBX_TRUST_RTC
#endif #endif
#cmakedefine01 MDBX_DISABLE_PAGECHECKS #cmakedefine01 MDBX_DISABLE_VALIDATION
/* Windows */ /* Windows */
#cmakedefine01 MDBX_WITHOUT_MSVC_CRT #cmakedefine01 MDBX_WITHOUT_MSVC_CRT

View File

@ -1,6 +1,6 @@
.\" Copyright 2015-2022 Leonid Yuriev <leo@yuriev.ru>. .\" Copyright 2015-2022 Leonid Yuriev <leo@yuriev.ru>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_CHK 1 "2022-04-22" "MDBX 0.11.8" .TH MDBX_CHK 1 "2022-08-24" "MDBX 0.12.1"
.SH NAME .SH NAME
mdbx_chk \- MDBX checking tool mdbx_chk \- MDBX checking tool
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -2,7 +2,7 @@
.\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_COPY 1 "2022-04-22" "MDBX 0.11.8" .TH MDBX_COPY 1 "2022-08-24" "MDBX 0.12.1"
.SH NAME .SH NAME
mdbx_copy \- MDBX environment copy tool mdbx_copy \- MDBX environment copy tool
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -1,7 +1,7 @@
.\" Copyright 2021-2022 Leonid Yuriev <leo@yuriev.ru>. .\" Copyright 2021-2022 Leonid Yuriev <leo@yuriev.ru>.
.\" Copyright 2014-2021 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2014-2021 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_DROP 1 "2022-04-22" "MDBX 0.11.8" .TH MDBX_DROP 1 "2022-08-24" "MDBX 0.12.1"
.SH NAME .SH NAME
mdbx_drop \- MDBX database delete tool mdbx_drop \- MDBX database delete tool
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -2,7 +2,7 @@
.\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_DUMP 1 "2022-04-22" "MDBX 0.11.8" .TH MDBX_DUMP 1 "2022-08-24" "MDBX 0.12.1"
.SH NAME .SH NAME
mdbx_dump \- MDBX environment export tool mdbx_dump \- MDBX environment export tool
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -2,7 +2,7 @@
.\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_LOAD 1 "2022-04-22" "MDBX 0.11.8" .TH MDBX_LOAD 1 "2022-08-24" "MDBX 0.12.1"
.SH NAME .SH NAME
mdbx_load \- MDBX environment import tool mdbx_load \- MDBX environment import tool
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -2,7 +2,7 @@
.\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDBX_STAT 1 "2022-04-22" "MDBX 0.11.8" .TH MDBX_STAT 1 "2022-08-24" "MDBX 0.12.1"
.SH NAME .SH NAME
mdbx_stat \- MDBX environment status tool mdbx_stat \- MDBX environment status tool
.SH SYNOPSIS .SH SYNOPSIS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -626,9 +626,9 @@ typedef mode_t mdbx_mode_t;
extern "C" { extern "C" {
#endif #endif
/* MDBX version 0.11.x */ /* MDBX version 0.12.x */
#define MDBX_VERSION_MAJOR 0 #define MDBX_VERSION_MAJOR 0
#define MDBX_VERSION_MINOR 11 #define MDBX_VERSION_MINOR 12
#ifndef LIBMDBX_API #ifndef LIBMDBX_API
#if defined(LIBMDBX_EXPORTS) #if defined(LIBMDBX_EXPORTS)
@ -824,13 +824,33 @@ enum MDBX_constants {
/* THE FILES ******************************************************************* /* THE FILES *******************************************************************
* At the file system level, the environment corresponds to a pair of files. */ * At the file system level, the environment corresponds to a pair of files. */
/** \brief The name of the lock file in the environment */ #ifndef MDBX_LOCKNAME
/** \brief The name of the lock file in the environment
* without using \ref MDBX_NOSUBDIR */
#if !(defined(_WIN32) || defined(_WIN64))
#define MDBX_LOCKNAME "/mdbx.lck" #define MDBX_LOCKNAME "/mdbx.lck"
/** \brief The name of the data file in the environment */ #else
#define MDBX_LOCKNAME L"\\mdbx.lck"
#endif
#endif /* MDBX_LOCKNAME */
#ifndef MDBX_DATANAME
/** \brief The name of the data file in the environment
* without using \ref MDBX_NOSUBDIR */
#if !(defined(_WIN32) || defined(_WIN64))
#define MDBX_DATANAME "/mdbx.dat" #define MDBX_DATANAME "/mdbx.dat"
#else
#define MDBX_DATANAME L"\\mdbx.dat"
#endif
#endif /* MDBX_DATANAME */
#ifndef MDBX_LOCK_SUFFIX
/** \brief The suffix of the lock file when \ref MDBX_NOSUBDIR is used */ /** \brief The suffix of the lock file when \ref MDBX_NOSUBDIR is used */
#if !(defined(_WIN32) || defined(_WIN64))
#define MDBX_LOCK_SUFFIX "-lck" #define MDBX_LOCK_SUFFIX "-lck"
#else
#define MDBX_LOCK_SUFFIX L"-lck"
#endif
#endif /* MDBX_LOCK_SUFFIX */
/* DEBUG & LOGGING ************************************************************/ /* DEBUG & LOGGING ************************************************************/
@ -1015,6 +1035,13 @@ LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg,
enum MDBX_env_flags_t { enum MDBX_env_flags_t {
MDBX_ENV_DEFAULTS = 0, MDBX_ENV_DEFAULTS = 0,
/** Extra validation of DB structure and pages content.
*
* The `MDBX_VALIDATION` enabled the simple safe/careful mode for working
* with damaged or untrusted DB. However, a notable performance
* degradation should be expected. */
MDBX_VALIDATION = UINT32_C(0x00002000),
/** No environment directory. /** No environment directory.
* *
* By default, MDBX creates its environment in a directory whose pathname is * By default, MDBX creates its environment in a directory whose pathname is
@ -1087,8 +1114,8 @@ enum MDBX_env_flags_t {
* while opening the database/environment which is already used by another * while opening the database/environment which is already used by another
* process(es) with unknown mode/flags. In such cases, if there is a * process(es) with unknown mode/flags. In such cases, if there is a
* difference in the specified flags (\ref MDBX_NOMETASYNC, * difference in the specified flags (\ref MDBX_NOMETASYNC,
* \ref MDBX_SAFE_NOSYNC, \ref MDBX_UTTERLY_NOSYNC, \ref MDBX_LIFORECLAIM, * \ref MDBX_SAFE_NOSYNC, \ref MDBX_UTTERLY_NOSYNC, \ref MDBX_LIFORECLAIM
* \ref MDBX_COALESCE and \ref MDBX_NORDAHEAD), instead of returning an error, * and \ref MDBX_NORDAHEAD), instead of returning an error,
* the database will be opened in a compatibility with the already used mode. * the database will be opened in a compatibility with the already used mode.
* *
* `MDBX_ACCEDE` has no effect if the current process is the only one either * `MDBX_ACCEDE` has no effect if the current process is the only one either
@ -1195,6 +1222,7 @@ enum MDBX_env_flags_t {
MDBX_NOMEMINIT = UINT32_C(0x1000000), MDBX_NOMEMINIT = UINT32_C(0x1000000),
/** Aims to coalesce a Garbage Collection items. /** Aims to coalesce a Garbage Collection items.
* \note Always enabled since v0.12
* *
* With `MDBX_COALESCE` flag MDBX will aims to coalesce items while recycling * With `MDBX_COALESCE` flag MDBX will aims to coalesce items while recycling
* a Garbage Collection. Technically, when possible short lists of pages * a Garbage Collection. Technically, when possible short lists of pages
@ -2259,6 +2287,11 @@ LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env,
LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname,
MDBX_env_flags_t flags, mdbx_mode_t mode); MDBX_env_flags_t flags, mdbx_mode_t mode);
#if defined(_WIN32) || defined(_WIN64)
LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathnameW,
MDBX_env_flags_t flags, mdbx_mode_t mode);
#endif /* Windows */
/** \brief Deletion modes for \ref mdbx_env_delete(). /** \brief Deletion modes for \ref mdbx_env_delete().
* \ingroup c_extra * \ingroup c_extra
* \see mdbx_env_delete() */ * \see mdbx_env_delete() */
@ -2301,6 +2334,10 @@ typedef enum MDBX_env_delete_mode_t MDBX_env_delete_mode_t;
* so no deletion was performed. */ * so no deletion was performed. */
LIBMDBX_API int mdbx_env_delete(const char *pathname, LIBMDBX_API int mdbx_env_delete(const char *pathname,
MDBX_env_delete_mode_t mode); MDBX_env_delete_mode_t mode);
#if defined(_WIN32) || defined(_WIN64)
LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathnameW,
MDBX_env_delete_mode_t mode);
#endif /* Windows */
/** \brief Copy an MDBX environment to the specified path, with options. /** \brief Copy an MDBX environment to the specified path, with options.
* \ingroup c_extra * \ingroup c_extra
@ -2335,6 +2372,10 @@ LIBMDBX_API int mdbx_env_delete(const char *pathname,
* \returns A non-zero error value on failure and 0 on success. */ * \returns A non-zero error value on failure and 0 on success. */
LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest,
MDBX_copy_flags_t flags); MDBX_copy_flags_t flags);
#if defined(_WIN32) || defined(_WIN64)
LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest,
MDBX_copy_flags_t flags);
#endif /* Windows */
/** \brief Copy an environment to the specified file descriptor, with /** \brief Copy an environment to the specified file descriptor, with
* options. * options.
@ -2482,6 +2523,9 @@ struct MDBX_envinfo {
uint64_t unspill; /**< Quantity of unspilled/reloaded pages */ uint64_t unspill; /**< Quantity of unspilled/reloaded pages */
uint64_t wops; /**< Number of explicit write operations (not a pages) uint64_t wops; /**< Number of explicit write operations (not a pages)
to a disk */ to a disk */
uint64_t
gcrtime_seconds16dot16; /**< Time spent loading and searching inside
GC (aka FreeDB) in 1/65536 of second. */
} mi_pgop_stat; } mi_pgop_stat;
}; };
#ifndef __cplusplus #ifndef __cplusplus
@ -2784,7 +2828,11 @@ LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
* \returns A non-zero error value on failure and 0 on success, * \returns A non-zero error value on failure and 0 on success,
* some possible errors are: * some possible errors are:
* \retval MDBX_EINVAL An invalid parameter was specified. */ * \retval MDBX_EINVAL An invalid parameter was specified. */
#if !(defined(_WIN32) || defined(_WIN64))
LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest); LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
#else
LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
#endif /* Windows */
/** \brief Return the file descriptor for the given environment. /** \brief Return the file descriptor for the given environment.
* \ingroup c_statinfo * \ingroup c_statinfo
@ -5055,11 +5103,12 @@ LIBMDBX_API int mdbx_thread_unregister(const MDBX_env *env);
* this value into account to evaluate the impact that * this value into account to evaluate the impact that
* a long-running transaction has. * a long-running transaction has.
* \param [in] retry A retry number starting from 0. * \param [in] retry A retry number starting from 0.
* If callback has returned 0 at least once, then at end * If callback has returned 0 at least once, then at end of
* of current handling loop the callback function will be * current handling loop the callback function will be
* called additionally with negative value to notify about * called additionally with negative `retry` value to notify
* the end of loop. The callback function can use this value * about the end of loop. The callback function can use this
* to implement timeout logic while waiting for readers. * fact to implement timeout reset logic while waiting for
* a readers.
* *
* \returns The RETURN CODE determines the further actions libmdbx and must * \returns The RETURN CODE determines the further actions libmdbx and must
* match the action which was executed by the callback: * match the action which was executed by the callback:
@ -5082,7 +5131,7 @@ LIBMDBX_API int mdbx_thread_unregister(const MDBX_env *env);
* \retval 1 Transaction aborted asynchronous and reader slot * \retval 1 Transaction aborted asynchronous and reader slot
* should be cleared immediately, i.e. read transaction * should be cleared immediately, i.e. read transaction
* will not continue but \ref mdbx_txn_abort() * will not continue but \ref mdbx_txn_abort()
* or \ref mdbx_txn_reset() will be called later. * nor \ref mdbx_txn_reset() will be called later.
* *
* \retval 2 or great The reader process was terminated or killed, * \retval 2 or great The reader process was terminated or killed,
* and libmdbx should entirely reset reader registration. * and libmdbx should entirely reset reader registration.
@ -5175,6 +5224,12 @@ LIBMDBX_API int mdbx_env_pgwalk(MDBX_txn *txn, MDBX_pgvisitor_func *visitor,
LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname, LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname,
unsigned target_meta, unsigned target_meta,
bool writeable); bool writeable);
#if defined(_WIN32) || defined(_WIN64)
LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env,
const wchar_t *pathnameW,
unsigned target_meta,
bool writeable);
#endif /* Windows */
/** \brief Turn database to the specified meta-page. /** \brief Turn database to the specified meta-page.
* *
@ -5185,230 +5240,8 @@ LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
/** end of btree_traversal @} */ /** end of btree_traversal @} */
/**** Attribute support functions for Nexenta (scheduled for removal)
* *****************************************************************/
#if defined(MDBX_NEXENTA_ATTRS) || defined(DOXYGEN)
/** \defgroup nexenta Attribute support functions for Nexenta
* \ingroup c_crud
* @{ */
typedef uint_fast64_t mdbx_attr_t;
/** Store by cursor with attribute.
*
* This function stores key/data pairs into the database. The cursor is
* positioned at the new item, or on failure usually near it.
*
* \note Internally based on \ref MDBX_RESERVE feature,
* therefore doesn't support \ref MDBX_DUPSORT.
*
* \param [in] cursor A cursor handle returned by \ref mdbx_cursor_open()
* \param [in] key The key operated on.
* \param [in] data The data operated on.
* \param [in] attr The attribute.
* \param [in] flags Options for this operation. This parameter must be set
* to 0 or one of the values described here:
* - \ref MDBX_CURRENT
* Replace the item at the current cursor position. The key parameter
* must still be provided, and must match it, otherwise the function
* return \ref MDBX_EKEYMISMATCH.
*
* - \ref MDBX_APPEND
* Append the given key/data pair to the end of the database. No key
* comparisons are performed. This option allows fast bulk loading when
* keys are already known to be in the correct order. Loading unsorted
* keys with this flag will cause a \ref MDBX_KEYEXIST error.
*
* \see \ref c_crud_hints "Quick reference for Insert/Update/Delete operations"
*
* \returns A non-zero error value on failure and 0 on success,
* some possible errors are:
* \retval MDBX_EKEYMISMATCH
* \retval MDBX_MAP_FULL The database is full, see \ref mdbx_env_set_mapsize().
* \retval MDBX_TXN_FULL The transaction has too many dirty pages.
* \retval MDBX_EACCES An attempt was made to write in a read-only
* transaction.
* \retval MDBX_EINVAL an invalid parameter was specified. */
LIBMDBX_API int mdbx_cursor_put_attr(MDBX_cursor *cursor, MDBX_val *key,
MDBX_val *data, mdbx_attr_t attr,
MDBX_put_flags_t flags);
/** Store items and attributes into a database.
*
* This function stores key/data pairs in the database. The default behavior
* is to enter the new key/data pair, replacing any previously existing key
* if duplicates are disallowed.
*
* \note Internally based on \ref MDBX_RESERVE feature,
* therefore doesn't support \ref MDBX_DUPSORT.
*
* \param [in] txn A transaction handle returned by \ref mdbx_txn_begin().
* \param [in] dbi A database handle returned by \ref mdbx_dbi_open().
* \param [in] key The key to store in the database.
* \param [in] attr The attribute to store in the database.
* \param [in,out] data The data to store.
* \param [in] flags Special options for this operation. This parameter
* must be set to 0 or by bitwise OR'ing together one or
* more of the values described here:
* - \ref MDBX_NOOVERWRITE
* Enter the new key/data pair only if the key does not already appear
* in the database. The function will return \ref MDBX_KEYEXIST if the key
* already appears in the database. The data parameter will be set to
* point to the existing item.
*
* - \ref MDBX_CURRENT
* Update an single existing entry, but not add new ones. The function
* will return \ref MDBX_NOTFOUND if the given key not exist in the
* database. Or the \ref MDBX_EMULTIVAL in case duplicates for the given
* key.
*
* - \ref MDBX_APPEND
* Append the given key/data pair to the end of the database. This option
* allows fast bulk loading when keys are already known to be in the
* correct order. Loading unsorted keys with this flag will cause
* a \ref MDBX_EKEYMISMATCH error.
*
* \see \ref c_crud_hints "Quick reference for Insert/Update/Delete operations"
*
* \returns A non-zero error value on failure and 0 on success,
* some possible errors are:
* \retval MDBX_KEYEXIST
* \retval MDBX_MAP_FULL The database is full, see \ref mdbx_env_set_mapsize().
* \retval MDBX_TXN_FULL The transaction has too many dirty pages.
* \retval MDBX_EACCES An attempt was made to write
* in a read-only transaction.
* \retval MDBX_EINVAL An invalid parameter was specified. */
LIBMDBX_API int mdbx_put_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
MDBX_val *data, mdbx_attr_t attr,
MDBX_put_flags_t flags);
/** Set items attribute from a database.
*
* This function stores key/data pairs attribute to the database.
*
* \note Internally based on \ref MDBX_RESERVE feature,
* therefore doesn't support \ref MDBX_DUPSORT.
*
* \param [in] txn A transaction handle returned by \ref mdbx_txn_begin().
* \param [in] dbi A database handle returned by \ref mdbx_dbi_open().
* \param [in] key The key to search for in the database.
* \param [in] data The data to be stored or NULL to save previous value.
* \param [in] attr The attribute to be stored.
*
* \returns A non-zero error value on failure and 0 on success,
* some possible errors are:
* \retval MDBX_NOTFOUND The key-value pair was not in the database.
* \retval MDBX_EINVAL An invalid parameter was specified. */
LIBMDBX_API int mdbx_set_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
MDBX_val *data, mdbx_attr_t attr);
/** Get items attribute from a database cursor.
*
* This function retrieves key/data pairs from the database. The address and
* length of the key are returned in the object to which key refers (except
* for the case of the \ref MDBX_SET option, in which the key object is
* unchanged), and the address and length of the data are returned in the object
* to which data refers.
* \see mdbx_get()
*
* \param [in] cursor A cursor handle returned by \ref mdbx_cursor_open().
* \param [in,out] key The key for a retrieved item.
* \param [in,out] data The data of a retrieved item.
* \param [out] pattr The pointer to retrieve attribute.
* \param [in] op A cursor operation MDBX_cursor_op.
*
* \returns A non-zero error value on failure and 0 on success,
* some possible errors are:
* \retval MDBX_NOTFOUND No matching key found.
* \retval MDBX_EINVAL An invalid parameter was specified. */
LIBMDBX_API int mdbx_cursor_get_attr(MDBX_cursor *cursor, MDBX_val *key,
MDBX_val *data, mdbx_attr_t *pattr,
MDBX_cursor_op op);
/** Get items attribute from a database.
*
* This function retrieves key/data pairs from the database. The address
* and length of the data associated with the specified key are returned
* in the structure to which data refers.
* If the database supports duplicate keys (see \ref MDBX_DUPSORT) then the
* first data item for the key will be returned. Retrieval of other
* items requires the use of \ref mdbx_cursor_get().
*
* \note The memory pointed to by the returned values is owned by the
* database. The caller need not dispose of the memory, and may not
* modify it in any way. For values returned in a read-only transaction
* any modification attempts will cause a `SIGSEGV`.
*
* \note Values returned from the database are valid only until a
* subsequent update operation, or the end of the transaction.
*
* \param [in] txn A transaction handle returned by \ref mdbx_txn_begin().
* \param [in] dbi A database handle returned by \ref mdbx_dbi_open().
* \param [in] key The key to search for in the database.
* \param [in,out] data The data corresponding to the key.
* \param [out] pattr The pointer to retrieve attribute.
*
* \returns A non-zero error value on failure and 0 on success,
* some possible errors are:
* \retval MDBX_NOTFOUND The key was not in the database.
* \retval MDBX_EINVAL An invalid parameter was specified. */
LIBMDBX_API int mdbx_get_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
MDBX_val *data, mdbx_attr_t *pattr);
/** end of nexenta @} */
#endif /* MDBX_NEXENTA_ATTRS */
/** end of c_api @} */ /** end of c_api @} */
/*******************************************************************************
* Workaround for mmaped-lookahead-cross-page-boundary bug
* in an obsolete versions of Elbrus's libc and kernels. */
#if defined(__e2k__) && defined(MDBX_E2K_MLHCPB_WORKAROUND) && \
MDBX_E2K_MLHCPB_WORKAROUND
LIBMDBX_API int mdbx_e2k_memcmp_bug_workaround(const void *s1, const void *s2,
size_t n);
LIBMDBX_API int mdbx_e2k_strcmp_bug_workaround(const char *s1, const char *s2);
LIBMDBX_API int mdbx_e2k_strncmp_bug_workaround(const char *s1, const char *s2,
size_t n);
LIBMDBX_API size_t mdbx_e2k_strlen_bug_workaround(const char *s);
LIBMDBX_API size_t mdbx_e2k_strnlen_bug_workaround(const char *s,
size_t maxlen);
#ifdef __cplusplus
namespace std {
inline int mdbx_e2k_memcmp_bug_workaround(const void *s1, const void *s2,
size_t n) {
return ::mdbx_e2k_memcmp_bug_workaround(s1, s2, n);
}
inline int mdbx_e2k_strcmp_bug_workaround(const char *s1, const char *s2) {
return ::mdbx_e2k_strcmp_bug_workaround(s1, s2);
}
inline int mdbx_e2k_strncmp_bug_workaround(const char *s1, const char *s2,
size_t n) {
return ::mdbx_e2k_strncmp_bug_workaround(s1, s2, n);
}
inline size_t mdbx_e2k_strlen_bug_workaround(const char *s) {
return ::mdbx_e2k_strlen_bug_workaround(s);
}
inline size_t mdbx_e2k_strnlen_bug_workaround(const char *s, size_t maxlen) {
return ::mdbx_e2k_strnlen_bug_workaround(s, maxlen);
}
} // namespace std
#endif /* __cplusplus */
#include <string.h>
#include <strings.h>
#undef memcmp
#define memcmp mdbx_e2k_memcmp_bug_workaround
#undef bcmp
#define bcmp mdbx_e2k_memcmp_bug_workaround
#undef strcmp
#define strcmp mdbx_e2k_strcmp_bug_workaround
#undef strncmp
#define strncmp mdbx_e2k_strncmp_bug_workaround
#undef strlen
#define strlen mdbx_e2k_strlen_bug_workaround
#undef strnlen
#define strnlen mdbx_e2k_strnlen_bug_workaround
#endif /* MDBX_E2K_MLHCPB_WORKAROUND */
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif

View File

@ -965,20 +965,21 @@ struct LIBMDBX_API_TYPE slice : public ::MDBX_val {
hash_value() const noexcept; hash_value() const noexcept;
/// \brief Three-way fast non-lexicographically length-based comparison. /// \brief Three-way fast non-lexicographically length-based comparison.
/// \return value: /// \details Firstly compares length and if it equal then compare content
/// == 0 if "a" == "b", /// lexicographically. \return value:
/// < 0 if "a" shorter than "b", /// `== 0` if `a` the same as `b`;
/// > 0 if "a" longer than "b", /// `< 0` if `a` shorter than `b`,
/// < 0 if "a" length-equal and lexicographically less than "b", /// or the same length and lexicographically less than `b`;
/// > 0 if "a" length-equal and lexicographically great than "b". /// `> 0` if `a` longer than `b`,
/// or the same length and lexicographically great than `b`.
MDBX_NOTHROW_PURE_FUNCTION static MDBX_CXX14_CONSTEXPR intptr_t MDBX_NOTHROW_PURE_FUNCTION static MDBX_CXX14_CONSTEXPR intptr_t
compare_fast(const slice &a, const slice &b) noexcept; compare_fast(const slice &a, const slice &b) noexcept;
/// \brief Three-way lexicographically comparison. /// \brief Three-way lexicographically comparison.
/// \return value: /// \return value:
/// < 0 if "a" < "b", /// `== 0` if `a` lexicographically equal `b`;
/// == 0 if "a" == "b", /// `< 0` if `a` lexicographically less than `b`;
/// > 0 if "a" > "b". /// `> 0` if `a` lexicographically great than `b`.
MDBX_NOTHROW_PURE_FUNCTION static MDBX_CXX14_CONSTEXPR intptr_t MDBX_NOTHROW_PURE_FUNCTION static MDBX_CXX14_CONSTEXPR intptr_t
compare_lexicographically(const slice &a, const slice &b) noexcept; compare_lexicographically(const slice &a, const slice &b) noexcept;
friend MDBX_CXX14_CONSTEXPR bool operator==(const slice &a, friend MDBX_CXX14_CONSTEXPR bool operator==(const slice &a,
@ -3224,9 +3225,13 @@ public:
#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN) #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
env &copy(const ::std::wstring &destination, bool compactify, env &copy(const ::std::wstring &destination, bool compactify,
bool force_dynamic_size = false); bool force_dynamic_size = false);
env &copy(const wchar_t *destination, bool compactify,
bool force_dynamic_size = false);
#endif /* Windows */ #endif /* Windows */
env &copy(const ::std::string &destination, bool compactify, env &copy(const ::std::string &destination, bool compactify,
bool force_dynamic_size = false); bool force_dynamic_size = false);
env &copy(const char *destination, bool compactify,
bool force_dynamic_size = false);
/// \brief Copy an environment to the specified file descriptor. /// \brief Copy an environment to the specified file descriptor.
env &copy(filehandle fd, bool compactify, bool force_dynamic_size = false); env &copy(filehandle fd, bool compactify, bool force_dynamic_size = false);
@ -3251,14 +3256,18 @@ public:
/// \brief Removes the environment's files in a proper and multiprocess-safe /// \brief Removes the environment's files in a proper and multiprocess-safe
/// way. /// way.
#ifdef MDBX_STD_FILESYSTEM_PATH #ifdef MDBX_STD_FILESYSTEM_PATH
static bool remove(const MDBX_STD_FILESYSTEM_PATH &, static bool remove(const MDBX_STD_FILESYSTEM_PATH &pathname,
const remove_mode mode = just_remove); const remove_mode mode = just_remove);
#endif /* MDBX_STD_FILESYSTEM_PATH */ #endif /* MDBX_STD_FILESYSTEM_PATH */
#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN) #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
static bool remove(const ::std::wstring &, static bool remove(const ::std::wstring &pathname,
const remove_mode mode = just_remove);
static bool remove(const wchar_t *pathname,
const remove_mode mode = just_remove); const remove_mode mode = just_remove);
#endif /* Windows */ #endif /* Windows */
static bool remove(const ::std::string &, static bool remove(const ::std::string &pathname,
const remove_mode mode = just_remove);
static bool remove(const char *pathname,
const remove_mode mode = just_remove); const remove_mode mode = just_remove);
/// \brief Statistics for a database in the MDBX environment. /// \brief Statistics for a database in the MDBX environment.
@ -3496,15 +3505,19 @@ public:
/// \brief Open existing database. /// \brief Open existing database.
#ifdef MDBX_STD_FILESYSTEM_PATH #ifdef MDBX_STD_FILESYSTEM_PATH
env_managed(const MDBX_STD_FILESYSTEM_PATH &, const operate_parameters &, env_managed(const MDBX_STD_FILESYSTEM_PATH &pathname,
bool accede = true); const operate_parameters &, bool accede = true);
#endif /* MDBX_STD_FILESYSTEM_PATH */ #endif /* MDBX_STD_FILESYSTEM_PATH */
#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN) #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
env_managed(const ::std::wstring &, const operate_parameters &, env_managed(const ::std::wstring &pathname, const operate_parameters &,
bool accede = true); bool accede = true);
explicit env_managed(const wchar_t *pathname, const operate_parameters &,
bool accede = true);
#endif /* Windows */ #endif /* Windows */
env_managed(const ::std::string &, const operate_parameters &, env_managed(const ::std::string &pathname, const operate_parameters &,
bool accede = true); bool accede = true);
explicit env_managed(const char *pathname, const operate_parameters &,
bool accede = true);
/// \brief Additional parameters for creating a new database. /// \brief Additional parameters for creating a new database.
struct create_parameters { struct create_parameters {
@ -3517,15 +3530,20 @@ public:
/// \brief Create new or open existing database. /// \brief Create new or open existing database.
#ifdef MDBX_STD_FILESYSTEM_PATH #ifdef MDBX_STD_FILESYSTEM_PATH
env_managed(const MDBX_STD_FILESYSTEM_PATH &, const create_parameters &, env_managed(const MDBX_STD_FILESYSTEM_PATH &pathname,
const operate_parameters &, bool accede = true); const create_parameters &, const operate_parameters &,
bool accede = true);
#endif /* MDBX_STD_FILESYSTEM_PATH */ #endif /* MDBX_STD_FILESYSTEM_PATH */
#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN) #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
env_managed(const ::std::wstring &, const create_parameters &, env_managed(const ::std::wstring &pathname, const create_parameters &,
const operate_parameters &, bool accede = true); const operate_parameters &, bool accede = true);
explicit env_managed(const wchar_t *pathname, const create_parameters &,
const operate_parameters &, bool accede = true);
#endif /* Windows */ #endif /* Windows */
env_managed(const ::std::string &, const create_parameters &, env_managed(const ::std::string &pathname, const create_parameters &,
const operate_parameters &, bool accede = true); const operate_parameters &, bool accede = true);
explicit env_managed(const char *pathname, const create_parameters &,
const operate_parameters &, bool accede = true);
/// \brief Explicitly closes the environment and release the memory map. /// \brief Explicitly closes the environment and release the memory map.
/// ///

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,8 @@ pub use crate::{
cursor::{Cursor, Iter, IterDup}, cursor::{Cursor, Iter, IterDup},
database::Database, database::Database,
environment::{ environment::{
Environment, EnvironmentBuilder, EnvironmentKind, Geometry, Info, NoWriteMap, Stat, Environment, EnvironmentBuilder, EnvironmentKind, Geometry, Info, NoWriteMap, PageSize,
WriteMap, Stat, WriteMap,
}, },
error::{Error, Result}, error::{Error, Result},
flags::*, flags::*,
@ -42,10 +42,8 @@ mod test_utils {
let env = { let env = {
let mut builder = Environment::new(); let mut builder = Environment::new();
builder.set_max_dbs(2); builder.set_max_dbs(2);
builder.set_geometry(Geometry { builder
size: Some(1_000_000..1_000_000), .set_geometry(Geometry { size: Some(1_000_000..1_000_000), ..Default::default() });
..Default::default()
});
builder.open(dir.path()).expect("open mdbx env") builder.open(dir.path()).expect("open mdbx env")
}; };
@ -53,11 +51,8 @@ mod test_utils {
let mut value = [0u8; 8]; let mut value = [0u8; 8];
LittleEndian::write_u64(&mut value, height); LittleEndian::write_u64(&mut value, height);
let tx = env.begin_rw_txn().expect("begin_rw_txn"); let tx = env.begin_rw_txn().expect("begin_rw_txn");
let index = tx let index = tx.create_db(None, DatabaseFlags::DUP_SORT).expect("open index db");
.create_db(None, DatabaseFlags::DUP_SORT) tx.put(&index, &HEIGHT_KEY, &value, WriteFlags::empty()).expect("tx.put");
.expect("open index db");
tx.put(&index, &HEIGHT_KEY, &value, WriteFlags::empty())
.expect("tx.put");
tx.commit().expect("tx.commit"); tx.commit().expect("tx.commit");
} }
} }

View File

@ -1,8 +1,8 @@
use libmdbx::*; use reth_libmdbx::*;
use std::borrow::Cow; use std::borrow::Cow;
use tempfile::tempdir; use tempfile::tempdir;
type Environment = libmdbx::Environment<NoWriteMap>; type Environment = reth_libmdbx::Environment<NoWriteMap>;
#[test] #[test]
fn test_get() { fn test_get() {

View File

@ -1,8 +1,8 @@
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use libmdbx::*; use reth_libmdbx::*;
use tempfile::tempdir; use tempfile::tempdir;
type Environment = libmdbx::Environment<NoWriteMap>; type Environment = reth_libmdbx::Environment<NoWriteMap>;
#[test] #[test]
fn test_open() { fn test_open() {

View File

@ -1,4 +1,4 @@
use libmdbx::*; use reth_libmdbx::*;
use std::{ use std::{
borrow::Cow, borrow::Cow,
io::Write, io::Write,
@ -7,7 +7,7 @@ use std::{
}; };
use tempfile::tempdir; use tempfile::tempdir;
type Environment = libmdbx::Environment<NoWriteMap>; type Environment = reth_libmdbx::Environment<NoWriteMap>;
#[test] #[test]
fn test_put_get_del() { fn test_put_get_del() {