Commit 5a780f2e authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into 10.3

parents f4116613 1caec9c8
......@@ -2349,7 +2349,8 @@ static void rocksdb_copy_back() {
return;
char rocksdb_home_dir[FN_REFLEN];
if (xb_rocksdb_datadir && is_abs_path(xb_rocksdb_datadir)) {
strncpy(rocksdb_home_dir, xb_rocksdb_datadir, sizeof(rocksdb_home_dir));
strncpy(rocksdb_home_dir, xb_rocksdb_datadir, sizeof rocksdb_home_dir - 1);
rocksdb_home_dir[sizeof rocksdb_home_dir - 1] = '\0';
} else {
snprintf(rocksdb_home_dir, sizeof(rocksdb_home_dir), "%s/%s", mysql_data_home,
xb_rocksdb_datadir?trim_dotslash(xb_rocksdb_datadir): ROCKSDB_BACKUP_DIR);
......
......@@ -2547,8 +2547,9 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
goto error;
}
strncpy(dst_name, (dest_name)?dest_name : cursor.rel_path, sizeof(dst_name));
strncpy(dst_name, dest_name ? dest_name : cursor.rel_path,
sizeof dst_name - 1);
dst_name[sizeof dst_name - 1] = '\0';
/* Setup the page write filter */
if (xtrabackup_incremental) {
......@@ -2867,7 +2868,8 @@ static void dbug_mariabackup_event(const char *event,const char *key)
if (slash)
*slash = '_';
} else {
strncpy(envvar, event, sizeof(envvar));
strncpy(envvar, event, sizeof envvar - 1);
envvar[sizeof envvar - 1] = '\0';
}
char *sql = getenv(envvar);
if (sql) {
......@@ -3278,7 +3280,7 @@ static dberr_t xb_assign_undo_space_start()
byte* page;
bool ret;
dberr_t error = DB_SUCCESS;
ulint space, page_no __attribute__((unused));
ulint space;
int n_retries = 5;
if (srv_undo_tablespaces == 0) {
......@@ -3320,10 +3322,10 @@ static dberr_t xb_assign_undo_space_start()
/* 0th slot always points to system tablespace.
1st slot should point to first undotablespace which is minimum. */
page_no = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS
+ TRX_SYS_RSEG_SLOT_SIZE
+ TRX_SYS_RSEG_PAGE_NO + page, MLOG_4BYTES);
ut_ad(page_no != FIL_NULL);
ut_ad(mach_read_from_4(TRX_SYS + TRX_SYS_RSEGS
+ TRX_SYS_RSEG_SLOT_SIZE
+ TRX_SYS_RSEG_PAGE_NO + page)
!= FIL_NULL);
space = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS
+ TRX_SYS_RSEG_SLOT_SIZE
......@@ -4484,7 +4486,8 @@ void backup_fix_ddl(void)
const char *extension = is_remote ? ".isl" : ".ibd";
name.append(extension);
char buf[FN_REFLEN];
strncpy(buf, name.c_str(), sizeof(buf));
strncpy(buf, name.c_str(), sizeof buf - 1);
buf[sizeof buf - 1] = '\0';
const char *dbname = buf;
char *p = strchr(buf, '/');
if (p == 0) {
......
......@@ -7769,7 +7769,6 @@ ha_innobase::build_template(
/* Include the fields that are not needed in index condition
pushdown. */
for (ulint i = 0; i < n_fields; i++) {
mysql_row_templ_t* templ;
const Field* field = table->field[i];
const bool is_v = !field->stored_in_db();
if (is_v && skip_virtual) {
......@@ -7800,7 +7799,8 @@ ha_innobase::build_template(
}
}
templ = build_template_field(
ut_d(mysql_row_templ_t* templ =)
build_template_field(
m_prebuilt, clust_index, index,
table, field, i - num_v, num_v);
ut_ad(templ->is_virtual == (ulint)is_v);
......@@ -7814,7 +7814,6 @@ ha_innobase::build_template(
m_prebuilt->idx_cond = this;
} else {
no_icp:
mysql_row_templ_t* templ;
/* No index condition pushdown */
m_prebuilt->idx_cond = NULL;
ut_ad(num_v == 0);
......@@ -7874,7 +7873,8 @@ ha_innobase::build_template(
}
}
templ = build_template_field(
ut_d(mysql_row_templ_t* templ =)
build_template_field(
m_prebuilt, clust_index, index,
table, field, i - num_v, num_v);
ut_ad(templ->is_virtual == (ulint)is_v);
......
......@@ -73,8 +73,9 @@ trx_rsegf_undo_find_free(const trx_rsegf_t* rsegf);
@param[in] rseg_id rollback segment identifier
@param[in,out] sys_header the TRX_SYS page (NULL for temporary rseg)
@param[in,out] mtr mini-transaction
@return page number of the created segment, FIL_NULL if fail */
ulint
@return the created rollback segment
@retval NULL on failure */
buf_block_t*
trx_rseg_header_create(
fil_space_t* space,
ulint rseg_id,
......
......@@ -4625,6 +4625,7 @@ row_merge_build_indexes(
DBUG_RETURN(DB_OUT_OF_MEMORY);
}
crypt_pfx.m_size = 0; /* silence bogus -Wmaybe-uninitialized */
TRASH_ALLOC(&crypt_pfx, sizeof crypt_pfx);
if (log_tmp_is_encrypted()) {
......
......@@ -1059,11 +1059,10 @@ row_purge_parse_undo_rec(
node->table = dict_table_open_on_id(
table_id, FALSE, DICT_TABLE_OP_NORMAL);
trx_id_t trx_id;
trx_id_t trx_id = TRX_ID_MAX;
if (node->table == NULL) {
/* The table has been dropped: no need to do purge */
trx_id = TRX_ID_MAX;
goto err_exit;
}
......
......@@ -981,15 +981,11 @@ trx_purge_initiate_truncate(
buf_block_t* sys_header = trx_sysf_get(&mtr);
for (ulint i = 0; i < undo_trunc->rsegs_size(); ++i) {
trx_rsegf_t* rseg_header;
trx_rseg_t* rseg = undo_trunc->get_ith_rseg(i);
rseg->page_no = trx_rseg_header_create(
buf_block_t* rblock = trx_rseg_header_create(
space, rseg->id, sys_header, &mtr);
rseg_header = trx_rsegf_get_new(
space_id, rseg->page_no, &mtr);
ut_ad(rblock);
rseg->page_no = rblock ? rblock->page.id.page_no() : FIL_NULL;
/* Before re-initialization ensure that we free the existing
structure. There can't be any active transactions. */
......@@ -1013,8 +1009,10 @@ trx_purge_initiate_truncate(
UT_LIST_INIT(rseg->old_insert_list, &trx_undo_t::undo_list);
/* These were written by trx_rseg_header_create(). */
ut_ad(!mach_read_from_4(rseg_header + TRX_RSEG_FORMAT));
ut_ad(!mach_read_from_4(rseg_header + TRX_RSEG_HISTORY_SIZE));
ut_ad(!mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT
+ rblock->frame));
ut_ad(!mach_read_from_4(TRX_RSEG + TRX_RSEG_HISTORY_SIZE
+ rblock->frame));
/* Initialize the undo log lists according to the rseg header */
rseg->curr_size = 1;
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -265,16 +265,15 @@ void trx_rseg_format_upgrade(trx_rsegf_t* rseg_header, mtr_t* mtr)
@param[in] rseg_id rollback segment identifier
@param[in,out] sys_header the TRX_SYS page (NULL for temporary rseg)
@param[in,out] mtr mini-transaction
@return page number of the created segment, FIL_NULL if fail */
ulint
@return the created rollback segment
@retval NULL on failure */
buf_block_t*
trx_rseg_header_create(
fil_space_t* space,
ulint rseg_id,
buf_block_t* sys_header,
mtr_t* mtr)
{
ulint page_no;
trx_rsegf_t* rsegf;
buf_block_t* block;
ut_ad(mtr_memo_contains(mtr, &space->latch, MTR_MEMO_X_LOCK));
......@@ -285,29 +284,25 @@ trx_rseg_header_create(
if (block == NULL) {
/* No space left */
return(FIL_NULL);
return block;
}
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
page_no = block->page.id.page_no();
/* Get the rollback segment file page */
rsegf = trx_rsegf_get_new(space->id, page_no, mtr);
mlog_write_ulint(rsegf + TRX_RSEG_FORMAT, 0, MLOG_4BYTES, mtr);
mlog_write_ulint(TRX_RSEG + TRX_RSEG_FORMAT + block->frame, 0,
MLOG_4BYTES, mtr);
/* Initialize the history list */
mlog_write_ulint(rsegf + TRX_RSEG_HISTORY_SIZE, 0, MLOG_4BYTES, mtr);
flst_init(rsegf + TRX_RSEG_HISTORY, mtr);
mlog_write_ulint(TRX_RSEG + TRX_RSEG_HISTORY_SIZE + block->frame, 0,
MLOG_4BYTES, mtr);
flst_init(TRX_RSEG + TRX_RSEG_HISTORY + block->frame, mtr);
trx_rsegf_t* rsegf = TRX_RSEG + block->frame;
/* Reset the undo log slots */
for (ulint i = 0; i < TRX_RSEG_N_SLOTS; i++) {
/* FIXME: This is generating a lot of redo log.
Why not just let it remain zero-initialized,
and adjust trx_rsegf_undo_find_free() and friends? */
/* This is generating a lot of redo log. MariaDB 10.4
introduced MLOG_MEMSET to reduce the redo log volume. */
trx_rsegf_set_nth_undo(rsegf, i, FIL_NULL, mtr);
}
......@@ -324,10 +319,10 @@ trx_rseg_header_create(
+ TRX_SYS_RSEG_PAGE_NO
+ rseg_id * TRX_SYS_RSEG_SLOT_SIZE
+ sys_header->frame,
page_no, MLOG_4BYTES, mtr);
block->page.id.page_no(), MLOG_4BYTES, mtr);
}
return(page_no);
return block;
}
/** Free a rollback segment in memory. */
......@@ -604,14 +599,14 @@ trx_rseg_create(ulint space_id)
if (buf_block_t* sys_header = trx_sysf_get(&mtr)) {
ulint rseg_id = trx_sys_rseg_find_free(sys_header);
ulint page_no = rseg_id == ULINT_UNDEFINED
? FIL_NULL
: trx_rseg_header_create(space, rseg_id, sys_header,
&mtr);
if (page_no != FIL_NULL) {
if (buf_block_t* rblock = rseg_id == ULINT_UNDEFINED
? NULL
: trx_rseg_header_create(space, rseg_id, sys_header,
&mtr)) {
ut_ad(trx_sysf_rseg_get_space(sys_header, rseg_id)
== space_id);
rseg = trx_rseg_mem_create(rseg_id, space, page_no);
rseg = trx_rseg_mem_create(rseg_id, space,
rblock->page.id.page_no());
ut_ad(rseg->id == rseg_id);
ut_ad(rseg->is_persistent());
ut_ad(!trx_sys.rseg_array[rseg->id]);
......@@ -635,10 +630,10 @@ trx_temp_rseg_create()
mtr.set_log_mode(MTR_LOG_NO_REDO);
mtr_x_lock(&fil_system.temp_space->latch, &mtr);
ulint page_no = trx_rseg_header_create(
buf_block_t* rblock = trx_rseg_header_create(
fil_system.temp_space, i, NULL, &mtr);
trx_rseg_t* rseg = trx_rseg_mem_create(
i, fil_system.temp_space, page_no);
i, fil_system.temp_space, rblock->page.id.page_no());
ut_ad(!rseg->is_persistent());
ut_ad(!trx_sys.temp_rsegs[i]);
trx_sys.temp_rsegs[i] = rseg;
......
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -148,7 +148,6 @@ trx_sysf_create(
ulint slot_no;
buf_block_t* block;
page_t* page;
ulint page_no;
byte* ptr;
ut_ad(mtr);
......@@ -197,11 +196,11 @@ trx_sysf_create(
/* Create the first rollback segment in the SYSTEM tablespace */
slot_no = trx_sys_rseg_find_free(block);
page_no = trx_rseg_header_create(fil_system.sys_space, slot_no, block,
mtr);
buf_block_t* rblock = trx_rseg_header_create(fil_system.sys_space,
slot_no, block, mtr);
ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
ut_a(page_no == FSP_FIRST_RSEG_PAGE_NO);
ut_a(rblock->page.id.page_no() == FSP_FIRST_RSEG_PAGE_NO);
}
/** Create the instance */
......
......@@ -89,7 +89,6 @@ rbt_check_ordering(
return(TRUE);
}
#endif /* UNIV_DEBUG || IB_RBT_TESTING */
/**********************************************************************//**
Check that every path from the root to the leaves has the same count.
......@@ -138,6 +137,7 @@ rbt_count_black_nodes(
return(result);
}
#endif /* UNIV_DEBUG || IB_RBT_TESTING */
/**********************************************************************//**
Turn the node's right child's left sub-tree into node's right sub-tree.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment