Skip to content
Permalink
Browse files
Cleanup: Make InnoDB page numbers uint32_t
InnoDB stores a 32-bit page number in page headers and in some
data structures, such as FIL_ADDR (consisting of a 32-bit page number
and a 16-bit byte offset within a page). For better compile-time
error detection and to reduce the memory footprint in some data
structures, let us use a uint32_t for the page number, instead
of ulint (size_t) which can be 64 bits.
  • Loading branch information
dr-m committed Oct 15, 2020
1 parent 61161d5 commit 9028cc6
Show file tree
Hide file tree
Showing 46 changed files with 443 additions and 606 deletions.
@@ -3099,7 +3099,7 @@ xb_load_single_table_tablespace(

ut_a(space != NULL);

space->add(file->filepath(), OS_FILE_CLOSED, ulint(n_pages),
space->add(file->filepath(), OS_FILE_CLOSED, uint32_t(n_pages),
false, false);
/* by opening the tablespace we forcing node and space objects
in the cache to be populated with fields from space header */
@@ -4901,7 +4901,7 @@ xtrabackup_apply_delta(
space->chain);
bool fail = !strcmp(n->name, dst_path)
&& !fil_space_extend(
space, (ulint)n_pages);
space, uint32_t(n_pages));
if (fail) goto error;
}
}
@@ -9,15 +9,6 @@
VARIABLE_COMMENT Number of InnoDB Adaptive Hash Index Partitions (default 8)
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 512
@@ -73,7 +73,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 64
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Data file autoextend increment in megabytes
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1000
@@ -85,7 +85,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 1
@@ -94,15 +85,6 @@
VARIABLE_COMMENT Maximum number of seconds that semaphore times out in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 4294967295
@@ -793,7 +793,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Make the first page of the given tablespace dirty.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -805,7 +805,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 30
@@ -398,15 +380,6 @@
VARIABLE_COMMENT Number of background read I/O threads in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
@@ -1657,7 +1657,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT An InnoDB page number.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -1705,7 +1705,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 1048576
@@ -73,7 +73,7 @@ VARIABLE_NAME INNODB_AUTOEXTEND_INCREMENT
SESSION_VALUE NULL
DEFAULT_VALUE 64
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Data file autoextend increment in megabytes
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1000
@@ -793,7 +793,7 @@ VARIABLE_NAME INNODB_FIL_MAKE_PAGE_DIRTY_DEBUG
SESSION_VALUE NULL
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Make the first page of the given tablespace dirty.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -1657,7 +1657,7 @@ VARIABLE_NAME INNODB_SAVED_PAGE_NUMBER_DEBUG
SESSION_VALUE NULL
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT An InnoDB page number.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -55,7 +55,7 @@ bool
btr_can_merge_with_page(
/*====================*/
btr_cur_t* cursor, /*!< in: cursor on the page to merge */
ulint page_no, /*!< in: a sibling page */
uint32_t page_no, /*!< in: a sibling page */
buf_block_t** merge_block, /*!< out: the merge block */
mtr_t* mtr); /*!< in: mini-transaction */

