Commit 1bd98154 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14126: Fix type mismatch

Backport some changes to B-tree page accessor functions from 10.3,
including changing page_get_n_recs() to return uint16_t.
parent 72b934e3
...@@ -175,7 +175,7 @@ inline ...@@ -175,7 +175,7 @@ inline
page_t* page_t*
page_align(const void* ptr) page_align(const void* ptr)
{ {
return(static_cast<page_t*>(ut_align_down(ptr, UNIV_PAGE_SIZE))); return(static_cast<page_t*>(ut_align_down(ptr, srv_page_size)));
} }
/** Gets the byte offset within a page frame. /** Gets the byte offset within a page frame.
...@@ -186,7 +186,7 @@ inline ...@@ -186,7 +186,7 @@ inline
ulint ulint
page_offset(const void* ptr) page_offset(const void* ptr)
{ {
return(ut_align_offset(ptr, UNIV_PAGE_SIZE)); return(ut_align_offset(ptr, srv_page_size));
} }
/** Determine whether an index page is not in ROW_FORMAT=REDUNDANT. /** Determine whether an index page is not in ROW_FORMAT=REDUNDANT.
...@@ -286,7 +286,7 @@ page_rec_is_user_rec_low(ulint offset) ...@@ -286,7 +286,7 @@ page_rec_is_user_rec_low(ulint offset)
compile_time_assert(PAGE_NEW_SUPREMUM < PAGE_OLD_SUPREMUM_END); compile_time_assert(PAGE_NEW_SUPREMUM < PAGE_OLD_SUPREMUM_END);
compile_time_assert(PAGE_OLD_SUPREMUM < PAGE_NEW_SUPREMUM_END); compile_time_assert(PAGE_OLD_SUPREMUM < PAGE_NEW_SUPREMUM_END);
ut_ad(offset >= PAGE_NEW_INFIMUM); ut_ad(offset >= PAGE_NEW_INFIMUM);
ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); ut_ad(offset <= srv_page_size - PAGE_EMPTY_DIR_START);
return(offset != PAGE_NEW_SUPREMUM return(offset != PAGE_NEW_SUPREMUM
&& offset != PAGE_NEW_INFIMUM && offset != PAGE_NEW_INFIMUM
...@@ -302,7 +302,7 @@ bool ...@@ -302,7 +302,7 @@ bool
page_rec_is_supremum_low(ulint offset) page_rec_is_supremum_low(ulint offset)
{ {
ut_ad(offset >= PAGE_NEW_INFIMUM); ut_ad(offset >= PAGE_NEW_INFIMUM);
ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); ut_ad(offset <= srv_page_size - PAGE_EMPTY_DIR_START);
return(offset == PAGE_NEW_SUPREMUM || offset == PAGE_OLD_SUPREMUM); return(offset == PAGE_NEW_SUPREMUM || offset == PAGE_OLD_SUPREMUM);
} }
...@@ -314,7 +314,7 @@ bool ...@@ -314,7 +314,7 @@ bool
page_rec_is_infimum_low(ulint offset) page_rec_is_infimum_low(ulint offset)
{ {
ut_ad(offset >= PAGE_NEW_INFIMUM); ut_ad(offset >= PAGE_NEW_INFIMUM);
ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); ut_ad(offset <= srv_page_size - PAGE_EMPTY_DIR_START);
return(offset == PAGE_NEW_INFIMUM || offset == PAGE_OLD_INFIMUM); return(offset == PAGE_NEW_INFIMUM || offset == PAGE_OLD_INFIMUM);
} }
...@@ -455,7 +455,7 @@ page_header_set_field( ...@@ -455,7 +455,7 @@ page_header_set_field(
Returns the offset stored in the given header field. Returns the offset stored in the given header field.
@return offset from the start of the page, or 0 */ @return offset from the start of the page, or 0 */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_header_get_offs( page_header_get_offs(
/*=================*/ /*=================*/
const page_t* page, /*!< in: page */ const page_t* page, /*!< in: page */
...@@ -549,7 +549,7 @@ Gets the number of user records on page (the infimum and supremum records ...@@ -549,7 +549,7 @@ Gets the number of user records on page (the infimum and supremum records
are not user records). are not user records).
@return number of user records */ @return number of user records */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_get_n_recs( page_get_n_recs(
/*============*/ /*============*/
const page_t* page); /*!< in: index page */ const page_t* page); /*!< in: index page */
...@@ -567,7 +567,7 @@ page_rec_get_n_recs_before( ...@@ -567,7 +567,7 @@ page_rec_get_n_recs_before(
Gets the number of records in the heap. Gets the number of records in the heap.
@return number of user records */ @return number of user records */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_dir_get_n_heap( page_dir_get_n_heap(
/*================*/ /*================*/
const page_t* page); /*!< in: index page */ const page_t* page); /*!< in: index page */
...@@ -588,7 +588,7 @@ page_dir_set_n_heap( ...@@ -588,7 +588,7 @@ page_dir_set_n_heap(
Gets the number of dir slots in directory. Gets the number of dir slots in directory.
@return number of slots */ @return number of slots */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_dir_get_n_slots( page_dir_get_n_slots(
/*=================*/ /*=================*/
const page_t* page); /*!< in: index page */ const page_t* page); /*!< in: index page */
...@@ -614,7 +614,7 @@ page_dir_get_nth_slot( ...@@ -614,7 +614,7 @@ page_dir_get_nth_slot(
ulint n); /*!< in: position */ ulint n); /*!< in: position */
#else /* UNIV_DEBUG */ #else /* UNIV_DEBUG */
# define page_dir_get_nth_slot(page, n) \ # define page_dir_get_nth_slot(page, n) \
((page) + (UNIV_PAGE_SIZE - PAGE_DIR \ ((page) + (srv_page_size - PAGE_DIR \
- (n + 1) * PAGE_DIR_SLOT_SIZE)) - (n + 1) * PAGE_DIR_SLOT_SIZE))
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/**************************************************************//** /**************************************************************//**
...@@ -868,7 +868,7 @@ Returns the sum of the sizes of the records in the record list ...@@ -868,7 +868,7 @@ Returns the sum of the sizes of the records in the record list
excluding the infimum and supremum records. excluding the infimum and supremum records.
@return data in bytes */ @return data in bytes */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_get_data_size( page_get_data_size(
/*===============*/ /*===============*/
const page_t* page); /*!< in: index page */ const page_t* page); /*!< in: index page */
......
...@@ -188,19 +188,17 @@ page_header_set_field( ...@@ -188,19 +188,17 @@ page_header_set_field(
Returns the offset stored in the given header field. Returns the offset stored in the given header field.
@return offset from the start of the page, or 0 */ @return offset from the start of the page, or 0 */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_header_get_offs( page_header_get_offs(
/*=================*/ /*=================*/
const page_t* page, /*!< in: page */ const page_t* page, /*!< in: page */
ulint field) /*!< in: PAGE_FREE, ... */ ulint field) /*!< in: PAGE_FREE, ... */
{ {
ulint offs;
ut_ad((field == PAGE_FREE) ut_ad((field == PAGE_FREE)
|| (field == PAGE_LAST_INSERT) || (field == PAGE_LAST_INSERT)
|| (field == PAGE_HEAP_TOP)); || (field == PAGE_HEAP_TOP));
offs = page_header_get_field(page, field); uint16_t offs = page_header_get_field(page, field);
ut_ad((field != PAGE_HEAP_TOP) || offs); ut_ad((field != PAGE_HEAP_TOP) || offs);
...@@ -400,7 +398,8 @@ page_get_middle_rec( ...@@ -400,7 +398,8 @@ page_get_middle_rec(
/*================*/ /*================*/
page_t* page) /*!< in: page */ page_t* page) /*!< in: page */
{ {
ulint middle = (page_get_n_recs(page) + PAGE_HEAP_NO_USER_LOW) / 2; ulint middle = (ulint(page_get_n_recs(page))
+ PAGE_HEAP_NO_USER_LOW) / 2;
return(page_rec_get_nth(page, middle)); return(page_rec_get_nth(page, middle));
} }
...@@ -441,7 +440,7 @@ Gets the number of user records on page (infimum and supremum records ...@@ -441,7 +440,7 @@ Gets the number of user records on page (infimum and supremum records
are not user records). are not user records).
@return number of user records */ @return number of user records */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_get_n_recs( page_get_n_recs(
/*============*/ /*============*/
const page_t* page) /*!< in: index page */ const page_t* page) /*!< in: index page */
...@@ -454,7 +453,7 @@ page_get_n_recs( ...@@ -454,7 +453,7 @@ page_get_n_recs(
Gets the number of dir slots in directory. Gets the number of dir slots in directory.
@return number of slots */ @return number of slots */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_dir_get_n_slots( page_dir_get_n_slots(
/*=================*/ /*=================*/
const page_t* page) /*!< in: index page */ const page_t* page) /*!< in: index page */
...@@ -479,7 +478,7 @@ page_dir_set_n_slots( ...@@ -479,7 +478,7 @@ page_dir_set_n_slots(
Gets the number of records in the heap. Gets the number of records in the heap.
@return number of user records */ @return number of user records */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_dir_get_n_heap( page_dir_get_n_heap(
/*================*/ /*================*/
const page_t* page) /*!< in: index page */ const page_t* page) /*!< in: index page */
...@@ -524,7 +523,7 @@ page_dir_get_nth_slot( ...@@ -524,7 +523,7 @@ page_dir_get_nth_slot(
ut_ad(page_dir_get_n_slots(page) > n); ut_ad(page_dir_get_n_slots(page) > n);
return((page_dir_slot_t*) return((page_dir_slot_t*)
page + UNIV_PAGE_SIZE - PAGE_DIR page + srv_page_size - PAGE_DIR
- (n + 1) * PAGE_DIR_SLOT_SIZE); - (n + 1) * PAGE_DIR_SLOT_SIZE);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -643,7 +642,7 @@ page_rec_get_next_low( ...@@ -643,7 +642,7 @@ page_rec_get_next_low(
offs = rec_get_next_offs(rec, comp); offs = rec_get_next_offs(rec, comp);
if (offs >= UNIV_PAGE_SIZE) { if (offs >= srv_page_size) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Next record offset is nonsensical %lu" "InnoDB: Next record offset is nonsensical %lu"
" in record at offset %lu\n" " in record at offset %lu\n"
...@@ -832,9 +831,8 @@ page_rec_get_base_extra_size( ...@@ -832,9 +831,8 @@ page_rec_get_base_extra_size(
/*=========================*/ /*=========================*/
const rec_t* rec) /*!< in: physical record */ const rec_t* rec) /*!< in: physical record */
{ {
#if REC_N_NEW_EXTRA_BYTES + 1 != REC_N_OLD_EXTRA_BYTES compile_time_assert(REC_N_NEW_EXTRA_BYTES + 1
# error "REC_N_NEW_EXTRA_BYTES + 1 != REC_N_OLD_EXTRA_BYTES" == REC_N_OLD_EXTRA_BYTES);
#endif
return(REC_N_NEW_EXTRA_BYTES + (ulint) !page_rec_is_comp(rec)); return(REC_N_NEW_EXTRA_BYTES + (ulint) !page_rec_is_comp(rec));
} }
...@@ -845,21 +843,17 @@ Returns the sum of the sizes of the records in the record list, excluding ...@@ -845,21 +843,17 @@ Returns the sum of the sizes of the records in the record list, excluding
the infimum and supremum records. the infimum and supremum records.
@return data in bytes */ @return data in bytes */
UNIV_INLINE UNIV_INLINE
ulint uint16_t
page_get_data_size( page_get_data_size(
/*===============*/ /*===============*/
const page_t* page) /*!< in: index page */ const page_t* page) /*!< in: index page */
{ {
ulint ret; uint16_t ret = page_header_get_field(page, PAGE_HEAP_TOP)
ret = (ulint)(page_header_get_field(page, PAGE_HEAP_TOP)
- (page_is_comp(page) - (page_is_comp(page)
? PAGE_NEW_SUPREMUM_END ? PAGE_NEW_SUPREMUM_END
: PAGE_OLD_SUPREMUM_END) : PAGE_OLD_SUPREMUM_END)
- page_header_get_field(page, PAGE_GARBAGE)); - page_header_get_field(page, PAGE_GARBAGE);
ut_ad(ret < srv_page_size);
ut_ad(ret < UNIV_PAGE_SIZE);
return(ret); return(ret);
} }
...@@ -907,13 +901,13 @@ page_get_free_space_of_empty( ...@@ -907,13 +901,13 @@ page_get_free_space_of_empty(
ulint comp) /*!< in: nonzero=compact page layout */ ulint comp) /*!< in: nonzero=compact page layout */
{ {
if (comp) { if (comp) {
return((ulint)(UNIV_PAGE_SIZE return((ulint)(srv_page_size
- PAGE_NEW_SUPREMUM_END - PAGE_NEW_SUPREMUM_END
- PAGE_DIR - PAGE_DIR
- 2 * PAGE_DIR_SLOT_SIZE)); - 2 * PAGE_DIR_SLOT_SIZE));
} }
return((ulint)(UNIV_PAGE_SIZE return((ulint)(srv_page_size
- PAGE_OLD_SUPREMUM_END - PAGE_OLD_SUPREMUM_END
- PAGE_DIR - PAGE_DIR
- 2 * PAGE_DIR_SLOT_SIZE)); - 2 * PAGE_DIR_SLOT_SIZE));
...@@ -1051,7 +1045,7 @@ page_mem_free( ...@@ -1051,7 +1045,7 @@ page_mem_free(
page_zip_dir_delete(page_zip, rec, index, offsets, free); page_zip_dir_delete(page_zip, rec, index, offsets, free);
} else { } else {
page_header_set_field(page, page_zip, PAGE_N_RECS, page_header_set_field(page, page_zip, PAGE_N_RECS,
page_get_n_recs(page) - 1); ulint(page_get_n_recs(page)) - 1);
} }
} }
......
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