Classes | |
struct | MDBX_stat |
Statistics for a database in the environment. More... | |
struct | MDBX_envinfo |
Information about the environment. More... | |
struct | MDBX_txn_info |
Information about the transaction. More... | |
Typedefs | |
typedef enum MDBX_dbi_state_t | MDBX_dbi_state_t |
typedef int() | MDBX_reader_list_func(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid, uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT |
A callback function used to enumerate the reader lock table. More... | |
Enumerations | |
enum | MDBX_dbi_state_t { MDBX_DBI_DIRTY = 0x01, MDBX_DBI_STALE = 0x02, MDBX_DBI_FRESH = 0x04, MDBX_DBI_CREAT = 0x08 } |
DBI state bits returted by mdbx_dbi_flags_ex() More... | |
Functions | |
LIBMDBX_API int | mdbx_env_stat_ex (const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes) |
Return statistics about the MDBX environment. More... | |
MDBX_DEPRECATED int | mdbx_env_stat (const MDBX_env *env, MDBX_stat *stat, size_t bytes) |
Return statistics about the MDBX environment. More... | |
LIBMDBX_API int | mdbx_env_info_ex (const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes) |
Return information about the MDBX environment. More... | |
MDBX_DEPRECATED int | mdbx_env_info (const MDBX_env *env, MDBX_envinfo *info, size_t bytes) |
Return information about the MDBX environment. More... | |
int | mdbx_env_get_syncbytes (const MDBX_env *env, size_t *threshold) |
Get threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the environment. More... | |
int | mdbx_env_get_syncperiod (const MDBX_env *env, unsigned *period_seconds_16dot16) |
Get relative period since the last unsteady commit to force flush the data buffers to disk, even of MDBX_SAFE_NOSYNC flag in the environment. More... | |
LIBMDBX_API int | mdbx_env_get_flags (const MDBX_env *env, unsigned *flags) |
Get environment flags. More... | |
LIBMDBX_API int | mdbx_env_get_path (const MDBX_env *env, const char **dest) |
Return the path that was used in mdbx_env_open(). More... | |
LIBMDBX_API int | mdbx_env_get_fd (const MDBX_env *env, mdbx_filehandle_t *fd) |
Return the file descriptor for the given environment. More... | |
MDBX_NOTHROW_CONST_FUNCTION intptr_t | mdbx_limits_pgsize_min (void) |
Returns the minimal database page size in bytes. More... | |
MDBX_NOTHROW_CONST_FUNCTION intptr_t | mdbx_limits_pgsize_max (void) |
Returns the maximal database page size in bytes. More... | |
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t | mdbx_limits_dbsize_min (intptr_t pagesize) |
Returns minimal database size in bytes for given page size, or -1 if pagesize is invalid. More... | |
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t | mdbx_limits_dbsize_max (intptr_t pagesize) |
Returns maximal database size in bytes for given page size, or -1 if pagesize is invalid. More... | |
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t | mdbx_limits_keysize_max (intptr_t pagesize, MDBX_db_flags_t flags) |
Returns maximal key size in bytes for given page size and database flags, or -1 if pagesize is invalid. More... | |
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t | mdbx_limits_valsize_max (intptr_t pagesize, MDBX_db_flags_t flags) |
Returns maximal data size in bytes for given page size and database flags, or -1 if pagesize is invalid. More... | |
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t | mdbx_limits_txnsize_max (intptr_t pagesize) |
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for given page size, or -1 if pagesize is invalid. More... | |
int | mdbx_env_get_maxreaders (const MDBX_env *env, unsigned *readers) |
Get the maximum number of threads/reader slots for the environment. More... | |
int | mdbx_env_get_maxdbs (const MDBX_env *env, MDBX_dbi *dbs) |
Get the maximum number of named databases for the environment. More... | |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API size_t | mdbx_default_pagesize (void) |
Returns the default size of database page for the current system. More... | |
LIBMDBX_API int | mdbx_get_sysraminfo (intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages) |
Returns basic information about system RAM. This function provides a portable way to get information about available RAM and can be useful in that it returns the same information that libmdbx uses internally to adjust various options and control readahead. More... | |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int | mdbx_env_get_maxkeysize_ex (const MDBX_env *env, MDBX_db_flags_t flags) |
Returns the maximum size of keys can put. More... | |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int | mdbx_env_get_maxvalsize_ex (const MDBX_env *env, MDBX_db_flags_t flags) |
Returns the maximum size of data we can put. More... | |
MDBX_NOTHROW_PURE_FUNCTION MDBX_DEPRECATED LIBMDBX_API int | mdbx_env_get_maxkeysize (const MDBX_env *env) |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API void * | mdbx_env_get_userctx (const MDBX_env *env) |
Returns an application information (a context pointer) associated with the environment. More... | |
LIBMDBX_API int | mdbx_txn_info (const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt) |
Return information about the MDBX transaction. More... | |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t | mdbx_txn_id (const MDBX_txn *txn) |
Return the transaction's ID. More... | |
LIBMDBX_API int | mdbx_txn_commit_ex (MDBX_txn *txn, MDBX_commit_latency *latency) |
Commit all the operations of a transaction into the database and collect latency information. More... | |
LIBMDBX_API int | mdbx_dbi_stat (MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes) |
Retrieve statistics for a database. More... | |
LIBMDBX_API int | mdbx_dbi_dupsort_depthmask (MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask) |
Retrieve depth (bitmask) information of nested dupsort (multi-value) B+trees for given database. More... | |
LIBMDBX_API int | mdbx_dbi_flags_ex (MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state) |
Retrieve the DB flags and status for a database handle. More... | |
int | mdbx_dbi_flags (MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) |
The shortcut to calling mdbx_dbi_flags_ex() with state=NULL for discarding it result. More... | |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int | mdbx_is_dirty (const MDBX_txn *txn, const void *ptr) |
Determines whether the given address is on a dirty database page of the transaction or not. More... | |
LIBMDBX_API int | mdbx_reader_list (const MDBX_env *env, MDBX_reader_list_func *func, void *ctx) |
Enumerate the entries in the reader lock table. More... | |
MDBX_DEPRECATED LIBMDBX_API int | mdbx_txn_straggler (const MDBX_txn *txn, int *percent) |
Returns a lag of the reading for the given transaction. More... | |
typedef enum MDBX_dbi_state_t MDBX_dbi_state_t |
typedef int() MDBX_reader_list_func(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid, uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT |
A callback function used to enumerate the reader lock table.
[in] | ctx | An arbitrary context pointer for the callback. |
[in] | num | The serial number during enumeration, starting from 1. |
[in] | slot | The reader lock table slot number. |
[in] | txnid | The ID of the transaction being read, i.e. the MVCC-snapshot number. |
[in] | lag | The lag from a recent MVCC-snapshot, i.e. the number of committed write transactions since the current read transaction started. |
[in] | pid | The reader process ID. |
[in] | thread | The reader thread ID. |
[in] | bytes_used | The number of last used page in the MVCC-snapshot which being read, i.e. database file can't shrinked beyond this. |
[in] | bytes_retired | The total size of the database pages that were retired by committed write transactions after the reader's MVCC-snapshot, i.e. the space which would be freed after the Reader releases the MVCC-snapshot for reuse by completion read transaction. |
enum MDBX_dbi_state_t |
DBI state bits returted by mdbx_dbi_flags_ex()
LIBMDBX_API int mdbx_dbi_dupsort_depthmask | ( | MDBX_txn * | txn, |
MDBX_dbi | dbi, | ||
uint32_t * | mask | ||
) |
Retrieve depth (bitmask) information of nested dupsort (multi-value) B+trees for given database.
[in] | txn | A transaction handle returned by mdbx_txn_begin(). |
[in] | dbi | A database handle returned by mdbx_dbi_open(). |
[out] | mask | The address of an uint32_t value where the bitmask will be stored. |
MDBX_THREAD_MISMATCH | Given transaction is not owned by current thread. |
MDBX_EINVAL | An invalid parameter was specified. |
MDBX_RESULT_TRUE | The dbi isn't a dupsort (multi-value) database. |
The shortcut to calling mdbx_dbi_flags_ex() with state=NULL
for discarding it result.
LIBMDBX_API int mdbx_dbi_flags_ex | ( | MDBX_txn * | txn, |
MDBX_dbi | dbi, | ||
unsigned * | flags, | ||
unsigned * | state | ||
) |
Retrieve the DB flags and status for a database handle.
[in] | txn | A transaction handle returned by mdbx_txn_begin(). |
[in] | dbi | A database handle returned by mdbx_dbi_open(). |
[out] | flags | Address where the flags will be returned. |
[out] | state | Address where the state will be returned. |
LIBMDBX_API int mdbx_dbi_stat | ( | MDBX_txn * | txn, |
MDBX_dbi | dbi, | ||
MDBX_stat * | stat, | ||
size_t | bytes | ||
) |
Retrieve statistics for a database.
[in] | txn | A transaction handle returned by mdbx_txn_begin(). |
[in] | dbi | A database handle returned by mdbx_dbi_open(). |
[out] | stat | The address of an MDBX_stat structure where the statistics will be copied. |
[in] | bytes | The size of MDBX_stat. |
MDBX_THREAD_MISMATCH | Given transaction is not owned by current thread. |
MDBX_EINVAL | An invalid parameter was specified. |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API size_t mdbx_default_pagesize | ( | void | ) |
Returns the default size of database page for the current system.
Default size of database page depends on the size of the system page and usually exactly match it.
LIBMDBX_API int mdbx_env_get_fd | ( | const MDBX_env * | env, |
mdbx_filehandle_t * | fd | ||
) |
Return the file descriptor for the given environment.
FD_CLOEXEC
and couldn't be used after exec() and or fork()
.[in] | env | An environment handle returned by mdbx_env_create(). |
[out] | fd | Address of a int to contain the descriptor. |
MDBX_EINVAL | An invalid parameter was specified. |
LIBMDBX_API int mdbx_env_get_flags | ( | const MDBX_env * | env, |
unsigned * | flags | ||
) |
Get environment flags.
[in] | env | An environment handle returned by mdbx_env_create(). |
[out] | flags | The address of an integer to store the flags. |
MDBX_EINVAL | An invalid parameter was specified. |
Get the maximum number of named databases for the environment.
[in] | env | An environment handle returned by mdbx_env_create(). |
[out] | dbs | Address to store the maximum number of databases. |
MDBX_EINVAL | An invalid parameter was specified. |
MDBX_NOTHROW_PURE_FUNCTION MDBX_DEPRECATED LIBMDBX_API int mdbx_env_get_maxkeysize | ( | const MDBX_env * | env | ) |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int mdbx_env_get_maxkeysize_ex | ( | const MDBX_env * | env, |
MDBX_db_flags_t | flags | ||
) |
Returns the maximum size of keys can put.
[in] | env | An environment handle returned by mdbx_env_create(). |
[in] | flags | Database options (MDBX_DUPSORT, MDBX_INTEGERKEY and so on). |
|
inline |
Get the maximum number of threads/reader slots for the environment.
[in] | env | An environment handle returned by mdbx_env_create(). |
[out] | readers | Address of an integer to store the number of readers. |
MDBX_EINVAL | An invalid parameter was specified. |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int mdbx_env_get_maxvalsize_ex | ( | const MDBX_env * | env, |
MDBX_db_flags_t | flags | ||
) |
Returns the maximum size of data we can put.
[in] | env | An environment handle returned by mdbx_env_create(). |
[in] | flags | Database options (MDBX_DUPSORT, MDBX_INTEGERKEY and so on). |
LIBMDBX_API int mdbx_env_get_path | ( | const MDBX_env * | env, |
const char ** | dest | ||
) |
Return the path that was used in mdbx_env_open().
[in] | env | An environment handle returned by mdbx_env_create() |
[out] | dest | Address of a string pointer to contain the path. This is the actual string in the environment, not a copy. It should not be altered in any way. |
MDBX_EINVAL | An invalid parameter was specified. |
|
inline |
Get threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the environment.
[in] | env | An environment handle returned by mdbx_env_create(). |
[out] | threshold | Address of an size_t to store the number of bytes of summary changes when a synchronous flush would be made. |
MDBX_EINVAL | An invalid parameter was specified. |
|
inline |
Get relative period since the last unsteady commit to force flush the data buffers to disk, even of MDBX_SAFE_NOSYNC flag in the environment.
[in] | env | An environment handle returned by mdbx_env_create(). |
[out] | period_seconds_16dot16 | Address of an size_t to store the period in 1/65536 of second when a synchronous flush would be made since the last unsteady commit. |
MDBX_EINVAL | An invalid parameter was specified. |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API void* mdbx_env_get_userctx | ( | const MDBX_env * | env | ) |
Returns an application information (a context pointer) associated with the environment.
[in] | env | An environment handle returned by mdbx_env_create() |
NULL
if something wrong.
|
inline |
Return information about the MDBX environment.
LIBMDBX_API int mdbx_env_info_ex | ( | const MDBX_env * | env, |
const MDBX_txn * | txn, | ||
MDBX_envinfo * | info, | ||
size_t | bytes | ||
) |
Return information about the MDBX environment.
At least one of env or txn argument must be non-null. If txn is passed non-null then stat will be filled accordingly to the given transaction. Otherwise, if txn is null, then stat will be populated by a snapshot from the last committed write transaction, and at next time, other information can be returned.
Legacy mdbx_env_info() correspond to calling mdbx_env_info_ex() with the null txn
argument.
[in] | env | An environment handle returned by mdbx_env_create() |
[in] | txn | A transaction handle returned by mdbx_txn_begin() |
[out] | info | The address of an MDBX_envinfo structure where the information will be copied |
[in] | bytes | The size of MDBX_envinfo. |
|
inline |
Return statistics about the MDBX environment.
LIBMDBX_API int mdbx_env_stat_ex | ( | const MDBX_env * | env, |
const MDBX_txn * | txn, | ||
MDBX_stat * | stat, | ||
size_t | bytes | ||
) |
Return statistics about the MDBX environment.
At least one of env or txn argument must be non-null. If txn is passed non-null then stat will be filled accordingly to the given transaction. Otherwise, if txn is null, then stat will be populated by a snapshot from the last committed write transaction, and at next time, other information can be returned.
Legacy mdbx_env_stat() correspond to calling mdbx_env_stat_ex() with the null txn
argument.
[in] | env | An environment handle returned by mdbx_env_create() |
[in] | txn | A transaction handle returned by mdbx_txn_begin() |
[out] | stat | The address of an MDBX_stat structure where the statistics will be copied |
[in] | bytes | The size of MDBX_stat. |
LIBMDBX_API int mdbx_get_sysraminfo | ( | intptr_t * | page_size, |
intptr_t * | total_pages, | ||
intptr_t * | avail_pages | ||
) |
Returns basic information about system RAM. This function provides a portable way to get information about available RAM and can be useful in that it returns the same information that libmdbx uses internally to adjust various options and control readahead.
[out] | page_size | Optional address where the system page size will be stored. |
[out] | total_pages | Optional address where the number of total RAM pages will be stored. |
[out] | avail_pages | Optional address where the number of available/free RAM pages will be stored. |
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int mdbx_is_dirty | ( | const MDBX_txn * | txn, |
const void * | ptr | ||
) |
Determines whether the given address is on a dirty database page of the transaction or not.
Ultimately, this allows to avoid copy data from non-dirty pages.
"Dirty" pages are those that have already been changed during a write transaction. Accordingly, any further changes may result in such pages being overwritten. Therefore, all functions libmdbx performing changes inside the database as arguments should NOT get pointers to data in those pages. In turn, "not dirty" pages before modification will be copied.
In other words, data from dirty pages must either be copied before being passed as arguments for further processing or rejected at the argument validation stage. Thus, mdbx_is_dirty()
allows you to get rid of unnecessary copying, and perform a more complete check of the arguments.
[in] | txn | A transaction handle returned by mdbx_txn_begin(). |
[in] | ptr | The address of data to check. |
MDBX_RESULT_TRUE | Given address is on the dirty page. |
MDBX_RESULT_FALSE | Given address is NOT on the dirty page. |
Otherwise | the error code. |
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t mdbx_limits_dbsize_max | ( | intptr_t | pagesize | ) |
Returns maximal database size in bytes for given page size, or -1 if pagesize is invalid.
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t mdbx_limits_dbsize_min | ( | intptr_t | pagesize | ) |
Returns minimal database size in bytes for given page size, or -1 if pagesize is invalid.
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t mdbx_limits_keysize_max | ( | intptr_t | pagesize, |
MDBX_db_flags_t | flags | ||
) |
Returns maximal key size in bytes for given page size and database flags, or -1 if pagesize is invalid.
|
inline |
Returns the maximal database page size in bytes.
|
inline |
Returns the minimal database page size in bytes.
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t mdbx_limits_txnsize_max | ( | intptr_t | pagesize | ) |
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for given page size, or -1 if pagesize is invalid.
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API intptr_t mdbx_limits_valsize_max | ( | intptr_t | pagesize, |
MDBX_db_flags_t | flags | ||
) |
Returns maximal data size in bytes for given page size and database flags, or -1 if pagesize is invalid.
LIBMDBX_API int mdbx_reader_list | ( | const MDBX_env * | env, |
MDBX_reader_list_func * | func, | ||
void * | ctx | ||
) |
Enumerate the entries in the reader lock table.
[in] | env | An environment handle returned by mdbx_env_create(). |
[in] | func | A MDBX_reader_list_func function. |
[in] | ctx | An arbitrary context pointer for the enumeration function. |
LIBMDBX_API int mdbx_txn_commit_ex | ( | MDBX_txn * | txn, |
MDBX_commit_latency * | latency | ||
) |
Commit all the operations of a transaction into the database and collect latency information.
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_txn_id | ( | const MDBX_txn * | txn | ) |
Return the transaction's ID.
This returns the identifier associated with this transaction. For a read-only transaction, this corresponds to the snapshot being read; concurrent readers will frequently have the same transaction ID.
[in] | txn | A transaction handle returned by mdbx_txn_begin(). |
LIBMDBX_API int mdbx_txn_info | ( | const MDBX_txn * | txn, |
MDBX_txn_info * | info, | ||
bool | scan_rlt | ||
) |
Return information about the MDBX transaction.
[in] | txn | A transaction handle returned by mdbx_txn_begin() |
[out] | info | The address of an MDBX_txn_info structure where the information will be copied. |
[in] | scan_rlt | The boolean flag controls the scan of the read lock table to provide complete information. Such scan is relatively expensive and you can avoid it if corresponding fields are not needed. See description of MDBX_txn_info. |
MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler | ( | const MDBX_txn * | txn, |
int * | percent | ||
) |
Returns a lag of the reading for the given transaction.
Returns an information for estimate how much given read-only transaction is lagging relative the to actual head.
[in] | txn | A transaction handle returned by mdbx_txn_begin(). |
[out] | percent | Percentage of page allocation in the database. |