summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-07-22 11:22:47 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-07-22 11:22:47 +0300
commitca501ffb04246dcaa1f1d433d916d8436e30602e (patch)
tree60ba69fde916518ab478033f20714872fb1c63dc
parentcee37b5d26453538dc7830a20fa4c8da3d9285b7 (diff)
downloadmariadb-git-ca501ffb04246dcaa1f1d433d916d8436e30602e.tar.gz
MDEV-26195: Use a 32-bit data type for some tablespace fields
In the InnoDB data files, we allocate 32 bits for tablespace identifiers and page numbers as well as tablespace flags. But, in main memory data structures we allocate 32 or 64 bits, depending on the register width of the processor. Let us always use 32-bit fields to eliminate a mismatch and reduce the memory footprint on 64-bit systems.
-rw-r--r--extra/innochecksum.cc2
-rw-r--r--extra/mariabackup/backup_mysql.cc3
-rw-r--r--extra/mariabackup/common.h5
-rw-r--r--extra/mariabackup/ds_local.cc4
-rw-r--r--extra/mariabackup/fil_cur.cc13
-rw-r--r--extra/mariabackup/fil_cur.h4
-rw-r--r--extra/mariabackup/read_filt.h2
-rw-r--r--extra/mariabackup/write_filt.cc4
-rw-r--r--extra/mariabackup/xtrabackup.cc97
-rw-r--r--extra/mariabackup/xtrabackup.h20
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff9
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_innodb.result2
-rw-r--r--storage/innobase/btr/btr0btr.cc4
-rw-r--r--storage/innobase/btr/btr0cur.cc3
-rw-r--r--storage/innobase/buf/buf0buf.cc22
-rw-r--r--storage/innobase/buf/buf0dblwr.cc2
-rw-r--r--storage/innobase/buf/buf0dump.cc7
-rw-r--r--storage/innobase/buf/buf0flu.cc2
-rw-r--r--storage/innobase/buf/buf0rea.cc14
-rw-r--r--storage/innobase/dict/dict0boot.cc8
-rw-r--r--storage/innobase/dict/dict0crea.cc8
-rw-r--r--storage/innobase/dict/dict0load.cc42
-rw-r--r--storage/innobase/dict/dict0mem.cc2
-rw-r--r--storage/innobase/fil/fil0crypt.cc14
-rw-r--r--storage/innobase/fil/fil0fil.cc162
-rw-r--r--storage/innobase/fil/fil0pagecompress.cc18
-rw-r--r--storage/innobase/fsp/fsp0file.cc27
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc11
-rw-r--r--storage/innobase/fsp/fsp0space.cc4
-rw-r--r--storage/innobase/handler/ha_innodb.cc11
-rw-r--r--storage/innobase/handler/handler0alter.cc4
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc6
-rw-r--r--storage/innobase/include/buf0buf.h30
-rw-r--r--storage/innobase/include/buf0flu.h2
-rw-r--r--storage/innobase/include/buf0rea.h12
-rw-r--r--storage/innobase/include/buf0types.h10
-rw-r--r--storage/innobase/include/dict0boot.h4
-rw-r--r--storage/innobase/include/dict0dict.h7
-rw-r--r--storage/innobase/include/dict0dict.ic16
-rw-r--r--storage/innobase/include/dict0mem.h4
-rw-r--r--storage/innobase/include/fil0crypt.h6
-rw-r--r--storage/innobase/include/fil0fil.h573
-rw-r--r--storage/innobase/include/fil0pagecompress.h11
-rw-r--r--storage/innobase/include/fsp0file.h33
-rw-r--r--storage/innobase/include/fsp0fsp.h45
-rw-r--r--storage/innobase/include/fsp0space.h52
-rw-r--r--storage/innobase/include/fsp0sysspace.h18
-rw-r--r--storage/innobase/include/fsp0types.h13
-rw-r--r--storage/innobase/include/fut0fut.h2
-rw-r--r--storage/innobase/include/ibuf0ibuf.h4
-rw-r--r--storage/innobase/include/log0recv.h2
-rw-r--r--storage/innobase/include/mtr0mtr.h18
-rw-r--r--storage/innobase/include/srv0srv.h4
-rw-r--r--storage/innobase/include/trx0rseg.h12
-rw-r--r--storage/innobase/include/trx0rseg.ic21
-rw-r--r--storage/innobase/include/trx0types.h2
-rw-r--r--storage/innobase/include/univ.i2
-rw-r--r--storage/innobase/log/log0recv.cc17
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc5
-rw-r--r--storage/innobase/os/os0file.cc10
-rw-r--r--storage/innobase/row/row0import.cc62
-rw-r--r--storage/innobase/srv/srv0srv.cc8
-rw-r--r--storage/innobase/srv/srv0start.cc42
-rw-r--r--storage/innobase/trx/trx0purge.cc14
-rw-r--r--storage/innobase/trx/trx0rseg.cc21
-rw-r--r--storage/innobase/trx/trx0sys.cc6
-rw-r--r--storage/innobase/trx/trx0undo.cc2
67 files changed, 692 insertions, 934 deletions
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index 6ca68c47834..69e293a7b7a 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -70,7 +70,7 @@ static my_bool per_page_details;
static ulint n_merge;
static ulint physical_page_size; /* Page size in bytes on disk. */
ulong srv_page_size;
-ulong srv_page_size_shift;
+uint32_t srv_page_size_shift;
/* Current page number (0 based). */
unsigned long long cur_page_num;
/* Current space. */
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc
index f287af82e6f..91ee82f3486 100644
--- a/extra/mariabackup/backup_mysql.cc
+++ b/extra/mariabackup/backup_mysql.cc
@@ -514,7 +514,8 @@ bool get_mysql_vars(MYSQL *connection)
if (innodb_undo_tablespaces_var)
{
- srv_undo_tablespaces= strtoul(innodb_undo_tablespaces_var, &endptr, 10);
+ srv_undo_tablespaces= static_cast<uint32_t>
+ (strtoul(innodb_undo_tablespaces_var, &endptr, 10));
ut_ad(*endptr == 0);
}
diff --git a/extra/mariabackup/common.h b/extra/mariabackup/common.h
index 1973512ad82..89b189e3a87 100644
--- a/extra/mariabackup/common.h
+++ b/extra/mariabackup/common.h
@@ -149,10 +149,9 @@ static inline ATTRIBUTE_FORMAT(printf, 1,2) ATTRIBUTE_NORETURN void die(const ch
/***********************************************************************
Computes bit shift for a given value. If the argument is not a power
of 2, returns 0.*/
-static inline size_t
-get_bit_shift(size_t value)
+static inline unsigned get_bit_shift(size_t value)
{
- size_t shift;
+ unsigned shift;
if (value == 0)
return 0;
diff --git a/extra/mariabackup/ds_local.cc b/extra/mariabackup/ds_local.cc
index ddaa213491d..4c3016ec8f7 100644
--- a/extra/mariabackup/ds_local.cc
+++ b/extra/mariabackup/ds_local.cc
@@ -181,8 +181,8 @@ static void init_ibd_data(ds_local_file_t *local_file, const uchar *buf, size_t
return;
}
- ulint flags = mach_read_from_4(&buf[FIL_PAGE_DATA + FSP_SPACE_FLAGS]);
- ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
+ auto flags = mach_read_from_4(&buf[FIL_PAGE_DATA + FSP_SPACE_FLAGS]);
+ auto ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
local_file->pagesize= ssize == 0 ? UNIV_PAGE_SIZE_ORIG : ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
local_file->compressed = fil_space_t::full_crc32(flags)
? fil_space_t::is_compressed(flags)
diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc
index 824fb4f4232..37d2fc5972d 100644
--- a/extra/mariabackup/fil_cur.cc
+++ b/extra/mariabackup/fil_cur.cc
@@ -232,8 +232,8 @@ xb_fil_cur_open(
mysql_mutex_unlock(&fil_system.mutex);
}
- cursor->space_size = (ulint)(cursor->statinfo.st_size
- / cursor->page_size);
+ cursor->space_size = uint32_t(cursor->statinfo.st_size
+ / cursor->page_size);
cursor->read_filter = read_filter;
cursor->read_filter->init(&cursor->read_filter_ctxt, cursor,
@@ -441,8 +441,8 @@ read_retry:
"corrupted.%s", cursor->abs_path, ignore_corruption_warn);
ut_print_buf(stderr, page, page_size);
if (opt_log_innodb_page_corruption) {
- corrupted_pages.add_page(cursor->node->name, cursor->node->space->id,
- page_no);
+ corrupted_pages.add_page(cursor->node->name,
+ {cursor->node->space->id, page_no});
retry_count = 1;
}
else {
@@ -465,8 +465,9 @@ read_retry:
unsigned corrupted_page_no =
static_cast<unsigned>(strtoul(dbug_val, NULL, 10));
if (page_no == corrupted_page_no)
- corrupted_pages.add_page(cursor->node->name, cursor->node->space->id,
- corrupted_page_no);
+ corrupted_pages.add_page(cursor->node->name,
+ {cursor->node->space->id,
+ corrupted_page_no});
});
cursor->buf_read += page_size;
cursor->buf_npages++;
diff --git a/extra/mariabackup/fil_cur.h b/extra/mariabackup/fil_cur.h
index 0027b7768e9..6b868bf3edd 100644
--- a/extra/mariabackup/fil_cur.h
+++ b/extra/mariabackup/fil_cur.h
@@ -56,8 +56,8 @@ struct xb_fil_cur_t {
unsigned buf_page_no; /*!< number of the first page in
buffer */
uint thread_n; /*!< thread number for diagnostics */
- ulint space_id; /*!< ID of tablespace */
- ulint space_size; /*!< space size in pages */
+ uint32_t space_id; /*!< ID of tablespace */
+ uint32_t space_size; /*!< space size in pages */
/** @return whether this is not a file-per-table tablespace */
bool is_system() const
diff --git a/extra/mariabackup/read_filt.h b/extra/mariabackup/read_filt.h
index 2cd52d3d581..51150705367 100644
--- a/extra/mariabackup/read_filt.h
+++ b/extra/mariabackup/read_filt.h
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
#include "changed_page_bitmap.h"
-typedef ulint space_id_t;
+typedef uint32_t space_id_t;
struct xb_fil_cur_t;
diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc
index 8339286e1df..01e4d83e344 100644
--- a/extra/mariabackup/write_filt.cc
+++ b/extra/mariabackup/write_filt.cc
@@ -124,8 +124,8 @@ wf_incremental_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
i++, page += page_size) {
if ((!cp->corrupted_pages ||
- !cp->corrupted_pages->contains(cursor->node->space->id,
- cursor->buf_page_no + i)) &&
+ !cp->corrupted_pages->contains({cursor->node->space->id,
+ cursor->buf_page_no + i})) &&
incremental_lsn >= mach_read_from_8(page + FIL_PAGE_LSN))
continue;
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 8c9090480e8..f579ae51f68 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -369,45 +369,45 @@ CorruptedPages::CorruptedPages() { ut_a(!pthread_mutex_init(&m_mutex, NULL)); }
CorruptedPages::~CorruptedPages() { ut_a(!pthread_mutex_destroy(&m_mutex)); }
-void CorruptedPages::add_page_no_lock(const char *space_name, ulint space_id,
- unsigned page_no,
+void CorruptedPages::add_page_no_lock(const char *space_name,
+ page_id_t page_id,
bool convert_space_name)
{
- space_info_t &space_info = m_spaces[space_id];
+ space_info_t &space_info = m_spaces[page_id.space()];
if (space_info.space_name.empty())
space_info.space_name= convert_space_name
? filename_to_spacename(space_name, strlen(space_name))
: space_name;
- (void)space_info.pages.insert(page_no);
+ (void)space_info.pages.insert(page_id.page_no());
}
-void CorruptedPages::add_page(const char *file_name, ulint space_id,
- unsigned page_no)
+void CorruptedPages::add_page(const char *file_name, page_id_t page_id)
{
- ut_a(!pthread_mutex_lock(&m_mutex));
- add_page_no_lock(file_name, space_id, page_no, true);
- ut_a(!pthread_mutex_unlock(&m_mutex));
+ pthread_mutex_lock(&m_mutex);
+ add_page_no_lock(file_name, page_id, true);
+ pthread_mutex_unlock(&m_mutex);
}
-bool CorruptedPages::contains(ulint space_id, unsigned page_no) const
+bool CorruptedPages::contains(page_id_t page_id) const
{
bool result = false;
ut_a(!pthread_mutex_lock(&m_mutex));
- container_t::const_iterator space_it= m_spaces.find(space_id);
+ container_t::const_iterator space_it= m_spaces.find(page_id.space());
if (space_it != m_spaces.end())
- result = space_it->second.pages.count(page_no);
+ result = space_it->second.pages.count(page_id.page_no());
ut_a(!pthread_mutex_unlock(&m_mutex));
return result;
}
-void CorruptedPages::drop_space(ulint space_id)
+void CorruptedPages::drop_space(uint32_t space_id)
{
ut_a(!pthread_mutex_lock(&m_mutex));
m_spaces.erase(space_id);
ut_a(!pthread_mutex_unlock(&m_mutex));
}
-void CorruptedPages::rename_space(ulint space_id, const std::string &new_name)
+void CorruptedPages::rename_space(uint32_t space_id,
+ const std::string &new_name)
{
ut_a(!pthread_mutex_lock(&m_mutex));
container_t::iterator space_it = m_spaces.find(space_id);
@@ -468,7 +468,7 @@ void CorruptedPages::read_from_file(const char *file_name)
strerror(errno));
std::string line;
std::string space_name;
- ulint space_id;
+ uint32_t space_id;
ulint line_number= 0;
while (std::getline(infile, line))
{
@@ -488,7 +488,7 @@ void CorruptedPages::read_from_file(const char *file_name)
std::istringstream iss(line);
unsigned page_no;
while ((iss >> page_no))
- add_page_no_lock(space_name.c_str(), space_id, page_no, false);
+ add_page_no_lock(space_name.c_str(), {space_id, page_no}, false);
if (!iss.eof())
die("Corrupted pages file parse error on line number " ULINTPF,
line_number);
@@ -506,7 +506,7 @@ bool CorruptedPages::empty() const
static void xb_load_single_table_tablespace(const std::string &space_name,
bool set_size,
- ulint defer_space_id=0);
+ uint32_t defer_space_id=0);
static void xb_data_files_close();
static fil_space_t* fil_space_get_by_name(const char* name);
@@ -521,7 +521,7 @@ void CorruptedPages::zero_out_free_pages()
for (container_t::const_iterator space_it= m_spaces.begin();
space_it != m_spaces.end(); ++space_it)
{
- ulint space_id = space_it->first;
+ uint32_t space_id = space_it->first;
const std::string &space_name = space_it->second.space_name;
// There is no need to close tablespaces explixitly as they will be closed
// in innodb_shutdown().
@@ -584,7 +584,7 @@ typedef void (*process_single_tablespace_func_t)(const char *dirname,
const char *filname,
bool is_remote,
bool skip_node_page0,
- ulint defer_space_id);
+ uint32_t defer_space_id);
static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback);
/* ======== Datafiles iterator ======== */
@@ -774,7 +774,7 @@ static std::string filename_to_spacename(const void *filename, size_t len)
@param[in] len length of name, in bytes
@param[in] new_name new file name (NULL if not rename)
@param[in] new_len length of new_name, in bytes (0 if NULL) */
-static void backup_file_op(ulint space_id, bool create,
+static void backup_file_op(uint32_t space_id, bool create,
const byte* name, ulint len,
const byte* new_name, ulint new_len)
{
@@ -787,15 +787,15 @@ static void backup_file_op(ulint space_id, bool create,
if (create) {
ddl_tracker.id_to_name[space_id] = filename_to_spacename(name, len);
- msg("DDL tracking : create %zu \"%.*s\"", space_id, int(len), name);
+ msg("DDL tracking : create %u \"%.*s\"", space_id, int(len), name);
}
else if (new_name) {
ddl_tracker.id_to_name[space_id] = filename_to_spacename(new_name, new_len);
- msg("DDL tracking : rename %zu \"%.*s\",\"%.*s\"",
+ msg("DDL tracking : rename %u \"%.*s\",\"%.*s\"",
space_id, int(len), name, int(new_len), new_name);
} else {
ddl_tracker.drops.insert(space_id);
- msg("DDL tracking : delete %zu \"%.*s\"", space_id, int(len), name);
+ msg("DDL tracking : delete %u \"%.*s\"", space_id, int(len), name);
}
pthread_mutex_unlock(&backup_mutex);
}
@@ -810,19 +810,19 @@ static void backup_file_op(ulint space_id, bool create,
We will abort backup in this case.
*/
-static void backup_file_op_fail(ulint space_id, bool create,
+static void backup_file_op_fail(uint32_t space_id, bool create,
const byte* name, ulint len,
const byte* new_name, ulint new_len)
{
bool fail;
if (create) {
- msg("DDL tracking : create %zu \"%.*s\"",
+ msg("DDL tracking : create %u \"%.*s\"",
space_id, int(len), name);
std::string spacename = filename_to_spacename(name, len);
fail = !check_if_skip_table(spacename.c_str());
}
else if (new_name) {
- msg("DDL tracking : rename %zu \"%.*s\",\"%.*s\"",
+ msg("DDL tracking : rename %u \"%.*s\",\"%.*s\"",
space_id, int(len), name, int(new_len), new_name);
std::string spacename = filename_to_spacename(name, len);
std::string new_spacename = filename_to_spacename(new_name, new_len);
@@ -831,7 +831,7 @@ static void backup_file_op_fail(ulint space_id, bool create,
else {
std::string spacename = filename_to_spacename(name, len);
fail = !check_if_skip_table(spacename.c_str());
- msg("DDL tracking : delete %zu \"%.*s\"", space_id, int(len), name);
+ msg("DDL tracking : delete %u \"%.*s\"", space_id, int(len), name);
}
if (fail) {
ut_a(opt_no_lock);
@@ -1541,7 +1541,7 @@ struct my_option xb_server_options[] =
{"innodb_undo_tablespaces", OPT_INNODB_UNDO_TABLESPACES,
"Number of undo tablespaces to use.",
(G_PTR*)&srv_undo_tablespaces, (G_PTR*)&srv_undo_tablespaces,
- 0, GET_ULONG, REQUIRED_ARG, 0, 0, 126, 0, 1, 0},
+ 0, GET_UINT, REQUIRED_ARG, 0, 0, 126, 0, 1, 0},
{"innodb_compression_level", OPT_INNODB_COMPRESSION_LEVEL,
"Compression level used for zlib compression.",
@@ -1612,7 +1612,7 @@ static std::set<std::string> tables_for_export;
static void append_export_table(const char *dbname, const char *tablename,
bool is_remote, bool skip_node_page0,
- ulint defer_space_id)
+ uint32_t defer_space_id)
{
if(dbname && tablename && !is_remote)
{
@@ -1948,7 +1948,7 @@ static bool innodb_init_param()
size_t n_shift = get_bit_shift(size_t(innobase_page_size));
if (n_shift >= 12 && n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX) {
- srv_page_size_shift = ulong(n_shift);
+ srv_page_size_shift = uint32_t(n_shift);
srv_page_size = 1U << n_shift;
msg("InnoDB: The universal page size of the "
"database is set to %lu.", srv_page_size);
@@ -2298,7 +2298,7 @@ xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
/* set defaults */
ulint page_size = ULINT_UNDEFINED, zip_size = 0;
- info->space_id = ULINT_UNDEFINED;
+ info->space_id = UINT32_MAX;
fp = fopen(filepath, "r");
if (!fp) {
@@ -2313,7 +2313,8 @@ xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
} else if (strcmp(key, "zip_size") == 0) {
zip_size = strtoul(value, NULL, 10);
} else if (strcmp(key, "space_id") == 0) {
- info->space_id = strtoul(value, NULL, 10);
+ info->space_id = static_cast<uint32_t>
+ (strtoul(value, NULL, 10));
}
}
}
@@ -2327,7 +2328,7 @@ xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
info->page_size = zip_size ? zip_size : page_size;
}
- if (info->space_id == ULINT_UNDEFINED) {
+ if (info->space_id == UINT32_MAX) {
msg("mariabackup: Warning: This backup was taken with XtraBackup 2.0.1 "
"or earlier, some DDL operations between full and incremental "
"backups may be handled incorrectly");
@@ -2351,7 +2352,7 @@ xb_write_delta_metadata(const char *filename, const xb_delta_info_t *info)
snprintf(buf, sizeof(buf),
"page_size = " ULINTPF "\n"
"zip_size = " ULINTPF " \n"
- "space_id = " ULINTPF "\n",
+ "space_id = %u\n",
info->page_size,
info->zip_size,
info->space_id);
@@ -3216,7 +3217,7 @@ static void xb_load_single_table_tablespace(const char *dirname,
const char *filname,
bool is_remote,
bool skip_node_page0,
- ulint defer_space_id)
+ uint32_t defer_space_id)
{
ut_ad(srv_operation == SRV_OPERATION_BACKUP
|| srv_operation == SRV_OPERATION_RESTORE_DELTA
@@ -3328,7 +3329,7 @@ static void xb_load_single_table_tablespace(const char *dirname,
static void xb_load_single_table_tablespace(const std::string &space_name,
bool skip_node_page0,
- ulint defer_space_id)
+ uint32_t defer_space_id)
{
std::string name(space_name);
bool is_remote= access((name + ".ibd").c_str(), R_OK) != 0;
@@ -3707,9 +3708,9 @@ static dberr_t xb_assign_undo_space_start()
pfs_os_file_t file;
bool ret;
dberr_t error = DB_SUCCESS;
- ulint space;
+ uint32_t space;
+ uint32_t fsp_flags;
int n_retries = 5;
- ulint fsp_flags;
if (srv_undo_tablespaces == 0) {
return error;
@@ -3734,7 +3735,7 @@ static dberr_t xb_assign_undo_space_start()
}
fsp_flags = mach_read_from_4(
- page + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS);
+ page + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS);
retry:
if (os_file_read(IORequestRead, file, page,
TRX_SYS_PAGE_NO << srv_page_size_shift,
@@ -4766,7 +4767,7 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
iter++) {
const std::string name = iter->second;
- ulint id = iter->first;
+ uint32_t id = iter->first;
if (ddl_tracker.drops.find(id) != ddl_tracker.drops.end()) {
dropped_tables.insert(name);
@@ -4792,7 +4793,7 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
iter != ddl_tracker.id_to_name.end();
iter++) {
- ulint id = iter->first;
+ uint32_t id = iter->first;
std::string name = iter->second;
if (ddl_tracker.tables_in_backup.find(id) != ddl_tracker.tables_in_backup.end()) {
@@ -4903,8 +4904,8 @@ bool
xb_space_create_file(
/*==================*/
const char* path, /*!<in: path to tablespace */
- ulint space_id, /*!<in: space id */
- ulint flags, /*!<in: tablespace flags */
+ uint32_t space_id, /*!<in: space id */
+ uint32_t flags, /*!<in: tablespace flags */
pfs_os_file_t* file) /*!<out: file handle */
{
bool ret;
@@ -4967,7 +4968,7 @@ xb_delta_open_matching_space(
ut_a(dbname != NULL ||
!fil_is_user_tablespace_id(info.space_id) ||
- info.space_id == ULINT_UNDEFINED);
+ info.space_id == UINT32_MAX);
*success = false;
@@ -5043,14 +5044,14 @@ exit:
if (fil_space != NULL) {
if (fil_space->id == info.space_id
- || info.space_id == ULINT_UNDEFINED) {
+ || info.space_id == UINT32_MAX) {
/* we found matching space */
goto found;
} else {
char tmpname[FN_REFLEN];
- snprintf(tmpname, FN_REFLEN, "%s/xtrabackup_tmp_#" ULINTPF,
+ snprintf(tmpname, FN_REFLEN, "%s/xtrabackup_tmp_#%u",
dbname, fil_space->id);
msg("mariabackup: Renaming %s to %s.ibd",
@@ -5064,7 +5065,7 @@ exit:
}
}
- if (info.space_id == ULINT_UNDEFINED)
+ if (info.space_id == UINT32_MAX)
{
die("Can't handle DDL operation on tablespace "
"%s\n", dest_space_name);
@@ -5090,7 +5091,7 @@ exit:
}
/* No matching space found. create the new one. */
- const ulint flags = info.zip_size
+ const uint32_t flags = info.zip_size
? get_bit_shift(info.page_size
>> (UNIV_ZIP_SIZE_SHIFT_MIN - 1))
<< FSP_FLAGS_POS_ZIP_SSIZE
diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h
index 37cc54e5abb..f2d76ff4103 100644
--- a/extra/mariabackup/xtrabackup.h
+++ b/extra/mariabackup/xtrabackup.h
@@ -29,12 +29,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
struct xb_delta_info_t
{
- xb_delta_info_t(ulint page_size, ulint zip_size, ulint space_id)
+ xb_delta_info_t(ulint page_size, ulint zip_size, uint32_t space_id)
: page_size(page_size), zip_size(zip_size), space_id(space_id) {}
ulint page_size;
ulint zip_size;
- ulint space_id;
+ uint32_t space_id;
};
class CorruptedPages
@@ -42,23 +42,23 @@ class CorruptedPages
public:
CorruptedPages();
~CorruptedPages();
- void add_page(const char *file_name, ulint space_id, unsigned page_no);
- bool contains(ulint space_id, unsigned page_no) const;
- void drop_space(ulint space_id);
- void rename_space(ulint space_id, const std::string &new_name);
+ void add_page(const char *file_name, page_id_t page_id);
+ bool contains(page_id_t page_id) const;
+ void drop_space(uint32_t space_id);
+ void rename_space(uint32_t space_id, const std::string &new_name);
bool print_to_file(const char *file_name) const;
void read_from_file(const char *file_name);
bool empty() const;
void zero_out_free_pages();
private:
- void add_page_no_lock(const char *space_name, ulint space_id,
- unsigned page_no, bool convert_space_name);
+ void add_page_no_lock(const char *space_name, page_id_t page_id,
+ bool convert_space_name);
struct space_info_t {
std::string space_name;
- std::set<unsigned> pages;
+ std::set<uint32_t> pages;
};
- typedef std::map<ulint, space_info_t> container_t;
+ typedef std::map<uint32_t, space_info_t> container_t;
mutable pthread_mutex_t m_mutex;
container_t m_spaces;
};
diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
index b0f0b46ded7..65937a4f358 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
@@ -348,12 +348,3 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
-@@ -1765,7 +1765,7 @@
- SESSION_VALUE NULL
- DEFAULT_VALUE 0
- VARIABLE_SCOPE GLOBAL
--VARIABLE_TYPE BIGINT UNSIGNED
-+VARIABLE_TYPE INT UNSIGNED
- VARIABLE_COMMENT Number of undo tablespaces to use.
- NUMERIC_MIN_VALUE 0
- NUMERIC_MAX_VALUE 127
diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
index 33df36dfb3b..7182d42c6ca 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result
@@ -1741,7 +1741,7 @@ VARIABLE_NAME INNODB_UNDO_TABLESPACES
SESSION_VALUE NULL
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of undo tablespaces to use.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 127
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index 07f2ee974c0..b1f69aeabdc 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -382,8 +382,8 @@ btr_root_adjust_on_import(
} else {
/* Check that the table flags and the tablespace
flags match. */
- ulint tf = dict_tf_to_fsp_flags(table->flags);
- ulint sf = table->space->flags;
+ uint32_t tf = dict_tf_to_fsp_flags(table->flags);
+ uint32_t sf = table->space->flags;
sf &= ~FSP_FLAGS_MEM_MASK;
tf &= ~FSP_FLAGS_MEM_MASK;
if (fil_space_t::is_flags_equal(tf, sf)
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index a88fceac6e6..0df92e9dc47 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -7236,7 +7236,6 @@ btr_store_big_rec_extern_fields(
byte* field_ref;
ulint extern_len;
ulint store_len;
- ulint space_id;
ulint i;
mtr_t mtr;
mem_heap_t* heap = NULL;
@@ -7259,7 +7258,6 @@ btr_store_big_rec_extern_fields(
btr_blob_log_check_t redo_log(pcur, btr_mtr, offsets, &rec_block,
&rec, op);
page_zip = buf_block_get_page_zip(rec_block);
- space_id = rec_block->page.id().space();
ut_a(fil_page_index_page_check(page_align(rec))
|| op == BTR_STORE_INSERT_BULK);
@@ -7377,6 +7375,7 @@ btr_store_big_rec_extern_fields(
ut_a(block != NULL);
+ const uint32_t space_id = block->page.id().space();
const uint32_t page_no = block->page.id().page_no();
if (prev_page_no != FIL_NULL) {
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index cca630872ac..9d1ae7d76d1 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -582,16 +582,12 @@ bool buf_is_zeroes(span<const byte> buf)
}
/** Check if a page is corrupt.
-@param[in] check_lsn whether the LSN should be checked
-@param[in] read_buf database page
-@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
-@param[in] space tablespace
+@param check_lsn whether FIL_PAGE_LSN should be checked
+@param read_buf database page
+@param fsp_flags contents of FIL_SPACE_FLAGS
@return whether the page is corrupted */
-bool
-buf_page_is_corrupted(
- bool check_lsn,
- const byte* read_buf,
- ulint fsp_flags)
+bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf,
+ uint32_t fsp_flags)
{
#ifndef UNIV_INNOCHECKSUM
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure", return(true); );
@@ -4330,10 +4326,10 @@ buf_print_io(
/** Verify that post encryption checksum match with the calculated checksum.
This function should be called only if tablespace contains crypt data metadata.
-@param[in] page page frame
-@param[in] fsp_flags tablespace flags
-@return true if true if page is encrypted and OK, false otherwise */
-bool buf_page_verify_crypt_checksum(const byte* page, ulint fsp_flags)
+@param page page frame
+@param fsp_flags contents of FSP_SPACE_FLAGS
+@return whether the page is encrypted and valid */
+bool buf_page_verify_crypt_checksum(const byte *page, uint32_t fsp_flags)
{
if (!fil_space_t::full_crc32(fsp_flags)) {
return fil_space_verify_crypt_checksum(
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc
index 447fba38323..c79cbe3224e 100644
--- a/storage/innobase/buf/buf0dblwr.cc
+++ b/storage/innobase/buf/buf0dblwr.cc
@@ -351,7 +351,7 @@ void buf_dblwr_t::recover()
if (recv_sys.parse_start_lsn > lsn)
/* Pages written before the checkpoint are not useful for recovery. */
continue;
- const ulint space_id= page_get_space_id(page);
+ const uint32_t space_id= page_get_space_id(page);
const page_id_t page_id(space_id, page_no);
if (recv_sys.scanned_lsn < lsn)
diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc
index 1a95de2b045..23e025e3408 100644
--- a/storage/innobase/buf/buf0dump.cc
+++ b/storage/innobase/buf/buf0dump.cc
@@ -634,7 +634,7 @@ buf_load()
/* Avoid calling the expensive fil_space_t::get() for each
page within the same tablespace. dump[] is sorted by (space, page),
so all pages from a given tablespace are consecutive. */
- ulint cur_space_id = dump[0].space();
+ uint32_t cur_space_id = dump[0].space();
fil_space_t* space = fil_space_t::get(cur_space_id);
ulint zip_size = space ? space->zip_size() : 0;
@@ -646,10 +646,9 @@ buf_load()
for (i = 0; i < dump_n && !SHUTTING_DOWN(); i++) {
/* space_id for this iteration of the loop */
- const ulint this_space_id = dump[i].space();
+ const uint32_t this_space_id = dump[i].space();
- if (this_space_id == SRV_TMP_SPACE_ID) {
- /* Ignore the innodb_temporary tablespace. */
+ if (this_space_id >= SRV_SPACE_ID_UPPER_BOUND) {
continue;
}
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 1ddea7be89e..d97f101849b 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -225,7 +225,7 @@ deleting the data file of that tablespace.
The pages still remain a part of LRU and are evicted from
the list as they age towards the tail of the LRU.
@param id tablespace identifier */
-void buf_flush_remove_pages(ulint id)
+void buf_flush_remove_pages(uint32_t id)
{
const page_id_t first(id, 0), end(id + 1, 0);
ut_ad(id);
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc
index 45379bccb8c..b08d7bf3580 100644
--- a/storage/innobase/buf/buf0rea.cc
+++ b/storage/innobase/buf/buf0rea.cc
@@ -718,11 +718,9 @@ failed:
}
/** Issues read requests for pages which recovery wants to read in.
-@param[in] space_id tablespace id
-@param[in] page_nos array of page numbers to read, with the
-highest page number the last in the array
-@param[in] n number of page numbers in the array */
-void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n)
+@param space_id tablespace identifier
+@param page_nos page numbers to read, in ascending order */
+void buf_read_recv_pages(uint32_t space_id, st_::span<uint32_t> page_nos)
{
fil_space_t* space = fil_space_t::get(space_id);
@@ -733,7 +731,7 @@ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n)
const ulint zip_size = space->zip_size();
- for (ulint i = 0; i < n; i++) {
+ for (ulint i = 0; i < page_nos.size(); i++) {
/* Ignore if the page already present in freed ranges. */
if (space->freed_ranges.contains(page_nos[i])) {
@@ -774,7 +772,7 @@ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n)
}
- DBUG_PRINT("ib_buf", ("recovery read (%u pages) for %s", n,
- space->chain.start->name));
+ DBUG_PRINT("ib_buf", ("recovery read (%zu pages) for %s",
+ page_nos.size(), space->chain.start->name));
space->release();
}
diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc
index 2792f71376d..a4cb92ea473 100644
--- a/storage/innobase/dict/dict0boot.cc
+++ b/storage/innobase/dict/dict0boot.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2020, MariaDB Corporation.
+Copyright (c) 2016, 2021, 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
@@ -44,7 +44,7 @@ dict_hdr_get_new_id(
(not assigned if NULL) */
index_id_t* index_id, /*!< out: index id
(not assigned if NULL) */
- ulint* space_id) /*!< out: space id
+ uint32_t* space_id) /*!< out: space id
(not assigned if NULL) */
{
ib_id_t id;
@@ -241,8 +241,8 @@ dict_boot(void)
header. */
dict_sys.recover_row_id(mach_read_from_8(dict_hdr + DICT_HDR_ROW_ID));
- if (ulint max_space_id = mach_read_from_4(dict_hdr
- + DICT_HDR_MAX_SPACE_ID)) {
+ if (uint32_t max_space_id
+ = mach_read_from_4(dict_hdr + DICT_HDR_MAX_SPACE_ID)) {
max_space_id--;
fil_assign_new_space_id(&max_space_id);
}
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index 70d9e2bb022..44d56d40151 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -347,8 +347,8 @@ dict_build_table_def_step(
dict_table_t* table = node->table;
ut_ad(!table->is_temporary());
ut_ad(!table->space);
- ut_ad(table->space_id == ULINT_UNDEFINED);
- dict_hdr_get_new_id(&table->id, NULL, NULL);
+ ut_ad(table->space_id == UINT32_MAX);
+ dict_hdr_get_new_id(&table->id, nullptr, nullptr);
/* Always set this bit for all new created tables */
DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME);
@@ -366,10 +366,10 @@ dict_build_table_def_step(
DBUG_EXECUTE_IF(
"ib_create_table_fail_out_of_space_ids",
- table->space_id = ULINT_UNDEFINED;
+ table->space_id = UINT32_MAX;
);
- if (table->space_id == ULINT_UNDEFINED) {
+ if (table->space_id == UINT32_MAX) {
return DB_ERROR;
}
} else {
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index db11f4ff003..0d8e21ebd1c 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -622,11 +622,10 @@ dict_sys_tables_type_valid(ulint type, bool not_redundant)
@param[in] not_redundant whether ROW_FORMAT=REDUNDANT is not used
@return table flags */
static
-ulint
-dict_sys_tables_type_to_tf(ulint type, bool not_redundant)
+uint32_t dict_sys_tables_type_to_tf(uint32_t type, bool not_redundant)
{
ut_ad(dict_sys_tables_type_valid(type, not_redundant));
- ulint flags = not_redundant ? 1 : 0;
+ uint32_t flags = not_redundant ? 1 : 0;
/* ZIP_SSIZE, ATOMIC_BLOBS, DATA_DIR, PAGE_COMPRESSION,
PAGE_COMPRESSION_LEVEL are the same. */
@@ -657,14 +656,13 @@ dict_sys_tables_rec_read(
const rec_t* rec,
const span<const char>& name,
table_id_t* table_id,
- ulint* space_id,
- ulint* n_cols,
- ulint* flags,
- ulint* flags2)
+ uint32_t* space_id,
+ uint32_t* n_cols,
+ uint32_t* flags,
+ uint32_t* flags2)
{
const byte* field;
ulint len;
- ulint type;
field = rec_get_nth_field_old(
rec, DICT_FLD__SYS_TABLES__ID, &len);
@@ -680,7 +678,7 @@ dict_sys_tables_rec_read(
field = rec_get_nth_field_old(
rec, DICT_FLD__SYS_TABLES__TYPE, &len);
ut_a(len == 4);
- type = mach_read_from_4(field);
+ uint32_t type = mach_read_from_4(field);
/* Handle MDEV-12873 InnoDB SYS_TABLES.TYPE incompatibility
for PAGE_COMPRESSED=YES in MariaDB 10.2.2 to 10.2.6.
@@ -820,9 +818,9 @@ Search SYS_TABLES and check each tablespace mentioned that has not
already been added to the fil_system. If it is valid, add it to the
file_system list.
@return the highest space ID found. */
-static ulint dict_check_sys_tables()
+static uint32_t dict_check_sys_tables()
{
- ulint max_space_id = 0;
+ uint32_t max_space_id = 0;
btr_pcur_t pcur;
mtr_t mtr;
@@ -837,10 +835,10 @@ static ulint dict_check_sys_tables()
rec; rec = dict_getnext_system_low(&pcur, &mtr)) {
ulint len;
table_id_t table_id;
- ulint space_id;
- ulint n_cols;
- ulint flags;
- ulint flags2;
+ uint32_t space_id;
+ uint32_t n_cols;
+ uint32_t flags;
+ uint32_t flags2;
/* If a table record is not useable, ignore it and continue
on to the next record. Error messages were logged. */
@@ -938,9 +936,9 @@ void dict_check_tablespaces_and_store_max_id()
/* Initialize the max space_id from sys header */
mtr.start();
- ulint max_space_id = mach_read_from_4(DICT_HDR_MAX_SPACE_ID
- + DICT_HDR
- + dict_hdr_get(&mtr)->frame);
+ uint32_t max_space_id = mach_read_from_4(DICT_HDR_MAX_SPACE_ID
+ + DICT_HDR
+ + dict_hdr_get(&mtr)->frame);
mtr.commit();
fil_set_max_space_id_if_bigger(max_space_id);
@@ -2074,12 +2072,8 @@ const char *dict_load_table_low(const span<const char> &name,
const rec_t *rec, dict_table_t **table)
{
table_id_t table_id;
- ulint space_id;
- ulint n_cols;
- ulint t_num;
- ulint flags;
- ulint flags2;
- ulint n_v_col;
+ uint32_t space_id, t_num, flags, flags2;
+ ulint n_cols, n_v_col;
if (const char* error_text = dict_sys_tables_rec_check(rec)) {
*table = NULL;
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index 5f273a60be8..1a8d5764d0f 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -162,7 +162,7 @@ dict_table_t *dict_table_t::create(const span<const char> &name,
table->mdl_name.m_name= table->name.m_name;
table->is_system_db= dict_mem_table_is_system(table->name.m_name);
table->space= space;
- table->space_id= space ? space->id : ULINT_UNDEFINED;
+ table->space_id= space ? space->id : UINT32_MAX;
table->n_t_cols= static_cast<unsigned>(n_cols + DATA_N_SYS_COLS) &
dict_index_t::MAX_N_FIELDS;
table->n_v_cols= static_cast<unsigned>(n_v_cols) &
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index 82c26b59675..f8a8253cf86 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -782,20 +782,20 @@ static bool fil_space_decrypt_for_non_full_checksum(
/** Decrypt a page.
@param[in] space_id tablespace id
+@param[in] fsp_flags Tablespace flags
@param[in] crypt_data crypt_data
@param[in] tmp_frame Temporary buffer
@param[in] physical_size page size
-@param[in] fsp_flags Tablespace flags
@param[in,out] src_frame Page to decrypt
@param[out] err DB_SUCCESS or DB_DECRYPTION_FAILED
@return true if page decrypted, false if not.*/
bool
fil_space_decrypt(
- ulint space_id,
+ uint32_t space_id,
+ uint32_t fsp_flags,
fil_space_crypt_t* crypt_data,
byte* tmp_frame,
ulint physical_size,
- ulint fsp_flags,
byte* src_frame,
dberr_t* err)
{
@@ -829,9 +829,9 @@ fil_space_decrypt(
ut_ad(space->crypt_data != NULL && space->crypt_data->is_encrypted());
ut_ad(space->referenced());
- bool encrypted = fil_space_decrypt(space->id, space->crypt_data,
+ bool encrypted = fil_space_decrypt(space->id, space->flags,
+ space->crypt_data,
tmp_frame, physical_size,
- space->flags,
src_frame, &err);
if (err == DB_SUCCESS) {
@@ -1399,7 +1399,7 @@ inline fil_space_t *fil_system_t::default_encrypt_next(fil_space_t *space,
mysql_mutex_assert_owner(&mutex);
auto it= space && space->is_in_default_encrypt
- ? sized_ilist<fil_space_t, rotation_list_tag_t>::iterator(space)
+ ? sized_ilist<fil_space_t, default_encrypt_tag_t>::iterator(space)
: default_encrypt_tables.begin();
const auto end= default_encrypt_tables.end();
@@ -1893,7 +1893,7 @@ fil_crypt_rotate_pages(
const key_state_t* key_state,
rotate_thread_t* state)
{
- ulint space_id = state->space->id;
+ const uint32_t space_id = state->space->id;
uint32_t end = std::min(state->offset + uint32_t(state->batch),
state->space->free_limit);
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 91e4df7ca26..48b19f0bb5d 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -54,15 +54,6 @@ Created 10/25/1995 Heikki Tuuri
# include <dirent.h>
#endif
-/** Determine if the space id is a user tablespace id or not.
-@param space_id tablespace identifier
-@return true if it is a user tablespace ID */
-inline bool fil_is_user_tablespace_id(ulint space_id)
-{
- return space_id != TRX_SYS_SPACE && space_id != SRV_TMP_SPACE_ID &&
- !srv_is_undo_tablespace(space_id);
-}
-
/** Try to close a file to adhere to the innodb_open_files limit.
@param print_info whether to diagnose why a file cannot be closed
@return whether a file was closed */
@@ -77,7 +68,7 @@ bool fil_space_t::try_to_close(bool print_info)
case FIL_TYPE_IMPORT:
break;
case FIL_TYPE_TABLESPACE:
- if (!fil_is_user_tablespace_id(space.id))
+ if (is_predefined_tablespace(space.id))
continue;
}
@@ -118,11 +109,8 @@ The tablespace must exist in the memory cache.
@param[in] new_path_in new file name,
or NULL if it is located in the normal data directory
@return true if success */
-static bool
-fil_rename_tablespace(
- ulint id,
- const char* old_path,
- const char* new_path_in);
+static bool fil_rename_tablespace(uint32_t id, const char *old_path,
+ const char *new_path_in);
/*
IMPLEMENTATION OF THE TABLESPACE MEMORY CACHE
@@ -210,14 +198,11 @@ fil_validate_skip(void)
}
#endif /* UNIV_DEBUG */
-/*******************************************************************//**
-Returns the table space by a given id, NULL if not found.
-It is unsafe to dereference the returned pointer. It is fine to check
-for NULL. */
-fil_space_t*
-fil_space_get_by_id(
-/*================*/
- ulint id) /*!< in: space id */
+/** Look up a tablespace.
+@param tablespace identifier
+@return tablespace
+@retval nullptr if not found */
+fil_space_t *fil_space_get_by_id(uint32_t id)
{
fil_space_t* space;
@@ -240,14 +225,12 @@ or the caller should be in single-threaded crash recovery mode
Normally, fil_space_t::get() should be used instead.
@param[in] id tablespace ID
@return tablespace, or NULL if not found */
-fil_space_t*
-fil_space_get(
- ulint id)
+fil_space_t *fil_space_get(uint32_t id)
{
- mysql_mutex_lock(&fil_system.mutex);
- fil_space_t* space = fil_space_get_by_id(id);
- mysql_mutex_unlock(&fil_system.mutex);
- return(space);
+ mysql_mutex_lock(&fil_system.mutex);
+ fil_space_t *space= fil_space_get_by_id(id);
+ mysql_mutex_unlock(&fil_system.mutex);
+ return space;
}
/** Validate the compression algorithm for full crc32 format.
@@ -409,7 +392,7 @@ static bool fil_node_open_file(fil_node_t *node)
{
mysql_mutex_assert_owner(&fil_system.mutex);
ut_ad(!node->is_open());
- ut_ad(fil_is_user_tablespace_id(node->space->id) ||
+ ut_ad(!is_predefined_tablespace(node->space->id) ||
srv_operation == SRV_OPERATION_BACKUP ||
srv_operation == SRV_OPERATION_RESTORE ||
srv_operation == SRV_OPERATION_RESTORE_DELTA);
@@ -844,13 +827,10 @@ fil_space_free_low(
/** Frees a space object from the tablespace memory cache.
Closes the files in the chain but does not delete them.
There must not be any pending i/o's or flushes on the files.
-@param[in] id tablespace identifier
-@param[in] x_latched whether the caller holds X-mode space->latch
+@param id tablespace identifier
+@param x_latched whether the caller holds exclusive fil_space_t::latch
@return true if success */
-bool
-fil_space_free(
- ulint id,
- bool x_latched)
+bool fil_space_free(uint32_t id, bool x_latched)
{
ut_ad(id != TRX_SYS_SPACE);
@@ -898,7 +878,7 @@ fil_space_free(
@param mode encryption mode
@return pointer to created tablespace, to be filled in with add()
@retval nullptr on failure (such as when the same tablespace exists) */
-fil_space_t *fil_space_t::create(ulint id, ulint flags,
+fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
fil_type_t purpose,
fil_space_crypt_t *crypt_data,
fil_encryption_t mode)
@@ -1004,18 +984,13 @@ Assigns a new space id for a new single-table tablespace. This works simply by
incrementing the global counter. If 4 billion id's is not enough, we may need
to recycle id's.
@return true if assigned, false if not */
-bool
-fil_assign_new_space_id(
-/*====================*/
- ulint* space_id) /*!< in/out: space id */
+bool fil_assign_new_space_id(uint32_t *space_id)
{
- ulint id;
+ uint32_t id = *space_id;
bool success;
mysql_mutex_lock(&fil_system.mutex);
- id = *space_id;
-
if (id < fil_system.max_assigned_id) {
id = fil_system.max_assigned_id;
}
@@ -1041,7 +1016,7 @@ fil_assign_new_space_id(
<< ". To reset the counter to zero"
" you have to dump all your tables and"
" recreate the whole InnoDB installation.";
- *space_id = ULINT_UNDEFINED;
+ *space_id = UINT32_MAX;
}
mysql_mutex_unlock(&fil_system.mutex);
@@ -1074,7 +1049,7 @@ bool fil_space_t::read_page0()
}
/** Look up a tablespace and ensure that its first page has been validated. */
-static fil_space_t *fil_space_get_space(ulint id)
+static fil_space_t *fil_space_get_space(uint32_t id)
{
if (fil_space_t *space= fil_space_get_by_id(id))
if (space->read_page0())
@@ -1082,7 +1057,8 @@ static fil_space_t *fil_space_get_space(ulint id)
return nullptr;
}
-void fil_space_set_recv_size_and_flags(ulint id, uint32_t size, uint32_t flags)
+void fil_space_set_recv_size_and_flags(uint32_t id, uint32_t size,
+ uint32_t flags)
{
ut_ad(id < SRV_SPACE_ID_UPPER_BOUND);
mysql_mutex_lock(&fil_system.mutex);
@@ -1360,14 +1336,9 @@ void fil_space_t::close_all()
/*******************************************************************//**
Sets the max tablespace id counter if the given number is bigger than the
previous value. */
-void
-fil_set_max_space_id_if_bigger(
-/*===========================*/
- ulint max_id) /*!< in: maximum known id */
+void fil_set_max_space_id_if_bigger(uint32_t max_id)
{
- if (max_id >= SRV_SPACE_ID_UPPER_BOUND) {
- ib::fatal() << "Max tablespace id is too high, " << max_id;
- }
+ ut_a(max_id < SRV_SPACE_ID_UPPER_BOUND);
mysql_mutex_lock(&fil_system.mutex);
@@ -1403,7 +1374,7 @@ fil_write_flushed_lsn(
mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
lsn);
- ulint fsp_flags = mach_read_from_4(
+ uint32_t fsp_flags = mach_read_from_4(
buf + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS);
if (fil_space_t::full_crc32(fsp_flags)) {
@@ -1425,7 +1396,7 @@ fil_write_flushed_lsn(
@param id tablespace identifier
@return tablespace
@retval nullptr if the tablespace is missing or inaccessible */
-fil_space_t *fil_space_t::get(ulint id)
+fil_space_t *fil_space_t::get(uint32_t id)
{
mysql_mutex_lock(&fil_system.mutex);
fil_space_t *space= fil_space_get_by_id(id);
@@ -1446,7 +1417,7 @@ fil_space_t *fil_space_t::get(ulint id)
@param first_page_no first page number in the file
@param path file path
@param new_path new file path for type=FILE_RENAME */
-inline void mtr_t::log_file_op(mfile_type_t type, ulint space_id,
+inline void mtr_t::log_file_op(mfile_type_t type, uint32_t space_id,
const char *path, const char *new_path)
{
ut_ad((new_path != nullptr) == (type == FILE_RENAME));
@@ -1505,13 +1476,8 @@ inline void mtr_t::log_file_op(mfile_type_t type, ulint space_id,
@param[in] old_name tablespace file name
@param[in] new_name tablespace file name after renaming
@param[in,out] mtr mini-transaction */
-static
-void
-fil_name_write_rename_low(
- ulint space_id,
- const char* old_name,
- const char* new_name,
- mtr_t* mtr)
+static void fil_name_write_rename_low(uint32_t space_id, const char *old_name,
+ const char *new_name, mtr_t *mtr)
{
ut_ad(!is_predefined_tablespace(space_id));
mtr->log_file_op(FILE_RENAME, space_id, old_name, new_name);
@@ -1521,35 +1487,28 @@ fil_name_write_rename_low(
@param[in] space_id tablespace id
@param[in] old_name tablespace file name
@param[in] new_name tablespace file name after renaming */
-static void
-fil_name_write_rename(
- ulint space_id,
- const char* old_name,
- const char* new_name)
+static void fil_name_write_rename(uint32_t space_id,
+ const char *old_name, const char* new_name)
{
- mtr_t mtr;
- mtr.start();
- fil_name_write_rename_low(space_id, old_name, new_name, &mtr);
- mtr.commit();
- log_write_up_to(mtr.commit_lsn(), true);
+ mtr_t mtr;
+ mtr.start();
+ fil_name_write_rename_low(space_id, old_name, new_name, &mtr);
+ mtr.commit();
+ log_write_up_to(mtr.commit_lsn(), true);
}
/** Write FILE_MODIFY for a file.
@param[in] space_id tablespace id
@param[in] name tablespace file name
@param[in,out] mtr mini-transaction */
-static
-void
-fil_name_write(
- ulint space_id,
- const char* name,
- mtr_t* mtr)
+static void fil_name_write(uint32_t space_id, const char *name,
+ mtr_t *mtr)
{
ut_ad(!is_predefined_tablespace(space_id));
mtr->log_file_op(FILE_MODIFY, space_id, name);
}
-fil_space_t *fil_space_t::check_pending_operations(ulint id)
+fil_space_t *fil_space_t::check_pending_operations(uint32_t id)
{
ut_a(!is_system_tablespace(id));
bool being_deleted= false;
@@ -1614,7 +1573,7 @@ fil_space_t *fil_space_t::check_pending_operations(ulint id)
/** Close a single-table tablespace on failed IMPORT TABLESPACE.
The tablespace must be cached in the memory cache.
Free all pages used by the tablespace. */
-void fil_close_tablespace(ulint id)
+void fil_close_tablespace(uint32_t id)
{
ut_ad(!is_system_tablespace(id));
fil_space_t* space = fil_space_t::check_pending_operations(id);
@@ -1654,7 +1613,7 @@ void fil_close_tablespace(ulint id)
@param id tablespace identifier
@return detached file handle (to be closed by the caller)
@return OS_FILE_CLOSED if no file existed */
-pfs_os_file_t fil_delete_tablespace(ulint id)
+pfs_os_file_t fil_delete_tablespace(uint32_t id)
{
ut_ad(!is_system_tablespace(id));
pfs_os_file_t handle= OS_FILE_CLOSED;
@@ -1863,11 +1822,8 @@ The tablespace must exist in the memory cache.
@param[in] new_path_in new file name,
or NULL if it is located in the normal data directory
@return true if success */
-static bool
-fil_rename_tablespace(
- ulint id,
- const char* old_path,
- const char* new_path_in)
+static bool fil_rename_tablespace(uint32_t id, const char *old_path,
+ const char *new_path_in)
{
fil_space_t* space;
fil_node_t* node;
@@ -1952,10 +1908,10 @@ must be >= FIL_IBD_FILE_INITIAL_SIZE
@retval NULL on error */
fil_space_t*
fil_ibd_create(
- ulint space_id,
+ uint32_t space_id,
const table_name_t name,
const char* path,
- ulint flags,
+ uint32_t flags,
uint32_t size,
fil_encryption_t mode,
uint32_t key_id,
@@ -2126,8 +2082,8 @@ fil_space_t*
fil_ibd_open(
bool validate,
fil_type_t purpose,
- ulint id,
- ulint flags,
+ uint32_t id,
+ uint32_t flags,
fil_space_t::name_type name,
const char* path_in,
dberr_t* err)
@@ -2147,7 +2103,7 @@ fil_ibd_open(
/* Table flags can be ULINT_UNDEFINED if
dict_tf_to_fsp_flags_failure is set. */
- if (flags == ULINT_UNDEFINED) {
+ if (flags == UINT32_MAX) {
corrupted:
local_err = DB_CORRUPTION;
func_exit:
@@ -2490,10 +2446,7 @@ of the file in validate_for_recovery().
@param[out] space the tablespace, or NULL on error
@return status of the operation */
enum fil_load_status
-fil_ibd_load(
- ulint space_id,
- const char* filename,
- fil_space_t*& space)
+fil_ibd_load(uint32_t space_id, const char *filename, fil_space_t *&space)
{
/* If the a space is already in the file system cache with this
space ID, then there is nothing to do. */
@@ -2612,7 +2565,7 @@ tablespace_check:
/* Adjust the memory-based flags that would normally be set by
dict_tf_to_fsp_flags(). In recovery, we have no data dictionary. */
- ulint flags = file.flags();
+ uint32_t flags = file.flags();
if (fil_space_t::is_compressed(flags)) {
flags |= page_zip_level
<< FSP_FLAGS_MEM_COMPRESSION_LEVEL;
@@ -2646,7 +2599,7 @@ tablespace_check:
(Typically when upgrading from MariaDB 10.1.0..10.1.20.)
@param[in,out] space tablespace
@param[in] flags desired tablespace flags */
-void fsp_flags_try_adjust(fil_space_t* space, ulint flags)
+void fsp_flags_try_adjust(fil_space_t *space, uint32_t flags)
{
ut_ad(!srv_read_only_mode);
ut_ad(fil_space_t::is_valid_flags(flags, space->id));
@@ -2696,14 +2649,15 @@ startup, there may be many tablespaces which are not yet in the memory cache.
@param[in] table_flags table flags
@return the tablespace
@retval NULL if no matching tablespace exists in the memory cache */
-fil_space_t *fil_space_for_table_exists_in_mem(ulint id, ulint table_flags)
+fil_space_t *fil_space_for_table_exists_in_mem(uint32_t id,
+ uint32_t table_flags)
{
- const ulint expected_flags = dict_tf_to_fsp_flags(table_flags);
+ const uint32_t expected_flags = dict_tf_to_fsp_flags(table_flags);
mysql_mutex_lock(&fil_system.mutex);
if (fil_space_t* space = fil_space_get_by_id(id)) {
- ulint tf = expected_flags & ~FSP_FLAGS_MEM_MASK;
- ulint sf = space->flags & ~FSP_FLAGS_MEM_MASK;
+ uint32_t tf = expected_flags & ~FSP_FLAGS_MEM_MASK;
+ uint32_t sf = space->flags & ~FSP_FLAGS_MEM_MASK;
if (!fil_space_t::is_flags_equal(tf, sf)
&& !fil_space_t::is_flags_equal(sf, tf)) {
diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc
index ffa2563d338..13f8432e8d4 100644
--- a/storage/innobase/fil/fil0pagecompress.cc
+++ b/storage/innobase/fil/fil0pagecompress.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (C) 2013, 2020, MariaDB Corporation.
+Copyright (C) 2013, 2021, 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
@@ -195,7 +195,7 @@ static ulint fil_page_compress_low(
static ulint fil_page_compress_for_full_crc32(
const byte* buf,
byte* out_buf,
- ulint flags,
+ uint32_t flags,
ulint block_size,
bool encrypted)
{
@@ -378,7 +378,7 @@ static ulint fil_page_compress_for_non_full_crc32(
ulint fil_page_compress(
const byte* buf,
byte* out_buf,
- ulint flags,
+ uint32_t flags,
ulint block_size,
bool encrypted)
{
@@ -502,7 +502,8 @@ static bool fil_page_decompress_low(
@return size of the compressed data
@retval 0 if decompression failed
@retval srv_page_size if the page was not compressed */
-ulint fil_page_decompress_for_full_crc32(byte* tmp_buf, byte* buf, ulint flags)
+static size_t fil_page_decompress_for_full_crc32(byte *tmp_buf, byte *buf,
+ uint32_t flags)
{
ut_ad(fil_space_t::full_crc32(flags));
bool compressed = false;
@@ -547,9 +548,7 @@ ulint fil_page_decompress_for_full_crc32(byte* tmp_buf, byte* buf, ulint flags)
@return size of the compressed data
@retval 0 if decompression failed
@retval srv_page_size if the page was not compressed */
-ulint fil_page_decompress_for_non_full_crc32(
- byte* tmp_buf,
- byte* buf)
+static size_t fil_page_decompress_for_non_full_crc32(byte *tmp_buf, byte *buf)
{
ulint header_len;
uint comp_algo;
@@ -599,10 +598,7 @@ ulint fil_page_decompress_for_non_full_crc32(
@return size of the compressed data
@retval 0 if decompression failed
@retval srv_page_size if the page was not compressed */
-ulint fil_page_decompress(
- byte* tmp_buf,
- byte* buf,
- ulint flags)
+ulint fil_page_decompress(byte *tmp_buf, byte *buf, uint32_t flags)
{
if (fil_space_t::full_crc32(flags)) {
return fil_page_decompress_for_full_crc32(tmp_buf, buf, flags);
diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc
index aebe6c9ce23..b8c355b13e9 100644
--- a/storage/innobase/fsp/fsp0file.cc
+++ b/storage/innobase/fsp/fsp0file.cc
@@ -304,8 +304,8 @@ Datafile::read_first_page(bool read_only_mode)
+ m_first_page);
m_flags = fsp_header_get_flags(m_first_page);
if (!fil_space_t::is_valid_flags(m_flags, m_space_id)) {
- ulint cflags = fsp_flags_convert_from_101(m_flags);
- if (cflags == ULINT_UNDEFINED) {
+ uint32_t cflags = fsp_flags_convert_from_101(m_flags);
+ if (cflags == UINT32_MAX) {
ib::error()
<< "Invalid flags " << ib::hex(m_flags)
<< " in " << m_filepath;
@@ -342,8 +342,7 @@ in order for this function to validate it.
@param[in] flags The expected tablespace flags.
@retval DB_SUCCESS if tablespace is valid, DB_ERROR if not.
m_is_valid is also set true on success, else false. */
-dberr_t
-Datafile::validate_to_dd(ulint space_id, ulint flags)
+dberr_t Datafile::validate_to_dd(uint32_t space_id, uint32_t flags)
{
dberr_t err;
@@ -421,7 +420,7 @@ Datafile::validate_for_recovery()
" the first 64 pages.";
return(err);
}
- if (m_space_id == ULINT_UNDEFINED) {
+ if (m_space_id == UINT32_MAX) {
return DB_SUCCESS; /* empty file */
}
@@ -613,15 +612,15 @@ Datafile::find_space_id()
page_size <<= 1) {
/* map[space_id] = count of pages */
typedef std::map<
- ulint,
- ulint,
+ uint32_t,
+ uint32_t,
std::less<ulint>,
ut_allocator<std::pair<const ulint, ulint> > >
Pages;
Pages verify;
- ulint page_count = 64;
- ulint valid_pages = 0;
+ uint32_t page_count = 64;
+ uint32_t valid_pages = 0;
/* Adjust the number of pages to analyze based on file size */
while ((page_count * page_size) > file_size) {
@@ -635,14 +634,14 @@ Datafile::find_space_id()
byte* page = static_cast<byte*>(
aligned_malloc(page_size, page_size));
- ulint fsp_flags;
+ uint32_t fsp_flags;
/* provide dummy value if the first os_file_read() fails */
switch (srv_checksum_algorithm) {
case SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32:
case SRV_CHECKSUM_ALGORITHM_FULL_CRC32:
fsp_flags = 1U << FSP_FLAGS_FCRC32_POS_MARKER
| FSP_FLAGS_FCRC32_PAGE_SSIZE()
- | innodb_compression_algorithm
+ | uint(innodb_compression_algorithm)
<< FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO;
break;
default:
@@ -682,7 +681,7 @@ Datafile::find_space_id()
if (noncompressed_ok || compressed_ok) {
- ulint space_id = mach_read_from_4(page
+ uint32_t space_id = mach_read_from_4(page
+ FIL_PAGE_SPACE_ID);
if (space_id > 0) {
@@ -761,14 +760,14 @@ Datafile::restore_from_doublewrite()
return(true);
}
- ulint flags = mach_read_from_4(
+ uint32_t flags = mach_read_from_4(
FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
if (!fil_space_t::is_valid_flags(flags, m_space_id)) {
flags = fsp_flags_convert_from_101(flags);
/* recv_dblwr_t::validate_page() inside find_page()
checked this already. */
- ut_ad(flags != ULINT_UNDEFINED);
+ ut_ad(flags != UINT32_MAX);
/* The flags on the page should be converted later. */
}
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 8477e74c5f1..7eb5611bb75 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1072,7 +1072,7 @@ fsp_alloc_free_page(
{
fil_addr_t first;
xdes_t* descr;
- const ulint space_id = space->id;
+ const uint32_t space_id = space->id;
ut_d(space->modify_check(*mtr));
buf_block_t* block = fsp_get_header(space, mtr);
@@ -1511,7 +1511,7 @@ static
fseg_inode_t*
fseg_inode_try_get(
const fseg_header_t* header,
- ulint space,
+ uint32_t space,
ulint zip_size,
mtr_t* mtr,
buf_block_t** block)
@@ -1548,7 +1548,7 @@ static
fseg_inode_t*
fseg_inode_get(
const fseg_header_t* header,
- ulint space,
+ uint32_t space,
ulint zip_size,
mtr_t* mtr,
buf_block_t** block = NULL)
@@ -1993,7 +1993,7 @@ fseg_alloc_free_page_low(
xdes_t* ret_descr; /*!< the extent of the allocated page */
buf_block_t* xdes;
ulint n;
- const ulint space_id = space->id;
+ const uint32_t space_id = space->id;
ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
@@ -2248,13 +2248,12 @@ fseg_alloc_free_page_general(
in which the page should be initialized. */
{
fseg_inode_t* inode;
- ulint space_id;
fil_space_t* space;
buf_block_t* iblock;
buf_block_t* block;
uint32_t n_reserved;
- space_id = page_get_space_id(page_align(seg_header));
+ const uint32_t space_id = page_get_space_id(page_align(seg_header));
space = mtr->x_lock_space(space_id);
inode = fseg_inode_get(seg_header, space_id, space->zip_size(),
mtr, &iblock);
diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc
index b069250ff9f..6bdf9fcc4d8 100644
--- a/storage/innobase/fsp/fsp0space.cc
+++ b/storage/innobase/fsp/fsp0space.cc
@@ -59,7 +59,7 @@ Tablespace::shutdown()
m_files.clear();
ut_free(m_path);
m_path = NULL;
- m_space_id = ULINT_UNDEFINED;
+ m_space_id = UINT32_MAX;
}
/** Note that the data file was found.
@@ -118,7 +118,7 @@ Tablespace::open_or_create(bool is_temp)
/* Create the tablespace entry for the multi-file
tablespace in the tablespace manager. */
- ulint fsp_flags = 0;
+ uint32_t fsp_flags;
switch (srv_checksum_algorithm) {
case SRV_CHECKSUM_ALGORITHM_FULL_CRC32:
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 65dc7fcae1a..41fb62c6ba0 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1733,16 +1733,11 @@ If correct, set the associated page_size_shift which is the power of 2
for this page size.
@param[in] page_size Page Size to evaluate
@return an associated page_size_shift if valid, 0 if invalid. */
-inline
-ulong
-innodb_page_size_validate(
- ulong page_size)
+inline uint32_t innodb_page_size_validate(ulong page_size)
{
- ulong n;
-
DBUG_ENTER("innodb_page_size_validate");
- for (n = UNIV_PAGE_SIZE_SHIFT_MIN;
+ for (uint32_t n = UNIV_PAGE_SIZE_SHIFT_MIN;
n <= UNIV_PAGE_SIZE_SHIFT_MAX;
n++) {
if (page_size == static_cast<ulong>(1 << n)) {
@@ -19081,7 +19076,7 @@ static MYSQL_SYSVAR_STR(undo_directory, srv_undo_dir,
"Directory where undo tablespace files live, this path can be absolute.",
NULL, NULL, NULL);
-static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces,
+static MYSQL_SYSVAR_UINT(undo_tablespaces, srv_undo_tablespaces,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of undo tablespaces to use.",
NULL, NULL,
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 044b760bf04..2ef58ceca74 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -10452,8 +10452,8 @@ commit_cache_norebuild(
space->flags
|= FSP_FLAGS_MASK_PAGE_COMPRESSION;
} else if (!space->is_compressed()) {
- space->flags
- |= innodb_compression_algorithm
+ space->flags |= static_cast<uint32_t>(
+ innodb_compression_algorithm)
<< FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO;
}
mysql_mutex_unlock(&fil_system.mutex);
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index bd471dff765..0ab1a35dfc7 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -2258,7 +2258,7 @@ static void ibuf_read_merge_pages(const uint32_t* space_ids,
#endif
for (ulint i = 0; i < n_stored; i++) {
- const ulint space_id = space_ids[i];
+ const uint32_t space_id = space_ids[i];
fil_space_t* s = fil_space_t::get(space_id);
if (!s) {
tablespace_deleted:
@@ -2944,7 +2944,7 @@ void
ibuf_update_max_tablespace_id(void)
/*===============================*/
{
- ulint max_space_id;
+ uint32_t max_space_id;
const rec_t* rec;
const byte* field;
ulint len;
@@ -4463,7 +4463,7 @@ reset_bit:
/** Delete all change buffer entries for a tablespace,
in DISCARD TABLESPACE, IMPORT TABLESPACE, or crash recovery.
@param[in] space missing or to-be-discarded tablespace */
-void ibuf_delete_for_discarded_space(ulint space)
+void ibuf_delete_for_discarded_space(uint32_t space)
{
mem_heap_t* heap;
btr_pcur_t pcur;
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index d47d499eb92..6ec8928608b 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -425,16 +425,13 @@ Decrements the bufferfix count. */
bool buf_is_zeroes(st_::span<const byte> buf);
/** Check if a page is corrupt.
-@param[in] check_lsn whether the LSN should be checked
-@param[in] read_buf database page
-@param[in] fsp_flags tablespace flags
+@param check_lsn whether FIL_PAGE_LSN should be checked
+@param read_buf database page
+@param fsp_flags contents of FIL_SPACE_FLAGS
@return whether the page is corrupted */
-bool
-buf_page_is_corrupted(
- bool check_lsn,
- const byte* read_buf,
- ulint fsp_flags)
- MY_ATTRIBUTE((warn_unused_result));
+bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf,
+ uint32_t fsp_flags)
+ MY_ATTRIBUTE((warn_unused_result));
inline void *aligned_malloc(size_t size, size_t align)
{
@@ -463,7 +460,8 @@ stored in 26th position.
@param[in] read_buf database page
@param[in] fsp_flags tablespace flags
@return key version of the page. */
-inline uint32_t buf_page_get_key_version(const byte* read_buf, ulint fsp_flags)
+inline uint32_t buf_page_get_key_version(const byte* read_buf,
+ uint32_t fsp_flags)
{
static_assert(FIL_PAGE_FCRC32_KEY_VERSION == 0, "compatibility");
return fil_space_t::full_crc32(fsp_flags)
@@ -478,7 +476,7 @@ stored in page type.
@param[in] read_buf database page
@param[in] fsp_flags tablespace flags
@return true if page is compressed. */
-inline bool buf_page_is_compressed(const byte* read_buf, ulint fsp_flags)
+inline bool buf_page_is_compressed(const byte* read_buf, uint32_t fsp_flags)
{
uint16_t page_type= fil_page_get_type(read_buf);
return fil_space_t::full_crc32(fsp_flags)
@@ -604,12 +602,10 @@ buf_pool_size_align(
/** Verify that post encryption checksum match with the calculated checksum.
This function should be called only if tablespace contains crypt data metadata.
-@param[in] page page frame
-@param[in] fsp_flags tablespace flags
-@return true if page is encrypted and OK, false otherwise */
-bool buf_page_verify_crypt_checksum(
- const byte* page,
- ulint fsp_flags);
+@param page page frame
+@param fsp_flags contents of FSP_SPACE_FLAGS
+@return whether the page is encrypted and valid */
+bool buf_page_verify_crypt_checksum(const byte *page, uint32_t fsp_flags);
/** Calculate a ROW_FORMAT=COMPRESSED page checksum and update the page.
@param[in,out] page page to update
diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h
index eed2ecac703..1f2907fc1d9 100644
--- a/storage/innobase/include/buf0flu.h
+++ b/storage/innobase/include/buf0flu.h
@@ -54,7 +54,7 @@ deleting the data file of that tablespace.
The pages still remain a part of LRU and are evicted from
the list as they age towards the tail of the LRU.
@param id tablespace identifier */
-void buf_flush_remove_pages(ulint id);
+void buf_flush_remove_pages(uint32_t id);
/*******************************************************************//**
Relocates a buffer control block on the flush_list.
diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h
index 87c6b5d7e75..bbe94ba2523 100644
--- a/storage/innobase/include/buf0rea.h
+++ b/storage/innobase/include/buf0rea.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2020, MariaDB Corporation.
+Copyright (c) 2015, 2021, 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
@@ -102,12 +102,10 @@ which could result in a deadlock if the OS does not support asynchronous io.
ulint
buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf);
-/** Issues read requests for pages which recovery wants to read in.
-@param[in] space_id tablespace id
-@param[in] page_nos array of page numbers to read, with the
-highest page number the last in the array
-@param[in] n number of page numbers in the array */
-void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n);
+/** Issue read requests for pages that need to be recovered.
+@param space_id tablespace identifier
+@param page_nos page numbers to read, in ascending order */
+void buf_read_recv_pages(uint32_t space_id, st_::span<uint32_t> page_nos);
/** @name Modes used in read-ahead @{ */
/** read only pages belonging to the insert buffer tree */
diff --git a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h
index 04b47aaddab..86fcc5a17d0 100644
--- a/storage/innobase/include/buf0types.h
+++ b/storage/innobase/include/buf0types.h
@@ -101,12 +101,10 @@ class page_id_t
public:
/** Constructor from (space, page_no).
- @param[in] space tablespace id
- @param[in] page_no page number */
- page_id_t(ulint space, uint32_t page_no) : m_id(uint64_t{space} << 32 | page_no)
- {
- ut_ad(space <= 0xFFFFFFFFU);
- }
+ @param space tablespace id
+ @param page_no page number */
+ page_id_t(uint32_t space, uint32_t page_no) :
+ m_id(uint64_t{space} << 32 | page_no) {}
page_id_t(uint64_t id) : m_id(id) {}
bool operator==(const page_id_t& rhs) const { return m_id == rhs.m_id; }
diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h
index 869905c6b97..07ecfe4edff 100644
--- a/storage/innobase/include/dict0boot.h
+++ b/storage/innobase/include/dict0boot.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2018, 2020, MariaDB Corporation.
+Copyright (c) 2018, 2021, 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
@@ -45,7 +45,7 @@ dict_hdr_get_new_id(
(not assigned if NULL) */
index_id_t* index_id, /*!< out: index id
(not assigned if NULL) */
- ulint* space_id); /*!< out: space id
+ uint32_t* space_id); /*!< out: space id
(not assigned if NULL) */
/** Update dict_sys.row_id in the dictionary header file page. */
void dict_hdr_flush_row_id(row_id_t id);
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 3c0e93edc8f..a68eea3652c 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -873,11 +873,8 @@ fil_space_t::flags | 0 | 0 | 1 | 1
==================================================================
@param[in] table_flags dict_table_t::flags
@return tablespace flags (fil_space_t::flags) */
-UNIV_INLINE
-ulint
-dict_tf_to_fsp_flags(ulint table_flags)
- MY_ATTRIBUTE((const));
-
+inline uint32_t dict_tf_to_fsp_flags(unsigned table_flags)
+ MY_ATTRIBUTE((const));
/** Extract the ROW_FORMAT=COMPRESSED page size from table flags.
@param[in] flags flags
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index a494eefdc32..07f4309f90d 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2020, MariaDB Corporation.
+Copyright (c) 2013, 2021, 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
@@ -618,19 +618,16 @@ fil_space_t::flags | 0 | 0 | 1 | 1
==================================================================
@param[in] table_flags dict_table_t::flags
@return tablespace flags (fil_space_t::flags) */
-UNIV_INLINE
-ulint
-dict_tf_to_fsp_flags(ulint table_flags)
+inline uint32_t dict_tf_to_fsp_flags(unsigned table_flags)
{
- ulint fsp_flags;
- ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(
+ uint32_t fsp_flags;
+ uint32_t page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(
table_flags);
ut_ad((DICT_TF_GET_PAGE_COMPRESSION(table_flags) == 0)
== (page_compression_level == 0));
- DBUG_EXECUTE_IF("dict_tf_to_fsp_flags_failure",
- return(ULINT_UNDEFINED););
+ DBUG_EXECUTE_IF("dict_tf_to_fsp_flags_failure", return UINT32_MAX;);
/* No ROW_FORMAT=COMPRESSED for innodb_checksum_algorithm=full_crc32 */
if ((srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_FULL_CRC32
@@ -641,7 +638,8 @@ dict_tf_to_fsp_flags(ulint table_flags)
| FSP_FLAGS_FCRC32_PAGE_SSIZE();
if (page_compression_level) {
- fsp_flags |= innodb_compression_algorithm
+ fsp_flags |= static_cast<uint32_t>(
+ innodb_compression_algorithm)
<< FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO;
}
} else {
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 5424fce9ba3..8fe0c75309c 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -112,7 +112,7 @@ are described in fsp0fsp.h. */
/** This bitmask is used in SYS_TABLES.N_COLS to set and test whether
the Compact page format is used, i.e ROW_FORMAT != REDUNDANT */
-#define DICT_N_COLS_COMPACT 0x80000000UL
+constexpr uint32_t DICT_N_COLS_COMPACT= 1U << 31;
/** Width of the COMPACT flag */
#define DICT_TF_WIDTH_COMPACT 1
@@ -2037,7 +2037,7 @@ public:
/** The tablespace of the table */
fil_space_t* space;
/** Tablespace ID */
- ulint space_id;
+ uint32_t space_id;
/** Stores information about:
1 row format (redundant or compact),
diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h
index 29a76defec1..8c698dafb5b 100644
--- a/storage/innobase/include/fil0crypt.h
+++ b/storage/innobase/include/fil0crypt.h
@@ -291,20 +291,20 @@ byte* fil_space_encrypt(
/** Decrypt a page.
@param]in] space_id space id
+@param[in] fsp_flags Tablespace flags
@param[in] crypt_data crypt_data
@param[in] tmp_frame Temporary buffer
@param[in] physical_size page size
-@param[in] fsp_flags Tablespace flags
@param[in,out] src_frame Page to decrypt
@param[out] err DB_SUCCESS or DB_DECRYPTION_FAILED
@return true if page decrypted, false if not.*/
bool
fil_space_decrypt(
- ulint space_id,
+ uint32_t space_id,
+ uint32_t fsp_flags,
fil_space_crypt_t* crypt_data,
byte* tmp_frame,
ulint physical_size,
- ulint fsp_flags,
byte* src_frame,
dberr_t* err);
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 9fd0b076520..2269ff80ae0 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -43,7 +43,7 @@ Created 10/25/1995 Heikki Tuuri
#include <mutex>
struct unflushed_spaces_tag_t;
-struct rotation_list_tag_t;
+struct default_encrypt_tag_t;
struct space_list_tag_t;
struct named_spaces_tag_t;
@@ -82,14 +82,14 @@ enum srv_flush_t
extern ulong srv_file_flush_method;
/** Undo tablespaces starts with space_id. */
-extern ulint srv_undo_space_id_start;
+extern uint32_t srv_undo_space_id_start;
/** The number of UNDO tablespaces that are open and ready to use. */
-extern ulint srv_undo_tablespaces_open;
+extern uint32_t srv_undo_tablespaces_open;
/** Check whether given space id is undo tablespace id
@param[in] space_id space id to check
@return true if it is undo tablespace else false. */
-inline bool srv_is_undo_tablespace(ulint space_id)
+inline bool srv_is_undo_tablespace(uint32_t space_id)
{
return srv_undo_space_id_start > 0 &&
space_id >= srv_undo_space_id_start &&
@@ -336,7 +336,7 @@ enum fil_encryption_t
};
struct fil_space_t final : ilist_node<unflushed_spaces_tag_t>,
- ilist_node<rotation_list_tag_t>,
+ ilist_node<default_encrypt_tag_t>,
ilist_node<space_list_tag_t>,
ilist_node<named_spaces_tag_t>
#else
@@ -352,8 +352,6 @@ struct fil_space_t final
latch.destroy();
}
- ulint id; /*!< space id */
-
/** fil_system.spaces chain node */
fil_space_t *hash;
lsn_t max_lsn;
@@ -363,6 +361,8 @@ struct fil_space_t final
Protected by log_sys.mutex.
If and only if this is nonzero, the
tablespace will be in named_spaces. */
+ /** tablespace identifier */
+ uint32_t id;
/** whether undo tablespace truncation is in progress */
bool is_being_truncated;
fil_type_t purpose;/*!< purpose */
@@ -520,7 +520,7 @@ public:
@param id tablespace identifier
@return tablespace
@retval nullptr if no tablespace was found */
- static fil_space_t *check_pending_operations(ulint id);
+ static fil_space_t *check_pending_operations(uint32_t id);
private:
MY_ATTRIBUTE((warn_unused_result))
@@ -640,274 +640,224 @@ public:
freed_ranges.clear();
}
#endif /* !UNIV_INNOCHECKSUM */
- /** FSP_SPACE_FLAGS and FSP_FLAGS_MEM_ flags;
- check fsp0types.h to more info about flags. */
- ulint flags;
-
- /** Determine if full_crc32 is used for a data file
- @param[in] flags tablespace flags (FSP_SPACE_FLAGS)
- @return whether the full_crc32 algorithm is active */
- static bool full_crc32(ulint flags) {
- return flags & FSP_FLAGS_FCRC32_MASK_MARKER;
- }
- /** @return whether innodb_checksum_algorithm=full_crc32 is active */
- bool full_crc32() const { return full_crc32(flags); }
- /** Determine the logical page size.
- @param flags tablespace flags (FSP_FLAGS)
- @return the logical page size
- @retval 0 if the flags are invalid */
- static unsigned logical_size(ulint flags) {
-
- ulint page_ssize = 0;
-
- if (full_crc32(flags)) {
- page_ssize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
- } else {
- page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
- }
-
- switch (page_ssize) {
- case 3: return 4096;
- case 4: return 8192;
- case 5:
- { ut_ad(full_crc32(flags)); return 16384; }
- case 0:
- { ut_ad(!full_crc32(flags)); return 16384; }
- case 6: return 32768;
- case 7: return 65536;
- default: return 0;
- }
- }
- /** Determine the ROW_FORMAT=COMPRESSED page size.
- @param flags tablespace flags (FSP_FLAGS)
- @return the ROW_FORMAT=COMPRESSED page size
- @retval 0 if ROW_FORMAT=COMPRESSED is not used */
- static unsigned zip_size(ulint flags) {
-
- if (full_crc32(flags)) {
- return 0;
- }
-
- ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
- return zip_ssize
- ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize : 0;
- }
- /** Determine the physical page size.
- @param flags tablespace flags (FSP_FLAGS)
- @return the physical page size */
- static unsigned physical_size(ulint flags) {
-
- if (full_crc32(flags)) {
- return logical_size(flags);
- }
-
- ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
- return zip_ssize
- ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize
- : unsigned(srv_page_size);
- }
- /** @return the ROW_FORMAT=COMPRESSED page size
- @retval 0 if ROW_FORMAT=COMPRESSED is not used */
- unsigned zip_size() const { return zip_size(flags); }
- /** @return the physical page size */
- unsigned physical_size() const { return physical_size(flags); }
- /** Check whether the compression enabled in tablespace.
- @param[in] flags tablespace flags */
- static bool is_compressed(ulint flags) {
-
- if (full_crc32(flags)) {
- ulint algo = FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(
- flags);
- DBUG_ASSERT(algo <= PAGE_ALGORITHM_LAST);
- return algo > 0;
- }
-
- return FSP_FLAGS_HAS_PAGE_COMPRESSION(flags);
- }
- /** @return whether the compression enabled for the tablespace. */
- bool is_compressed() const { return is_compressed(flags); }
-
- /** Get the compression algorithm for full crc32 format.
- @param[in] flags tablespace flags
- @return algorithm type of tablespace */
- static ulint get_compression_algo(ulint flags)
- {
- return full_crc32(flags)
- ? FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags)
- : 0;
- }
- /** @return the page_compressed algorithm
- @retval 0 if not page_compressed */
- ulint get_compression_algo() const {
- return fil_space_t::get_compression_algo(flags);
- }
- /** Determine if the page_compressed page contains an extra byte
- for exact compressed stream length
- @param[in] flags tablespace flags
- @return whether the extra byte is needed */
- static bool full_crc32_page_compressed_len(ulint flags)
- {
- DBUG_ASSERT(full_crc32(flags));
- switch (get_compression_algo(flags)) {
- case PAGE_LZ4_ALGORITHM:
- case PAGE_LZO_ALGORITHM:
- case PAGE_SNAPPY_ALGORITHM:
- return true;
- }
- return false;
- }
-
- /** Whether the full checksum matches with non full checksum flags.
- @param[in] flags flags present
- @param[in] expected expected flags
- @return true if it is equivalent */
- static bool is_flags_full_crc32_equal(ulint flags, ulint expected)
- {
- ut_ad(full_crc32(flags));
- ulint fcrc32_psize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
-
- if (full_crc32(expected)) {
- /* The data file may have been created with a
- different innodb_compression_algorithm. But
- we only support one innodb_page_size for all files. */
- return fcrc32_psize
- == FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected);
- }
-
- ulint non_fcrc32_psize = FSP_FLAGS_GET_PAGE_SSIZE(expected);
-
- if (!non_fcrc32_psize) {
- if (fcrc32_psize != 5) {
- return false;
- }
- } else if (fcrc32_psize != non_fcrc32_psize) {
- return false;
- }
-
- return true;
- }
- /** Whether old tablespace flags match full_crc32 flags.
- @param[in] flags flags present
- @param[in] expected expected flags
- @return true if it is equivalent */
- static bool is_flags_non_full_crc32_equal(ulint flags, ulint expected)
- {
- ut_ad(!full_crc32(flags));
-
- if (!full_crc32(expected)) {
- return false;
- }
-
- ulint non_fcrc32_psize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
- ulint fcrc32_psize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(
- expected);
-
- if (!non_fcrc32_psize) {
- if (fcrc32_psize != 5) {
- return false;
- }
- } else if (fcrc32_psize != non_fcrc32_psize) {
- return false;
- }
-
- return true;
- }
- /** Whether both fsp flags are equivalent */
- static bool is_flags_equal(ulint flags, ulint expected)
- {
- if (!((flags ^ expected) & ~(1U << FSP_FLAGS_POS_RESERVED))) {
- return true;
- }
+ /** FSP_SPACE_FLAGS and FSP_FLAGS_MEM_ flags;
+ check fsp0types.h to more info about flags. */
+ uint32_t flags;
+
+ /** Determine if full_crc32 is used for a data file
+ @param[in] flags tablespace flags (FSP_SPACE_FLAGS)
+ @return whether the full_crc32 algorithm is active */
+ static bool full_crc32(uint32_t flags)
+ { return flags & FSP_FLAGS_FCRC32_MASK_MARKER; }
+ /** @return whether innodb_checksum_algorithm=full_crc32 is active */
+ bool full_crc32() const { return full_crc32(flags); }
+ /** Determine the logical page size.
+ @param flags tablespace flags (FSP_SPACE_FLAGS)
+ @return the logical page size
+ @retval 0 if the flags are invalid */
+ static unsigned logical_size(uint32_t flags)
+ {
+ switch (full_crc32(flags)
+ ? FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags)
+ : FSP_FLAGS_GET_PAGE_SSIZE(flags)) {
+ case 3: return 4096;
+ case 4: return 8192;
+ case 5: return full_crc32(flags) ? 16384 : 0;
+ case 0: return full_crc32(flags) ? 0 : 16384;
+ case 6: return 32768;
+ case 7: return 65536;
+ default: return 0;
+ }
+ }
+ /** Determine the ROW_FORMAT=COMPRESSED page size.
+ @param flags tablespace flags (FSP_SPACE_FLAGS)
+ @return the ROW_FORMAT=COMPRESSED page size
+ @retval 0 if ROW_FORMAT=COMPRESSED is not used */
+ static unsigned zip_size(uint32_t flags)
+ {
+ if (full_crc32(flags))
+ return 0;
+ const uint32_t zip_ssize= FSP_FLAGS_GET_ZIP_SSIZE(flags);
+ return zip_ssize ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize : 0;
+ }
+ /** Determine the physical page size.
+ @param flags tablespace flags (FSP_SPACE_FLAGS)
+ @return the physical page size */
+ static unsigned physical_size(uint32_t flags)
+ {
+ if (full_crc32(flags))
+ return logical_size(flags);
- return full_crc32(flags)
- ? is_flags_full_crc32_equal(flags, expected)
- : is_flags_non_full_crc32_equal(flags, expected);
- }
- /** Validate the tablespace flags for full crc32 format.
- @param[in] flags the content of FSP_SPACE_FLAGS
- @return whether the flags are correct in full crc32 format */
- static bool is_fcrc32_valid_flags(ulint flags)
- {
- ut_ad(flags & FSP_FLAGS_FCRC32_MASK_MARKER);
- const ulint page_ssize = physical_size(flags);
- if (page_ssize < 3 || page_ssize & 8) {
- return false;
- }
+ const uint32_t zip_ssize= FSP_FLAGS_GET_ZIP_SSIZE(flags);
+ return zip_ssize
+ ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize
+ : unsigned(srv_page_size);
+ }
- flags >>= FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO;
+ /** @return the ROW_FORMAT=COMPRESSED page size
+ @retval 0 if ROW_FORMAT=COMPRESSED is not used */
+ unsigned zip_size() const { return zip_size(flags); }
+ /** @return the physical page size */
+ unsigned physical_size() const { return physical_size(flags); }
+ /** Check whether the the tablespace is PAGE_COMPRESSED.
+ @param flags contents of FSP_SPACE_FLAGS */
+ static bool is_compressed(uint32_t flags)
+ {
+ if (!full_crc32(flags))
+ return FSP_FLAGS_HAS_PAGE_COMPRESSION(flags);
+ const uint32_t algo= FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags);
+ DBUG_ASSERT(algo <= PAGE_ALGORITHM_LAST);
+ return algo > 0;
+ }
- return flags <= PAGE_ALGORITHM_LAST;
- }
- /** Validate the tablespace flags.
- @param[in] flags content of FSP_SPACE_FLAGS
- @param[in] is_ibd whether this is an .ibd file
- (not system tablespace)
- @return whether the flags are correct. */
- static bool is_valid_flags(ulint flags, bool is_ibd)
- {
- DBUG_EXECUTE_IF("fsp_flags_is_valid_failure",
- return false;);
+ /** @return whether the compression enabled for the tablespace. */
+ bool is_compressed() const { return is_compressed(flags); }
- if (full_crc32(flags)) {
- return is_fcrc32_valid_flags(flags);
- }
+ /** Get the compression algorithm for full crc32 format.
+ @param flags contents of FSP_SPACE_FLAGS
+ @return PAGE_COMPRESSED algorithm of full_crc32 tablespace
+ @retval 0 if not PAGE_COMPRESSED or not full_crc32 */
+ static unsigned get_compression_algo(uint32_t flags)
+ {
+ return full_crc32(flags)
+ ? FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags)
+ : 0;
+ }
+ /** @return the page_compressed algorithm
+ @retval 0 if not page_compressed */
+ unsigned get_compression_algo() const { return get_compression_algo(flags); }
+ /** Determine if the page_compressed page contains an extra byte
+ for exact compressed stream length
+ @param flags contents of FSP_SPACE_FLAGS
+ @return whether the extra byte is needed */
+ static bool full_crc32_page_compressed_len(uint32_t flags)
+ {
+ DBUG_ASSERT(full_crc32(flags));
+ switch (get_compression_algo(flags)) {
+ case PAGE_LZ4_ALGORITHM:
+ case PAGE_LZO_ALGORITHM:
+ case PAGE_SNAPPY_ALGORITHM:
+ return true;
+ }
+ return false;
+ }
- if (flags == 0) {
- return true;
- }
+ /** Whether the full checksum matches with non full checksum flags.
+ @param flags contents of FSP_SPACE_FLAGS
+ @param expected expected flags
+ @return true if it is equivalent */
+ static bool is_flags_full_crc32_equal(uint32_t flags, uint32_t expected)
+ {
+ ut_ad(full_crc32(flags));
+ uint32_t fcrc32_psize= FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
+
+ if (full_crc32(expected))
+ /* The data file may have been created with a
+ different innodb_compression_algorithm. But
+ we only support one innodb_page_size for all files. */
+ return fcrc32_psize == FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected);
+
+ uint32_t non_fcrc32_psize = FSP_FLAGS_GET_PAGE_SSIZE(expected);
+ if (!non_fcrc32_psize)
+ return fcrc32_psize == 5;
+ return fcrc32_psize == non_fcrc32_psize;
+ }
- if (flags & ~FSP_FLAGS_MASK) {
- return false;
- }
+ /** Whether old tablespace flags match full_crc32 flags.
+ @param flags contents of FSP_SPACE_FLAGS
+ @param expected expected flags
+ @return true if it is equivalent */
+ static bool is_flags_non_full_crc32_equal(uint32_t flags, uint32_t expected)
+ {
+ ut_ad(!full_crc32(flags));
+ if (!full_crc32(expected))
+ return false;
- if ((flags & (FSP_FLAGS_MASK_POST_ANTELOPE
- | FSP_FLAGS_MASK_ATOMIC_BLOBS))
- == FSP_FLAGS_MASK_ATOMIC_BLOBS) {
- /* If the "atomic blobs" flag (indicating
- ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED) flag
- is set, then the "post Antelope"
- (ROW_FORMAT!=REDUNDANT) flag must also be set. */
- return false;
- }
+ uint32_t non_fcrc32_psize= FSP_FLAGS_GET_PAGE_SSIZE(flags);
+ uint32_t fcrc32_psize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected);
- /* Bits 10..14 should be 0b0000d where d is the DATA_DIR flag
- of MySQL 5.6 and MariaDB 10.0, which we ignore.
- In the buggy FSP_SPACE_FLAGS written by MariaDB 10.1.0 to 10.1.20,
- bits 10..14 would be nonzero 0bsssaa where sss is
- nonzero PAGE_SSIZE (3, 4, 6, or 7)
- and aa is ATOMIC_WRITES (not 0b11). */
- if (FSP_FLAGS_GET_RESERVED(flags) & ~1U) {
- return false;
- }
+ if (!non_fcrc32_psize)
+ return fcrc32_psize == 5;
+ return fcrc32_psize == non_fcrc32_psize;
+ }
- const ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
- if (ssize == 1 || ssize == 2 || ssize == 5 || ssize & 8) {
- /* the page_size is not between 4k and 64k;
- 16k should be encoded as 0, not 5 */
- return false;
- }
+ /** Whether both fsp flags are equivalent */
+ static bool is_flags_equal(uint32_t flags, uint32_t expected)
+ {
+ if (!((flags ^ expected) & ~(1U << FSP_FLAGS_POS_RESERVED)))
+ return true;
+ return full_crc32(flags)
+ ? is_flags_full_crc32_equal(flags, expected)
+ : is_flags_non_full_crc32_equal(flags, expected);
+ }
- const ulint zssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
- if (zssize == 0) {
- /* not ROW_FORMAT=COMPRESSED */
- } else if (zssize > (ssize ? ssize : 5)) {
- /* Invalid KEY_BLOCK_SIZE */
- return false;
- } else if (~flags & (FSP_FLAGS_MASK_POST_ANTELOPE
- | FSP_FLAGS_MASK_ATOMIC_BLOBS)) {
- /* both these flags should be set for
- ROW_FORMAT=COMPRESSED */
- return false;
- }
+ /** Validate the tablespace flags for full crc32 format.
+ @param flags contents of FSP_SPACE_FLAGS
+ @return whether the flags are correct in full crc32 format */
+ static bool is_fcrc32_valid_flags(uint32_t flags)
+ {
+ ut_ad(flags & FSP_FLAGS_FCRC32_MASK_MARKER);
+ const ulint page_ssize= physical_size(flags);
+ if (page_ssize < 3 || page_ssize & 8)
+ return false;
+ flags >>= FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO;
+ return flags <= PAGE_ALGORITHM_LAST;
+ }
+ /** Validate the tablespace flags.
+ @param flags contents of FSP_SPACE_FLAGS
+ @param is_ibd whether this is an .ibd file (not system tablespace)
+ @return whether the flags are correct */
+ static bool is_valid_flags(uint32_t flags, bool is_ibd)
+ {
+ DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", return false;);
+ if (full_crc32(flags))
+ return is_fcrc32_valid_flags(flags);
- /* The flags do look valid. But, avoid misinterpreting
- buggy MariaDB 10.1 format flags for
- PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL={0,2,3}
- as valid-looking PAGE_SSIZE if this is known to be
- an .ibd file and we are using the default innodb_page_size=16k. */
- return(ssize == 0 || !is_ibd
- || srv_page_size != UNIV_PAGE_SIZE_ORIG);
- }
+ if (flags == 0)
+ return true;
+ if (~FSP_FLAGS_MASK & flags)
+ return false;
+
+ if (FSP_FLAGS_MASK_ATOMIC_BLOBS ==
+ (flags & (FSP_FLAGS_MASK_POST_ANTELOPE | FSP_FLAGS_MASK_ATOMIC_BLOBS)))
+ /* If the "atomic blobs" flag (indicating
+ ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED) flag is set, then the
+ ROW_FORMAT!=REDUNDANT flag must also be set. */
+ return false;
+
+ /* Bits 10..14 should be 0b0000d where d is the DATA_DIR flag
+ of MySQL 5.6 and MariaDB 10.0, which we ignore.
+ In the buggy FSP_SPACE_FLAGS written by MariaDB 10.1.0 to 10.1.20,
+ bits 10..14 would be nonzero 0bsssaa where sss is
+ nonzero PAGE_SSIZE (3, 4, 6, or 7)
+ and aa is ATOMIC_WRITES (not 0b11). */
+ if (FSP_FLAGS_GET_RESERVED(flags) & ~1U)
+ return false;
+
+ const uint32_t ssize= FSP_FLAGS_GET_PAGE_SSIZE(flags);
+ if (ssize == 1 || ssize == 2 || ssize == 5 || ssize & 8)
+ /* the page_size is not between 4k and 64k;
+ 16k should be encoded as 0, not 5 */
+ return false;
+
+ const uint32_t zssize= FSP_FLAGS_GET_ZIP_SSIZE(flags);
+ if (zssize == 0)
+ /* not ROW_FORMAT=COMPRESSED */;
+ else if (zssize > (ssize ? ssize : 5))
+ /* Invalid KEY_BLOCK_SIZE */
+ return false;
+ else if (~flags &
+ (FSP_FLAGS_MASK_POST_ANTELOPE | FSP_FLAGS_MASK_ATOMIC_BLOBS))
+ /* both these flags must set for ROW_FORMAT=COMPRESSED */
+ return false;
+
+ /* The flags do look valid. But, avoid misinterpreting
+ buggy MariaDB 10.1 format flags for
+ PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL={0,2,3}
+ as valid-looking PAGE_SSIZE if this is known to be
+ an .ibd file and we are using the default innodb_page_size=16k. */
+ return(ssize == 0 || !is_ibd || srv_page_size != UNIV_PAGE_SIZE_ORIG);
+ }
#ifndef UNIV_INNOCHECKSUM
MY_ATTRIBUTE((warn_unused_result))
@@ -919,7 +869,7 @@ public:
@param mode encryption mode
@return pointer to created tablespace, to be filled in with add()
@retval nullptr on failure (such as when the same tablespace exists) */
- static fil_space_t *create(ulint id, ulint flags,
+ static fil_space_t *create(uint32_t id, uint32_t flags,
fil_type_t purpose, fil_space_crypt_t *crypt_data,
fil_encryption_t mode= FIL_ENCRYPTION_DEFAULT);
@@ -928,7 +878,7 @@ public:
@param id tablespace identifier
@return tablespace
@retval nullptr if the tablespace is missing or inaccessible */
- static fil_space_t *get(ulint id);
+ static fil_space_t *get(uint32_t id);
/** Add/remove the free page in the freed ranges list.
@param[in] offset page number to be added
@@ -1381,14 +1331,12 @@ or the caller should be in single-threaded crash recovery mode
Normally, fil_space_t::get() should be used instead.
@param[in] id tablespace ID
@return tablespace, or NULL if not found */
-fil_space_t*
-fil_space_get(
- ulint id)
- MY_ATTRIBUTE((warn_unused_result));
+fil_space_t *fil_space_get(uint32_t id)
+ MY_ATTRIBUTE((warn_unused_result));
-/** The tablespace memory cache; also the totality of logs (the log
-data space) is stored here; below we talk about tablespaces */
-struct fil_system_t {
+/** The tablespace memory cache */
+struct fil_system_t
+{
/**
Constructor.
@@ -1445,12 +1393,8 @@ public:
sized_ilist<fil_space_t, unflushed_spaces_tag_t> unflushed_spaces;
/** number of currently open files; protected by mutex */
ulint n_open;
- ulint max_assigned_id;/*!< maximum space id in the existing
- tables, or assigned during the time
- mysqld has been up; at an InnoDB
- startup we scan the data dictionary
- and set here the maximum of the
- space id's of the tables there */
+ /** maximum persistent tablespace id that has ever been assigned */
+ uint32_t max_assigned_id;
/** nonzero if fil_node_open_file_low() should avoid moving the tablespace
to the end of space_list, for FIFO policy of try_to_close() */
ulint freeze_space_list;
@@ -1463,13 +1407,13 @@ public:
the latest redo log checkpoint.
Protected only by log_sys.mutex. */
- /** List of all file spaces need key rotation */
- ilist<fil_space_t, rotation_list_tag_t> default_encrypt_tables;
+ /** list of all ENCRYPTED=DEFAULT tablespaces that need
+ to be converted to the current value of innodb_encrypt_tables */
+ ilist<fil_space_t, default_encrypt_tag_t> default_encrypt_tables;
- bool space_id_reuse_warned;
- /*!< whether fil_space_t::create()
- has issued a warning about
- potential space_id reuse */
+ /** whether fil_space_t::create() has issued a warning about
+ potential space_id reuse */
+ bool space_id_reuse_warned;
/** Return the next tablespace from default_encrypt_tables list.
@param space previous tablespace (nullptr to start from the start)
@@ -1558,36 +1502,27 @@ Assigns a new space id for a new single-table tablespace. This works simply by
incrementing the global counter. If 4 billion id's is not enough, we may need
to recycle id's.
@return true if assigned, false if not */
-bool
-fil_assign_new_space_id(
-/*====================*/
- ulint* space_id); /*!< in/out: space id */
+bool fil_assign_new_space_id(uint32_t *space_id);
/** Frees a space object from the tablespace memory cache.
Closes the files in the chain but does not delete them.
There must not be any pending i/o's or flushes on the files.
-@param[in] id tablespace identifier
-@param[in] x_latched whether the caller holds X-mode space->latch
+@param id tablespace identifier
+@param x_latched whether the caller holds exclusive fil_space_t::latch
@return true if success */
-bool
-fil_space_free(
- ulint id,
- bool x_latched);
+bool fil_space_free(uint32_t id, bool x_latched);
/** Set the recovered size of a tablespace in pages.
@param id tablespace ID
@param size recovered size in pages
@param flags tablespace flags */
-void fil_space_set_recv_size_and_flags(ulint id, uint32_t size,
+void fil_space_set_recv_size_and_flags(uint32_t id, uint32_t size,
uint32_t flags);
/*******************************************************************//**
Sets the max tablespace id counter if the given number is bigger than the
previous value. */
-void
-fil_set_max_space_id_if_bigger(
-/*===========================*/
- ulint max_id);/*!< in: maximum known id */
+void fil_set_max_space_id_if_bigger(uint32_t max_id);
/** Write the flushed LSN to the page header of the first page in the
system tablespace.
@@ -1603,12 +1538,12 @@ MY_ATTRIBUTE((warn_unused_result))
@param id tablespace identifier
@return detached file handle (to be closed by the caller)
@return OS_FILE_CLOSED if no file existed */
-pfs_os_file_t fil_delete_tablespace(ulint id);
+pfs_os_file_t fil_delete_tablespace(uint32_t id);
/** Close a single-table tablespace on failed IMPORT TABLESPACE.
The tablespace must be cached in the memory cache.
Free all pages used by the tablespace. */
-void fil_close_tablespace(ulint id);
+void fil_close_tablespace(uint32_t id);
/*******************************************************************//**
Allocates and builds a file name from a path, a table or tablespace name
@@ -1638,10 +1573,10 @@ must be >= FIL_IBD_FILE_INITIAL_SIZE
@retval NULL on error */
fil_space_t*
fil_ibd_create(
- ulint space_id,
+ uint32_t space_id,
const table_name_t name,
const char* path,
- ulint flags,
+ uint32_t flags,
uint32_t size,
fil_encryption_t mode,
uint32_t key_id,
@@ -1652,7 +1587,7 @@ fil_ibd_create(
(Typically when upgrading from MariaDB 10.1.0..10.1.20.)
@param[in,out] space tablespace
@param[in] flags desired tablespace flags */
-void fsp_flags_try_adjust(fil_space_t* space, ulint flags);
+void fsp_flags_try_adjust(fil_space_t *space, uint32_t flags);
/********************************************************************//**
Tries to open a single-table tablespace and optionally checks the space id is
@@ -1688,8 +1623,8 @@ fil_space_t*
fil_ibd_open(
bool validate,
fil_type_t purpose,
- ulint id,
- ulint flags,
+ uint32_t id,
+ uint32_t flags,
fil_space_t::name_type name,
const char* path_in,
dberr_t* err = NULL)
@@ -1714,12 +1649,8 @@ enum fil_load_status {
@param[out] space the tablespace, or NULL on error
@return status of the operation */
enum fil_load_status
-fil_ibd_load(
- ulint space_id,
- const char* filename,
- fil_space_t*& space)
- MY_ATTRIBUTE((warn_unused_result));
-
+fil_ibd_load(uint32_t space_id, const char *filename, fil_space_t *&space)
+ MY_ATTRIBUTE((warn_unused_result));
/** Determine if a matching tablespace exists in the InnoDB tablespace
memory cache. Note that if we have not done a crash recovery at the database
@@ -1728,7 +1659,8 @@ startup, there may be many tablespaces which are not yet in the memory cache.
@param[in] table_flags table flags
@return the tablespace
@retval NULL if no matching tablespace exists in the memory cache */
-fil_space_t *fil_space_for_table_exists_in_mem(ulint id, ulint table_flags);
+fil_space_t *fil_space_for_table_exists_in_mem(uint32_t id,
+ uint32_t table_flags);
/** Try to extend a tablespace if it is smaller than the specified size.
@param[in,out] space tablespace
@@ -1759,12 +1691,11 @@ fil_delete_file(
/*============*/
const char* path); /*!< in: filepath of the ibd tablespace */
-/*******************************************************************//**
-Returns the table space by a given id, NULL if not found. */
-fil_space_t*
-fil_space_get_by_id(
-/*================*/
- ulint id); /*!< in: space id */
+/** Look up a tablespace.
+@param tablespace identifier
+@return tablespace
+@retval nullptr if not found */
+fil_space_t *fil_space_get_by_id(uint32_t id);
/** Note that a non-predefined persistent tablespace has been modified
by redo log.
diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h
index c6ba24faaad..1d5e3317bfd 100644
--- a/storage/innobase/include/fil0pagecompress.h
+++ b/storage/innobase/include/fil0pagecompress.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (C) 2013, 2019 MariaDB Corporation.
+Copyright (C) 2013, 2021, 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
@@ -40,7 +40,7 @@ Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
ulint fil_page_compress(
const byte* buf,
byte* out_buf,
- ulint flags,
+ uint32_t flags,
ulint block_size,
bool encrypted)
MY_ATTRIBUTE((nonnull, warn_unused_result));
@@ -52,9 +52,6 @@ ulint fil_page_compress(
@return size of the compressed data
@retval 0 if decompression failed
@retval srv_page_size if the page was not compressed */
-ulint fil_page_decompress(
- byte* tmp_buf,
- byte* buf,
- ulint flags)
- MY_ATTRIBUTE((nonnull, warn_unused_result));
+ulint fil_page_decompress(byte *tmp_buf, byte *buf, uint32_t flags)
+ MY_ATTRIBUTE((nonnull, warn_unused_result));
#endif
diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h
index 8c11d61c5aa..9dfb3cc7561 100644
--- a/storage/innobase/include/fsp0file.h
+++ b/storage/innobase/include/fsp0file.h
@@ -56,7 +56,7 @@ public:
m_size(),
m_order(),
m_type(SRV_NOT_RAW),
- m_space_id(ULINT_UNDEFINED),
+ m_space_id(UINT32_MAX),
m_flags(),
m_exists(),
m_is_valid(),
@@ -67,7 +67,7 @@ public:
/* No op */
}
- Datafile(ulint flags, uint32_t size, ulint order)
+ Datafile(uint32_t flags, uint32_t size, ulint order)
:
m_filepath(),
m_filename(),
@@ -76,7 +76,7 @@ public:
m_size(size),
m_order(order),
m_type(SRV_NOT_RAW),
- m_space_id(ULINT_UNDEFINED),
+ m_space_id(UINT32_MAX),
m_flags(flags),
m_exists(),
m_is_valid(),
@@ -154,7 +154,7 @@ public:
}
/** Initialize the tablespace flags */
- void init(ulint flags) { m_flags= flags; }
+ void init(uint32_t flags) { m_flags= flags; }
/** Release the resources. */
virtual void shutdown();
@@ -198,7 +198,7 @@ public:
@param[in] flags The expected tablespace flags.
@retval DB_SUCCESS if tablespace is valid, DB_ERROR if not.
m_is_valid is also set true on success, else false. */
- dberr_t validate_to_dd(ulint space_id, ulint flags)
+ dberr_t validate_to_dd(uint32_t space_id, uint32_t flags)
MY_ATTRIBUTE((warn_unused_result));
/** Validates this datafile for the purpose of recovery.
@@ -254,24 +254,15 @@ public:
/** Get Datafile::m_space_id.
@return m_space_id */
- ulint space_id() const
- {
- return(m_space_id);
- }
+ uint32_t space_id() const { return m_space_id; }
/** Get Datafile::m_flags.
@return m_flags */
- ulint flags() const
- {
- return(m_flags);
- }
+ uint32_t flags() const { return m_flags; }
/**
@return true if m_handle is open, false if not */
- bool is_open() const
- {
- return(m_handle != OS_FILE_CLOSED);
- }
+ bool is_open() const { return m_handle != OS_FILE_CLOSED; }
/** Get Datafile::m_is_valid.
@return m_is_valid */
@@ -324,9 +315,9 @@ public:
@return the first data page */
const byte* get_first_page() const { return(m_first_page); }
- void set_space_id(ulint space_id) { m_space_id= space_id; }
+ void set_space_id(uint32_t space_id) { m_space_id= space_id; }
- void set_flags(ulint flags) { m_flags = flags; }
+ void set_flags(uint32_t flags) { m_flags = flags; }
private:
/** Free the filepath buffer. */
void free_filepath();
@@ -425,12 +416,12 @@ private:
/** Tablespace ID. Contained in the datafile header.
If this is a system tablespace, FSP_SPACE_ID is only valid
in the first datafile. */
- ulint m_space_id;
+ uint32_t m_space_id;
/** Tablespace flags. Contained in the datafile header.
If this is a system tablespace, FSP_SPACE_FLAGS are only valid
in the first datafile. */
- ulint m_flags;
+ uint32_t m_flags;
/** true if file already existed on startup */
bool m_exists;
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index 51333cb5955..1f8f4081163 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -596,14 +596,11 @@ fseg_print(
/** Convert FSP_SPACE_FLAGS from the buggy MariaDB 10.1.0..10.1.20 format.
@param[in] flags the contents of FSP_SPACE_FLAGS
@return the flags corrected from the buggy MariaDB 10.1 format
-@retval ULINT_UNDEFINED if the flags are not in the buggy 10.1 format */
+@retval UINT32_MAX if the flags are not in the buggy 10.1 format */
MY_ATTRIBUTE((warn_unused_result, const))
-UNIV_INLINE
-ulint
-fsp_flags_convert_from_101(ulint flags)
+inline uint32_t fsp_flags_convert_from_101(uint32_t flags)
{
- DBUG_EXECUTE_IF("fsp_flags_is_valid_failure",
- return(ULINT_UNDEFINED););
+ DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", return UINT32_MAX;);
if (flags == 0 || fil_space_t::full_crc32(flags)) {
return(flags);
}
@@ -612,7 +609,7 @@ fsp_flags_convert_from_101(ulint flags)
/* The most significant FSP_SPACE_FLAGS bit that was ever set
by MariaDB 10.1.0 to 10.1.20 was bit 17 (misplaced DATA_DIR flag).
The flags must be less than 1<<18 in order to be valid. */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
}
if ((flags & (FSP_FLAGS_MASK_POST_ANTELOPE | FSP_FLAGS_MASK_ATOMIC_BLOBS))
@@ -621,7 +618,7 @@ fsp_flags_convert_from_101(ulint flags)
ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED) flag
is set, then the "post Antelope" (ROW_FORMAT!=REDUNDANT) flag
must also be set. */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
}
/* Bits 6..10 denote compression in MariaDB 10.1.0 to 10.1.20.
@@ -650,19 +647,19 @@ fsp_flags_convert_from_101(ulint flags)
invalid (COMPRESSION_LEVEL=3 but COMPRESSION=0)
+0b00000: innodb_page_size=16k (looks like COMPRESSION=0)
??? Could actually be compressed; see PAGE_SSIZE below */
- const ulint level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL_MARIADB101(
+ const uint32_t level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL_MARIADB101(
flags);
if (FSP_FLAGS_GET_PAGE_COMPRESSION_MARIADB101(flags) != (level != 0)
|| level > 9) {
/* The compression flags are not in the buggy MariaDB
10.1 format. */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
}
if (!(~flags & FSP_FLAGS_MASK_ATOMIC_WRITES_MARIADB101)) {
/* The ATOMIC_WRITES flags cannot be 0b11.
(The bits 11..12 should actually never be 0b11,
because in MySQL they would be SHARED|TEMPORARY.) */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
}
/* Bits 13..16 are the wrong position for PAGE_SSIZE, and they
@@ -677,23 +674,23 @@ fsp_flags_convert_from_101(ulint flags)
will be properly rejected by older MariaDB 10.1.x because they
would read as PAGE_SSIZE>=8 which is not valid. */
- const ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE_MARIADB101(flags);
+ const uint32_t ssize = FSP_FLAGS_GET_PAGE_SSIZE_MARIADB101(flags);
if (ssize == 1 || ssize == 2 || ssize == 5 || ssize & 8) {
/* the page_size is not between 4k and 64k;
16k should be encoded as 0, not 5 */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
}
- const ulint zssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
+ const uint32_t zssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
if (zssize == 0) {
/* not ROW_FORMAT=COMPRESSED */
} else if (zssize > (ssize ? ssize : 5)) {
/* invalid KEY_BLOCK_SIZE */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
} else if (~flags & (FSP_FLAGS_MASK_POST_ANTELOPE
| FSP_FLAGS_MASK_ATOMIC_BLOBS)) {
/* both these flags should be set for
ROW_FORMAT=COMPRESSED */
- return(ULINT_UNDEFINED);
+ return UINT32_MAX;
}
flags = ((flags & 0x3f) | ssize << FSP_FLAGS_POS_PAGE_SSIZE
@@ -708,19 +705,11 @@ fsp_flags_convert_from_101(ulint flags)
@param[in] actual flags read from FSP_SPACE_FLAGS
@return whether the flags match */
MY_ATTRIBUTE((warn_unused_result))
-UNIV_INLINE
-bool
-fsp_flags_match(ulint expected, ulint actual)
+inline bool fsp_flags_match(uint32_t expected, uint32_t actual)
{
- expected &= ~FSP_FLAGS_MEM_MASK;
- ut_ad(fil_space_t::is_valid_flags(expected, false));
-
- if (actual == expected) {
- return(true);
- }
-
- actual = fsp_flags_convert_from_101(actual);
- return(actual == expected);
+ expected&= ~FSP_FLAGS_MEM_MASK;
+ ut_ad(fil_space_t::is_valid_flags(expected, false));
+ return actual == expected || fsp_flags_convert_from_101(actual) == expected;
}
/** Determine the descriptor index within a descriptor page.
diff --git a/storage/innobase/include/fsp0space.h b/storage/innobase/include/fsp0space.h
index ed65af52bc8..a2bb46d3125 100644
--- a/storage/innobase/include/fsp0space.h
+++ b/storage/innobase/include/fsp0space.h
@@ -47,22 +47,13 @@ public:
/** Data file iterator */
typedef files_t::const_iterator const_iterator;
- Tablespace()
- :
- m_files(),
- m_space_id(ULINT_UNDEFINED),
- m_path(),
- m_flags(),
- m_ignore_read_only(false)
- {
- /* No op */
- }
+ Tablespace() {}
virtual ~Tablespace()
{
shutdown();
ut_ad(m_files.empty());
- ut_ad(m_space_id == ULINT_UNDEFINED);
+ ut_ad(m_space_id == UINT32_MAX);
}
// Disable copying
@@ -104,22 +95,19 @@ public:
/** Set the space id of the tablespace
@param[in] space_id tablespace ID to set */
- void set_space_id(ulint space_id)
+ void set_space_id(uint32_t space_id)
{
- ut_ad(m_space_id == ULINT_UNDEFINED);
+ ut_ad(m_space_id == UINT32_MAX);
m_space_id = space_id;
}
/** Get the space id of the tablespace
@return m_space_id space id of the tablespace */
- ulint space_id() const
- {
- return(m_space_id);
- }
+ uint32_t space_id() const { return m_space_id; }
/** Set the tablespace flags
@param[in] fsp_flags tablespace flags */
- void set_flags(ulint fsp_flags)
+ void set_flags(uint32_t fsp_flags)
{
ut_ad(fil_space_t::is_valid_flags(fsp_flags, false));
m_flags = fsp_flags;
@@ -127,24 +115,15 @@ public:
/** Get the tablespace flags
@return m_flags tablespace flags */
- ulint flags() const
- {
- return(m_flags);
- }
+ uint32_t flags() const { return m_flags; }
/** Get the tablespace encryption mode
@return m_mode tablespace encryption mode */
- fil_encryption_t encryption_mode() const
- {
- return (m_mode);
- }
+ fil_encryption_t encryption_mode() const { return m_mode; }
/** Get the tablespace encryption key_id
@return m_key_id tablespace encryption key_id */
- uint32_t key_id() const
- {
- return (m_key_id);
- }
+ uint32_t key_id() const { return m_key_id; }
/** Set Ignore Read Only Status for tablespace.
@param[in] read_only_status read only status indicator */
@@ -210,24 +189,21 @@ private:
@param[in] file data file object */
void file_found(Datafile& file);
- /* DATA MEMBERS */
-
/** Tablespace ID */
- ulint m_space_id;
+ uint32_t m_space_id = UINT32_MAX;
+ /** Tablespace flags */
+ uint32_t m_flags = UINT32_MAX;
- /** Path where tablespace files will reside, not including a filename.*/
+ /** Path where tablespace files will reside, excluding a filename */
char* m_path;
- /** Tablespace flags */
- ulint m_flags;
-
/** Encryption mode and key_id */
fil_encryption_t m_mode;
uint32_t m_key_id;
protected:
/** Ignore server read only configuration for this tablespace. */
- bool m_ignore_read_only;
+ bool m_ignore_read_only = false;
};
#endif /* fsp0space_h */
diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h
index 2e0a395f71c..b6bdadd3501 100644
--- a/storage/innobase/include/fsp0sysspace.h
+++ b/storage/innobase/include/fsp0sysspace.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2016, 2021, 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
@@ -266,24 +267,15 @@ extern SysTablespace srv_tmp_space;
/** Check if the space_id is for a system-tablespace (shared + temp).
@param[in] id Space ID to check
@return true if id is a system tablespace, false if not. */
-UNIV_INLINE
-bool
-is_system_tablespace(ulint id)
+inline bool is_system_tablespace(uint32_t id)
{
- return(id == TRX_SYS_SPACE || id == SRV_TMP_SPACE_ID);
+ return id == TRX_SYS_SPACE || id == SRV_TMP_SPACE_ID;
}
/** Check if predefined shared tablespace.
@return true if predefined shared tablespace */
-UNIV_INLINE
-bool
-is_predefined_tablespace(
- ulint id)
+inline bool is_predefined_tablespace(uint32_t id)
{
- ut_ad(srv_sys_space.space_id() == TRX_SYS_SPACE);
- ut_ad(TRX_SYS_SPACE == 0);
- return(id == TRX_SYS_SPACE
- || id == SRV_TMP_SPACE_ID
- || srv_is_undo_tablespace(id));
+ return is_system_tablespace(id) || srv_is_undo_tablespace(id);
}
#endif /* fsp0sysspace_h */
diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h
index f8e4c06baae..4f23b403050 100644
--- a/storage/innobase/include/fsp0types.h
+++ b/storage/innobase/include/fsp0types.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2020, MariaDB Corporation.
+Copyright (c) 2014, 2021, 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
@@ -25,15 +25,12 @@ Created May 26, 2009 Vasil Dimov
*******************************************************/
#pragma once
-#include <cstddef>
+#include "ut0byte.h"
-/** The fil_space_t::id of the redo log. All persistent tablespaces
-have a smaller fil_space_t::id. */
-static constexpr size_t SRV_SPACE_ID_UPPER_BOUND= 0xFFFFFFF0;
+/** All persistent tablespaces have a smaller fil_space_t::id than this. */
+constexpr uint32_t SRV_SPACE_ID_UPPER_BOUND= 0xFFFFFFF0U;
/** The fil_space_t::id of the innodb_temporary tablespace. */
-#define SRV_TMP_SPACE_ID 0xFFFFFFFEU
-
-#include "ut0byte.h"
+constexpr uint32_t SRV_TMP_SPACE_ID= 0xFFFFFFFEU;
/* Possible values of innodb_compression_algorithm */
#define PAGE_UNCOMPRESSED 0
diff --git a/storage/innobase/include/fut0fut.h b/storage/innobase/include/fut0fut.h
index 5169db95549..1ac670bbc70 100644
--- a/storage/innobase/include/fut0fut.h
+++ b/storage/innobase/include/fut0fut.h
@@ -42,7 +42,7 @@ bufferfixed and latched */
inline
byte*
fut_get_ptr(
- ulint space,
+ uint32_t space,
ulint zip_size,
fil_addr_t addr,
rw_lock_type_t rw_latch,
diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h
index c5849a43d3e..3ffa9facdbf 100644
--- a/storage/innobase/include/ibuf0ibuf.h
+++ b/storage/innobase/include/ibuf0ibuf.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2020, MariaDB Corporation.
+Copyright (c) 2016, 2021, 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
@@ -334,7 +334,7 @@ void ibuf_merge_or_delete_for_page(buf_block_t *block, const page_id_t page_id,
/** Delete all change buffer entries for a tablespace,
in DISCARD TABLESPACE, IMPORT TABLESPACE, or crash recovery.
@param[in] space missing or to-be-discarded tablespace */
-void ibuf_delete_for_discarded_space(ulint space);
+void ibuf_delete_for_discarded_space(uint32_t space);
/** Contract the change buffer by reading pages to the buffer pool.
@return a lower limit for the combined size in bytes of entries which
diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h
index 46c09fecf7a..8273a8981bd 100644
--- a/storage/innobase/include/log0recv.h
+++ b/storage/innobase/include/log0recv.h
@@ -87,7 +87,7 @@ void recv_sys_justify_left_parsing_buf();
@param[in] len length of name, in bytes
@param[in] new_name new file name (NULL if not rename)
@param[in] new_len length of new_name, in bytes (0 if NULL) */
-extern void (*log_file_op)(ulint space_id, bool create,
+extern void (*log_file_op)(uint32_t space_id, bool create,
const byte* name, ulint len,
const byte* new_name, ulint new_len);
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 00df3525fe7..0085008707e 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -170,10 +170,10 @@ struct mtr_t {
(needed for generating a FILE_MODIFY record)
@param[in] space_id user or system tablespace ID
@return the tablespace */
- fil_space_t* set_named_space_id(ulint space_id)
+ fil_space_t* set_named_space_id(uint32_t space_id)
{
ut_ad(!m_user_space_id);
- ut_d(m_user_space_id = static_cast<uint32_t>(space_id));
+ ut_d(m_user_space_id = space_id);
if (!space_id) {
return fil_system.sys_space;
} else {
@@ -191,7 +191,7 @@ struct mtr_t {
void set_named_space(fil_space_t* space)
{
ut_ad(!m_user_space_id);
- ut_d(m_user_space_id = static_cast<uint32_t>(space->id));
+ ut_d(m_user_space_id = space->id);
if (space->id) {
m_user_space = space;
}
@@ -202,7 +202,7 @@ struct mtr_t {
(needed for generating a FILE_MODIFY record)
@param[in] space tablespace
@return whether the mini-transaction is associated with the space */
- bool is_named_space(ulint space) const;
+ bool is_named_space(uint32_t space) const;
/** Check the tablespace associated with the mini-transaction
(needed for generating a FILE_MODIFY record)
@param[in] space tablespace
@@ -210,10 +210,10 @@ struct mtr_t {
bool is_named_space(const fil_space_t* space) const;
#endif /* UNIV_DEBUG */
- /** Acquire a tablespace X-latch.
- @param[in] space_id tablespace ID
- @return the tablespace object (never NULL) */
- fil_space_t* x_lock_space(ulint space_id);
+ /** Acquire a tablespace X-latch.
+ @param space_id tablespace ID
+ @return the tablespace object (never NULL) */
+ fil_space_t *x_lock_space(uint32_t space_id);
/** Acquire a shared rw-latch. */
void s_lock(
@@ -559,7 +559,7 @@ public:
@param space_id tablespace identifier
@param path file path
@param new_path new file path for type=FILE_RENAME */
- inline void log_file_op(mfile_type_t type, ulint space_id,
+ inline void log_file_op(mfile_type_t type, uint32_t space_id,
const char *path,
const char *new_path= nullptr);
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 0c32d5d686a..df939afd314 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -261,12 +261,12 @@ extern bool srv_was_started;
extern char* srv_undo_dir;
/** Number of undo tablespaces to use. */
-extern ulong srv_undo_tablespaces;
+extern uint srv_undo_tablespaces;
/** The number of UNDO tablespaces that are active (hosting some rollback
segment). It is quite possible that some of the tablespaces doesn't host
any of the rollback-segment based on configuration used. */
-extern ulint srv_undo_tablespaces_active;
+extern uint32_t srv_undo_tablespaces_active;
/** Maximum size of undo tablespace. */
extern unsigned long long srv_max_undo_log_size;
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index 02e6f290c56..87bc68f47e7 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -40,18 +40,6 @@ UNIV_INLINE
buf_block_t*
trx_rsegf_get(fil_space_t* space, uint32_t page_no, mtr_t* mtr);
-/** Gets a newly created rollback segment header.
-@param[in] space space where placed
-@param[in] page_no page number of the header
-@param[in,out] mtr mini-transaction
-@return rollback segment header, page x-latched */
-UNIV_INLINE
-buf_block_t*
-trx_rsegf_get_new(
- ulint space,
- uint32_t page_no,
- mtr_t* mtr);
-
/** Create a rollback segment header.
@param[in,out] space system, undo, or temporary tablespace
@param[in] rseg_id rollback segment identifier
diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic
index 8805a4c8ac3..af63d6acbf2 100644
--- a/storage/innobase/include/trx0rseg.ic
+++ b/storage/innobase/include/trx0rseg.ic
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 2021, 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
@@ -43,22 +43,3 @@ trx_rsegf_get(fil_space_t* space, uint32_t page_no, mtr_t* mtr)
return buf_page_get(page_id_t(space->id, page_no),
0, RW_X_LATCH, mtr);
}
-
-/** Gets a newly created rollback segment header.
-@param[in] space space where placed
-@param[in] page_no page number of the header
-@param[in,out] mtr mini-transaction
-@return rollback segment header, page x-latched */
-UNIV_INLINE
-buf_block_t*
-trx_rsegf_get_new(
- ulint space,
- uint32_t page_no,
- mtr_t* mtr)
-{
- ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID
- || !srv_was_started);
- ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID);
-
- return buf_page_get(page_id_t(space, page_no), 0, RW_X_LATCH, mtr);
-}
diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h
index 07c1c6a756b..d6ce902977c 100644
--- a/storage/innobase/include/trx0types.h
+++ b/storage/innobase/include/trx0types.h
@@ -38,7 +38,7 @@ the terminating NUL character. */
static const ulint TRX_ID_MAX_LEN = 17;
/** Space id of the transaction system page (the system tablespace) */
-static const ulint TRX_SYS_SPACE = 0;
+static constexpr uint32_t TRX_SYS_SPACE= 0;
/** Page number of the transaction system page */
#define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index eb32e91298d..cc2ccd0ebaf 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -524,7 +524,7 @@ it is read or written. */
#include "ut0lst.h"
#include "ut0ut.h"
-extern ulong srv_page_size_shift;
+extern uint32_t srv_page_size_shift;
extern ulong srv_page_size;
/* Dimension of spatial object we support so far. It has its root in
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index f1e1c350135..bb7cb6a0498 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -577,7 +577,7 @@ struct file_name_t {
/** Map of dirty tablespaces during recovery */
typedef std::map<
- ulint,
+ uint32_t,
file_name_t,
std::less<ulint>,
ut_allocator<std::pair<const ulint, file_name_t> > > recv_spaces_t;
@@ -877,7 +877,7 @@ fail:
@param[in] len length of name, in bytes
@param[in] new_name new file name (NULL if not rename)
@param[in] new_len length of new_name, in bytes (0 if NULL) */
-void (*log_file_op)(ulint space_id, bool create,
+void (*log_file_op)(uint32_t space_id, bool create,
const byte* name, ulint len,
const byte* new_name, ulint new_len);
@@ -1079,7 +1079,7 @@ inline size_t recv_sys_t::files_size()
stored */
static
void
-fil_name_process(char* name, ulint len, ulint space_id,
+fil_name_process(char* name, ulint len, uint32_t space_id,
bool deleted, lsn_t lsn, store_t *store)
{
if (srv_operation == SRV_OPERATION_BACKUP) {
@@ -2870,8 +2870,7 @@ static void recv_read_in_area(page_id_t page_id)
if (p != page_nos) {
mysql_mutex_unlock(&recv_sys.mutex);
- buf_read_recv_pages(page_id.space(), page_nos,
- ulint(p - page_nos));
+ buf_read_recv_pages(page_id.space(), {page_nos, p});
mysql_mutex_lock(&recv_sys.mutex);
}
}
@@ -3621,7 +3620,7 @@ recv_validate_tablespace(bool rescan, bool& missing_tablespace)
for (recv_sys_t::map::iterator p = recv_sys.pages.begin();
p != recv_sys.pages.end();) {
ut_ad(!p->second.log.empty());
- const ulint space = p->first.space();
+ const uint32_t space = p->first.space();
if (is_predefined_tablespace(space)) {
next:
p++;
@@ -4157,11 +4156,11 @@ bool recv_dblwr_t::validate_page(const page_id_t page_id,
{
if (page_id.page_no() == 0)
{
- ulint flags= fsp_header_get_flags(page);
+ uint32_t flags= fsp_header_get_flags(page);
if (!fil_space_t::is_valid_flags(flags, page_id.space()))
{
- ulint cflags= fsp_flags_convert_from_101(flags);
- if (cflags == ULINT_UNDEFINED)
+ uint32_t cflags= fsp_flags_convert_from_101(flags);
+ if (cflags == UINT32_MAX)
{
ib::warn() << "Ignoring a doublewrite copy of page " << page_id
<< "due to invalid flags " << ib::hex(flags);
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index 76a703b7496..3ed547e57bc 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -507,7 +507,7 @@ void mtr_t::commit_files(lsn_t checkpoint_lsn)
@param[in] space tablespace
@return whether the mini-transaction is associated with the space */
bool
-mtr_t::is_named_space(ulint space) const
+mtr_t::is_named_space(uint32_t space) const
{
ut_ad(!m_user_space || m_user_space->id != TRX_SYS_SPACE);
@@ -547,8 +547,7 @@ bool mtr_t::is_named_space(const fil_space_t* space) const
/** Acquire a tablespace X-latch.
@param[in] space_id tablespace ID
@return the tablespace object (never NULL) */
-fil_space_t*
-mtr_t::x_lock_space(ulint space_id)
+fil_space_t *mtr_t::x_lock_space(uint32_t space_id)
{
fil_space_t* space;
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index e888c4aed1a..0c39b5318d2 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -4222,14 +4222,14 @@ corrupted:
FSP_HEADER_OFFSET + FSP_SPACE_ID + page, 4)
? ULINT_UNDEFINED
: mach_read_from_4(FIL_PAGE_SPACE_ID + page);
- ulint flags= fsp_header_get_flags(page);
+ uint32_t flags= fsp_header_get_flags(page);
const uint32_t size= fsp_header_get_field(page, FSP_SIZE);
const uint32_t free_limit= fsp_header_get_field(page, FSP_FREE_LIMIT);
const uint32_t free_len= flst_get_len(FSP_HEADER_OFFSET + FSP_FREE + page);
if (!fil_space_t::is_valid_flags(flags, space->id))
{
- ulint cflags= fsp_flags_convert_from_101(flags);
- if (cflags == ULINT_UNDEFINED)
+ uint32_t cflags= fsp_flags_convert_from_101(flags);
+ if (cflags == UINT32_MAX)
{
invalid:
ib::error() << "Expected tablespace flags "
@@ -4239,8 +4239,8 @@ invalid:
goto corrupted;
}
- ulint cf= cflags & ~FSP_FLAGS_MEM_MASK;
- ulint sf= space->flags & ~FSP_FLAGS_MEM_MASK;
+ uint32_t cf= cflags & ~FSP_FLAGS_MEM_MASK;
+ uint32_t sf= space->flags & ~FSP_FLAGS_MEM_MASK;
if (!fil_space_t::is_flags_equal(cf, sf) &&
!fil_space_t::is_flags_equal(sf, cf))
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index b2638c6fea2..7a5074b5b71 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -80,9 +80,9 @@ struct row_index_t {
in the exporting server */
byte* m_name; /*!< Index name */
- ulint m_space; /*!< Space where it is placed */
+ uint32_t m_space; /*!< Space where it is placed */
- ulint m_page_no; /*!< Root page number */
+ uint32_t m_page_no; /*!< Root page number */
ulint m_type; /*!< Index type */
@@ -390,14 +390,14 @@ class AbstractCallback
public:
/** Constructor
@param trx covering transaction */
- AbstractCallback(trx_t* trx, ulint space_id)
+ AbstractCallback(trx_t* trx, uint32_t space_id)
:
m_zip_size(0),
m_trx(trx),
m_space(space_id),
m_xdes(),
- m_xdes_page_no(ULINT_UNDEFINED),
- m_space_flags(ULINT_UNDEFINED) UNIV_NOTHROW { }
+ m_xdes_page_no(UINT32_MAX),
+ m_space_flags(UINT32_MAX) UNIV_NOTHROW { }
/** Free any extent descriptor instance */
virtual ~AbstractCallback()
@@ -420,10 +420,7 @@ public:
}
/** @return the tablespace flags */
- ulint get_space_flags() const
- {
- return(m_space_flags);
- }
+ uint32_t get_space_flags() const { return m_space_flags; }
/**
Set the name of the physical file and the file handle that is used
@@ -454,7 +451,7 @@ public:
virtual dberr_t operator()(buf_block_t* block) UNIV_NOTHROW = 0;
/** @return the tablespace identifier */
- ulint get_space_id() const { return m_space; }
+ uint32_t get_space_id() const { return m_space; }
bool is_interrupted() const { return trx_is_interrupted(m_trx); }
@@ -493,7 +490,7 @@ protected:
@param page page contents
@return DB_SUCCESS or error code. */
dberr_t set_current_xdes(
- ulint page_no,
+ uint32_t page_no,
const page_t* page) UNIV_NOTHROW
{
m_xdes_page_no = page_no;
@@ -558,19 +555,16 @@ protected:
trx_t* m_trx;
/** Space id of the file being iterated over. */
- ulint m_space;
-
- /** Current size of the space in pages */
- ulint m_size;
+ uint32_t m_space;
/** Current extent descriptor page */
xdes_t* m_xdes;
/** Physical page offset in the file of the extent descriptor */
- ulint m_xdes_page_no;
+ uint32_t m_xdes_page_no;
/** Flags value read from the header page */
- ulint m_space_flags;
+ uint32_t m_space_flags;
};
/** Determine the page size to use for traversing the tablespace
@@ -586,8 +580,8 @@ AbstractCallback::init(
m_space_flags = fsp_header_get_flags(page);
if (!fil_space_t::is_valid_flags(m_space_flags, true)) {
- ulint cflags = fsp_flags_convert_from_101(m_space_flags);
- if (cflags == ULINT_UNDEFINED) {
+ uint32_t cflags = fsp_flags_convert_from_101(m_space_flags);
+ if (cflags == UINT32_MAX) {
ib::error() << "Invalid FSP_SPACE_FLAGS="
<< ib::hex(m_space_flags);
return(DB_CORRUPTION);
@@ -618,8 +612,7 @@ AbstractCallback::init(
return(DB_CORRUPTION);
}
- m_size = mach_read_from_4(page + FSP_SIZE);
- if (m_space == ULINT_UNDEFINED) {
+ if (m_space == UINT32_MAX) {
m_space = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_ID
+ page);
}
@@ -635,13 +628,13 @@ struct FetchIndexRootPages : public AbstractCallback {
/** Index information gathered from the .ibd file. */
struct Index {
- Index(index_id_t id, ulint page_no)
+ Index(index_id_t id, uint32_t page_no)
:
m_id(id),
m_page_no(page_no) { }
index_id_t m_id; /*!< Index id */
- ulint m_page_no; /*!< Root page number */
+ uint32_t m_page_no; /*!< Root page number */
};
typedef std::vector<Index, ut_allocator<Index> > Indexes;
@@ -651,7 +644,7 @@ struct FetchIndexRootPages : public AbstractCallback {
@param table table definition in server .*/
FetchIndexRootPages(const dict_table_t* table, trx_t* trx)
:
- AbstractCallback(trx, ULINT_UNDEFINED),
+ AbstractCallback(trx, UINT32_MAX),
m_table(table) UNIV_NOTHROW { }
/** Destructor */
@@ -698,8 +691,10 @@ dberr_t FetchIndexRootPages::operator()(buf_block_t* block) UNIV_NOTHROW
m_indexes.push_back(Index(id, block->page.id().page_no()));
if (m_indexes.size() == 1) {
- /* Check that the tablespace flags match the table flags. */
- ulint expected = dict_tf_to_fsp_flags(m_table->flags);
+ /* Check that the tablespace flags match the
+ table flags. */
+ const uint32_t expected
+ = dict_tf_to_fsp_flags(m_table->flags);
if (!fsp_flags_match(expected, m_space_flags)) {
ib_errf(m_trx->mysql_thd, IB_LOG_LEVEL_ERROR,
ER_TABLE_SCHEMA_MISMATCH,
@@ -817,7 +812,7 @@ public:
@param cfg config of table being imported.
@param space_id tablespace identifier
@param trx transaction covering the import */
- PageConverter(row_import* cfg, ulint space_id, trx_t* trx)
+ PageConverter(row_import* cfg, uint32_t space_id, trx_t* trx)
:
AbstractCallback(trx, space_id),
m_cfg(cfg),
@@ -1388,7 +1383,7 @@ row_import::set_root_by_name() UNIV_NOTHROW
/* We've already checked that it exists. */
ut_a(index != 0);
- index->page = static_cast<uint32_t>(cfg_index->m_page_no);
+ index->page = cfg_index->m_page_no;
}
}
@@ -1447,8 +1442,7 @@ row_import::set_root_by_heuristic() UNIV_NOTHROW
cfg_index[i].m_srv_index = index;
- index->page = static_cast<uint32_t>(
- cfg_index[i++].m_page_no);
+ index->page = cfg_index[i++].m_page_no;
}
}
@@ -3427,7 +3421,7 @@ fil_iterate(
return DB_OUT_OF_MEMORY;
}
- ulint actual_space_id = 0;
+ uint32_t actual_space_id = 0;
const bool full_crc32 = fil_space_t::full_crc32(
callback.get_space_flags());
@@ -3556,9 +3550,9 @@ not_encrypted:
decrypted = fil_space_decrypt(
actual_space_id,
+ callback.get_space_flags(),
iter.crypt_data, dst,
callback.physical_size(),
- callback.get_space_flags(),
src, &err);
if (err != DB_SUCCESS) {
@@ -4115,11 +4109,9 @@ row_import_for_mysql(
we will not be writing any redo log for it before we have invoked
fil_space_t::set_imported() to declare it a persistent tablespace. */
- ulint fsp_flags = dict_tf_to_fsp_flags(table->flags);
-
table->space = fil_ibd_open(
true, FIL_TYPE_IMPORT, table->space_id,
- fsp_flags, name, filepath, &err);
+ dict_tf_to_fsp_flags(table->flags), name, filepath, &err);
ut_ad((table->space == NULL) == (err != DB_SUCCESS));
DBUG_EXECUTE_IF("ib_import_open_tablespace_failure",
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 81e0a3d2b79..6654c768760 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -94,15 +94,15 @@ char* srv_data_home;
char* srv_undo_dir;
/** The number of tablespaces to use for rollback segments. */
-ulong srv_undo_tablespaces;
+uint srv_undo_tablespaces;
/** The number of UNDO tablespaces that are open and ready to use. */
-ulint srv_undo_tablespaces_open;
+uint32_t srv_undo_tablespaces_open;
/** The number of UNDO tablespaces that are active (hosting some rollback
segment). It is quite possible that some of the tablespaces doesn't host
any of the rollback-segment based on configuration used. */
-ulint srv_undo_tablespaces_active;
+uint32_t srv_undo_tablespaces_active;
/** Rate at which UNDO records should be purged. */
ulong srv_purge_rseg_truncate_frequency;
@@ -166,7 +166,7 @@ uint srv_flush_log_at_timeout;
/** innodb_page_size */
ulong srv_page_size;
/** log2 of innodb_page_size; @see innodb_init_params() */
-ulong srv_page_size_shift;
+uint32_t srv_page_size_shift;
/** innodb_log_write_ahead_size */
ulong srv_log_write_ahead_size;
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 3f0ccf44b1e..8827605f04f 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -113,7 +113,7 @@ ibool srv_start_raw_disk_in_use;
uint srv_n_file_io_threads;
/** UNDO tablespaces starts with space id. */
-ulint srv_undo_space_id_start;
+uint32_t srv_undo_space_id_start;
/** TRUE if the server is being started, before rolling back any
incomplete transactions */
@@ -455,7 +455,7 @@ static dberr_t srv_validate_undo_tablespaces()
}
/** @return the number of active undo tablespaces (except system tablespace) */
-static ulint trx_rseg_get_n_undo_tablespaces()
+static uint32_t trx_rseg_get_n_undo_tablespaces()
{
std::set<uint32_t> space_ids;
mtr_t mtr;
@@ -467,7 +467,7 @@ static ulint trx_rseg_get_n_undo_tablespaces()
if (uint32_t space= trx_sysf_rseg_get_space(sys_header, rseg_id))
space_ids.insert(space);
mtr.commit();
- return space_ids.size();
+ return static_cast<uint32_t>(space_ids.size());
}
/** Open an undo tablespace.
@@ -476,11 +476,12 @@ static ulint trx_rseg_get_n_undo_tablespaces()
@param[in] i undo tablespace count
@return undo tablespace identifier
@retval 0 on failure */
-static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
+static uint32_t srv_undo_tablespace_open(bool create, const char *name,
+ uint32_t i)
{
bool success;
- ulint space_id= 0;
- ulint fsp_flags= 0;
+ uint32_t space_id= 0;
+ uint32_t fsp_flags= 0;
if (create)
{
@@ -636,20 +637,21 @@ srv_check_undo_redo_logs_exists()
return(DB_SUCCESS);
}
-static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, ulint n_undo)
+static dberr_t srv_all_undo_tablespaces_open(bool create_new_db,
+ uint32_t n_undo)
{
/* Open all the undo tablespaces that are currently in use. If we
fail to open any of these it is a fatal error. The tablespace ids
should be contiguous. It is a fatal error because they are required
for recovery and are referenced by the UNDO logs (a.k.a RBS). */
- ulint prev_id= create_new_db ? srv_undo_space_id_start - 1 : 0;
+ uint32_t prev_id= create_new_db ? srv_undo_space_id_start - 1 : 0;
- for (ulint i= 0; i < n_undo; ++i)
+ for (uint32_t i= 0; i < n_undo; ++i)
{
char name[OS_FILE_MAX_PATH];
- snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i + 1);
- ulint space_id= srv_undo_tablespace_open(create_new_db, name, i);
+ snprintf(name, sizeof name, "%s/undo%03u", srv_undo_dir, i + 1);
+ uint32_t space_id= srv_undo_tablespace_open(create_new_db, name, i);
if (!space_id)
{
if (!create_new_db)
@@ -674,11 +676,11 @@ static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, ulint n_undo)
not in use and therefore not required by recovery. We only check
that there are no gaps. */
- for (ulint i= prev_id + 1; i < srv_undo_space_id_start + TRX_SYS_N_RSEGS;
+ for (uint32_t i= prev_id + 1; i < srv_undo_space_id_start + TRX_SYS_N_RSEGS;
++i)
{
char name[OS_FILE_MAX_PATH];
- snprintf(name, sizeof name, "%s/undo%03zu", srv_undo_dir, i);
+ snprintf(name, sizeof name, "%s/undo%03u", srv_undo_dir, i);
if (!srv_undo_tablespace_open(create_new_db, name, i))
break;
++srv_undo_tablespaces_open;
@@ -690,8 +692,7 @@ static dberr_t srv_all_undo_tablespaces_open(bool create_new_db, ulint n_undo)
/** Open the configured number of dedicated undo tablespaces.
@param[in] create_new_db whether the database is being initialized
@return DB_SUCCESS or error code */
-dberr_t
-srv_undo_tablespaces_init(bool create_new_db)
+dberr_t srv_undo_tablespaces_init(bool create_new_db)
{
srv_undo_tablespaces_open= 0;
@@ -727,8 +728,8 @@ srv_undo_tablespaces_init(bool create_new_db)
already exist. */
srv_undo_tablespaces_active= srv_undo_tablespaces;
- ulint n_undo= (create_new_db || srv_operation == SRV_OPERATION_BACKUP ||
- srv_operation == SRV_OPERATION_RESTORE_DELTA)
+ uint32_t n_undo= (create_new_db || srv_operation == SRV_OPERATION_BACKUP ||
+ srv_operation == SRV_OPERATION_RESTORE_DELTA)
? srv_undo_tablespaces : TRX_SYS_N_RSEGS;
if (dberr_t err= srv_all_undo_tablespaces_open(create_new_db, n_undo))
@@ -742,7 +743,7 @@ srv_undo_tablespaces_init(bool create_new_db)
if (create_new_db)
{
mtr_t mtr;
- for (ulint i= 0; i < srv_undo_tablespaces; ++i)
+ for (uint32_t i= 0; i < srv_undo_tablespaces; ++i)
{
mtr.start();
fsp_header_init(fil_space_get(srv_undo_space_id_start + i),
@@ -1501,8 +1502,9 @@ file_checked:
fil_system.space_id_reuse_warned = false;
if (!srv_read_only_mode) {
- const ulint flags = FSP_FLAGS_PAGE_SSIZE();
- for (ulint id = 0; id <= srv_undo_tablespaces; id++) {
+ const uint32_t flags = FSP_FLAGS_PAGE_SSIZE();
+ for (uint32_t id = 0; id <= srv_undo_tablespaces;
+ id++) {
if (fil_space_t* space = fil_space_get(id)) {
fsp_flags_try_adjust(space, flags);
}
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index 609e058ca52..15ffc5a4aa3 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -570,11 +570,12 @@ static void trx_purge_truncate_history()
if (!purge_sys.truncate.current) {
const ulint threshold = ulint(srv_max_undo_log_size
>> srv_page_size_shift);
- for (ulint i = purge_sys.truncate.last
+ for (uint32_t i = purge_sys.truncate.last
? purge_sys.truncate.last->id
- srv_undo_space_id_start
: 0, j = i;; ) {
- ulint space_id = srv_undo_space_id_start + i;
+ uint32_t space_id = srv_undo_space_id_start
+ + i;
ut_ad(srv_is_undo_tablespace(space_id));
fil_space_t* space= fil_space_get(space_id);
@@ -956,8 +957,7 @@ trx_purge_get_next_rec(
ut_ad(purge_sys.next_stored);
ut_ad(purge_sys.tail.trx_no < purge_sys.low_limit_no());
- const ulint space = purge_sys.rseg->space->id;
- const uint32_t page_no = purge_sys.page_no;
+ const page_id_t page_id{purge_sys.rseg->space->id, purge_sys.page_no};
const uint16_t offset = purge_sys.offset;
if (offset == 0) {
@@ -975,8 +975,7 @@ trx_purge_get_next_rec(
mtr_start(&mtr);
- buf_block_t* undo_page = trx_undo_page_get_s_latched(
- page_id_t(space, page_no), &mtr);
+ buf_block_t* undo_page = trx_undo_page_get_s_latched(page_id, &mtr);
buf_block_t* rec2_page = undo_page;
const trx_undo_rec_t* rec2 = trx_undo_page_get_next_rec(
@@ -999,8 +998,7 @@ trx_purge_get_next_rec(
mtr_start(&mtr);
- undo_page = trx_undo_page_get_s_latched(
- page_id_t(space, page_no), &mtr);
+ undo_page = trx_undo_page_get_s_latched(page_id, &mtr);
} else {
purge_sys.offset = page_offset(rec2);
purge_sys.page_no = rec2_page->page.id().page_no();
diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc
index 6c83feb0b8a..50ffbe0a138 100644
--- a/storage/innobase/trx/trx0rseg.cc
+++ b/storage/innobase/trx/trx0rseg.cc
@@ -31,6 +31,22 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0purge.h"
#include "srv0mon.h"
+/** Get a newly created rollback segment header.
+@param page_id header page location
+@param mtr mini-transaction
+@return rollback segment header, page x-latched */
+static buf_block_t *trx_rsegf_get_new(page_id_t page_id, mtr_t *mtr)
+{
+#ifdef UNIV_DEBUG
+ if (page_id.space() != SRV_TMP_SPACE_ID)
+ {
+ ut_ad(page_id.space() <= srv_undo_tablespaces_active || !srv_was_started);
+ ut_ad(page_id.space() <= TRX_SYS_MAX_UNDO_SPACES);
+ }
+#endif
+ return buf_page_get(page_id, 0, RW_X_LATCH, mtr);
+}
+
#ifdef WITH_WSREP
#include <mysql/service_wsrep.h>
@@ -258,7 +274,8 @@ bool trx_rseg_read_wsrep_checkpoint(XID& xid)
}
const buf_block_t* rseg_header = trx_rsegf_get_new(
- trx_sysf_rseg_get_space(sys, rseg_id), page_no, &mtr);
+ page_id_t(trx_sysf_rseg_get_space(sys, rseg_id),
+ page_no), &mtr);
if (mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT
+ rseg_header->frame)) {
@@ -445,7 +462,7 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, trx_id_t &max_trx_id,
mtr_t *mtr)
{
buf_block_t* rseg_hdr = trx_rsegf_get_new(
- rseg->space->id, rseg->page_no, mtr);
+ page_id_t(rseg->space->id, rseg->page_no), mtr);
if (!mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT + rseg_hdr->frame)) {
trx_id_t id = mach_read_from_8(TRX_RSEG + TRX_RSEG_MAX_TRX_ID
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index fd5617fec76..10991ce3f39 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -279,7 +279,7 @@ trx_sys_create_sys_pages(void)
@param space_id system or undo tablespace id
@return pointer to new rollback segment
@retval nullptr on failure */
-static trx_rseg_t *trx_rseg_create(ulint space_id)
+static trx_rseg_t *trx_rseg_create(uint32_t space_id)
{
trx_rseg_t *rseg= nullptr;
mtr_t mtr;
@@ -333,11 +333,11 @@ bool trx_sys_create_rsegs()
in the system tablespace. */
ut_a(srv_available_undo_logs > 0);
- for (ulint i = 0; srv_available_undo_logs < TRX_SYS_N_RSEGS;
+ for (uint32_t i = 0; srv_available_undo_logs < TRX_SYS_N_RSEGS;
i++, srv_available_undo_logs++) {
/* Tablespace 0 is the system tablespace.
Dedicated undo log tablespaces start from 1. */
- ulint space = srv_undo_tablespaces > 0
+ uint32_t space = srv_undo_tablespaces > 0
? (i % srv_undo_tablespaces)
+ srv_undo_space_id_start
: TRX_SYS_SPACE;
diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc
index da3f6b592fa..12374fdf1e2 100644
--- a/storage/innobase/trx/trx0undo.cc
+++ b/storage/innobase/trx/trx0undo.cc
@@ -607,7 +607,7 @@ trx_undo_free_page(
undo log page; the caller must have reserved
the rollback segment mutex */
{
- const ulint space = rseg->space->id;
+ const uint32_t space = rseg->space->id;
ut_a(hdr_page_no != page_no);