mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-31 11:18:21 +08:00
mdbx: add MDBX_MAXDATASIZE.
This commit is contained in:
parent
a2593625cc
commit
ab4597cedc
4
mdbx.h
4
mdbx.h
@ -225,6 +225,10 @@ typedef struct iovec MDB_val;
|
|||||||
#define mv_size iov_len
|
#define mv_size iov_len
|
||||||
#define mv_data iov_base
|
#define mv_data iov_base
|
||||||
|
|
||||||
|
/* The maximum size of a data item.
|
||||||
|
* MDBX only store a 32 bit value for node sizes. */
|
||||||
|
#define MDBX_MAXDATASIZE INT32_MAX
|
||||||
|
|
||||||
/* A callback function used to compare two keys in a database */
|
/* A callback function used to compare two keys in a database */
|
||||||
typedef int(MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
|
typedef int(MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
|
||||||
|
|
||||||
|
14
src/mdbx.c
14
src/mdbx.c
@ -317,12 +317,6 @@ txnid_t mdbx_debug_edge;
|
|||||||
/** The version number for a database's lockfile format. */
|
/** The version number for a database's lockfile format. */
|
||||||
#define MDB_LOCK_VERSION ((MDB_DEVEL) ? 999 : 1)
|
#define MDB_LOCK_VERSION ((MDB_DEVEL) ? 999 : 1)
|
||||||
|
|
||||||
/** @brief The maximum size of a data item.
|
|
||||||
*
|
|
||||||
* We only store a 32 bit value for node sizes.
|
|
||||||
*/
|
|
||||||
#define MAXDATASIZE 0xffffffffUL
|
|
||||||
|
|
||||||
#define DKBUF_MAXKEYSIZE 511 /* FIXME */
|
#define DKBUF_MAXKEYSIZE 511 /* FIXME */
|
||||||
/** Key size which fits in a #DKBUF.
|
/** Key size which fits in a #DKBUF.
|
||||||
* @ingroup debug
|
* @ingroup debug
|
||||||
@ -5618,16 +5612,10 @@ int mdbx_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
|
|||||||
if (unlikely(key->mv_size > env->me_maxkey_limit))
|
if (unlikely(key->mv_size > env->me_maxkey_limit))
|
||||||
return MDB_BAD_VALSIZE;
|
return MDB_BAD_VALSIZE;
|
||||||
|
|
||||||
#if SIZE_MAX > MAXDATASIZE
|
|
||||||
if (unlikely(data->mv_size > ((mc->mc_db->md_flags & MDB_DUPSORT)
|
if (unlikely(data->mv_size > ((mc->mc_db->md_flags & MDB_DUPSORT)
|
||||||
? env->me_maxkey_limit
|
? env->me_maxkey_limit
|
||||||
: MAXDATASIZE)))
|
: MDBX_MAXDATASIZE)))
|
||||||
return MDB_BAD_VALSIZE;
|
return MDB_BAD_VALSIZE;
|
||||||
#else
|
|
||||||
if ((mc->mc_db->md_flags & MDB_DUPSORT) &&
|
|
||||||
unlikely(data->mv_size > env->me_maxkey_limit))
|
|
||||||
return MDB_BAD_VALSIZE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((mc->mc_db->md_flags & MDB_INTEGERKEY) &&
|
if ((mc->mc_db->md_flags & MDB_INTEGERKEY) &&
|
||||||
unlikely(key->mv_size != sizeof(uint32_t) &&
|
unlikely(key->mv_size != sizeof(uint32_t) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user