diff --git a/btr/btr0btr.c b/btr/btr0btr.c index 46a2b9372df..bac51cd12bc 100644 --- a/btr/btr0btr.c +++ b/btr/btr0btr.c @@ -535,7 +535,7 @@ btr_node_ptr_get_child( ulint space; ut_ad(rec_offs_validate(node_ptr, index, offsets)); - space = page_get_space_id(page_align((rec_t*) node_ptr)); + space = page_get_space_id(page_align(node_ptr)); page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); return(btr_block_get(space, dict_table_zip_size(index->table), @@ -2252,12 +2252,14 @@ btr_lift_page_up( (!page_copy_rec_list_end(father_block, block, page_get_infimum_rec(page), index, mtr))) { + const page_zip_des_t* page_zip + = buf_block_get_page_zip(block); ut_a(father_page_zip); + ut_a(page_zip); /* Copy the page byte for byte. */ page_zip_copy(father_page_zip, father_page, - buf_block_get_page_zip(block), - page, index, mtr); + page_zip, page, index, mtr); } lock_update_copy_and_discard(father_block, block); @@ -2432,8 +2434,11 @@ err_exit: merge_page_zip = buf_block_get_page_zip(merge_block); #ifdef UNIV_ZIP_DEBUG if (UNIV_LIKELY_NULL(merge_page_zip)) { + const page_zip_des_t* page_zip + = buf_block_get_page_zip(block); + ut_a(page_zip); ut_a(page_zip_validate(merge_page_zip, merge_page)); - ut_a(page_zip_validate(buf_block_get_page_zip(block), page)); + ut_a(page_zip_validate(page_zip, page)); } #endif /* UNIV_ZIP_DEBUG */ diff --git a/btr/btr0cur.c b/btr/btr0cur.c index 04bf296fe95..7b777352598 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -494,10 +494,11 @@ retry_page_get: page = buf_block_get_frame(block); #ifdef UNIV_ZIP_DEBUG - ut_a(rw_latch == RW_NO_LATCH - || !buf_block_get_page_zip(block) - || page_zip_validate(buf_block_get_page_zip(block), - page)); + if (rw_latch != RW_NO_LATCH) { + const page_zip_des_t* page_zip + = buf_block_get_page_zip(block); + ut_a(!page_zip || page_zip_validate(page_zip, page)); + } #endif /* UNIV_ZIP_DEBUG */ block->check_index_page_at_flush = TRUE; @@ -1048,8 +1049,10 @@ btr_cur_optimistic_insert( /* If necessary for updating the insert buffer bitmap, calculate the current maximum insert size on a compressed page. */ if (zip_size && UNIV_LIKELY(leaf) && !dict_index_is_clust(index)) { - lint zip_max = page_zip_max_ins_size( - buf_block_get_page_zip(block), FALSE); + const page_zip_des_t* page_zip + = buf_block_get_page_zip(block); + lint zip_max + = page_zip_max_ins_size(page_zip, FALSE); if (zip_max >= 0 && max_size > (ulint) zip_max) { max_size_zip = (ulint) zip_max; diff --git a/btr/btr0sea.c b/btr/btr0sea.c index 6b512f87eb9..fe4e7da0547 100644 --- a/btr/btr0sea.c +++ b/btr/btr0sea.c @@ -776,7 +776,7 @@ btr_search_guess_on_hash( goto failure_unlock; } - page = page_align((rec_t*) rec); + page = page_align(rec); { ulint page_no = page_get_page_no(page); ulint space_id = page_get_space_id(page); diff --git a/include/btr0btr.ic b/include/btr0btr.ic index 52a44144354..5bbabe7e07c 100644 --- a/include/btr0btr.ic +++ b/include/btr0btr.ic @@ -258,7 +258,7 @@ btr_node_ptr_get_child_page_no( "InnoDB: a nonsensical page number 0" " in a node ptr record at offset %lu\n", (ulong) page_offset(rec)); - buf_page_print(page_align((rec_t*) rec), 0); + buf_page_print(page_align(rec), 0); } return(page_no); diff --git a/include/buf0buf.h b/include/buf0buf.h index ff86b8eb42b..08ddefc6fe8 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -854,32 +854,26 @@ buf_block_get_zip_size( /************************************************************************* Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ -UNIV_INLINE -page_zip_des_t* -buf_block_get_page_zip( -/*===================*/ - /* out: compressed page descriptor, or NULL */ - buf_block_t* block) /* in: pointer to the control block */ - __attribute((pure)); +#define buf_block_get_page_zip(block) \ + (UNIV_LIKELY_NULL((block)->page.zip.data) ? &(block)->page.zip : NULL) #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG /*********************************************************************** Gets the block to whose frame the pointer is pointing to. */ UNIV_INLINE -buf_block_t* +const buf_block_t* buf_block_align( /*============*/ - /* out: pointer to block */ - byte* ptr); /* in: pointer to a frame */ + /* out: pointer to block */ + const byte* ptr); /* in: pointer to a frame */ /************************************************************************* Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ UNIV_INLINE -page_zip_des_t* +const page_zip_des_t* buf_frame_get_page_zip( /*===================*/ - /* out: compressed page descriptor, or NULL */ - byte* ptr) /* in: pointer to the page */ - __attribute((pure)); + /* out: compressed page descriptor, or NULL */ + const byte* ptr); /* in: pointer to the page */ #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ /************************************************************************ This function is used to get info if there is an io operation diff --git a/include/buf0buf.ic b/include/buf0buf.ic index 21b20a19c27..890c5611e31 100644 --- a/include/buf0buf.ic +++ b/include/buf0buf.ic @@ -598,41 +598,24 @@ buf_block_get_zip_size( return(block->page.zip.ssize ? 512 << block->page.zip.ssize : 0); } -/************************************************************************* -Gets the compressed page descriptor corresponding to an uncompressed page -if applicable. */ -UNIV_INLINE -page_zip_des_t* -buf_block_get_page_zip( -/*===================*/ - /* out: compressed page descriptor, or NULL */ - buf_block_t* block) /* in: pointer to the control block */ -{ - if (UNIV_LIKELY_NULL(block->page.zip.data)) { - return(&block->page.zip); - } - - return(NULL); -} - #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG /*********************************************************************** Gets the block to whose frame the pointer is pointing to. */ UNIV_INLINE -buf_block_t* +const buf_block_t* buf_block_align( /*============*/ - /* out: pointer to block */ - byte* ptr) /* in: pointer to a frame */ + /* out: pointer to block */ + const byte* ptr) /* in: pointer to a frame */ { - buf_block_t* block; - ulint space_id, page_no; + const buf_block_t* block; + ulint space_id, page_no; ptr = ut_align_down(ptr, UNIV_PAGE_SIZE); page_no = mach_read_from_4(ptr + FIL_PAGE_OFFSET); space_id = mach_read_from_4(ptr + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - block = (buf_block_t*) buf_page_hash_get(space_id, page_no); + block = (const buf_block_t*) buf_page_hash_get(space_id, page_no); ut_ad(block); ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_ad(block->frame == ptr); @@ -643,11 +626,11 @@ buf_block_align( Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ UNIV_INLINE -page_zip_des_t* +const page_zip_des_t* buf_frame_get_page_zip( /*===================*/ - /* out: compressed page descriptor, or NULL */ - byte* ptr) /* in: pointer to the page */ + /* out: compressed page descriptor, or NULL */ + const byte* ptr) /* in: pointer to the page */ { page_zip_des_t* page_zip; mutex_enter(&buf_pool->mutex); @@ -668,7 +651,7 @@ buf_ptr_get_fsp_addr( ulint* space, /* out: space id */ fil_addr_t* addr) /* out: page offset and byte offset */ { - const page_t* page = (const page_t*) ut_align_down((void*) ptr, + const page_t* page = (const page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE); *space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); diff --git a/include/mtr0log.h b/include/mtr0log.h index 29d996859ec..9ec8b161a87 100644 --- a/include/mtr0log.h +++ b/include/mtr0log.h @@ -62,11 +62,11 @@ type and four-byte space and page numbers. */ void mlog_write_initial_log_record( /*==========================*/ - byte* ptr, /* in: pointer to (inside) a buffer frame - holding the file page where modification - is made */ - byte type, /* in: log item type: MLOG_1BYTE, ... */ - mtr_t* mtr); /* in: mini-transaction handle */ + const byte* ptr, /* in: pointer to (inside) a buffer + frame holding the file page where + modification is made */ + byte type, /* in: log item type: MLOG_1BYTE, ... */ + mtr_t* mtr); /* in: mini-transaction handle */ /************************************************************ Writes a log record about an .ibd file create/delete/rename. */ UNIV_INLINE @@ -140,12 +140,14 @@ UNIV_INLINE byte* mlog_write_initial_log_record_fast( /*===============================*/ - /* out: new value of log_ptr */ - byte* ptr, /* in: pointer to (inside) a buffer frame holding the - file page where modification is made */ - byte type, /* in: log item type: MLOG_1BYTE, ... */ - byte* log_ptr,/* in: pointer to mtr log which has been opened */ - mtr_t* mtr); /* in: mtr */ + /* out: new value of log_ptr */ + const byte* ptr, /* in: pointer to (inside) a buffer + frame holding the file page where + modification is made */ + byte type, /* in: log item type: MLOG_1BYTE, ... */ + byte* log_ptr,/* in: pointer to mtr log which has + been opened */ + mtr_t* mtr); /* in: mtr */ /************************************************************ Parses an initial log record written by mlog_write_initial_log_record. */ diff --git a/include/mtr0log.ic b/include/mtr0log.ic index 57f0abe255e..e3f60c2cd3f 100644 --- a/include/mtr0log.ic +++ b/include/mtr0log.ic @@ -153,12 +153,14 @@ UNIV_INLINE byte* mlog_write_initial_log_record_fast( /*===============================*/ - /* out: new value of log_ptr */ - byte* ptr, /* in: pointer to (inside) a buffer frame holding the - file page where modification is made */ - byte type, /* in: log item type: MLOG_1BYTE, ... */ - byte* log_ptr,/* in: pointer to mtr log which has been opened */ - mtr_t* mtr) /* in: mtr */ + /* out: new value of log_ptr */ + const byte* ptr, /* in: pointer to (inside) a buffer + frame holding the file page where + modification is made */ + byte type, /* in: log item type: MLOG_1BYTE, ... */ + byte* log_ptr,/* in: pointer to mtr log which has + been opened */ + mtr_t* mtr) /* in: mtr */ { #ifdef UNIV_DEBUG buf_block_t* block; @@ -191,7 +193,7 @@ mlog_write_initial_log_record_fast( #ifdef UNIV_DEBUG mutex_enter(&buf_pool->mutex); /* We now assume that all x-latched pages have been modified! */ - block = buf_block_align(ptr); + block = (buf_block_t*) buf_block_align(ptr); mutex_exit(&buf_pool->mutex); if (!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY)) { diff --git a/include/mtr0mtr.h b/include/mtr0mtr.h index 03c5958832d..5737c4ac4fa 100644 --- a/include/mtr0mtr.h +++ b/include/mtr0mtr.h @@ -272,10 +272,10 @@ UNIV_INLINE ibool mtr_memo_contains( /*==============*/ - /* out: TRUE if contains */ - mtr_t* mtr, /* in: mtr */ - void* object, /* in: object to search */ - ulint type); /* in: type of object */ + /* out: TRUE if contains */ + mtr_t* mtr, /* in: mtr */ + const void* object, /* in: object to search */ + ulint type); /* in: type of object */ /************************************************************** Checks if memo contains the given page. */ diff --git a/include/mtr0mtr.ic b/include/mtr0mtr.ic index 8d2ce27086a..7bccf65537f 100644 --- a/include/mtr0mtr.ic +++ b/include/mtr0mtr.ic @@ -120,10 +120,10 @@ UNIV_INLINE ibool mtr_memo_contains( /*==============*/ - /* out: TRUE if contains */ - mtr_t* mtr, /* in: mtr */ - void* object, /* in: object to search */ - ulint type) /* in: type of object */ + /* out: TRUE if contains */ + mtr_t* mtr, /* in: mtr */ + const void* object, /* in: object to search */ + ulint type) /* in: type of object */ { mtr_memo_slot_t* slot; dyn_array_t* memo; diff --git a/include/page0page.h b/include/page0page.h index ca3b842ae7b..67fc36fd9de 100644 --- a/include/page0page.h +++ b/include/page0page.h @@ -146,8 +146,8 @@ UNIV_INLINE page_t* page_align( /*=======*/ - /* out: start of the page */ - void* ptr) /* in: pointer to page frame */ + /* out: start of the page */ + const void* ptr) /* in: pointer to page frame */ __attribute__((const)); /**************************************************************** Gets the offset within a page. */ @@ -205,14 +205,22 @@ page_header_set_field( ulint field, /* in: PAGE_N_DIR_SLOTS, ... */ ulint val); /* in: value */ /***************************************************************** -Returns the pointer stored in the given header field. */ +Returns the offset stored in the given header field. */ UNIV_INLINE -byte* -page_header_get_ptr( -/*================*/ - /* out: pointer or NULL */ - page_t* page, /* in: page */ - ulint field); /* in: PAGE_FREE, ... */ +ulint +page_header_get_offs( +/*=================*/ + /* out: offset from the start of the page, + or 0 */ + const page_t* page, /* in: page */ + ulint field) /* in: PAGE_FREE, ... */ + __attribute__((nonnull, pure)); + +/***************************************************************** +Returns the pointer stored in the given header field, or NULL. */ +#define page_header_get_ptr(page, field) \ + (page_header_get_offs(page, field) \ + ? page + page_header_get_offs(page, field) : NULL) /***************************************************************** Sets the pointer stored in the given header field. */ UNIV_INLINE diff --git a/include/page0page.ic b/include/page0page.ic index 1d72c5cd9a3..dfc48b9defb 100644 --- a/include/page0page.ic +++ b/include/page0page.ic @@ -22,8 +22,8 @@ UNIV_INLINE page_t* page_align( /*=======*/ - /* out: start of the page */ - void* ptr) /* in: pointer to page frame */ + /* out: start of the page */ + const void* ptr) /* in: pointer to page frame */ { return((page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE)); } @@ -112,14 +112,15 @@ page_header_set_field( } /***************************************************************** -Returns the pointer stored in the given header field. */ +Returns the offset stored in the given header field. */ UNIV_INLINE -byte* -page_header_get_ptr( -/*================*/ - /* out: pointer or NULL */ - page_t* page, /* in: page */ - ulint field) /* in: PAGE_FREE, ... */ +ulint +page_header_get_offs( +/*=================*/ + /* out: offset from the start of the page, + or 0 */ + const page_t* page, /* in: page */ + ulint field) /* in: PAGE_FREE, ... */ { ulint offs; @@ -132,12 +133,7 @@ page_header_get_ptr( ut_ad((field != PAGE_HEAP_TOP) || offs); - if (offs == 0) { - - return(NULL); - } - - return(page + offs); + return(offs); } /***************************************************************** @@ -218,7 +214,7 @@ page_rec_is_comp( /* out: nonzero if in compact format */ const rec_t* rec) /* in: record */ { - return(page_is_comp(page_align((rec_t*) rec))); + return(page_is_comp(page_align(rec))); } /******************************************************************* @@ -562,7 +558,7 @@ page_rec_check( /* out: TRUE if succeed */ const rec_t* rec) /* in: record */ { - const page_t* page = page_align((rec_t*) rec); + const page_t* page = page_align(rec); ut_a(rec); @@ -862,9 +858,10 @@ page_mem_alloc_free( ulint garbage; #ifdef UNIV_DEBUG - rec_t* old_rec = page_header_get_ptr(page, PAGE_FREE); + const rec_t* old_rec = page_header_get_ptr(page, PAGE_FREE); ut_ad(old_rec); - ut_ad(next_rec == rec_get_next_ptr(old_rec, page_is_comp(page))); + ut_ad(next_rec == page + rec_get_next_offs(old_rec, + page_is_comp(page))); #endif page_header_set_ptr(page, page_zip, PAGE_FREE, next_rec); diff --git a/include/page0zip.ic b/include/page0zip.ic index 525847e3124..6582b801e18 100644 --- a/include/page0zip.ic +++ b/include/page0zip.ic @@ -350,7 +350,7 @@ page_zip_write_header( { ulint pos; - ut_ad(buf_frame_get_page_zip((byte*)str) == page_zip); + ut_ad(buf_frame_get_page_zip(str) == page_zip); ut_ad(page_zip_simple_validate(page_zip)); pos = page_offset(str); diff --git a/include/ut0byte.h b/include/ut0byte.h index eb291fd2dc0..827590dbef2 100644 --- a/include/ut0byte.h +++ b/include/ut0byte.h @@ -226,9 +226,9 @@ UNIV_INLINE void* ut_align_down( /*==========*/ - /* out: aligned pointer */ - void* ptr, /* in: pointer */ - ulint align_no) /* in: align by this number */ + /* out: aligned pointer */ + const void* ptr, /* in: pointer */ + ulint align_no) /* in: align by this number */ __attribute__((const)); /************************************************************* The following function computes the offset of a pointer from the nearest diff --git a/include/ut0byte.ic b/include/ut0byte.ic index 1afc858c0da..b48465d8c63 100644 --- a/include/ut0byte.ic +++ b/include/ut0byte.ic @@ -358,9 +358,9 @@ UNIV_INLINE void* ut_align_down( /*==========*/ - /* out: aligned pointer */ - void* ptr, /* in: pointer */ - ulint align_no) /* in: align by this number */ + /* out: aligned pointer */ + const void* ptr, /* in: pointer */ + ulint align_no) /* in: align by this number */ { ut_ad(align_no > 0); ut_ad(((align_no - 1) & align_no) == 0); diff --git a/lock/lock0lock.c b/lock/lock0lock.c index 327fdf24144..d665084dbac 100644 --- a/lock/lock0lock.c +++ b/lock/lock0lock.c @@ -573,7 +573,7 @@ lock_sec_rec_cons_read_sees( return(FALSE); } - max_trx_id = page_get_max_trx_id(page_align((rec_t*) rec)); + max_trx_id = page_get_max_trx_id(page_align(rec)); return(ut_dulint_cmp(max_trx_id, view->up_limit_id) < 0); } @@ -1322,10 +1322,10 @@ lock_rec_get_prev( const lock_t* in_lock,/* in: record lock */ ulint heap_no)/* in: heap number of the record */ { - const lock_t* lock; - ulint space; - ulint page_no; - const lock_t* found_lock = NULL; + lock_t* lock; + ulint space; + ulint page_no; + lock_t* found_lock = NULL; ut_ad(mutex_own(&kernel_mutex)); ut_ad(lock_get_type_low(in_lock) == LOCK_REC); @@ -1348,7 +1348,7 @@ lock_rec_get_prev( found_lock = lock; } - lock = lock_rec_get_next_on_page((lock_t*) lock); + lock = lock_rec_get_next_on_page(lock); } } @@ -1586,7 +1586,7 @@ lock_sec_rec_some_has_impl_off_kernel( dict_index_t* index, /* in: secondary index */ const ulint* offsets)/* in: rec_get_offsets(rec, index) */ { - const page_t* page = page_align((rec_t*) rec); + const page_t* page = page_align(rec); ut_ad(mutex_own(&kernel_mutex)); ut_ad(!dict_index_is_clust(index)); @@ -2774,8 +2774,8 @@ lock_move_rec_list_start( lock_t* lock; const ulint comp = page_rec_is_comp(rec); - ut_ad(block->frame == page_align((rec_t*) rec)); - ut_ad(new_block->frame == page_align((rec_t*) old_end)); + ut_ad(block->frame == page_align(rec)); + ut_ad(new_block->frame == page_align(old_end)); lock_mutex_enter_kernel(); @@ -3014,7 +3014,7 @@ lock_update_merge_left( { const rec_t* left_next_rec; - ut_ad(left_block->frame == page_align((rec_t*) orig_pred)); + ut_ad(left_block->frame == page_align(orig_pred)); lock_mutex_enter_kernel(); @@ -3149,7 +3149,7 @@ lock_update_insert( ulint receiver_heap_no; ulint donator_heap_no; - ut_ad(block->frame == page_align((rec_t*) rec)); + ut_ad(block->frame == page_align(rec)); /* Inherit the gap-locking locks for rec, in gap mode, from the next record */ @@ -3228,7 +3228,7 @@ lock_rec_store_on_page_infimum( { ulint heap_no = page_rec_get_heap_no(rec); - ut_ad(block->frame == page_align((rec_t*) rec)); + ut_ad(block->frame == page_align(rec)); lock_mutex_enter_kernel(); @@ -3899,7 +3899,7 @@ lock_rec_unlock( ulint heap_no; ut_ad(trx && rec); - ut_ad(block->frame == page_align((rec_t*) rec)); + ut_ad(block->frame == page_align(rec)); heap_no = page_rec_get_heap_no(rec); @@ -4569,7 +4569,7 @@ lock_rec_queue_validate( ulint heap_no; ut_a(rec); - ut_a(block->frame == page_align((rec_t*) rec)); + ut_a(block->frame == page_align(rec)); ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!page_rec_is_comp(rec) == !rec_offs_comp(offsets)); @@ -5044,7 +5044,7 @@ lock_clust_rec_modify_check_and_lock( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(dict_index_is_clust(index)); - ut_ad(block->frame == page_align((rec_t*) rec)); + ut_ad(block->frame == page_align(rec)); if (flags & BTR_NO_LOCKING_FLAG) { @@ -5179,7 +5179,7 @@ lock_sec_rec_read_check_and_lock( ulint heap_no; ut_ad(!dict_index_is_clust(index)); - ut_ad(block->frame == page_align((rec_t*) rec)); + ut_ad(block->frame == page_align(rec)); ut_ad(page_rec_is_user_rec(rec) || page_rec_is_supremum(rec)); ut_ad(rec_offs_validate(rec, index, offsets)); @@ -5255,7 +5255,7 @@ lock_clust_rec_read_check_and_lock( ulint heap_no; ut_ad(dict_index_is_clust(index)); - ut_ad(block->frame == page_align((rec_t*) rec)); + ut_ad(block->frame == page_align(rec)); ut_ad(page_rec_is_user_rec(rec) || page_rec_is_supremum(rec)); ut_ad(gap_mode == LOCK_ORDINARY || gap_mode == LOCK_GAP || gap_mode == LOCK_REC_NOT_GAP); diff --git a/mtr/mtr0log.c b/mtr/mtr0log.c index d8dacf0bcb4..59df9f1c336 100644 --- a/mtr/mtr0log.c +++ b/mtr/mtr0log.c @@ -47,10 +47,11 @@ to the mtr memo that a buffer page has been modified. */ void mlog_write_initial_log_record( /*==========================*/ - byte* ptr, /* in: pointer to (inside) a buffer frame holding the - file page where modification is made */ - byte type, /* in: log item type: MLOG_1BYTE, ... */ - mtr_t* mtr) /* in: mini-transaction handle */ + const byte* ptr, /* in: pointer to (inside) a buffer + frame holding the file page where + modification is made */ + byte type, /* in: log item type: MLOG_1BYTE, ... */ + mtr_t* mtr) /* in: mini-transaction handle */ { byte* log_ptr; diff --git a/mtr/mtr0mtr.c b/mtr/mtr0mtr.c index 5223d43b3a4..ba362a904c0 100644 --- a/mtr/mtr0mtr.c +++ b/mtr/mtr0mtr.c @@ -315,7 +315,7 @@ mtr_memo_contains_page( ibool ret; mutex_enter(&buf_pool->mutex); - ret = mtr_memo_contains(mtr, buf_block_align((byte*) ptr), type); + ret = mtr_memo_contains(mtr, buf_block_align(ptr), type); mutex_exit(&buf_pool->mutex); return(ret); } diff --git a/page/page0page.c b/page/page0page.c index e3a62ff06ce..79f18a339c2 100644 --- a/page/page0page.c +++ b/page/page0page.c @@ -477,16 +477,18 @@ page_create_zip( ulint level, /* in: the B-tree level of the page */ mtr_t* mtr) /* in: mini-transaction handle */ { - page_t* page; + page_t* page; + page_zip_des_t* page_zip = buf_block_get_page_zip(block); - ut_ad(block && buf_block_get_page_zip(block) && index); + ut_ad(block); + ut_ad(page_zip); + ut_ad(index); ut_ad(dict_table_is_comp(index->table)); page = page_create_low(block, TRUE); mach_write_to_2(page + PAGE_HEADER + PAGE_LEVEL, level); - if (UNIV_UNLIKELY(!page_zip_compress(buf_block_get_page_zip(block), - page, index, mtr))) { + if (UNIV_UNLIKELY(!page_zip_compress(page_zip, page, index, mtr))) { /* The compression of a newly created page should always succeed. */ ut_error; diff --git a/page/page0zip.c b/page/page0zip.c index 7915a2ad750..57ebeaab064 100644 --- a/page/page0zip.c +++ b/page/page0zip.c @@ -279,7 +279,7 @@ page_zip_get_n_prev_extern( on a B-tree leaf page */ dict_index_t* index) /* in: record descriptor */ { - const page_t* page = page_align((rec_t*) rec); + const page_t* page = page_align(rec); ulint n_ext = 0; ulint i; ulint left; @@ -2848,7 +2848,7 @@ page_zip_write_rec( ulint heap_no; byte* slot; - ut_ad(buf_frame_get_page_zip((byte*) rec) == page_zip); + ut_ad(buf_frame_get_page_zip(rec) == page_zip); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + page_zip_dir_size(page_zip)); @@ -2857,7 +2857,7 @@ page_zip_write_rec( ut_ad(page_zip->m_start >= PAGE_DATA); - page = page_align((rec_t*) rec); + page = page_align(rec); ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(page_simple_validate_new((page_t*) page)); @@ -2895,7 +2895,7 @@ page_zip_write_rec( ut_ad(!*data); { - const byte* start = rec_get_start((rec_t*) rec, offsets); + const byte* start = rec - rec_offs_extra_size(offsets); const byte* b = rec - REC_N_NEW_EXTRA_BYTES; /* Write the extra bytes backwards, so that @@ -3010,7 +3010,7 @@ page_zip_write_rec( page_zip->m_nonempty = TRUE; #ifdef UNIV_ZIP_DEBUG - ut_a(page_zip_validate(page_zip, page_align((byte*) rec))); + ut_a(page_zip_validate(page_zip, page_align(rec))); #endif /* UNIV_ZIP_DEBUG */ } @@ -3091,12 +3091,12 @@ page_zip_write_blob_ptr( { const byte* field; byte* externs; - page_t* page = page_align((byte*) rec); + const page_t* page = page_align(rec); ulint blob_no; ulint len; - ut_ad(buf_frame_get_page_zip((byte*) rec) == page_zip); - ut_ad(page_simple_validate_new(page)); + ut_ad(buf_frame_get_page_zip(rec) == page_zip); + ut_ad(page_simple_validate_new((page_t*) page)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + page_zip_dir_size(page_zip)); @@ -3128,7 +3128,7 @@ page_zip_write_blob_ptr( memcpy(externs, field, BTR_EXTERN_FIELD_REF_SIZE); #ifdef UNIV_ZIP_DEBUG - ut_a(page_zip_validate(page_zip, page_align((rec_t*) rec))); + ut_a(page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ if (mtr) {