mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:14:12 +08:00
mdbx: backport - Refix root split check from 5da67968afb599697d7557c13b65fb961ec408dd.
Change-Id: If012ddcf223a3312bbe13c4b24d776b488ed3772
This commit is contained in:
parent
6ba0b8b467
commit
90fdef7a6a
13
mdb.c
13
mdb.c
@ -8611,6 +8611,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
|
|||||||
/* Copy separator key to the parent.
|
/* Copy separator key to the parent.
|
||||||
*/
|
*/
|
||||||
if (SIZELEFT(mn.mc_pg[ptop]) < mdb_branch_size(env, &sepkey)) {
|
if (SIZELEFT(mn.mc_pg[ptop]) < mdb_branch_size(env, &sepkey)) {
|
||||||
|
int snum = mc->mc_snum;
|
||||||
mn.mc_snum--;
|
mn.mc_snum--;
|
||||||
mn.mc_top--;
|
mn.mc_top--;
|
||||||
did_split = 1;
|
did_split = 1;
|
||||||
@ -8619,13 +8620,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* root split? */
|
/* root split? */
|
||||||
if (mn.mc_snum == mc->mc_snum) {
|
if (mc->mc_snum > snum) {
|
||||||
mc->mc_pg[mc->mc_snum] = mc->mc_pg[mc->mc_top];
|
|
||||||
mc->mc_ki[mc->mc_snum] = mc->mc_ki[mc->mc_top];
|
|
||||||
mc->mc_pg[mc->mc_top] = mc->mc_pg[ptop];
|
|
||||||
mc->mc_ki[mc->mc_top] = mc->mc_ki[ptop];
|
|
||||||
mc->mc_snum++;
|
|
||||||
mc->mc_top++;
|
|
||||||
ptop++;
|
ptop++;
|
||||||
}
|
}
|
||||||
/* Right page might now have changed parent.
|
/* Right page might now have changed parent.
|
||||||
@ -8756,8 +8751,6 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
|
|||||||
continue;
|
continue;
|
||||||
if (!(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
|
if (!(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
|
||||||
continue;
|
continue;
|
||||||
if (m3->mc_flags & C_SPLITTING)
|
|
||||||
continue;
|
|
||||||
if (new_root) {
|
if (new_root) {
|
||||||
int k;
|
int k;
|
||||||
/* root split */
|
/* root split */
|
||||||
@ -8774,6 +8767,8 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
|
|||||||
m3->mc_snum++;
|
m3->mc_snum++;
|
||||||
m3->mc_top++;
|
m3->mc_top++;
|
||||||
}
|
}
|
||||||
|
if (m3->mc_flags & C_SPLITTING)
|
||||||
|
continue;
|
||||||
if (m3->mc_top >= mc->mc_top && m3->mc_pg[mc->mc_top] == mp) {
|
if (m3->mc_top >= mc->mc_top && m3->mc_pg[mc->mc_top] == mp) {
|
||||||
if (m3->mc_ki[mc->mc_top] >= newindx && !(nflags & MDB_SPLIT_REPLACE))
|
if (m3->mc_ki[mc->mc_top] >= newindx && !(nflags & MDB_SPLIT_REPLACE))
|
||||||
m3->mc_ki[mc->mc_top]++;
|
m3->mc_ki[mc->mc_top]++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user