Commit 4b252f24 authored by marko's avatar marko

branches/zip: page_zip_dir_insert(): When looking for slot_rec, use the

old value of PAGE_N_RECS.

page_zip_dir_find_free_low(): Rename to page_zip_dir_find_low().

page_zip_dir_find(): Make use of page_zip_dir_find_low().
parent 1180ce98
...@@ -88,23 +88,18 @@ page_zip_dir_user_size( ...@@ -88,23 +88,18 @@ page_zip_dir_user_size(
} }
/***************************************************************** /*****************************************************************
Find the slot of the given non-free record in the dense page directory. */ Find the slot of the given record in the dense page directory. */
UNIV_INLINE UNIV_INLINE
byte* byte*
page_zip_dir_find( page_zip_dir_find_low(
/*==============*/ /*==================*/
/* out: dense directory slot, /* out: dense directory slot,
or NULL if record not found */ or NULL if record not found */
page_zip_des_t* page_zip, /* in: compressed page */ byte* slot, /* in: start of records */
byte* end, /* in: end of records */
ulint offset) /* in: offset of user record */ ulint offset) /* in: offset of user record */
{ {
byte* slot; ut_ad(slot <= end);
byte* end;
ut_ad(page_zip_simple_validate(page_zip));
end = page_zip->data + page_zip->size;
slot = end - page_zip_dir_user_size(page_zip);
for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) { for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) {
if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK) if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK)
...@@ -117,27 +112,23 @@ page_zip_dir_find( ...@@ -117,27 +112,23 @@ page_zip_dir_find(
} }
/***************************************************************** /*****************************************************************
Find the slot of the given free record in the dense page directory. */ Find the slot of the given non-free record in the dense page directory. */
UNIV_INLINE UNIV_INLINE
byte* byte*
page_zip_dir_find_free_low( page_zip_dir_find(
/*=======================*/ /*==============*/
/* out: dense directory slot, /* out: dense directory slot,
or NULL if record not found */ or NULL if record not found */
byte* slot, /* in: start of deleted records */ page_zip_des_t* page_zip, /* in: compressed page */
byte* end, /* in: end of deleted records */
ulint offset) /* in: offset of user record */ ulint offset) /* in: offset of user record */
{ {
ut_ad(slot <= end); byte* end = page_zip->data + page_zip->size;
for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) { ut_ad(page_zip_simple_validate(page_zip));
if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK)
== offset) {
return(slot);
}
}
return(NULL); return(page_zip_dir_find_low(
end - page_zip_dir_user_size(page_zip),
end, offset));
} }
/***************************************************************** /*****************************************************************
...@@ -155,7 +146,7 @@ page_zip_dir_find_free( ...@@ -155,7 +146,7 @@ page_zip_dir_find_free(
ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_simple_validate(page_zip));
return(page_zip_dir_find_free_low( return(page_zip_dir_find_low(
end - page_zip_dir_size(page_zip), end - page_zip_dir_size(page_zip),
end - page_zip_dir_user_size(page_zip), offset)); end - page_zip_dir_user_size(page_zip), offset));
} }
...@@ -956,7 +947,7 @@ page_zip_compress( ...@@ -956,7 +947,7 @@ page_zip_compress(
/* Skip deleted records. */ /* Skip deleted records. */
if (UNIV_LIKELY_NULL( if (UNIV_LIKELY_NULL(
page_zip_dir_find_free_low( page_zip_dir_find_low(
buf_end - PAGE_ZIP_DIR_SLOT_SIZE buf_end - PAGE_ZIP_DIR_SLOT_SIZE
* n_dense, * n_dense,
buf_end - PAGE_ZIP_DIR_SLOT_SIZE buf_end - PAGE_ZIP_DIR_SLOT_SIZE
...@@ -2864,12 +2855,24 @@ page_zip_dir_insert( ...@@ -2864,12 +2855,24 @@ page_zip_dir_insert(
ut_ad(prev_rec != rec); ut_ad(prev_rec != rec);
ut_ad(page_rec_get_next((rec_t*) prev_rec) == rec); ut_ad(page_rec_get_next((rec_t*) prev_rec) == rec);
ut_ad(page_zip_simple_validate(page_zip));
if (page_rec_is_infimum(prev_rec)) { if (page_rec_is_infimum(prev_rec)) {
/* Use the first slot. */ /* Use the first slot. */
slot_rec = page_zip->data + page_zip->size; slot_rec = page_zip->data + page_zip->size;
} else { } else {
slot_rec = page_zip_dir_find(page_zip, byte* end = page_zip->data + page_zip->size;
byte* start = end - page_zip_dir_user_size(page_zip);
if (UNIV_LIKELY(!free_rec)) {
/* PAGE_N_RECS was already incremented
in page_cur_insert_rec_low(), but the
dense directory slot at that position
contains garbage. Skip it. */
start += PAGE_ZIP_DIR_SLOT_SIZE;
}
slot_rec = page_zip_dir_find_low(start, end,
ut_align_offset(prev_rec, UNIV_PAGE_SIZE)); ut_align_offset(prev_rec, UNIV_PAGE_SIZE));
ut_a(slot_rec); ut_a(slot_rec);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment