Skip to content

Commit 98ed192

Browse files
hychfuru
authored andcommitted
ITS#7956 fix compact of empty env
1 parent af99820 commit 98ed192

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libraries/liblmdb/mdb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8589,8 +8589,12 @@ mdb_env_copyfd1(MDB_env *env, HANDLE fd)
85898589
/* Set metapage 1 */
85908590
mm->mm_last_pg = txn->mt_next_pgno - freecount - 1;
85918591
mm->mm_dbs[1] = txn->mt_dbs[1];
8592-
mm->mm_dbs[1].md_root = mm->mm_last_pg;
8593-
mm->mm_txnid = 1;
8592+
if (mm->mm_last_pg > 1) {
8593+
mm->mm_dbs[1].md_root = mm->mm_last_pg;
8594+
mm->mm_txnid = 1;
8595+
} else {
8596+
mm->mm_dbs[1].md_root = P_INVALID;
8597+
}
85948598
}
85958599
my.mc_wlen[0] = env->me_psize * 2;
85968600
my.mc_txn = txn;

0 commit comments

Comments
 (0)