mdb_page_list(MDB_page *mp)
{
MDB_node *node;
- unsigned int i, nkeys, nsize;
+ unsigned int i, nkeys, nsize, total = 0;
MDB_val key;
DKBUF;
node = NODEPTR(mp, i);
key.mv_size = node->mn_ksize;
key.mv_data = node->mn_data;
- nsize = NODESIZE + NODEKSZ(node) + sizeof(indx_t);
+ nsize = NODESIZE + key.mv_size;
if (IS_BRANCH(mp)) {
fprintf(stderr, "key %d: page %"Z"u, %s\n", i, NODEPGNO(node),
DKEY(&key));
+ total += nsize;
} else {
if (F_ISSET(node->mn_flags, F_BIGDATA))
nsize += sizeof(pgno_t);
else
nsize += NODEDSZ(node);
+ total += nsize;
+ nsize += sizeof(indx_t);
fprintf(stderr, "key %d: nsize %d, %s\n", i, nsize, DKEY(&key));
}
+ total += (total & 1);
}
+ fprintf(stderr, "Total: %d\n", total);
}
void
MDB_node *node;
char *base;
size_t len;
- int delta, delta0;
+ int delta, ksize, oksize;
indx_t ptr, i, numkeys, indx;
DKBUF;
}
#endif
- delta0 = delta = key->mv_size - node->mn_ksize;
+ ksize = key->mv_size;
+ ksize += (ksize & 1);
+ oksize = node->mn_ksize;
+ oksize += (oksize & 1);
+ delta = ksize - oksize;
/* Must be 2-byte aligned. If new key is
* shorter by 1, the shift will be skipped.
*/
- delta += (delta & 1);
if (delta) {
if (delta > 0 && SIZELEFT(mp) < delta) {
pgno_t pgno;
}
/* But even if no shift was needed, update ksize */
- if (delta0)
+ if (node->mn_ksize != key->mv_size)
node->mn_ksize = key->mv_size;
if (key->mv_size)