From 17eb5eab4da1549e2d3e195350c9a151e7fcca86 Mon Sep 17 00:00:00 2001 From: marko <> Date: Thu, 11 May 2006 12:31:22 +0000 Subject: [PATCH] branches/zip: Minor cleanup. btr_cur_compress_if_useful(): Replace if () return(); return() with return. page_rec_get_next_low(): New function. page_rec_get_prev(): Invoke page_is_comp() outside the loop. Replace page_rec_get_next() with loop-specific instances of page_rec_get_next_low(). page_copy_rec_list_end(): Add some debug assertions. --- btr/btr0cur.c | 8 ++------ include/page0page.h | 12 ++++++++++-- include/page0page.ic | 33 ++++++++++++++++++++++++++------- page/page0page.c | 8 ++++---- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/btr/btr0cur.c b/btr/btr0cur.c index c44bc3e4c01..019ad8b9744 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -2535,12 +2535,8 @@ btr_cur_compress_if_useful( ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)), MTR_MEMO_PAGE_X_FIX)); - if (btr_cur_compress_recommendation(cursor, mtr)) { - - return(btr_compress(cursor, mtr)); - } - - return(FALSE); + return(btr_cur_compress_recommendation(cursor, mtr) + && btr_compress(cursor, mtr)); } /*********************************************************** diff --git a/include/page0page.h b/include/page0page.h index 94e0b0b14b0..931faff7ffb 100644 --- a/include/page0page.h +++ b/include/page0page.h @@ -416,11 +416,19 @@ page_is_leaf( Gets the pointer to the next record on the page. */ UNIV_INLINE rec_t* +page_rec_get_next_low( +/*==================*/ + /* out: pointer to next record */ + rec_t* rec, /* in: pointer to record */ + ulint comp); /* in: nonzero=compact page layout */ +/**************************************************************** +Gets the pointer to the next record on the page. */ +UNIV_INLINE +rec_t* page_rec_get_next( /*==============*/ /* out: pointer to next record */ - rec_t* rec); /* in: pointer to record, must not be page - supremum */ + rec_t* rec); /* in: pointer to record */ /**************************************************************** Sets the pointer to the next record on the page. */ UNIV_INLINE diff --git a/include/page0page.ic b/include/page0page.ic index 6686438909b..433dabcf4a8 100644 --- a/include/page0page.ic +++ b/include/page0page.ic @@ -589,10 +589,11 @@ page_dir_calc_reserved_space( Gets the pointer to the next record on the page. */ UNIV_INLINE rec_t* -page_rec_get_next( -/*==============*/ +page_rec_get_next_low( +/*==================*/ /* out: pointer to next record */ - rec_t* rec) /* in: pointer to record */ + rec_t* rec, /* in: pointer to record */ + ulint comp) /* in: nonzero=compact page layout */ { ulint offs; page_t* page; @@ -601,7 +602,7 @@ page_rec_get_next( page = ut_align_down(rec, UNIV_PAGE_SIZE); - offs = rec_get_next_offs(rec, page_is_comp(page)); + offs = rec_get_next_offs(rec, comp); if (UNIV_UNLIKELY(offs >= UNIV_PAGE_SIZE)) { fprintf(stderr, @@ -625,6 +626,17 @@ page_rec_get_next( return(page + offs); } +/**************************************************************** +Gets the pointer to the next record on the page. */ +UNIV_INLINE +rec_t* +page_rec_get_next( +/*==============*/ + /* out: pointer to next record */ + rec_t* rec) /* in: pointer to record */ +{ + return(page_rec_get_next_low(rec, page_rec_is_comp(rec))); +} /**************************************************************** Sets the pointer to the next record on the page. */ UNIV_INLINE @@ -688,9 +700,16 @@ page_rec_get_prev( rec2 = page_dir_slot_get_rec(slot); - while (rec != rec2) { - prev_rec = rec2; - rec2 = page_rec_get_next(rec2); + if (page_is_comp(page)) { + while (rec != rec2) { + prev_rec = rec2; + rec2 = page_rec_get_next_low(rec2, TRUE); + } + } else { + while (rec != rec2) { + prev_rec = rec2; + rec2 = page_rec_get_next_low(rec2, FALSE); + } } ut_a(prev_rec); diff --git a/page/page0page.c b/page/page0page.c index f9517b06b2b..bbaa8aa8210 100644 --- a/page/page0page.c +++ b/page/page0page.c @@ -599,10 +599,12 @@ page_copy_rec_list_end( dict_index_t* index, /* in: record descriptor */ mtr_t* mtr) /* in: mtr */ { - page_t* page; - ulint log_mode = 0; /* remove warning */ + page_t* page = ut_align_down(rec, UNIV_PAGE_SIZE); + ulint log_mode= 0; /* remove warning */ ut_ad(!new_page_zip || page_zip_validate(new_page_zip, new_page)); + ut_ad(page_is_leaf(page) == page_is_leaf(new_page)); + ut_ad(page_is_comp(page) == page_is_comp(new_page)); if (UNIV_LIKELY_NULL(new_page_zip)) { log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); @@ -615,8 +617,6 @@ page_copy_rec_list_end( page_copy_rec_list_end_no_locks(new_page, rec, index, mtr); } - page = ut_align_down(rec, UNIV_PAGE_SIZE); - if (UNIV_LIKELY_NULL(new_page_zip)) { mtr_set_log_mode(mtr, log_mode); -- 2.30.9