Commit 311f071c authored by Howard Chu's avatar Howard Chu
Browse files

Support db_pagesize in mdb_load

Since setting was added in de08119a
parent fccd990c
......@@ -40,6 +40,8 @@ static MDB_envinfo info;
static MDB_val kbuf, dbuf;
static MDB_val k0buf;
static unsigned int pagesize;
#define Yu MDB_PRIy(u)
#define STRLENOF(s) (sizeof(s)-1)
......@@ -128,6 +130,17 @@ static void readhdr(void)
prog, lineno, (char *)dbuf.mv_data+STRLENOF("maxreaders="));
} else if (!strncmp(dbuf.mv_data, "db_pagesize=", STRLENOF("db_pagesize="))) {
int i;
ptr = memchr(dbuf.mv_data, '\n', dbuf.mv_size);
if (ptr) *ptr = '\0';
i = sscanf((char *)dbuf.mv_data+STRLENOF("db_pagesize="),
"%u", &pagesize);
if (i != 1) {
fprintf(stderr, "%s: line %"Yu": invalid pagesize %s\n",
prog, lineno, (char *)dbuf.mv_data+STRLENOF("db_pagesize="));
} else {
int i;
for (i=0; dbflags[i].bit; i++) {
......@@ -384,6 +397,9 @@ int main(int argc, char *argv[])
if (info.me_mapsize)
mdb_env_set_mapsize(env, info.me_mapsize);
if (pagesize)
mdb_env_set_pagesize(env, pagesize);
if (info.me_mapaddr)
envflags |= MDB_FIXEDMAP;
......@@ -443,6 +459,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "%s: line %"Yu": failed to read key value\n", prog, lineno);
goto txn_abort;
if (!key.mv_size) {
fprintf(stderr, "%s: line %"Yu": zero-length key(ignored)\n", prog, lineno);
if (append) {
appflag = MDB_APPEND;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment