Skip to content
Snippets Groups Projects
Commit d7c8128b authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#7219 fixup keysize in previous commit

parent 2150d16e
No related branches found
No related tags found
No related merge requests found
...@@ -5057,7 +5057,7 @@ mdb_update_key(MDB_page *mp, indx_t indx, MDB_val *key) ...@@ -5057,7 +5057,7 @@ mdb_update_key(MDB_page *mp, indx_t indx, MDB_val *key)
MDB_node *node; MDB_node *node;
char *base; char *base;
size_t len; size_t len;
int delta; int delta, delta0;
indx_t ptr, i, numkeys; indx_t ptr, i, numkeys;
DKBUF; DKBUF;
...@@ -5077,7 +5077,11 @@ mdb_update_key(MDB_page *mp, indx_t indx, MDB_val *key) ...@@ -5077,7 +5077,11 @@ mdb_update_key(MDB_page *mp, indx_t indx, MDB_val *key)
} }
#endif #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); delta += (delta & 1);
if (delta) { if (delta) {
if (delta > 0 && SIZELEFT(mp) < delta) { if (delta > 0 && SIZELEFT(mp) < delta) {
...@@ -5097,9 +5101,12 @@ mdb_update_key(MDB_page *mp, indx_t indx, MDB_val *key) ...@@ -5097,9 +5101,12 @@ mdb_update_key(MDB_page *mp, indx_t indx, MDB_val *key)
mp->mp_upper -= delta; mp->mp_upper -= delta;
node = NODEPTR(mp, indx); 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) if (key->mv_size)
memcpy(NODEKEY(node), key->mv_data, key->mv_size); memcpy(NODEKEY(node), key->mv_data, key->mv_size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment