Renumber MDB_NOSUBDIR. Check mdb_env_open() flags.

MDB_NOSUBDIR was == MDB_REVERSEKEY. That affected the freelist:
Env flags are stored in mm_flags alias mm_dbs[FREE_DBI].md_flags.

It stays a persistent flag, in case mdb_env_open someday wants
to pick/verify which lockfile to use with the datafile.

Catch bad flags so they will no longer make it into the data file.
vmware
Hallvard Furuseth 12 years ago
parent bb36bdcd1c
commit 52e3adbdec
  1. 13
      libraries/libmdb/mdb.c
  2. 6
      libraries/libmdb/mdb.h

@ -3146,6 +3146,12 @@ fail:
#define DATANAME "/data.mdb" #define DATANAME "/data.mdb"
/** The suffix of the lock file when no subdir is used */ /** The suffix of the lock file when no subdir is used */
#define LOCKSUFF "-lock" #define LOCKSUFF "-lock"
/** Only a subset of the @ref mdb_env flags can be changed
* at runtime. Changing other flags requires closing the
* environment and re-opening it with the new flags.
*/
#define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC)
#define CHANGELESS (MDB_FIXEDMAP|MDB_NOSUBDIR|MDB_RDONLY|MDB_WRITEMAP)
int int
mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode) mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode)
@ -3153,7 +3159,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode)
int oflags, rc, len, excl; int oflags, rc, len, excl;
char *lpath, *dpath; char *lpath, *dpath;
if (env->me_fd != INVALID_HANDLE_VALUE) if (env->me_fd!=INVALID_HANDLE_VALUE || (flags & ~(CHANGEABLE|CHANGELESS)))
return EINVAL; return EINVAL;
len = strlen(path); len = strlen(path);
@ -6599,11 +6605,6 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi,
return mdb_cursor_put(&mc, key, data, flags); return mdb_cursor_put(&mc, key, data, flags);
} }
/** Only a subset of the @ref mdb_env flags can be changed
* at runtime. Changing other flags requires closing the environment
* and re-opening it with the new flags.
*/
#define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC)
int int
mdb_env_set_flags(MDB_env *env, unsigned int flag, int onoff) mdb_env_set_flags(MDB_env *env, unsigned int flag, int onoff)
{ {

@ -213,12 +213,14 @@ typedef int (MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *relctx); typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *relctx);
/** @defgroup mdb_env Environment Flags /** @defgroup mdb_env Environment Flags
*
* Values do not overlap Database Flags.
* @{ * @{
*/ */
/** mmap at a fixed address */ /** mmap at a fixed address */
#define MDB_FIXEDMAP 0x01 #define MDB_FIXEDMAP 0x01
/** no environment directory */ /** no environment directory */
#define MDB_NOSUBDIR 0x02 #define MDB_NOSUBDIR 0x4000
/** don't fsync after commit */ /** don't fsync after commit */
#define MDB_NOSYNC 0x10000 #define MDB_NOSYNC 0x10000
/** read only */ /** read only */
@ -232,6 +234,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
/** @} */ /** @} */
/** @defgroup mdb_open Database Flags /** @defgroup mdb_open Database Flags
*
* Values do not overlap Environment Flags.
* @{ * @{
*/ */
/** use reverse string keys */ /** use reverse string keys */

Loading…
Cancel
Save