mdbx: add MDBX_MAXDATASIZE.

This commit is contained in:
Leo Yuriev 2017-03-31 17:59:12 +03:00
parent a2593625cc
commit ab4597cedc
2 changed files with 5 additions and 13 deletions

4
mdbx.h
View File

@ -225,6 +225,10 @@ typedef struct iovec MDB_val;
#define mv_size iov_len
#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 */
typedef int(MDB_cmp_func)(const MDB_val *a, const MDB_val *b);

View File

@ -317,12 +317,6 @@ txnid_t mdbx_debug_edge;
/** The version number for a database's lockfile format. */
#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 */
/** Key size which fits in a #DKBUF.
* @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))
return MDB_BAD_VALSIZE;
#if SIZE_MAX > MAXDATASIZE
if (unlikely(data->mv_size > ((mc->mc_db->md_flags & MDB_DUPSORT)
? env->me_maxkey_limit
: MAXDATASIZE)))
: MDBX_MAXDATASIZE)))
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) &&
unlikely(key->mv_size != sizeof(uint32_t) &&