|
|
@ -6497,21 +6497,19 @@ mdb_node_shrink(MDB_page *mp, indx_t indx) |
|
|
|
MDB_node *node; |
|
|
|
MDB_node *node; |
|
|
|
MDB_page *sp, *xp; |
|
|
|
MDB_page *sp, *xp; |
|
|
|
char *base; |
|
|
|
char *base; |
|
|
|
int osize, nsize; |
|
|
|
int nsize, delta; |
|
|
|
int delta; |
|
|
|
|
|
|
|
indx_t i, numkeys, ptr; |
|
|
|
indx_t i, numkeys, ptr; |
|
|
|
|
|
|
|
|
|
|
|
node = NODEPTR(mp, indx); |
|
|
|
node = NODEPTR(mp, indx); |
|
|
|
sp = (MDB_page *)NODEDATA(node); |
|
|
|
sp = (MDB_page *)NODEDATA(node); |
|
|
|
osize = NODEDSZ(node); |
|
|
|
delta = SIZELEFT(sp); |
|
|
|
|
|
|
|
|
|
|
|
delta = sp->mp_upper - sp->mp_lower; |
|
|
|
|
|
|
|
SETDSZ(node, osize - delta); |
|
|
|
|
|
|
|
xp = (MDB_page *)((char *)sp + delta); |
|
|
|
xp = (MDB_page *)((char *)sp + delta); |
|
|
|
|
|
|
|
|
|
|
|
/* shift subpage upward */ |
|
|
|
/* shift subpage upward */ |
|
|
|
if (IS_LEAF2(sp)) { |
|
|
|
if (IS_LEAF2(sp)) { |
|
|
|
nsize = NUMKEYS(sp) * sp->mp_pad; |
|
|
|
nsize = NUMKEYS(sp) * sp->mp_pad; |
|
|
|
|
|
|
|
if (nsize & 1) |
|
|
|
|
|
|
|
return; /* do not make the node uneven-sized */ |
|
|
|
memmove(METADATA(xp), METADATA(sp), nsize); |
|
|
|
memmove(METADATA(xp), METADATA(sp), nsize); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int i; |
|
|
|
int i; |
|
|
@ -6525,6 +6523,9 @@ mdb_node_shrink(MDB_page *mp, indx_t indx) |
|
|
|
xp->mp_pad = sp->mp_pad; |
|
|
|
xp->mp_pad = sp->mp_pad; |
|
|
|
COPY_PGNO(xp->mp_pgno, mp->mp_pgno); |
|
|
|
COPY_PGNO(xp->mp_pgno, mp->mp_pgno); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsize = NODEDSZ(node) - delta; |
|
|
|
|
|
|
|
SETDSZ(node, nsize); |
|
|
|
|
|
|
|
|
|
|
|
/* shift lower nodes upward */ |
|
|
|
/* shift lower nodes upward */ |
|
|
|
ptr = mp->mp_ptrs[indx]; |
|
|
|
ptr = mp->mp_ptrs[indx]; |
|
|
|
numkeys = NUMKEYS(mp); |
|
|
|
numkeys = NUMKEYS(mp); |
|
|
|