libmdbx  0.11.6.39 (2022-04-13T11:05:50+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.

Typedefs

typedef uint_fast64_t mdbx_attr_t
 

Functions

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)
 
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)
 
LIBMDBX_API int mdbx_set_attr (MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, mdbx_attr_t attr)
 
LIBMDBX_API int mdbx_cursor_get_attr (MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, mdbx_attr_t *pattr, MDBX_cursor_op op)
 
LIBMDBX_API int mdbx_get_attr (MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, mdbx_attr_t *pattr)
 

Detailed Description

Typedef Documentation

◆ mdbx_attr_t

typedef uint_fast64_t mdbx_attr_t

Function Documentation

◆ mdbx_cursor_get_attr()

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 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 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 also
mdbx_get()
Parameters
[in]cursorA cursor handle returned by mdbx_cursor_open().
[in,out]keyThe key for a retrieved item.
[in,out]dataThe data of a retrieved item.
[out]pattrThe pointer to retrieve attribute.
[in]opA cursor operation MDBX_cursor_op.
Returns
A non-zero error value on failure and 0 on success, some possible errors are:
Return values
MDBX_NOTFOUNDNo matching key found.
MDBX_EINVALAn invalid parameter was specified.

◆ mdbx_cursor_put_attr()

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 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 MDBX_RESERVE feature, therefore doesn't support MDBX_DUPSORT.
Parameters
[in]cursorA cursor handle returned by mdbx_cursor_open()
[in]keyThe key operated on.
[in]dataThe data operated on.
[in]attrThe attribute.
[in]flagsOptions for this operation. This parameter must be set to 0 or one of the values described here:
  • 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 MDBX_EKEYMISMATCH.
  • 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 MDBX_KEYEXIST error.
See also
Quick reference for Insert/Update/Delete operations
Returns
A non-zero error value on failure and 0 on success, some possible errors are:
Return values
MDBX_EKEYMISMATCH
MDBX_MAP_FULLThe database is full, see mdbx_env_set_mapsize().
MDBX_TXN_FULLThe transaction has too many dirty pages.
MDBX_EACCESAn attempt was made to write in a read-only transaction.
MDBX_EINVALan invalid parameter was specified.

◆ mdbx_get_attr()

LIBMDBX_API int mdbx_get_attr ( MDBX_txn txn,
MDBX_dbi  dbi,
MDBX_val key,
MDBX_val data,
mdbx_attr_t pattr 
)

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 MDBX_DUPSORT) then the first data item for the key will be returned. Retrieval of other items requires the use of 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.
Values returned from the database are valid only until a subsequent update operation, or the end of the transaction.
Parameters
[in]txnA transaction handle returned by mdbx_txn_begin().
[in]dbiA database handle returned by mdbx_dbi_open().
[in]keyThe key to search for in the database.
[in,out]dataThe data corresponding to the key.
[out]pattrThe pointer to retrieve attribute.
Returns
A non-zero error value on failure and 0 on success, some possible errors are:
Return values
MDBX_NOTFOUNDThe key was not in the database.
MDBX_EINVALAn invalid parameter was specified.

◆ mdbx_put_attr()

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 
)

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 MDBX_RESERVE feature, therefore doesn't support MDBX_DUPSORT.
Parameters
[in]txnA transaction handle returned by mdbx_txn_begin().
[in]dbiA database handle returned by mdbx_dbi_open().
[in]keyThe key to store in the database.
[in]attrThe attribute to store in the database.
[in,out]dataThe data to store.
[in]flagsSpecial 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:
  • MDBX_NOOVERWRITE Enter the new key/data pair only if the key does not already appear in the database. The function will return MDBX_KEYEXIST if the key already appears in the database. The data parameter will be set to point to the existing item.
  • MDBX_CURRENT Update an single existing entry, but not add new ones. The function will return MDBX_NOTFOUND if the given key not exist in the database. Or the MDBX_EMULTIVAL in case duplicates for the given key.
  • 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 MDBX_EKEYMISMATCH error.
See also
Quick reference for Insert/Update/Delete operations
Returns
A non-zero error value on failure and 0 on success, some possible errors are:
Return values
MDBX_KEYEXIST
MDBX_MAP_FULLThe database is full, see mdbx_env_set_mapsize().
MDBX_TXN_FULLThe transaction has too many dirty pages.
MDBX_EACCESAn attempt was made to write in a read-only transaction.
MDBX_EINVALAn invalid parameter was specified.

◆ mdbx_set_attr()

LIBMDBX_API int mdbx_set_attr ( MDBX_txn txn,
MDBX_dbi  dbi,
MDBX_val key,
MDBX_val data,
mdbx_attr_t  attr 
)

Set items attribute from a database.

This function stores key/data pairs attribute to the database.

Note
Internally based on MDBX_RESERVE feature, therefore doesn't support MDBX_DUPSORT.
Parameters
[in]txnA transaction handle returned by mdbx_txn_begin().
[in]dbiA database handle returned by mdbx_dbi_open().
[in]keyThe key to search for in the database.
[in]dataThe data to be stored or NULL to save previous value.
[in]attrThe attribute to be stored.
Returns
A non-zero error value on failure and 0 on success, some possible errors are:
Return values
MDBX_NOTFOUNDThe key-value pair was not in the database.
MDBX_EINVALAn invalid parameter was specified.