@@ -511,7 +511,7 @@ buf_block_t*
btr_page_alloc_low(
/*===============*/
dict_index_t* index, /*!< in: index */
ulint hint_page_no, /*!< in: hint of a good page */
uint32_t hint_page_no, /*!< in: hint of a good page */
byte file_direction, /*!< in: direction where a possible
page split is made */
ulint level, /*!< in: level where the page is placed
@@ -548,7 +548,7 @@ buf_block_t*
btr_page_alloc(
/*===========*/
dict_index_t* index, /*!< in: index */
ulint hint_page_no, /*!< in: hint of a good page */
uint32_t hint_page_no, /*!< in: hint of a good page */
byte file_direction, /*!< in: direction where a possible
page split is made */
ulint level, /*!< in: level where the page is placed
@@ -2801,7 +2801,7 @@ btr_page_split_and_insert(
tuple to be inserted should be the first record on the upper
half-page */
bool insert_left = false;
ulint hint_page_no = block->page.id().page_no() + 1;
uint32_t hint_page_no = block->page.id().page_no() + 1;
byte direction = FSP_UP;

if (tuple && n_iterations > 0) {
@@ -3386,8 +3386,6 @@ btr_compress(
mtr_t* mtr) /*!< in/out: mini-transaction */
{
dict_index_t* index;
ulint left_page_no;
ulint right_page_no;
buf_block_t* merge_block;
page_t* merge_page = NULL;
page_zip_des_t* merge_page_zip;
@@ -3416,8 +3414,8 @@ btr_compress(

MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS);

left_page_no = btr_page_get_prev(page);
right_page_no = btr_page_get_next(page);
const uint32_t left_page_no = btr_page_get_prev(page);
const uint32_t right_page_no = btr_page_get_next(page);

#ifdef UNIV_DEBUG
if (!page_is_leaf(page) && left_page_no == FIL_NULL) {
@@ -3989,8 +3987,6 @@ btr_discard_page(
mtr_t* mtr) /*!< in: mtr */
{
dict_index_t* index;
ulint left_page_no;
ulint right_page_no;
buf_block_t* merge_block;
buf_block_t* block;
btr_cur_t parent_cursor;
@@ -4014,8 +4010,8 @@ btr_discard_page(

/* Decide the page which will inherit the locks */

left_page_no = btr_page_get_prev(block->frame);
right_page_no = btr_page_get_next(block->frame);
const uint32_t left_page_no = btr_page_get_prev(block->frame);
const uint32_t right_page_no = btr_page_get_next(block->frame);

ut_d(bool parent_is_different = false);
if (left_page_no != FIL_NULL) {
@@ -4598,8 +4594,6 @@ btr_validate_level(
btr_cur_t node_cur;
btr_cur_t right_node_cur;
rec_t* rec;
ulint right_page_no;
ulint left_page_no;
page_cur_t cursor;
dtuple_t* node_ptr_tuple;
bool ret = true;
@@ -4612,8 +4606,8 @@ btr_validate_level(
#endif /* UNIV_ZIP_DEBUG */
ulint savepoint = 0;
ulint savepoint2 = 0;
ulint parent_page_no = FIL_NULL;
ulint parent_right_page_no = FIL_NULL;
uint32_t parent_page_no = FIL_NULL;
uint32_t parent_right_page_no = FIL_NULL;
bool rightmost_child = false;

mtr.start();
@@ -4669,7 +4663,7 @@ btr_validate_level(
does not use such scan for any of its DML or query
operations */
if (dict_index_is_spatial(index)) {
left_page_no = btr_page_get_prev(page);
uint32_t left_page_no = btr_page_get_prev(page);

while (left_page_no != FIL_NULL) {
/* To obey latch order of tree blocks,
@@ -4738,8 +4732,8 @@ btr_validate_level(

ut_a(btr_page_get_level(page) == level);

right_page_no = btr_page_get_next(page);
left_page_no = btr_page_get_prev(page);
uint32_t right_page_no = btr_page_get_next(page);
uint32_t left_page_no = btr_page_get_prev(page);

ut_a(!page_is_empty(page)
|| (level == 0
@@ -4860,8 +4854,7 @@ btr_validate_level(

rec = btr_cur_get_rec(&node_cur);
fprintf(stderr, "\n"
"InnoDB: node ptr child page n:o "
ULINTPF "\n",
"InnoDB: node ptr child page n:o %u\n",
btr_node_ptr_get_child_page_no(rec, offsets));

fputs("InnoDB: record on page ", stderr);
@@ -5096,7 +5089,7 @@ bool
btr_can_merge_with_page(
/*====================*/
btr_cur_t* cursor, /*!< in: cursor on the page to merge */
ulint page_no, /*!< in: a sibling page */
uint32_t page_no, /*!< in: a sibling page */
buf_block_t** merge_block, /*!< out: the merge block */
mtr_t* mtr) /*!< in: mini-transaction */
{
@@ -43,7 +43,6 @@ PageBulk::init()
{
buf_block_t* new_block;
page_t* new_page;
ulint new_page_no;

ut_ad(m_heap == NULL);
m_heap = mem_heap_create(1000);
@@ -81,7 +80,7 @@ PageBulk::init()
alloc_mtr.commit();

new_page = buf_block_get_frame(new_block);
new_page_no = page_get_page_no(new_page);
m_page_no = new_block->page.id().page_no();

byte* index_id = my_assume_aligned<2>
(PAGE_HEADER + PAGE_INDEX_ID + new_page);
@@ -108,8 +107,7 @@ PageBulk::init()
false, &m_mtr);

new_page = buf_block_get_frame(new_block);
new_page_no = page_get_page_no(new_page);
ut_ad(m_page_no == new_page_no);
ut_ad(new_block->page.id().page_no() == m_page_no);

ut_ad(page_dir_get_n_heap(new_page) == PAGE_HEAP_NO_USER_LOW);

@@ -125,7 +123,6 @@ PageBulk::init()

m_block = new_block;
m_page = new_page;
m_page_no = new_page_no;
m_cur_rec = page_get_infimum_rec(new_page);
ut_ad(m_is_comp == !!page_is_comp(new_page));
m_free_space = page_get_free_space_of_empty(m_is_comp);
@@ -1163,7 +1160,7 @@ if no error occurs.
dberr_t
BtrBulk::finish(dberr_t err)
{
ulint last_page_no = FIL_NULL;
uint32_t last_page_no = FIL_NULL;

ut_ad(!m_index->table->is_temporary());

0 comments on commit 9028cc6

Please sign in to comment.