diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 1e714eb3..e0863bad 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -19,6 +19,7 @@ alevel alexey alignas alldbs +ALLDUPS ALLEXTERNALS ALLINPUT allleaf @@ -28,6 +29,7 @@ ALLOCLEN allones ALLPOSTMESSAGE allthrough +alphabase AMAX amd amsmath @@ -55,6 +57,7 @@ asm asprintf aspx assection +atal atexit atfork attr @@ -68,6 +71,7 @@ autosync avalue AVPHYS badend +badpage bak bareos barrierattr @@ -134,6 +138,7 @@ cattr cbegin cch CCompiler +cctype cdefs cdnjs cdst @@ -177,7 +182,10 @@ condpair config constexpr copyable +copydetails +copydoc copyfd +copyfilerange copythr coredump coreos @@ -201,6 +209,7 @@ cstdarg cstddef cstdint cstr +cstring ctags ctest cthr @@ -210,6 +219,7 @@ ctx ctype ctz ctzl +currentkey cwalk cx cxa @@ -269,6 +279,7 @@ Desh dest DESTDIR devtoolset +df dgst DHTML diafile @@ -351,6 +362,7 @@ EFAULT EHa EHc EHsc +Ei EIDRM EINTR EINVAL @@ -420,6 +432,7 @@ Evensen's ewcommand EWOULDBLOCK Exa +exactkey exactp exe exename @@ -452,10 +465,12 @@ FILELIST fileno FILEPATH filesize +filesync filesystem filetime fillfactor Firefox +firstvalue fixedpoint FIXME flagbit @@ -584,6 +599,7 @@ HOSTUUID hpp hppa hpux +hrows htags htm html @@ -603,6 +619,7 @@ idx ieeetr ield ietf +iex IFBLK IFCHR ifdef @@ -668,6 +685,7 @@ isode isprint ISREG ISSET +isspace issuecomment istty isxdigit @@ -701,6 +719,7 @@ KEYEXIST keygen keygencase keylen +keymode keyptr keysize keyspace @@ -719,6 +738,7 @@ kval largedata largepage lastest +lastvalue lastword Launay lcc @@ -775,6 +795,8 @@ locktable LOGFILE loglevel LONGLONG +lowerbound +lowerboundvalue LPCSTR LPDWORD LPFILETIME @@ -839,6 +861,7 @@ MAYMOVE mbarrier mbstowcs mcount +mcst mday MDB mdbenv @@ -919,6 +942,7 @@ MRX msc mscfile msdn +msgpack msize mst msvc @@ -931,6 +955,7 @@ multiarch MULTILINE multimap MULTIOPEN +multivalue munmap Mup musl @@ -967,8 +992,11 @@ newindx newkey newpgno nexenta +nextkey +nextvalue nf nflags +nkey nkeys nlink nn @@ -1003,11 +1031,13 @@ NOOVERWRITE nops NOQEMU nordahead +NOREPLACE noreturn nospill nosubdir nosync NOTFOUND +notfound nothrow notls notracking @@ -1080,6 +1110,8 @@ osal osf oskari OSs +ostream +ostringstream osubgrouping osx ote @@ -1110,6 +1142,7 @@ pb pbuf PBYTE pcb +pchar pcount pcrf PDB @@ -1150,6 +1183,7 @@ pmax pmccntr pmcntenset pmedvedev +pmr pmuseren pmwkaa pn @@ -1174,6 +1208,8 @@ PREREQ prerequirements PRESORTED prevk +prevkey +prevvalue PRIa PRId PRIi @@ -1193,6 +1229,7 @@ projectnumber propget propput PROT +prot PSECTION pshared psrc @@ -1232,6 +1269,7 @@ quicksort Quinteiro qwest radvisory +RAII ramdev ramdisk ramfs @@ -1244,6 +1282,7 @@ rdata rdhwr RDLCK rdonly +rdp rdpmccntr rdrinfo rdt @@ -1259,6 +1298,7 @@ readlink README readonly READWRITE +readwrite realloc REALMEM REALPATH @@ -1321,6 +1361,7 @@ ru rusage rw samedata +samelength SAMSUNG savailable scalability @@ -1389,6 +1430,7 @@ SNAPTHREAD SNC snprintf Solaris +Soref sosuffix sourceforge sourcery @@ -1398,7 +1440,9 @@ spaceleft spage spanpgno sparc +SPDX spinics +Sporaw sprintf sqlite src @@ -1414,6 +1458,7 @@ SSDs sshfs ssize Sstimate +sstream Ssymbols standalone startuml @@ -1428,6 +1473,7 @@ stdatomic stdc stddef stderr +stdexcept STDGNU stdin stdint @@ -1487,6 +1533,7 @@ swait symas SYMLINKS syncbytes +syncfilerange syncmode syncperiod synctype @@ -1504,6 +1551,7 @@ sz tablename tagfile tagname +tailroom tarantool tarball tasklist @@ -1557,6 +1605,7 @@ tsd tsize ttf ttl +TVvqnwctdis tw twistylittlepassagesallalike txkey @@ -1606,6 +1655,8 @@ unregister unspill unsync UNTRACK +upsert +UPSERTING upsertion url usec @@ -1634,6 +1685,7 @@ validator valnum valsize valstr +valuemode vasprintf vedisdb VERINFO @@ -1657,7 +1709,6 @@ vscprintf vsnprintf vvn vvnw -Vvqnwcdis vvv vvvv vvvvv @@ -1674,6 +1725,7 @@ WCOREDUMP wcsnicmp wdm webassembly +webclient WERROR WEXITSTATUS WEXTRA @@ -1712,6 +1764,8 @@ WRLCK WRONLY wsize WSL +wstr +wstring WUNTRACED www WX diff --git a/ChangeLog.md b/ChangeLog.md index f6f1c0c4..958bceb4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -19,7 +19,7 @@ Added features: - Explicit `MDBX_SYNC_DURABLE` to sync modes for API clarity. - Explicit `MDBX_ALLDUPS` and `MDBX_UPSERT` for API clarity. - Support for read transactions preparation (`MDBX_TXN_RDONLY_PREPARE` flag). - - Support for cursor preparation/preallocation and reusing (`mdbx_cursor_create()` and `mdbx_cursor_bind()` functions). + - Support for cursor preparation/(pre)allocation and reusing (`mdbx_cursor_create()` and `mdbx_cursor_bind()` functions). - Support for checking database using specified meta-page (see `mdbx_chk -h`). - Support for turn to the specific meta-page after checking (see `mdbx_chk -h`). - Support for explicit reader threads (de)registration. @@ -37,7 +37,7 @@ Deprecated functions and flags: Fixes: - Fix `mdbx_strerror()` for `MDBX_BUSY` error (no error description is returned). - - Fix update internal meta-geo information in read-only mode (`EACCESS` or `EBADF` error). + - Fix update internal meta-geo information in read-only mode (`EACCESS` or `EBADFD` error). - Fix `mdbx_page_get()` null-defer when DB corrupted (crash by `SIGSEGV`). - Fix `mdbx_env_open()` for re-opening after non-fatal errors (`mdbx_chk` unexpected failures). - Workaround for MSVC 19.27 `static_assert()` bug. diff --git a/GNUmakefile b/GNUmakefile index e6b4193e..d8fd35af 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -33,7 +33,7 @@ MDBX_OPTIONS ?= -DNDEBUG=1 CFLAGS ?= -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes $(CFLAGS_EXTRA) # -Wno-tautological-compare CXX ?= g++ -# choicing C++ standard with deferred simple variable expansion trick +# Choosing C++ standard with deferred simple variable expansion trick CXXSTD ?= $(eval CXXSTD := $$(shell PROBE=$$$$([ -f mdbx.c++ ] && echo mdbx.c++ || echo src/mdbx.c++); for std in gnu++20 c++20 gnu++2a c++2a gnu++17 c++17 gnu++14 c++14 gnu+11 c++11; do $(CXX) -std=$$$${std} -c $$$${PROBE} -o /dev/null 2>/dev/null >/dev/null && echo "-std=$$$${std}" && exit; done))$(CXXSTD) CXXFLAGS = $(CXXSTD) $(filter-out -std=gnu11,$(CFLAGS)) diff --git a/mdbx.h b/mdbx.h index 925d214c..9f5100cd 100644 --- a/mdbx.h +++ b/mdbx.h @@ -93,11 +93,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \defgroup c_opening Opening & Closing \defgroup c_transactions Transactions \defgroup c_dbi Databases - \defgroup c_crud Create/Read/Update/Delete (see Roadmap in details) + \defgroup c_crud Create/Read/Update/Delete (see Quick Reference in details) \details \anchor c_crud_hints -# Quick reference for Insert/Update/Delete operations +# Quick Reference for Insert/Update/Delete operations Historically, libmdbx inherits the API basis from LMDB, where it is often difficult to select flags/options and functions for the desired operation. @@ -154,7 +154,7 @@ as a duplicates or as like a multiple values corresponds to keys. | _DELETING_||| |Key is absent → Error since no such key |\ref mdbx_del() or \ref mdbx_replace()|Error \ref MDBX_NOTFOUND| |Key exist → Delete all values corresponds given key|\ref mdbx_del() with the parameter `data = NULL`|Deletion| -|Key exist → Delete particular value corresponds given key|\ref mdbx_del() with the parameter `data` filled with the value that wanna to delete, or \ref mdbx_replace() with \ref MDBX_CURRENT + \ref MDBX_NOOVERWRITE and the `old_value` parameter filled with the value that wanna to delete and `new_data = NULL`| Deletion or \ref MDBX_NOTFOUND if no such ker-value pair| +|Key exist → Delete particular value corresponds given key|\ref mdbx_del() with the parameter `data` filled with the value that wanna to delete, or \ref mdbx_replace() with \ref MDBX_CURRENT + \ref MDBX_NOOVERWRITE and the `old_value` parameter filled with the value that wanna to delete and `new_data = NULL`| Deletion or \ref MDBX_NOTFOUND if no such key-value pair| |Delete one value at the current cursor position|\ref mdbx_cursor_del() with \ref MDBX_CURRENT flag|Deletion only the current entry| |Delete all values of key at the current cursor position|\ref mdbx_cursor_del() with with \ref MDBX_ALLDUPS flag|Deletion all duplicates of key (all multi-values) at the current cursor position| @@ -1603,7 +1603,7 @@ enum MDBX_error_t { MDBX_TXN_OVERLAPPING = -30415, /* The last of MDBX-added error codes */ - MDBX_LAST_ADDED_ERRCODEE = MDBX_TXN_OVERLAPPING, + MDBX_LAST_ADDED_ERRCODE = MDBX_TXN_OVERLAPPING, #if defined(_WIN32) || defined(_WIN64) MDBX_ENODATA = ERROR_HANDLE_EOF, diff --git a/mdbx.h++ b/mdbx.h++ index 7d39ca75..6d0b64d5 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -148,7 +148,7 @@ base for dll-interface 'mdbx::BAR' */ /* MSVC is mad and can generate this warning for its own intermediate * automatically generated code, which becomes unreachable after some kinds of - * optimization (copy ellision, etc). */ + * optimization (copy elision, etc). */ #pragma warning(disable : 4702) /* unreachable code */ #endif /* _MSC_VER (warnings) */ @@ -175,7 +175,7 @@ using version_info = ::MDBX_version_info; MDBX_CXX11_CONSTEXPR const version_info &get_version() noexcept; /// \copydoc MDBX_build_info using build_info = ::MDBX_build_info; -/// \brief Resutrns libmdbx build information. +/// \brief Returns libmdbx build information. MDBX_CXX11_CONSTEXPR const build_info &get_build() noexcept; /// \brief constexpr-compatible strlen(). @@ -351,7 +351,7 @@ MDBX_DECLARE_EXCEPTION(max_readers_reached); MDBX_DECLARE_EXCEPTION(multivalue); MDBX_DECLARE_EXCEPTION(no_data); MDBX_DECLARE_EXCEPTION(not_found); -MDBX_DECLARE_EXCEPTION(operation_not_permited); +MDBX_DECLARE_EXCEPTION(operation_not_permitted); MDBX_DECLARE_EXCEPTION(permission_denied_or_not_writeable); MDBX_DECLARE_EXCEPTION(reader_slot_busy); MDBX_DECLARE_EXCEPTION(remote_media); @@ -796,8 +796,8 @@ struct LIBMDBX_API_TYPE slice : public ::MDBX_val { } protected: - MDBX_CXX11_CONSTEXPR slice(size_t invalid_lenght) noexcept - : ::MDBX_val({nullptr, invalid_lenght}) {} + MDBX_CXX11_CONSTEXPR slice(size_t invalid_length) noexcept + : ::MDBX_val({nullptr, invalid_length}) {} }; //------------------------------------------------------------------------------ @@ -841,7 +841,7 @@ template class buffer { public: /// \todo buffer& operator<<(buffer&, ...) for writing - /// \todo buffer& operator>>(buffer&, ...) for reading (deletages to slice) + /// \todo buffer& operator>>(buffer&, ...) for reading (delegated to slice) /// \todo template key(X) for encoding keys while writing using allocator_type = ALLOCATOR; @@ -877,14 +877,14 @@ public: } /// \brief Returns the number of bytes that available in currently allocated - /// storage ahead of the currently beginning of data. + /// storage ahead the currently beginning of data. MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_CONSTEXPR size_t headroom() const noexcept { return is_freestanding() ? slice_.byte_ptr() - silo_begin() : 0; } /// \brief Returns the number of bytes that available in currently allocated - /// storage afther of the currently data end. + /// storage after the currently data end. MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_CONSTEXPR size_t tailroom() const noexcept { return is_freestanding() ? capacity() - headroom() - slice_.length() : 0; @@ -1693,7 +1693,7 @@ public: enum : int64_t { default_value = -1, ///< Means "keep current or use default" minimal_value = 0, ///< Means "minimal acceptable" - maximal_value = INTPTR_MAX, ///< Means "miximal acceptable" + maximal_value = INTPTR_MAX, ///< Means "maximal acceptable" kB = 1000, ///< \f$10^{3}\f$ bytes MB = kB * 1000, ///< \f$10^{6}\f$ bytes GB = MB * 1000, ///< \f$10^{9}\f$ bytes @@ -1982,7 +1982,7 @@ public: /// inline env &set_sync_threshold(size_t bytes); - /// \brief Sets relative period since the last unsteay commit to force flush + /// \brief Sets relative period since the last unsteady commit to force flush /// the data buffers to disk, for non-sync durability modes. /// /// The relative period value affects all processes which operates with given @@ -2000,10 +2000,10 @@ public: /// than mean no any timeout checked, and no additional flush will be made. /// /// \param [in] seconds_16dot16 The period in 1/65536 of second when a - /// synchronous flush would be made since the last unsteay commit. + /// synchronous flush would be made since the last unsteady commit. inline env &set_sync_period(unsigned seconds_16dot16); - /// \brief Sets relative period since the last unsteay commit to force flush + /// \brief Sets relative period since the last unsteady commit to force flush /// the data buffers to disk, for non-sync durability modes. /// /// The relative period value affects all processes which operates with given @@ -2021,7 +2021,7 @@ public: /// than mean no any timeout checked, and no additional flush will be made. /// /// \param [in] seconds The period in second when a synchronous flush would - /// be made since the last unsteay commit. + /// be made since the last unsteady commit. inline env &set_sync_period(double seconds); /// \brief Alter environment flags. @@ -2066,7 +2066,7 @@ public: mdbx_pid_t pid; ///< The reader process ID. mdbx_tid_t thread; ///< The reader thread ID. uint64_t transaction_id; ///< The ID of the transaction being read, - ///< i.e. the MVCC-snaphot number. + ///< i.e. the MVCC-snapshot number. uint64_t transaction_lag; ///< The lag from a recent MVCC-snapshot, ///< i.e. the number of committed write /// transactions since the current read @@ -2096,7 +2096,7 @@ public: /// \returns The last value returned from visitor' functor. template inline int enumerate_readers(VISITOR &visitor); - /// \brief Checks for stale readers in the lock tablea and + /// \brief Checks for stale readers in the lock table and /// return number of cleared slots. inline unsigned check_readers(); @@ -2104,7 +2104,7 @@ public: /// /// Such callback will be triggered in a case where there is not enough free /// space in the database due to long read transaction(s) which impedes - /// reusing the pages of an old MVCC shapshot(s). + /// reusing the pages of an old MVCC snapshot(s). /// /// Using this callback you can choose how to get out of the situation: /// - abort the record transaction with an error; @@ -2771,7 +2771,7 @@ MDBX_CXX11_CONSTEXPR bool error::is_mdbx_error() const noexcept { return (code() >= MDBX_FIRST_LMDB_ERRCODE && code() <= MDBX_LAST_LMDB_ERRCODE) || (code() >= MDBX_FIRST_ADDED_ERRCODE && - code() <= MDBX_LAST_ADDED_ERRCODEE); + code() <= MDBX_LAST_ADDED_ERRCODE); } inline void error::throw_exception(int error_code) { @@ -3488,7 +3488,7 @@ inline int env::enumerate_readers(VISITOR &visitor) { }; reader_visitor_thunk thunk(visitor); const auto rc = ::mdbx_reader_list(*this, thunk.cb, &thunk); - thunk.rethow_catched(); + thunk.rethrow_captured(); return rc; } diff --git a/src/core.c b/src/core.c index 9dc79e89..b445affa 100644 --- a/src/core.c +++ b/src/core.c @@ -14981,9 +14981,9 @@ static __cold int mdbx_page_check(MDBX_cursor *const mc, continue; } if (unlikely(number_of_ovpages(env, dsize) != lp->mp_pages)) - rc = bad_page( - mp, "big-node size (%zu) mismatch overflow npagse size (%u)\n", - dsize, lp->mp_pages); + rc = + bad_page(mp, "big-node size (%zu) mismatch n-pages size (%u)\n", + dsize, lp->mp_pages); } continue; } diff --git a/src/mdbx.c++ b/src/mdbx.c++ index c08c6b49..9f7d7571 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -159,7 +159,7 @@ class bug : public std::runtime_error { public: bug(const trouble_location &) noexcept; /* temporary workaround for "private field 'FOO' is not used" from CLANG - * and for "function 'BAR' was declared but never referenced" fomr LCC. */ + * and for "function 'BAR' was declared but never referenced" from LCC. */ #ifndef __LCC__ const trouble_location &location() const noexcept { return location_; } #endif @@ -311,7 +311,7 @@ DEFINE_EXCEPTION(max_readers_reached) DEFINE_EXCEPTION(multivalue) DEFINE_EXCEPTION(no_data) DEFINE_EXCEPTION(not_found) -DEFINE_EXCEPTION(operation_not_permited) +DEFINE_EXCEPTION(operation_not_permitted) DEFINE_EXCEPTION(permission_denied_or_not_writeable) DEFINE_EXCEPTION(reader_slot_busy) DEFINE_EXCEPTION(remote_media) @@ -397,7 +397,7 @@ __cold void error::throw_exception() const { CASE_EXCEPTION(multivalue, MDBX_EMULTIVAL); CASE_EXCEPTION(no_data, MDBX_ENODATA); CASE_EXCEPTION(not_found, MDBX_NOTFOUND); - CASE_EXCEPTION(operation_not_permited, MDBX_EPERM); + CASE_EXCEPTION(operation_not_permitted, MDBX_EPERM); CASE_EXCEPTION(permission_denied_or_not_writeable, MDBX_EACCESS); CASE_EXCEPTION(reader_slot_busy, MDBX_BAD_RSLOT); CASE_EXCEPTION(remote_media, MDBX_EREMOTE); diff --git a/src/mdbx_chk.c b/src/mdbx_chk.c index 3c1a512f..f1f66bf2 100644 --- a/src/mdbx_chk.c +++ b/src/mdbx_chk.c @@ -1050,7 +1050,7 @@ int main(int argc, char *argv[]) { if (argc < 2) usage(prog); - for (int i; (i = getopt(argc, argv, "Vvqnwc012tTdis:")) != EOF;) { + for (int i; (i = getopt(argc, argv, "012TVvqnwctdis:")) != EOF;) { switch (i) { case 'V': printf("mdbx_chk version %d.%d.%d.%d\n"