summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-03-25 11:27:29 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-03-25 11:27:29 +0200
commit1bd98154791d77a44d2afc4bf6eb78f692fb7b5b (patch)
tree01edb7006e9f9278314f1f26576568d4753305e4
parent72b934e3f7d5f0c717cb98b718c9529c74741b4a (diff)
downloadmariadb-git-1bd98154791d77a44d2afc4bf6eb78f692fb7b5b.tar.gz
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.
-rw-r--r--storage/innobase/include/page0page.h22
-rw-r--r--storage/innobase/include/page0page.ic48
2 files changed, 32 insertions, 38 deletions
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index 18c536c05e9..2b869dbe8c3 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -175,7 +175,7 @@ inline
page_t*
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.
@@ -186,7 +186,7 @@ inline
ulint
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.
@@ -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_OLD_SUPREMUM < PAGE_NEW_SUPREMUM_END);
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_NEW_INFIMUM
@@ -302,7 +302,7 @@ bool
page_rec_is_supremum_low(ulint offset)
{
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);
}
@@ -314,7 +314,7 @@ bool
page_rec_is_infimum_low(ulint offset)
{
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);
}
@@ -455,7 +455,7 @@ page_header_set_field(
Returns the offset stored in the given header field.
@return offset from the start of the page, or 0 */
UNIV_INLINE
-ulint
+uint16_t
page_header_get_offs(
/*=================*/
const page_t* page, /*!< in: page */
@@ -549,7 +549,7 @@ Gets the number of user records on page (the infimum and supremum records
are not user records).
@return number of user records */
UNIV_INLINE
-ulint
+uint16_t
page_get_n_recs(
/*============*/
const page_t* page); /*!< in: index page */
@@ -567,7 +567,7 @@ page_rec_get_n_recs_before(
Gets the number of records in the heap.
@return number of user records */
UNIV_INLINE
-ulint
+uint16_t
page_dir_get_n_heap(
/*================*/
const page_t* page); /*!< in: index page */
@@ -588,7 +588,7 @@ page_dir_set_n_heap(
Gets the number of dir slots in directory.
@return number of slots */
UNIV_INLINE
-ulint
+uint16_t
page_dir_get_n_slots(
/*=================*/
const page_t* page); /*!< in: index page */
@@ -614,7 +614,7 @@ page_dir_get_nth_slot(
ulint n); /*!< in: position */
#else /* UNIV_DEBUG */
# 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))
#endif /* UNIV_DEBUG */
/**************************************************************//**
@@ -868,7 +868,7 @@ Returns the sum of the sizes of the records in the record list
excluding the infimum and supremum records.
@return data in bytes */
UNIV_INLINE
-ulint
+uint16_t
page_get_data_size(
/*===============*/
const page_t* page); /*!< in: index page */
diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic
index 11d5e2d1854..d6fded4f178 100644
--- a/storage/innobase/include/page0page.ic
+++ b/storage/innobase/include/page0page.ic
@@ -188,19 +188,17 @@ page_header_set_field(
Returns the offset stored in the given header field.
@return offset from the start of the page, or 0 */
UNIV_INLINE
-ulint
+uint16_t
page_header_get_offs(
/*=================*/
const page_t* page, /*!< in: page */
ulint field) /*!< in: PAGE_FREE, ... */
{
- ulint offs;
-
ut_ad((field == PAGE_FREE)
|| (field == PAGE_LAST_INSERT)
|| (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);
@@ -400,7 +398,8 @@ page_get_middle_rec(
/*================*/
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));
}
@@ -441,7 +440,7 @@ Gets the number of user records on page (infimum and supremum records
are not user records).
@return number of user records */
UNIV_INLINE
-ulint
+uint16_t
page_get_n_recs(
/*============*/
const page_t* page) /*!< in: index page */
@@ -454,7 +453,7 @@ page_get_n_recs(
Gets the number of dir slots in directory.
@return number of slots */
UNIV_INLINE
-ulint
+uint16_t
page_dir_get_n_slots(
/*=================*/
const page_t* page) /*!< in: index page */
@@ -479,7 +478,7 @@ page_dir_set_n_slots(
Gets the number of records in the heap.
@return number of user records */
UNIV_INLINE
-ulint
+uint16_t
page_dir_get_n_heap(
/*================*/
const page_t* page) /*!< in: index page */
@@ -524,7 +523,7 @@ page_dir_get_nth_slot(
ut_ad(page_dir_get_n_slots(page) > n);
return((page_dir_slot_t*)
- page + UNIV_PAGE_SIZE - PAGE_DIR
+ page + srv_page_size - PAGE_DIR
- (n + 1) * PAGE_DIR_SLOT_SIZE);
}
#endif /* UNIV_DEBUG */
@@ -643,7 +642,7 @@ page_rec_get_next_low(
offs = rec_get_next_offs(rec, comp);
- if (offs >= UNIV_PAGE_SIZE) {
+ if (offs >= srv_page_size) {
fprintf(stderr,
"InnoDB: Next record offset is nonsensical %lu"
" in record at offset %lu\n"
@@ -832,9 +831,8 @@ page_rec_get_base_extra_size(
/*=========================*/
const rec_t* rec) /*!< in: physical record */
{
-#if REC_N_NEW_EXTRA_BYTES + 1 != REC_N_OLD_EXTRA_BYTES
-# error "REC_N_NEW_EXTRA_BYTES + 1 != REC_N_OLD_EXTRA_BYTES"
-#endif
+ compile_time_assert(REC_N_NEW_EXTRA_BYTES + 1
+ == REC_N_OLD_EXTRA_BYTES);
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
the infimum and supremum records.
@return data in bytes */
UNIV_INLINE
-ulint
+uint16_t
page_get_data_size(
/*===============*/
const page_t* page) /*!< in: index page */
{
- ulint ret;
-
- ret = (ulint)(page_header_get_field(page, PAGE_HEAP_TOP)
- - (page_is_comp(page)
- ? PAGE_NEW_SUPREMUM_END
- : PAGE_OLD_SUPREMUM_END)
- - page_header_get_field(page, PAGE_GARBAGE));
-
- ut_ad(ret < UNIV_PAGE_SIZE);
-
+ uint16_t ret = page_header_get_field(page, PAGE_HEAP_TOP)
+ - (page_is_comp(page)
+ ? PAGE_NEW_SUPREMUM_END
+ : PAGE_OLD_SUPREMUM_END)
+ - page_header_get_field(page, PAGE_GARBAGE);
+ ut_ad(ret < srv_page_size);
return(ret);
}
@@ -907,13 +901,13 @@ page_get_free_space_of_empty(
ulint comp) /*!< in: nonzero=compact page layout */
{
if (comp) {
- return((ulint)(UNIV_PAGE_SIZE
+ return((ulint)(srv_page_size
- PAGE_NEW_SUPREMUM_END
- PAGE_DIR
- 2 * PAGE_DIR_SLOT_SIZE));
}
- return((ulint)(UNIV_PAGE_SIZE
+ return((ulint)(srv_page_size
- PAGE_OLD_SUPREMUM_END
- PAGE_DIR
- 2 * PAGE_DIR_SLOT_SIZE));
@@ -1051,7 +1045,7 @@ page_mem_free(
page_zip_dir_delete(page_zip, rec, index, offsets, free);
} else {
page_header_set_field(page, page_zip, PAGE_N_RECS,
- page_get_n_recs(page) - 1);
+ ulint(page_get_n_recs(page)) - 1);
}
}