Commit 61f21148 authored by marko's avatar marko

branches/zip: Bug fixes and improvements.

page_header_reset_last_insert(): Add page_zip parameter.
rec_get_next_ptr(): Return a pointer to the same page, or NULL.
page_dir_delete_slot(): Fix off-by-one errors.
parent 18f8313a
......@@ -3192,7 +3192,11 @@ ibuf_merge_or_delete_for_page(
if (ibuf_rec_get_page_no(ibuf_rec) != page_no
|| ibuf_rec_get_space(ibuf_rec) != space) {
if (page) {
page_header_reset_last_insert(page, &mtr);
/* TODO: if the insert buffer is adapted for
use on compressed pages, pass the compressed
page as a parameter */
page_header_reset_last_insert(
page, NULL, &mtr);
}
goto reset_bit;
}
......
......@@ -191,7 +191,7 @@ void
page_header_set_ptr(
/*================*/
page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in: compressed page whose
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint field, /* in/out: PAGE_FREE, ... */
const byte* ptr); /* in: pointer or NULL*/
......@@ -202,8 +202,10 @@ UNIV_INLINE
void
page_header_reset_last_insert(
/*==========================*/
page_t* page, /* in: page */
mtr_t* mtr); /* in: mtr */
page_t* page, /* in: page */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
mtr_t* mtr); /* in: mtr */
/****************************************************************
Gets the first record on the page. */
UNIV_INLINE
......
......@@ -120,7 +120,7 @@ void
page_header_set_ptr(
/*================*/
page_t* page, /* in: page */
page_zip_des_t* page_zip,/* in: compressed page whose
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint field, /* in: PAGE_FREE, ... */
const byte* ptr) /* in: pointer or NULL*/
......@@ -150,13 +150,19 @@ UNIV_INLINE
void
page_header_reset_last_insert(
/*==========================*/
page_t* page, /* in: page */
mtr_t* mtr) /* in: mtr */
page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
mtr_t* mtr) /* in: mtr */
{
ut_ad(page && mtr);
mlog_write_ulint(page + PAGE_HEADER + PAGE_LAST_INSERT, 0,
mlog_write_ulint(page + (PAGE_HEADER + PAGE_LAST_INSERT), 0,
MLOG_2BYTES, mtr);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip,
page + (PAGE_HEADER + PAGE_LAST_INSERT), 2);
}
}
/****************************************************************
......
......@@ -294,7 +294,8 @@ rec_get_next_ptr(
+ ut_align_offset(rec, UNIV_PAGE_SIZE)
< UNIV_PAGE_SIZE);
#endif
return(rec + field_value);
return(ut_align_down(rec, UNIV_PAGE_SIZE)
+ ut_align_offset(rec + field_value, UNIV_PAGE_SIZE));
} else {
ut_ad(field_value < UNIV_PAGE_SIZE);
......
......@@ -1100,7 +1100,7 @@ page_dir_delete_slot(
ut_ad(!page_zip || page_zip_available(page_zip, 10));
ut_ad(!page_zip || page_is_comp(page));
ut_ad(slot_no > 0);
ut_ad(slot_no < page_dir_get_n_slots(page));
ut_ad(slot_no + 1 < page_dir_get_n_slots(page));
n_slots = page_dir_get_n_slots(page);
......@@ -1113,14 +1113,14 @@ page_dir_delete_slot(
/* 2. Update the n_owned value of the first non-deleted slot */
slot = page_dir_get_nth_slot(page, slot_no + 1);
page_dir_slot_set_n_owned(slot, page_zip, n_owned
+ page_dir_slot_get_n_owned(slot));
page_dir_slot_set_n_owned(slot, page_zip,
n_owned + page_dir_slot_get_n_owned(slot));
/* 3. Destroy the slot by copying slots */
for (i = slot_no + 1; i < n_slots; i++) {
rec_t* rec;
rec = page_dir_slot_get_rec(page_dir_get_nth_slot(page, i));
page_dir_slot_set_rec(page_dir_get_nth_slot(page, i),
page_dir_slot_set_rec(page_dir_get_nth_slot(page, i - 1),
page_zip, rec);
}
......@@ -1288,15 +1288,15 @@ page_dir_balance_slot(
rec_set_n_owned_new(old_rec, page_zip, 0);
rec_set_n_owned_new(new_rec, page_zip, n_owned + 1);
page_dir_slot_set_rec(slot, page_zip, new_rec);
} else {
new_rec = rec_get_next_ptr(old_rec, FALSE);
rec_set_n_owned_old(old_rec, 0);
rec_set_n_owned_old(new_rec, n_owned + 1);
page_dir_slot_set_rec(slot, page_zip, new_rec);
}
page_dir_slot_set_rec(slot, page_zip, new_rec);
page_dir_slot_set_n_owned(up_slot, page_zip, up_n_owned -1);
} else {
/* In this case we may merge the two slots */
......
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