mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Fix mdb_rebalance collapsing root
Shift the rest of the cursor stack as needed
This commit is contained in:
parent
4844a72d01
commit
4b9aed26a5
2 changed files with 6 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright 2011-2013 Howard Chu, Symas Corp.
|
Copyright 2011-2014 Howard Chu, Symas Corp.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
||||||
|
|
@ -7383,6 +7383,7 @@ mdb_rebalance(MDB_cursor *mc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_BRANCH(mp) && NUMKEYS(mp) == 1) {
|
} else if (IS_BRANCH(mp) && NUMKEYS(mp) == 1) {
|
||||||
|
int i;
|
||||||
DPUTS("collapsing root page!");
|
DPUTS("collapsing root page!");
|
||||||
rc = mdb_midl_append(&mc->mc_txn->mt_free_pgs, mp->mp_pgno);
|
rc = mdb_midl_append(&mc->mc_txn->mt_free_pgs, mp->mp_pgno);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|
@ -7394,6 +7395,10 @@ mdb_rebalance(MDB_cursor *mc)
|
||||||
mc->mc_db->md_depth--;
|
mc->mc_db->md_depth--;
|
||||||
mc->mc_db->md_branch_pages--;
|
mc->mc_db->md_branch_pages--;
|
||||||
mc->mc_ki[0] = mc->mc_ki[1];
|
mc->mc_ki[0] = mc->mc_ki[1];
|
||||||
|
for (i = 1; i<mc->mc_db->md_depth; i++) {
|
||||||
|
mc->mc_pg[i] = mc->mc_pg[i+1];
|
||||||
|
mc->mc_ki[i] = mc->mc_ki[i+1];
|
||||||
|
}
|
||||||
{
|
{
|
||||||
/* Adjust other cursors pointing to mp */
|
/* Adjust other cursors pointing to mp */
|
||||||
MDB_cursor *m2, *m3;
|
MDB_cursor *m2, *m3;
|
||||||
|
|
@ -7406,7 +7411,6 @@ mdb_rebalance(MDB_cursor *mc)
|
||||||
m3 = m2;
|
m3 = m2;
|
||||||
if (m3 == mc || m3->mc_snum < mc->mc_snum) continue;
|
if (m3 == mc || m3->mc_snum < mc->mc_snum) continue;
|
||||||
if (m3->mc_pg[0] == mp) {
|
if (m3->mc_pg[0] == mp) {
|
||||||
int i;
|
|
||||||
m3->mc_snum--;
|
m3->mc_snum--;
|
||||||
m3->mc_top--;
|
m3->mc_top--;
|
||||||
for (i=0; i<m3->mc_snum; i++) {
|
for (i=0; i<m3->mc_snum; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue