summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-08-03 13:02:56 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-08-03 13:02:56 +0300
commit814ae57daf3ba7ac7f8c7892fbd54a6142a70f44 (patch)
tree24a647cfd585c6ba42a185002fe9394ab74d4bd4
parent976f92051417a99369f5bb45d9f18c87655a9f85 (diff)
parent9d42eb5e28303adb4d9467ac3e9c3be35d46e643 (diff)
downloadmariadb-git-814ae57daf3ba7ac7f8c7892fbd54a6142a70f44.tar.gz
Merge 10.1 into 10.2
-rw-r--r--extra/mariabackup/backup_copy.cc19
-rw-r--r--extra/mariabackup/wsrep.cc3
-rw-r--r--mysql-test/suite/galera/disabled.def1
-rw-r--r--sql/handler.h4
-rw-r--r--sql/wsrep_xid.cc5
-rw-r--r--storage/innobase/buf/buf0buf.cc2
-rw-r--r--storage/innobase/buf/buf0lru.cc2
-rw-r--r--storage/innobase/dict/dict0defrag_bg.cc47
-rw-r--r--storage/innobase/dict/dict0stats_bg.cc65
-rw-r--r--storage/innobase/fts/fts0que.cc2
-rw-r--r--storage/innobase/include/dict0defrag_bg.h19
-rw-r--r--storage/innobase/include/dict0mem.h3
-rw-r--r--storage/innobase/include/row0ftsort.h12
-rw-r--r--storage/innobase/row/row0ftsort.cc1
-rw-r--r--storage/innobase/row/row0import.cc4
-rw-r--r--storage/innobase/trx/trx0sys.cc11
-rw-r--r--storage/innobase/trx/trx0trx.cc3
-rw-r--r--storage/xtradb/buf/buf0buf.cc2
-rw-r--r--storage/xtradb/buf/buf0lru.cc2
-rw-r--r--storage/xtradb/dict/dict0stats_bg.cc14
-rw-r--r--storage/xtradb/fts/fts0que.cc2
-rw-r--r--storage/xtradb/include/dict0mem.h3
-rw-r--r--storage/xtradb/include/row0ftsort.h10
-rw-r--r--storage/xtradb/row/row0ftsort.cc1
-rw-r--r--storage/xtradb/row/row0import.cc4
-rw-r--r--storage/xtradb/trx/trx0sys.cc12
-rw-r--r--storage/xtradb/trx/trx0trx.cc5
27 files changed, 134 insertions, 124 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index b583624c366..d32c1e6fde9 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -472,6 +472,21 @@ struct datafile_cur_t {
size_t buf_size;
size_t buf_read;
size_t buf_offset;
+
+ explicit datafile_cur_t(const char* filename = NULL) :
+ file(), thread_n(0), orig_buf(NULL), buf(NULL), buf_size(0),
+ buf_read(0), buf_offset(0)
+ {
+ memset(rel_path, 0, sizeof rel_path);
+ if (filename) {
+ strncpy(abs_path, filename, sizeof abs_path);
+ abs_path[(sizeof abs_path) - 1] = 0;
+ } else {
+ abs_path[0] = '\0';
+ }
+ rel_path[0] = '\0';
+ memset(&statinfo, 0, sizeof statinfo);
+ }
};
static
@@ -490,9 +505,7 @@ datafile_open(const char *file, datafile_cur_t *cursor, uint thread_n)
{
bool success;
- memset(cursor, 0, sizeof(datafile_cur_t));
-
- strncpy(cursor->abs_path, file, sizeof(cursor->abs_path));
+ new (cursor) datafile_cur_t(file);
/* Get the relative path for the destination tablespace name, i.e. the
one that can be appended to the backup root directory. Non-system
diff --git a/extra/mariabackup/wsrep.cc b/extra/mariabackup/wsrep.cc
index 1cc16affbf2..8e755171647 100644
--- a/extra/mariabackup/wsrep.cc
+++ b/extra/mariabackup/wsrep.cc
@@ -178,8 +178,7 @@ xb_write_galera_info(bool incremental_prepare)
return;
}
- memset(&xid, 0, sizeof(xid));
- xid.formatID = -1;
+ xid.null();
if (!trx_sys_read_wsrep_checkpoint(&xid)) {
diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 72a27277116..355beddbee2 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -35,3 +35,4 @@ galera.galera_pc_ignore_sb : MDEV-15811 Test failure on galera_pc_ignore_sb
galera_kill_applier : race condition at the start of the test
galera_ist_progress: MDEV-15236 galera_ist_progress fails when trying to read transfer status
pxc-421: Lock timeout exceeded
+galera_sst_mysqldump_with_key : MDEV-16890 Galera test failure
diff --git a/sql/handler.h b/sql/handler.h
index dad2b30dec0..ed2ef822c88 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2,7 +2,7 @@
#define HANDLER_INCLUDED
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, MariaDB Corporation.
+ Copyright (c) 2009, 2018, MariaDB
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -598,7 +598,7 @@ struct xid_t {
bqual_length= b;
memcpy(data, d, g+b);
}
- bool is_null() { return formatID == -1; }
+ bool is_null() const { return formatID == -1; }
void null() { formatID= -1; }
my_xid quick_get_my_xid()
{
diff --git a/sql/wsrep_xid.cc b/sql/wsrep_xid.cc
index 2ff6ea0b32e..c0b7669d8ca 100644
--- a/sql/wsrep_xid.cc
+++ b/sql/wsrep_xid.cc
@@ -131,15 +131,14 @@ bool wsrep_get_SE_checkpoint(wsrep_uuid_t& uuid, wsrep_seqno_t& seqno)
seqno= WSREP_SEQNO_UNDEFINED;
XID xid;
- memset(&xid, 0, sizeof(xid));
- xid.formatID= -1;
+ xid.null();
if (wsrep_get_SE_checkpoint(xid))
{
return true;
}
- if (xid.formatID == -1) // nil XID
+ if (xid.is_null())
{
return false;
}
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 0a5a59c9829..6ff71a150a2 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -3344,7 +3344,7 @@ buf_relocate(
}
#endif /* UNIV_DEBUG */
- memcpy(dpage, bpage, sizeof *dpage);
+ new (dpage) buf_page_t(*bpage);
/* Important that we adjust the hazard pointer before
removing bpage from LRU list. */
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index d71d9d08511..74e3bd57452 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -1611,7 +1611,7 @@ func_exit:
} else if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
b = buf_page_alloc_descriptor();
ut_a(b);
- memcpy(b, bpage, sizeof *b);
+ new (b) buf_page_t(*bpage);
}
ut_ad(buf_pool_mutex_own(buf_pool));
diff --git a/storage/innobase/dict/dict0defrag_bg.cc b/storage/innobase/dict/dict0defrag_bg.cc
index 949bbbc0d74..69038d4cb77 100644
--- a/storage/innobase/dict/dict0defrag_bg.cc
+++ b/storage/innobase/dict/dict0defrag_bg.cc
@@ -39,27 +39,13 @@ static ib_mutex_t defrag_pool_mutex;
static mysql_pfs_key_t defrag_pool_mutex_key;
#endif
-/** Indices whose defrag stats need to be saved to persistent storage.*/
-struct defrag_pool_item_t {
- table_id_t table_id;
- index_id_t index_id;
-};
-
-/** Allocator type, used by std::vector */
-typedef ut_allocator<defrag_pool_item_t>
- defrag_pool_allocator_t;
-
-/** The multitude of tables to be defragmented- an STL vector */
-typedef std::vector<defrag_pool_item_t, defrag_pool_allocator_t>
- defrag_pool_t;
-
/** Iterator type for iterating over the elements of objects of type
defrag_pool_t. */
typedef defrag_pool_t::iterator defrag_pool_iterator_t;
/** Pool where we store information on which tables are to be processed
by background defragmentation. */
-static defrag_pool_t* defrag_pool;
+defrag_pool_t defrag_pool;
extern bool dict_stats_start_shutdown;
@@ -70,14 +56,6 @@ dict_defrag_pool_init(void)
/*=======================*/
{
ut_ad(!srv_read_only_mode);
- /* JAN: TODO: MySQL 5.7 PSI
- const PSI_memory_key key2 = mem_key_dict_defrag_pool_t;
-
- defrag_pool = UT_NEW(defrag_pool_t(defrag_pool_allocator_t(key2)), key2);
-
- recalc_pool->reserve(RECALC_POOL_INITIAL_SLOTS);
- */
- defrag_pool = new std::vector<defrag_pool_item_t, defrag_pool_allocator_t>();
/* We choose SYNC_STATS_DEFRAG to be below SYNC_FSP_PAGE. */
mutex_create(LATCH_ID_DEFRAGMENT_MUTEX, &defrag_pool_mutex);
@@ -92,10 +70,7 @@ dict_defrag_pool_deinit(void)
{
ut_ad(!srv_read_only_mode);
- defrag_pool->clear();
mutex_free(&defrag_pool_mutex);
-
- UT_DELETE(defrag_pool);
}
/*****************************************************************//**
@@ -115,16 +90,16 @@ dict_stats_defrag_pool_get(
mutex_enter(&defrag_pool_mutex);
- if (defrag_pool->empty()) {
+ if (defrag_pool.empty()) {
mutex_exit(&defrag_pool_mutex);
return(false);
}
- defrag_pool_item_t& item = defrag_pool->back();
+ defrag_pool_item_t& item = defrag_pool.back();
*table_id = item.table_id;
*index_id = item.index_id;
- defrag_pool->pop_back();
+ defrag_pool.pop_back();
mutex_exit(&defrag_pool_mutex);
@@ -149,8 +124,8 @@ dict_stats_defrag_pool_add(
mutex_enter(&defrag_pool_mutex);
/* quit if already in the list */
- for (defrag_pool_iterator_t iter = defrag_pool->begin();
- iter != defrag_pool->end();
+ for (defrag_pool_iterator_t iter = defrag_pool.begin();
+ iter != defrag_pool.end();
++iter) {
if ((*iter).table_id == index->table->id
&& (*iter).index_id == index->id) {
@@ -161,7 +136,7 @@ dict_stats_defrag_pool_add(
item.table_id = index->table->id;
item.index_id = index->id;
- defrag_pool->push_back(item);
+ defrag_pool.push_back(item);
mutex_exit(&defrag_pool_mutex);
@@ -183,14 +158,14 @@ dict_stats_defrag_pool_del(
mutex_enter(&defrag_pool_mutex);
- defrag_pool_iterator_t iter = defrag_pool->begin();
- while (iter != defrag_pool->end()) {
+ defrag_pool_iterator_t iter = defrag_pool.begin();
+ while (iter != defrag_pool.end()) {
if ((table && (*iter).table_id == table->id)
|| (index
&& (*iter).table_id == index->table->id
&& (*iter).index_id == index->id)) {
/* erase() invalidates the iterator */
- iter = defrag_pool->erase(iter);
+ iter = defrag_pool.erase(iter);
if (index)
break;
} else {
@@ -252,7 +227,7 @@ void
dict_defrag_process_entries_from_defrag_pool()
/*==========================================*/
{
- while (defrag_pool->size() && !dict_stats_start_shutdown) {
+ while (defrag_pool.size() && !dict_stats_start_shutdown) {
dict_stats_process_entry_from_defrag_pool();
}
}
diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc
index b203c60bd3c..423558f70c8 100644
--- a/storage/innobase/dict/dict0stats_bg.cc
+++ b/storage/innobase/dict/dict0stats_bg.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2018, 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
@@ -82,40 +82,29 @@ typedef recalc_pool_t::iterator
/** Pool where we store information on which tables are to be processed
by background statistics gathering. */
-static recalc_pool_t* recalc_pool;
-
-
-/*****************************************************************//**
-Initialize the recalc pool, called once during thread initialization. */
-static
-void
-dict_stats_recalc_pool_init()
-/*=========================*/
-{
- ut_ad(!srv_read_only_mode);
- /* JAN: TODO: MySQL 5.7 PSI
- const PSI_memory_key key = mem_key_dict_stats_bg_recalc_pool_t;
-
- recalc_pool = UT_NEW(recalc_pool_t(recalc_pool_allocator_t(key)), key);
-
- recalc_pool->reserve(RECALC_POOL_INITIAL_SLOTS);
- */
- recalc_pool = new std::vector<table_id_t, recalc_pool_allocator_t>();
-}
+static recalc_pool_t recalc_pool;
/*****************************************************************//**
Free the resources occupied by the recalc pool, called once during
thread de-initialization. */
-static
-void
-dict_stats_recalc_pool_deinit()
-/*===========================*/
+static void dict_stats_recalc_pool_deinit()
{
ut_ad(!srv_read_only_mode);
- recalc_pool->clear();
-
- UT_DELETE(recalc_pool);
+ recalc_pool.clear();
+ defrag_pool.clear();
+ /*
+ recalc_pool may still have its buffer allocated. It will free it when
+ its destructor is called.
+ The problem is, memory leak detector is run before the recalc_pool's
+ destructor is invoked, and will report recalc_pool's buffer as leaked
+ memory. To avoid that, we force recalc_pool to surrender its buffer
+ to empty_pool object, which will free it when leaving this function:
+ */
+ recalc_pool_t recalc_empty_pool;
+ defrag_pool_t defrag_empty_pool;
+ recalc_pool.swap(recalc_empty_pool);
+ defrag_pool.swap(defrag_empty_pool);
}
/*****************************************************************//**
@@ -135,8 +124,8 @@ dict_stats_recalc_pool_add(
mutex_enter(&recalc_pool_mutex);
/* quit if already in the list */
- for (recalc_pool_iterator_t iter = recalc_pool->begin();
- iter != recalc_pool->end();
+ for (recalc_pool_iterator_t iter = recalc_pool.begin();
+ iter != recalc_pool.end();
++iter) {
if (*iter == table->id) {
@@ -145,7 +134,7 @@ dict_stats_recalc_pool_add(
}
}
- recalc_pool->push_back(table->id);
+ recalc_pool.push_back(table->id);
mutex_exit(&recalc_pool_mutex);
@@ -221,14 +210,14 @@ dict_stats_recalc_pool_get(
mutex_enter(&recalc_pool_mutex);
- if (recalc_pool->empty()) {
+ if (recalc_pool.empty()) {
mutex_exit(&recalc_pool_mutex);
return(false);
}
- *id = recalc_pool->at(0);
+ *id = recalc_pool.at(0);
- recalc_pool->erase(recalc_pool->begin());
+ recalc_pool.erase(recalc_pool.begin());
mutex_exit(&recalc_pool_mutex);
@@ -250,13 +239,13 @@ dict_stats_recalc_pool_del(
ut_ad(table->id > 0);
- for (recalc_pool_iterator_t iter = recalc_pool->begin();
- iter != recalc_pool->end();
+ for (recalc_pool_iterator_t iter = recalc_pool.begin();
+ iter != recalc_pool.end();
++iter) {
if (*iter == table->id) {
/* erase() invalidates the iterator */
- recalc_pool->erase(iter);
+ recalc_pool.erase(iter);
break;
}
}
@@ -314,9 +303,7 @@ dict_stats_thread_init()
mutex_create(LATCH_ID_RECALC_POOL, &recalc_pool_mutex);
- dict_stats_recalc_pool_init();
dict_defrag_pool_init();
-
}
/*****************************************************************//**
diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc
index 9956be93cb1..b6a6849f26f 100644
--- a/storage/innobase/fts/fts0que.cc
+++ b/storage/innobase/fts/fts0que.cc
@@ -4105,7 +4105,7 @@ fts_query(
if (trx_is_interrupted(trx)) {
error = DB_INTERRUPTED;
ut_free(lc_query_str);
- if (result != NULL) {
+ if (*result) {
fts_query_free_result(*result);
}
goto func_exit;
diff --git a/storage/innobase/include/dict0defrag_bg.h b/storage/innobase/include/dict0defrag_bg.h
index 8d77a461dc9..ddef139853c 100644
--- a/storage/innobase/include/dict0defrag_bg.h
+++ b/storage/innobase/include/dict0defrag_bg.h
@@ -33,6 +33,25 @@ Created 25/08/2016 Jan Lindström
#include "os0event.h"
#include "os0thread.h"
+
+/** Indices whose defrag stats need to be saved to persistent storage.*/
+struct defrag_pool_item_t {
+ table_id_t table_id;
+ index_id_t index_id;
+};
+
+/** Allocator type, used by std::vector */
+typedef ut_allocator<defrag_pool_item_t>
+ defrag_pool_allocator_t;
+
+/** The multitude of tables to be defragmented- an STL vector */
+typedef std::vector<defrag_pool_item_t, defrag_pool_allocator_t>
+ defrag_pool_t;
+
+/** Pool where we store information on which tables are to be processed
+by background defragmentation. */
+extern defrag_pool_t defrag_pool;
+
/*****************************************************************//**
Initialize the defrag pool, called once during thread initialization. */
void
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 02561176706..44d1a11ab33 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -733,6 +733,9 @@ struct dict_field_t{
unsigned fixed_len:10; /*!< 0 or the fixed length of the
column if smaller than
DICT_ANTELOPE_MAX_INDEX_COL_LEN */
+
+ /** Zero-initialize all fields */
+ dict_field_t() : col(NULL), name(NULL), prefix_len(0), fixed_len(0) {}
};
/**********************************************************************//**
diff --git a/storage/innobase/include/row0ftsort.h b/storage/innobase/include/row0ftsort.h
index c8556cc4ca4..8f7632ed9ac 100644
--- a/storage/innobase/include/row0ftsort.h
+++ b/storage/innobase/include/row0ftsort.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2017, MariaDB Corporation.
+Copyright (c) 2015, 2018, 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
@@ -122,6 +122,16 @@ struct fts_tokenize_ctx {
dfield_t sort_field[FTS_NUM_FIELDS_SORT];
/*!< in: sort field */
fts_token_list_t fts_token_list;
+
+ fts_tokenize_ctx() :
+ processed_len(0), init_pos(0), buf_used(0),
+ rows_added(), cached_stopword(NULL), sort_field(),
+ fts_token_list()
+ {
+ memset(rows_added, 0, sizeof rows_added);
+ memset(sort_field, 0, sizeof sort_field);
+ UT_LIST_INIT(fts_token_list, &row_fts_token_t::token_list);
+ }
};
typedef struct fts_tokenize_ctx fts_tokenize_ctx_t;
diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc
index 6abc84ddee7..507b7c25ed4 100644
--- a/storage/innobase/row/row0ftsort.cc
+++ b/storage/innobase/row/row0ftsort.cc
@@ -807,7 +807,6 @@ fts_parallel_tokenization(
merge_file = psort_info->merge_file;
blob_heap = mem_heap_create(512);
memset(&doc, 0, sizeof(doc));
- memset(&t_ctx, 0, sizeof(t_ctx));
memset(mycount, 0, FTS_NUM_AUX_INDEX * sizeof(int));
doc.charset = fts_index_get_charset(
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index 4ca878253ea..117a2e573de 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -2409,8 +2409,6 @@ row_import_cfg_read_index_fields(
dict_field_t* field = index->m_fields;
- memset(field, 0x0, sizeof(*field) * n_fields);
-
for (ulint i = 0; i < n_fields; ++i, ++field) {
byte* ptr = row;
@@ -2428,6 +2426,8 @@ row_import_cfg_read_index_fields(
return(DB_IO_ERROR);
}
+ new (field) dict_field_t();
+
field->prefix_len = mach_read_from_4(ptr);
ptr += sizeof(ib_uint32_t);
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index f7404e8a303..e2e42dc6569 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -336,11 +336,12 @@ trx_sys_read_wsrep_checkpoint(XID* xid)
if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD))
!= TRX_SYS_WSREP_XID_MAGIC_N) {
- memset(xid, 0, sizeof(*xid));
- long long seqno= -1;
- memcpy(xid->data + 24, &seqno, sizeof(long long));
- xid->formatID = -1;
- mtr_commit(&mtr);
+ mtr.commit();
+ xid->null();
+ xid->gtrid_length = 0;
+ xid->bqual_length = 0;
+ memset(xid->data, 0, sizeof xid->data);
+ memset(xid->data + 24, 0xff, 8);
return false;
}
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 7cf31ef89eb..7ebf41b3143 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1181,8 +1181,7 @@ trx_start_low(
}
#ifdef WITH_WSREP
- memset(trx->xid, 0, sizeof(xid_t));
- trx->xid->formatID = -1;
+ trx->xid->null();
#endif /* WITH_WSREP */
/* The initial value for trx->no: TRX_ID_MAX is used in
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index ce4dd4715db..2da74950cc7 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -1994,7 +1994,7 @@ buf_relocate(
}
#endif /* UNIV_DEBUG */
- memcpy(dpage, bpage, sizeof *dpage);
+ new (dpage) buf_page_t(*bpage);
ut_d(bpage->in_LRU_list = FALSE);
ut_d(bpage->in_page_hash = FALSE);
diff --git a/storage/xtradb/buf/buf0lru.cc b/storage/xtradb/buf/buf0lru.cc
index ec65bfbcce4..d71ba56fb37 100644
--- a/storage/xtradb/buf/buf0lru.cc
+++ b/storage/xtradb/buf/buf0lru.cc
@@ -1838,7 +1838,7 @@ not_freed:
}
if (b) {
- memcpy(b, bpage, sizeof *b);
+ new (b) buf_page_t(*bpage);
}
if (!buf_LRU_block_remove_hashed(bpage, zip)) {
diff --git a/storage/xtradb/dict/dict0stats_bg.cc b/storage/xtradb/dict/dict0stats_bg.cc
index 884f62103f5..9394ca2830d 100644
--- a/storage/xtradb/dict/dict0stats_bg.cc
+++ b/storage/xtradb/dict/dict0stats_bg.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2018, 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
@@ -95,17 +95,13 @@ dict_stats_pool_init()
/*****************************************************************//**
Free the resources occupied by the recalc pool, called once during
thread de-initialization. */
-static
-void
-dict_stats_pool_deinit()
-/*===========================*/
+static void dict_stats_pool_deinit()
{
ut_ad(!srv_read_only_mode);
recalc_pool.clear();
defrag_pool.clear();
-
- /*
+ /*
recalc_pool may still have its buffer allocated. It will free it when
its destructor is called.
The problem is, memory leak detector is run before the recalc_pool's
@@ -115,9 +111,7 @@ dict_stats_pool_deinit()
*/
recalc_pool_t recalc_empty_pool;
defrag_pool_t defrag_empty_pool;
- memset(&recalc_empty_pool, 0, sizeof(recalc_pool_t));
- memset(&defrag_empty_pool, 0, sizeof(defrag_pool_t));
- recalc_pool.swap(recalc_empty_pool);
+ recalc_pool.swap(recalc_empty_pool);
defrag_pool.swap(defrag_empty_pool);
}
diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc
index 50f198401f9..9966656e772 100644
--- a/storage/xtradb/fts/fts0que.cc
+++ b/storage/xtradb/fts/fts0que.cc
@@ -4038,7 +4038,7 @@ fts_query(
if (trx_is_interrupted(trx)) {
error = DB_INTERRUPTED;
ut_free(lc_query_str);
- if (result != NULL) {
+ if (*result) {
fts_query_free_result(*result);
}
goto func_exit;
diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h
index bdec503c88c..16aaab3e621 100644
--- a/storage/xtradb/include/dict0mem.h
+++ b/storage/xtradb/include/dict0mem.h
@@ -605,6 +605,9 @@ struct dict_field_t{
unsigned fixed_len:10; /*!< 0 or the fixed length of the
column if smaller than
DICT_ANTELOPE_MAX_INDEX_COL_LEN */
+
+ /** Zero-initialize all fields */
+ dict_field_t() : col(NULL), name(NULL), prefix_len(0), fixed_len(0) {}
};
/**********************************************************************//**
diff --git a/storage/xtradb/include/row0ftsort.h b/storage/xtradb/include/row0ftsort.h
index b2dd90e7e3b..b006385371d 100644
--- a/storage/xtradb/include/row0ftsort.h
+++ b/storage/xtradb/include/row0ftsort.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2017, MariaDB Corporation.
+Copyright (c) 2015, 2018, 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
@@ -111,6 +111,14 @@ struct fts_tokenize_ctx {
ib_rbt_t* cached_stopword;/*!< in: stopword list */
dfield_t sort_field[FTS_NUM_FIELDS_SORT];
/*!< in: sort field */
+
+ fts_tokenize_ctx() :
+ processed_len(0), init_pos(0), buf_used(0),
+ rows_added(), cached_stopword(NULL), sort_field()
+ {
+ memset(rows_added, 0, sizeof rows_added);
+ memset(sort_field, 0, sizeof sort_field);
+ }
};
typedef struct fts_tokenize_ctx fts_tokenize_ctx_t;
diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc
index bd57685b71c..7b7620c4a02 100644
--- a/storage/xtradb/row/row0ftsort.cc
+++ b/storage/xtradb/row/row0ftsort.cc
@@ -676,7 +676,6 @@ fts_parallel_tokenization(
merge_file = psort_info->merge_file;
blob_heap = mem_heap_create(512);
memset(&doc, 0, sizeof(doc));
- memset(&t_ctx, 0, sizeof(t_ctx));
memset(mycount, 0, FTS_NUM_AUX_INDEX * sizeof(int));
doc.charset = fts_index_get_charset(
diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc
index 83f5aca5d4c..47918e156ea 100644
--- a/storage/xtradb/row/row0import.cc
+++ b/storage/xtradb/row/row0import.cc
@@ -2514,8 +2514,6 @@ row_import_cfg_read_index_fields(
dict_field_t* field = index->m_fields;
- memset(field, 0x0, sizeof(*field) * n_fields);
-
for (ulint i = 0; i < n_fields; ++i, ++field) {
byte* ptr = row;
@@ -2533,6 +2531,8 @@ row_import_cfg_read_index_fields(
return(DB_IO_ERROR);
}
+ new (field) dict_field_t();
+
field->prefix_len = mach_read_from_4(ptr);
ptr += sizeof(ib_uint32_t);
diff --git a/storage/xtradb/trx/trx0sys.cc b/storage/xtradb/trx/trx0sys.cc
index 6108ab7ab94..30660df01f6 100644
--- a/storage/xtradb/trx/trx0sys.cc
+++ b/storage/xtradb/trx/trx0sys.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2018, 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
@@ -351,7 +351,7 @@ trx_sys_update_wsrep_checkpoint(
mtr_t* mtr)
{
#ifdef UNIV_DEBUG
- if (xid->formatID != -1
+ if (!xid->is_null()
&& mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD)
== TRX_SYS_WSREP_XID_MAGIC_N) {
@@ -372,7 +372,7 @@ trx_sys_update_wsrep_checkpoint(
#endif /* UNIV_DEBUG */
ut_ad(xid && mtr);
- ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const XID *)xid));
+ ut_a(xid->is_null() || wsrep_is_wsrep_xid((const XID *)xid));
if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD)
@@ -421,8 +421,10 @@ trx_sys_read_wsrep_checkpoint(XID* xid)
if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD))
!= TRX_SYS_WSREP_XID_MAGIC_N) {
- memset(xid, 0, sizeof(*xid));
- xid->formatID = -1;
+ xid->null();
+ xid->gtrid_length = 0;
+ xid->bqual_length = 0;
+ memset(xid->data, 0, sizeof xid->data);
trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr);
mtr_commit(&mtr);
return false;
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index a61198c54ae..6a033fbeb09 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -278,7 +278,7 @@ trx_create(void)
trx->distinct_page_access_hash = NULL;
trx->take_stats = FALSE;
- trx->xid.formatID = -1;
+ trx->xid.null();
trx->op_info = "";
@@ -1041,8 +1041,7 @@ trx_start_low(
}
#ifdef WITH_WSREP
- memset(&trx->xid, 0, sizeof(trx->xid));
- trx->xid.formatID = -1;
+ trx->xid.null();
#endif /* WITH_WSREP */
/* The initial value for trx->no: TRX_ID_MAX is used in