From ab4597cedc0634b088525b9d00d72aa37f532e76 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Fri, 31 Mar 2017 17:59:12 +0300 Subject: [PATCH] mdbx: add MDBX_MAXDATASIZE. --- mdbx.h | 4 ++++ src/mdbx.c | 14 +------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/mdbx.h b/mdbx.h index 594e488c..2d30b2b8 100644 --- a/mdbx.h +++ b/mdbx.h @@ -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); diff --git a/src/mdbx.c b/src/mdbx.c index 552a424f..384ecfda 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -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) &&