summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-11-08 09:41:06 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-11-08 09:41:06 +0200
commit78d0d2cdc56634cd6212b5c6320a938d4dff42cc (patch)
tree6579b79faaddd834ffca15f6a42f55c6cb416fef
parent8a5eb4141b2ca9b8cc4e6510f4eba8f5ff9eb7dd (diff)
downloadmariadb-git-78d0d2cdc56634cd6212b5c6320a938d4dff42cc.tar.gz
Cleanup: Remove mach_read_ulint()
The function mach_read_ulint() is a wrapper for the lower-level functions mach_read_from_1(), mach_read_from_2(), mach_read_from_8(). Invoke those functions directly, for better readability of the code. mtr_t::read_ulint(), mtr_read_ulint(): Remove. Yes, we will lose the ability to assert that the read is covered by the mini-transaction. We would still check that on writes, and any writes that wrongly bypass mini-transaction logging would likely be caught by stress testing with Mariabackup.
-rw-r--r--extra/mariabackup/xtrabackup.cc6
-rw-r--r--storage/innobase/dict/dict0crea.cc4
-rw-r--r--storage/innobase/dict/dict0load.cc9
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc48
-rw-r--r--storage/innobase/fts/fts0fts.cc3
-rw-r--r--storage/innobase/include/fsp0fsp.ic5
-rw-r--r--storage/innobase/include/fut0lst.ic6
-rw-r--r--storage/innobase/include/mach0data.h13
-rw-r--r--storage/innobase/include/mach0data.ic27
-rw-r--r--storage/innobase/include/mtr0mtr.h13
-rw-r--r--storage/innobase/include/mtr0mtr.ic18
-rw-r--r--storage/innobase/row/row0import.cc11
12 files changed, 34 insertions, 129 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index f695b5c7f6d..3ddd8786ee9 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -3343,9 +3343,9 @@ retry:
+ TRX_SYS_RSEG_PAGE_NO + page)
!= FIL_NULL);
- space = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS
- + TRX_SYS_RSEG_SLOT_SIZE
- + TRX_SYS_RSEG_SPACE + page, MLOG_4BYTES);
+ space = mach_read_from_4(TRX_SYS + TRX_SYS_RSEGS
+ + TRX_SYS_RSEG_SLOT_SIZE
+ + TRX_SYS_RSEG_SPACE + page);
srv_undo_space_id_start = space;
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index c142dd382a7..1a6c38a6651 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -920,7 +920,7 @@ dict_drop_index_tree(
btr_pcur_store_position(pcur, mtr);
- root_page_no = mtr_read_ulint(ptr, MLOG_4BYTES, mtr);
+ root_page_no = mach_read_from_4(ptr);
if (root_page_no == FIL_NULL) {
/* The tree has already been freed */
@@ -936,7 +936,7 @@ dict_drop_index_tree(
ut_ad(len == 4);
- space = mtr_read_ulint(ptr, MLOG_4BYTES, mtr);
+ space = mach_read_from_4(ptr);
ptr = rec_get_nth_field_old(
rec, DICT_FLD__SYS_INDEXES__ID, &len);
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index 27b3f5f2e5c..7d58bffc46f 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -1484,11 +1484,10 @@ void dict_check_tablespaces_and_store_max_id()
dict_sys_lock();
/* Initialize the max space_id from sys header */
- mtr_start(&mtr);
- ulint max_space_id = mtr_read_ulint(
- dict_hdr_get(&mtr) + DICT_HDR_MAX_SPACE_ID,
- MLOG_4BYTES, &mtr);
- mtr_commit(&mtr);
+ mtr.start();
+ ulint max_space_id = mach_read_from_4(DICT_HDR_MAX_SPACE_ID
+ + dict_hdr_get(&mtr));
+ mtr.commit();
fil_set_max_space_id_if_bigger(max_space_id);
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index dec1f0cecca..3b324b6c437 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1386,8 +1386,7 @@ static void fsp_free_page(fil_space_t* space, page_no_t offset,
xdes_set_bit(descr, XDES_FREE_BIT, bit, TRUE, mtr);
xdes_set_bit(descr, XDES_CLEAN_BIT, bit, TRUE, mtr);
- frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
- mtr);
+ frag_n_used = mach_read_from_4(header + FSP_FRAG_N_USED);
if (state == XDES_FULL_FRAG) {
/* The fragment was full: move it to another list */
flst_remove(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
@@ -2610,8 +2609,7 @@ try_again:
n_free_list_ext = flst_get_len(space_header + FSP_FREE);
ut_ad(space->free_len == n_free_list_ext);
- free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT,
- MLOG_4BYTES, mtr);
+ free_limit = mach_read_from_4(space_header + FSP_FREE_LIMIT);
ut_ad(space->free_limit == free_limit);
/* Below we play safe when counting free extents above the free limit:
@@ -2693,9 +2691,7 @@ fseg_mark_page_used(
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
-
- ut_ad(mtr_read_ulint(seg_inode + FSEG_ID, MLOG_4BYTES, mtr)
- == mtr_read_ulint(descr + XDES_ID, MLOG_4BYTES, mtr));
+ ut_ad(!memcmp(seg_inode + FSEG_ID, descr + XDES_ID, 4));
if (xdes_is_free(descr, mtr)) {
/* We move the extent from the free list to the
@@ -2712,8 +2708,7 @@ fseg_mark_page_used(
/* We mark the page as used */
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, FALSE, mtr);
- not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
- MLOG_4BYTES, mtr);
+ not_full_n_used = mach_read_from_4(seg_inode + FSEG_NOT_FULL_N_USED);
not_full_n_used++;
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, not_full_n_used,
MLOG_4BYTES, mtr);
@@ -2825,8 +2820,7 @@ fseg_free_page_low(
<< FORCE_RECOVERY_MSG;
}
- not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
- MLOG_4BYTES, mtr);
+ not_full_n_used = mach_read_from_4(seg_inode + FSEG_NOT_FULL_N_USED);
if (xdes_is_full(descr, mtr)) {
/* The fragment is full: move it to another list */
flst_remove(seg_inode + FSEG_FULL,
@@ -2991,9 +2985,8 @@ fseg_free_extent(
flst_remove(seg_inode + FSEG_NOT_FULL,
descr + XDES_FLST_NODE, mtr);
- not_full_n_used = mtr_read_ulint(
- seg_inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr);
-
+ not_full_n_used = mach_read_from_4(FSEG_NOT_FULL_N_USED
+ + seg_inode);
descr_n_used = xdes_get_n_used(descr, mtr);
ut_a(not_full_n_used >= descr_n_used);
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
@@ -3234,9 +3227,7 @@ fseg_print_low(
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
seg_id = mach_read_from_8(inode + FSEG_ID);
-
- n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
- MLOG_4BYTES, mtr);
+ n_used = mach_read_from_4(inode + FSEG_NOT_FULL_N_USED);
n_frag = fseg_get_n_frag_pages(inode, mtr);
n_free = flst_get_len(inode + FSEG_FREE);
n_not_full = flst_get_len(inode + FSEG_NOT_FULL);
@@ -3275,23 +3266,12 @@ fseg_print(
#endif /* UNIV_BTR_PRINT */
#ifdef UNIV_DEBUG
-/** Print the file segment header to the given output stream.
-@param[in] out the output stream into which the object is printed.
-@retval the output stream into which the object was printed. */
-std::ostream&
-fseg_header::to_stream(std::ostream& out) const
+std::ostream &fseg_header::to_stream(std::ostream &out) const
{
- const ulint space = mtr_read_ulint(m_header + FSEG_HDR_SPACE,
- MLOG_4BYTES, m_mtr);
- const ulint page_no = mtr_read_ulint(m_header + FSEG_HDR_PAGE_NO,
- MLOG_4BYTES, m_mtr);
-
- const ulint offset = mtr_read_ulint(m_header + FSEG_HDR_OFFSET,
- MLOG_2BYTES, m_mtr);
-
- out << "[fseg_header_t: space=" << space << ", page="
- << page_no << ", offset=" << offset << "]";
-
- return(out);
+ out << "[fseg_header_t: space="
+ << mach_read_from_4(m_header + FSEG_HDR_SPACE)
+ << ", page=" << mach_read_from_4(m_header + FSEG_HDR_PAGE_NO)
+ << ", offset=" << mach_read_from_2(m_header + FSEG_HDR_OFFSET) << "]";
+ return out;
}
#endif /* UNIV_DEBUG */
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 82e7130370e..a8b282198a6 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -3625,8 +3625,7 @@ fts_read_ulint(
dfield_t* dfield = que_node_get_val(exp);
void* data = dfield_get_data(dfield);
- *value = static_cast<ulint>(mach_read_from_4(
- static_cast<const byte*>(data)));
+ *value = mach_read_from_4(static_cast<const byte*>(data));
return(TRUE);
}
diff --git a/storage/innobase/include/fsp0fsp.ic b/storage/innobase/include/fsp0fsp.ic
index 731e0e7ea77..31b9d8c5dbe 100644
--- a/storage/innobase/include/fsp0fsp.ic
+++ b/storage/innobase/include/fsp0fsp.ic
@@ -44,8 +44,5 @@ xdes_get_bit(
ulint bit_index = index % 8;
ulint byte_index = index / 8;
- return(ut_bit_get_nth(
- mach_read_ulint(descr + XDES_BITMAP + byte_index,
- MLOG_1BYTE),
- bit_index));
+ return ut_bit_get_nth(descr[XDES_BITMAP + byte_index], bit_index);
}
diff --git a/storage/innobase/include/fut0lst.ic b/storage/innobase/include/fut0lst.ic
index 56627be46eb..0a4f2b24738 100644
--- a/storage/innobase/include/fut0lst.ic
+++ b/storage/innobase/include/fut0lst.ic
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -61,9 +62,8 @@ flst_read_addr(
ut_ad(faddr && mtr);
- addr.page = mtr_read_ulint(faddr + FIL_ADDR_PAGE, MLOG_4BYTES, mtr);
- addr.boffset = mtr_read_ulint(faddr + FIL_ADDR_BYTE, MLOG_2BYTES,
- mtr);
+ addr.page = mach_read_from_4(faddr + FIL_ADDR_PAGE);
+ addr.boffset = mach_read_from_2(faddr + FIL_ADDR_BYTE);
ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA);
ut_a(ut_align_offset(faddr, srv_page_size) >= FIL_PAGE_DATA);
return(addr);
diff --git a/storage/innobase/include/mach0data.h b/storage/innobase/include/mach0data.h
index a5d9af07f3b..3d0e48253eb 100644
--- a/storage/innobase/include/mach0data.h
+++ b/storage/innobase/include/mach0data.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -367,17 +367,6 @@ mach_write_ulonglong(
#endif /* !UNIV_INNOCHECKSUM */
-/** Read 1 to 4 bytes from a file page buffered in the buffer pool.
-@param[in] ptr pointer where to read
-@param[in] type MLOG_1BYTE, MLOG_2BYTES, or MLOG_4BYTES
-@return value read */
-UNIV_INLINE
-ulint
-mach_read_ulint(
- const byte* ptr,
- mlog_id_t type)
- MY_ATTRIBUTE((warn_unused_result));
-
#include "mach0data.ic"
#endif
diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic
index 408044292a5..80bd925d70b 100644
--- a/storage/innobase/include/mach0data.ic
+++ b/storage/innobase/include/mach0data.ic
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -866,28 +866,3 @@ mach_write_ulonglong(
}
#endif /* !UNIV_INNOCHECKSUM */
-
-/** Read 1 to 4 bytes from a file page buffered in the buffer pool.
-@param[in] ptr pointer where to read
-@param[in] type MLOG_1BYTE, MLOG_2BYTES, or MLOG_4BYTES
-@return value read */
-UNIV_INLINE
-ulint
-mach_read_ulint(
- const byte* ptr,
- mlog_id_t type)
-{
- switch (type) {
- case MLOG_1BYTE:
- return(mach_read_from_1(ptr));
- case MLOG_2BYTES:
- return(mach_read_from_2(ptr));
- case MLOG_4BYTES:
- return(mach_read_from_4(ptr));
- default:
- break;
- }
-
- ut_error;
- return(0);
-}
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 4b41506d339..63878773e05 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2018, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -54,10 +54,6 @@ savepoint. */
@return old mode */
#define mtr_set_log_mode(m, d) (m)->set_log_mode((d))
-/** Read 1 - 4 bytes from a file page buffered in the buffer pool.
-@return value read */
-#define mtr_read_ulint(p, t, m) (m)->read_ulint((p), (t))
-
/** Release an object in the memo stack.
@return true if released */
#define mtr_memo_release(m, o, t) \
@@ -306,13 +302,6 @@ struct mtr_t {
bool is_named_space(const fil_space_t* space) const;
#endif /* UNIV_DEBUG */
- /** Read 1 - 4 bytes from a file page buffered in the buffer pool.
- @param ptr pointer from where to read
- @param type) MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES
- @return value read */
- inline ulint read_ulint(const byte* ptr, mlog_id_t type) const
- MY_ATTRIBUTE((warn_unused_result));
-
/** Locks a rw-latch in S mode.
NOTE: use mtr_s_lock().
@param lock rw-lock
diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic
index 9a83badc173..99057303c90 100644
--- a/storage/innobase/include/mtr0mtr.ic
+++ b/storage/innobase/include/mtr0mtr.ic
@@ -275,21 +275,3 @@ mtr_t::sx_lock(rw_lock_t* lock, const char* file, unsigned line)
memo_push(lock, MTR_MEMO_SX_LOCK);
}
-
-/**
-Reads 1 - 4 bytes from a file page buffered in the buffer pool.
-@return value read */
-
-ulint
-mtr_t::read_ulint(const byte* ptr, mlog_id_t type) const
-{
- ut_ad(is_active());
-
- ut_ad(memo_contains_page_flagged(
- ptr,
- MTR_MEMO_PAGE_S_FIX
- | MTR_MEMO_PAGE_X_FIX
- | MTR_MEMO_PAGE_SX_FIX));
-
- return(mach_read_ulint(ptr, type));
-}
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index 9d48d90c962..104f142b807 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -466,17 +466,12 @@ protected:
UT_DELETE_ARRAY(m_xdes);
m_xdes = NULL;
- ulint state;
- const xdes_t* xdesc = page + XDES_ARR_OFFSET;
-
- state = mach_read_ulint(xdesc + XDES_STATE, MLOG_4BYTES);
-
- if (state != XDES_FREE) {
+ if (mach_read_from_4(XDES_ARR_OFFSET + XDES_STATE + page)
+ != XDES_FREE) {
const ulint physical_size = m_zip_size
? m_zip_size : srv_page_size;
- m_xdes = UT_NEW_ARRAY_NOKEY(xdes_t,
- physical_size);
+ m_xdes = UT_NEW_ARRAY_NOKEY(xdes_t, physical_size);
/* Trigger OOM */
DBUG_EXECUTE_IF(