MDB_node *node;
char *base;
size_t len;
- int delta;
+ int delta, delta0;
indx_t ptr, i, numkeys;
DKBUF;
}
#endif
- delta = key->mv_size - node->mn_ksize;
+ delta0 = delta = key->mv_size - node->mn_ksize;
+
+ /* 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) {
mp->mp_upper -= delta;
node = NODEPTR(mp, indx);
- node->mn_ksize = key->mv_size;
}
+ /* But even if no shift was needed, update ksize */
+ if (delta0)
+ node->mn_ksize = key->mv_size;
+
if (key->mv_size)
memcpy(NODEKEY(node), key->mv_data, key->mv_size);