summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-06-15 15:27:11 +0400
committerAlexander Barkov <bar@mariadb.org>2017-06-15 15:27:11 +0400
commit765347384af7fd3393ad37567a612d93ed8b3d92 (patch)
treea2c0a08596142312ec38f33e4e02f353a2730fe1 /storage/innobase/include
parent3b1921c714fcb4415cea9058408fb5a626e93b62 (diff)
parente813fe862226554cfe31754b3dfeafbb2b9a7159 (diff)
downloadmariadb-git-765347384af7fd3393ad37567a612d93ed8b3d92.tar.gz
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/btr0cur.h25
-rw-r--r--storage/innobase/include/btr0defragment.h16
-rw-r--r--storage/innobase/include/buf0buf.h7
-rw-r--r--storage/innobase/include/buf0buf.ic3
-rw-r--r--storage/innobase/include/buf0dblwr.h19
-rw-r--r--storage/innobase/include/data0type.ic3
-rw-r--r--storage/innobase/include/dict0mem.h9
-rw-r--r--storage/innobase/include/dict0stats.h7
-rw-r--r--storage/innobase/include/dict0stats_bg.h13
-rw-r--r--storage/innobase/include/fil0fil.h19
-rw-r--r--storage/innobase/include/fil0pagecompress.h3
-rw-r--r--storage/innobase/include/fsp0file.h8
-rw-r--r--storage/innobase/include/fsp0fsp.h14
-rw-r--r--storage/innobase/include/fts0priv.h7
-rw-r--r--storage/innobase/include/fts0types.h4
-rw-r--r--storage/innobase/include/fts0types.ic22
-rw-r--r--storage/innobase/include/lock0lock.h26
-rw-r--r--storage/innobase/include/log0log.h46
-rw-r--r--storage/innobase/include/log0recv.h7
-rw-r--r--storage/innobase/include/mach0data.ic14
-rw-r--r--storage/innobase/include/os0file.h106
-rw-r--r--storage/innobase/include/os0file.ic131
-rw-r--r--storage/innobase/include/os0thread.h13
-rw-r--r--storage/innobase/include/page0zip.ic3
-rw-r--r--storage/innobase/include/rem0cmp.h3
-rw-r--r--storage/innobase/include/row0merge.h14
-rw-r--r--storage/innobase/include/row0mysql.h1
-rw-r--r--storage/innobase/include/srv0srv.h2
-rw-r--r--storage/innobase/include/srv0start.h54
-rw-r--r--storage/innobase/include/sync0types.h6
-rw-r--r--storage/innobase/include/trx0rec.h18
-rw-r--r--storage/innobase/include/trx0rseg.h7
-rw-r--r--storage/innobase/include/trx0trx.h2
-rw-r--r--storage/innobase/include/trx0xa.h7
-rw-r--r--storage/innobase/include/univ.i15
-rw-r--r--storage/innobase/include/ut0new.h51
-rw-r--r--storage/innobase/include/ut0rnd.ic7
37 files changed, 370 insertions, 342 deletions
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index e1f5286e122..e62a5e90ce2 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -249,15 +249,17 @@ btr_cur_optimistic_insert(
btr_cur_t* cursor, /*!< in: cursor on page after which to insert;
cursor stays valid */
ulint** offsets,/*!< out: offsets on *rec */
- mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */
+ mem_heap_t** heap, /*!< in/out: pointer to memory heap */
dtuple_t* entry, /*!< in/out: entry to insert */
rec_t** rec, /*!< out: pointer to inserted record if
succeed */
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
- be stored externally by the caller, or
- NULL */
+ be stored externally by the caller */
ulint n_ext, /*!< in: number of externally stored columns */
- que_thr_t* thr, /*!< in: query thread or NULL */
+ que_thr_t* thr, /*!< in/out: query thread; can be NULL if
+ !(~flags
+ & (BTR_NO_LOCKING_FLAG
+ | BTR_NO_UNDO_LOG_FLAG)) */
mtr_t* mtr) /*!< in/out: mini-transaction;
if this function returns DB_SUCCESS on
a leaf page of a secondary index in a
@@ -284,15 +286,17 @@ btr_cur_pessimistic_insert(
cursor stays valid */
ulint** offsets,/*!< out: offsets on *rec */
mem_heap_t** heap, /*!< in/out: pointer to memory heap
- that can be emptied, or NULL */
+ that can be emptied */
dtuple_t* entry, /*!< in/out: entry to insert */
rec_t** rec, /*!< out: pointer to inserted record if
succeed */
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
- be stored externally by the caller, or
- NULL */
+ be stored externally by the caller */
ulint n_ext, /*!< in: number of externally stored columns */
- que_thr_t* thr, /*!< in: query thread or NULL */
+ que_thr_t* thr, /*!< in/out: query thread; can be NULL if
+ !(~flags
+ & (BTR_NO_LOCKING_FLAG
+ | BTR_NO_UNDO_LOG_FLAG)) */
mtr_t* mtr) /*!< in/out: mini-transaction */
MY_ATTRIBUTE((nonnull(2,3,4,5,6,7,10), warn_unused_result));
/*************************************************************//**
@@ -413,12 +417,12 @@ btr_cur_pessimistic_update(
ulint** offsets,/*!< out: offsets on cursor->page_cur.rec */
mem_heap_t** offsets_heap,
/*!< in/out: pointer to memory heap
- that can be emptied, or NULL */
+ that can be emptied */
mem_heap_t* entry_heap,
/*!< in/out: memory heap for allocating
big_rec and the index tuple */
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
- be stored externally by the caller, or NULL */
+ be stored externally by the caller */
upd_t* update, /*!< in/out: update vector; this is allowed to
also contain trx id and roll ptr fields.
Non-updated columns that are moved offpage will
@@ -439,7 +443,6 @@ undo log record created.
dberr_t
btr_cur_del_mark_set_clust_rec(
/*===========================*/
- ulint flags, /*!< in: undo logging and locking flags */
buf_block_t* block, /*!< in/out: buffer block of the record */
rec_t* rec, /*!< in/out: record */
dict_index_t* index, /*!< in: clustered index of the record */
diff --git a/storage/innobase/include/btr0defragment.h b/storage/innobase/include/btr0defragment.h
index 21ba6d9f426..9c78ec412a2 100644
--- a/storage/innobase/include/btr0defragment.h
+++ b/storage/innobase/include/btr0defragment.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (C) 2013, 2014 Facebook, Inc. All Rights Reserved.
-Copyright (C) 2014, 2015, MariaDB Corporation.
+Copyright (C) 2014, 2017, 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
@@ -85,13 +85,13 @@ UNIV_INTERN
void
btr_defragment_save_defrag_stats_if_needed(
dict_index_t* index); /*!< in: index */
-/******************************************************************//**
-Thread that merges consecutive b-tree pages into fewer pages to defragment
-the index. */
+
+/** Merge consecutive b-tree pages into fewer pages to defragment indexes */
extern "C" UNIV_INTERN
os_thread_ret_t
-DECLARE_THREAD(btr_defragment_thread)(
-/*==========================================*/
- void* arg); /*!< in: a dummy parameter required by
- os_thread_create */
+DECLARE_THREAD(btr_defragment_thread)(void*);
+
+/** Whether btr_defragment_thread is active */
+extern bool btr_defragment_thread_active;
+
#endif
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 928521e789e..9d5f373f5de 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1519,20 +1519,13 @@ directory (buf) to see it. Do not use from outside! */
typedef struct {
bool reserved; /*!< true if this slot is reserved
*/
-#ifdef HAVE_LZO
- byte* lzo_mem; /*!< Temporal memory used by LZO */
-#endif
byte* crypt_buf; /*!< for encryption the data needs to be
copied to a separate buffer before it's
encrypted&written. this as a page can be
read while it's being flushed */
- byte* crypt_buf_free; /*!< for encryption, allocated buffer
- that is then alligned */
byte* comp_buf; /*!< for compression we need
temporal buffer because page
can be read while it's being flushed */
- byte* comp_buf_free; /*!< for compression, allocated
- buffer that is then alligned */
byte* out_buf; /*!< resulting buffer after
encryption/compression. This is a
pointer and not allocated. */
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index f22dcc48a01..38c52d5e608 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -1286,9 +1286,8 @@ buf_page_release_zip(
rw_lock_s_unlock(&block->debug_latch);
}
}
- /* Fall through */
#endif /* UNIV_DEBUG */
-
+ /* Fall through */
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY:
buf_block_unfix(reinterpret_cast<buf_block_t*>(bpage));
diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h
index e1ecb6baf56..598609e2be4 100644
--- a/storage/innobase/include/buf0dblwr.h
+++ b/storage/innobase/include/buf0dblwr.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -38,24 +38,27 @@ extern buf_dblwr_t* buf_dblwr;
/** Set to TRUE when the doublewrite buffer is being created */
extern ibool buf_dblwr_being_created;
-/****************************************************************//**
-Creates the doublewrite buffer to a new InnoDB installation. The header of the
-doublewrite buffer is placed on the trx system header page.
-@return true if successful, false if not. */
+/** Create the doublewrite buffer if the doublewrite buffer header
+is not present in the TRX_SYS page.
+@return whether the operation succeeded
+@retval true if the doublewrite buffer exists or was created
+@retval false if the creation failed (too small first data file) */
MY_ATTRIBUTE((warn_unused_result))
bool
buf_dblwr_create();
-/****************************************************************//**
-At a database startup initializes the doublewrite buffer memory structure if
+/**
+At database startup initializes the doublewrite buffer memory structure if
we already have a doublewrite buffer created in the data files. If we are
upgrading to an InnoDB version which supports multiple tablespaces, then this
function performs the necessary update operations. If we are in a crash
recovery, this function loads the pages from double write buffer into memory.
+@param[in] file File handle
+@param[in] path Path name of file
@return DB_SUCCESS or error code */
dberr_t
buf_dblwr_init_or_load_pages(
- os_file_t file,
+ pfs_os_file_t file,
const char* path);
/** Process and remove the double write buffer pages for all tablespaces. */
diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic
index 9ec85dfaf50..b5a467455b9 100644
--- a/storage/innobase/include/data0type.ic
+++ b/storage/innobase/include/data0type.ic
@@ -527,7 +527,8 @@ dtype_get_fixed_size_low(
return(len);
}
}
- /* fall through for variable-length charsets */
+ /* Treat as variable-length. */
+ /* Fall through */
case DATA_VARCHAR:
case DATA_BINARY:
case DATA_DECIMAL:
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index f35a7810736..093a036b331 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -300,9 +300,8 @@ ROW_FORMAT=REDUNDANT. InnoDB engines do not check these flags
for unknown bits in order to protect backward incompatibility. */
/* @{ */
/** Total number of bits in table->flags2. */
-#define DICT_TF2_BITS 9
-#define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS | \
- 1U << DICT_TF_POS_SHARED_SPACE)
+#define DICT_TF2_BITS 7
+#define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS)
#define DICT_TF2_BIT_MASK ~DICT_TF2_UNUSED_BIT_MASK
/** TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE. */
@@ -924,8 +923,6 @@ struct dict_index_t{
dict_field_t* fields; /*!< array of field descriptions */
st_mysql_ftparser*
parser; /*!< fulltext parser plugin */
- bool is_ngram;
- /*!< true if it's ngram parser */
bool has_new_v_col;
/*!< whether it has a newly added virtual
column in ALTER */
@@ -1426,8 +1423,6 @@ struct dict_table_t {
5 whether the table is being created its own tablespace,
6 whether the table has been DISCARDed,
7 whether the aux FTS tables names are in hex.
- 8 whether the table is instinc table.
- 9 whether the table has encryption setting.
Use DICT_TF2_FLAG_IS_SET() to parse this flag. */
unsigned flags2:DICT_TF2_BITS;
diff --git a/storage/innobase/include/dict0stats.h b/storage/innobase/include/dict0stats.h
index 752c197f8c3..8846aeda7fd 100644
--- a/storage/innobase/include/dict0stats.h
+++ b/storage/innobase/include/dict0stats.h
@@ -110,6 +110,13 @@ dict_stats_deinit(
dict_table_t* table) /*!< in/out: table */
MY_ATTRIBUTE((nonnull));
+/** Update the table modification counter and if necessary,
+schedule new estimates for table and index statistics to be calculated.
+@param[in,out] table persistent or temporary table */
+void
+dict_stats_update_if_needed(dict_table_t* table)
+ MY_ATTRIBUTE((nonnull));
+
/*********************************************************************//**
Calculates new estimates for table and index statistics. The statistics
are used in query optimization.
diff --git a/storage/innobase/include/dict0stats_bg.h b/storage/innobase/include/dict0stats_bg.h
index b7bf1b0c170..f99cbeed780 100644
--- a/storage/innobase/include/dict0stats_bg.h
+++ b/storage/innobase/include/dict0stats_bg.h
@@ -47,17 +47,6 @@ extern my_bool innodb_dict_stats_disabled_debug;
#endif /* UNIV_DEBUG */
/*****************************************************************//**
-Add a table to the recalc pool, which is processed by the
-background stats gathering thread. Only the table id is added to the
-list, so the table can be closed after being enqueued and it will be
-opened when needed. If the table does not exist later (has been DROPped),
-then it will be removed from the pool and skipped. */
-void
-dict_stats_recalc_pool_add(
-/*=======================*/
- const dict_table_t* table); /*!< in: table to add */
-
-/*****************************************************************//**
Delete a given table from the auto recalc pool.
dict_stats_recalc_pool_del() */
void
@@ -151,7 +140,7 @@ DECLARE_THREAD(dict_stats_thread)(
void* arg); /*!< in: a dummy parameter
required by os_thread_create */
-/** Shutdown the dict stats thread. */
+/** Shut down the dict_stats_thread. */
void
dict_stats_shutdown();
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index d8b6cf33675..7d9327c598b 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -180,9 +180,6 @@ struct fil_space_t {
/** MariaDB encryption data */
fil_space_crypt_t* crypt_data;
- /** tablespace crypt data has been read */
- bool page_0_crypt_read;
-
/** True if we have already printed compression failure */
bool printed_compression_failure;
@@ -217,7 +214,7 @@ struct fil_node_t {
/** file name; protected by fil_system->mutex and log_sys->mutex. */
char* name;
/** file handle (valid if is_open) */
- os_file_t handle;
+ pfs_os_file_t handle;
/** event that groups and serializes calls to fsync;
os_event_set() and os_event_reset() are protected by
fil_system_t::mutex */
@@ -586,7 +583,6 @@ Error messages are issued to the server log.
@param[in] flags tablespace flags
@param[in] purpose tablespace purpose
@param[in,out] crypt_data encryption information
-@param[in] create_table whether this is CREATE TABLE
@param[in] mode encryption mode
@return pointer to created tablespace, to be filled in with fil_node_create()
@retval NULL on failure (such as when the same tablespace exists) */
@@ -597,7 +593,6 @@ fil_space_create(
ulint flags,
fil_type_t purpose,
fil_space_crypt_t* crypt_data,
- bool create_table,
fil_encryption_t mode = FIL_ENCRYPTION_DEFAULT)
MY_ATTRIBUTE((warn_unused_result));
@@ -1064,7 +1059,7 @@ fil_ibd_create(
ulint size,
fil_encryption_t mode,
uint32_t key_id)
- MY_ATTRIBUTE((warn_unused_result));
+ MY_ATTRIBUTE((nonnull(2), warn_unused_result));
/** Try to adjust FSP_SPACE_FLAGS if they differ from the expectations.
(Typically when upgrading from MariaDB 10.1.0..10.1.20.)
@@ -1404,19 +1399,19 @@ struct PageCallback {
/** Called for every page in the tablespace. If the page was not
updated then its state must be set to BUF_PAGE_NOT_USED. For
compressed tables the page descriptor memory will be at offset:
- block->frame + UNIV_PAGE_SIZE;
+ block->frame + UNIV_PAGE_SIZE;
@param offset physical offset within the file
@param block block read from file, note it is not from the buffer pool
@retval DB_SUCCESS or error code. */
virtual dberr_t operator()(
- os_offset_t offset,
+ os_offset_t offset,
buf_block_t* block) UNIV_NOTHROW = 0;
/** Set the name of the physical file and the file handle that is used
to open it for the file that is being iterated over.
- @param filename then physical name of the tablespace file.
+ @param filename the name of the tablespace file
@param file OS file handle */
- void set_file(const char* filename, os_file_t file) UNIV_NOTHROW
+ void set_file(const char* filename, pfs_os_file_t file) UNIV_NOTHROW
{
m_file = file;
m_filepath = filename;
@@ -1441,7 +1436,7 @@ struct PageCallback {
page_size_t m_page_size;
/** File handle to the tablespace */
- os_file_t m_file;
+ pfs_os_file_t m_file;
/** Physical file path. */
const char* m_filepath;
diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h
index 67ff7895b02..be10f99d0f0 100644
--- a/storage/innobase/include/fil0pagecompress.h
+++ b/storage/innobase/include/fil0pagecompress.h
@@ -46,9 +46,8 @@ fil_compress_page(
ulint level, /* in: compression level */
ulint block_size, /*!< in: block size */
bool encrypted, /*!< in: is page also encrypted */
- ulint* out_len, /*!< out: actual length of compressed
+ ulint* out_len); /*!< out: actual length of compressed
page */
- byte* lzo_mem); /*!< in: temporal memory used by LZO */
/****************************************************************//**
For page compressed pages decompress the page after actual read
diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h
index 1c4ac8152c9..974de9c75ed 100644
--- a/storage/innobase/include/fsp0file.h
+++ b/storage/innobase/include/fsp0file.h
@@ -54,7 +54,7 @@ public:
m_name(),
m_filepath(),
m_filename(),
- m_handle(OS_FILE_CLOSED),
+ m_handle(),
m_open_flags(OS_FILE_OPEN),
m_size(),
m_order(),
@@ -77,7 +77,7 @@ public:
m_name(mem_strdup(name)),
m_filepath(),
m_filename(),
- m_handle(OS_FILE_CLOSED),
+ m_handle(),
m_open_flags(OS_FILE_OPEN),
m_size(size),
m_order(order),
@@ -274,7 +274,7 @@ public:
/** Get Datafile::m_handle.
@return m_handle */
- os_file_t handle() const
+ pfs_os_file_t handle() const
{
return(m_handle);
}
@@ -416,7 +416,7 @@ private:
char* m_filename;
/** Open file handle */
- os_file_t m_handle;
+ pfs_os_file_t m_handle;
/** Flags to use for opening the data file */
os_file_create_t m_open_flags;
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index f6fee72300c..63fc211c88d 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -397,18 +397,12 @@ fsp_header_init_fields(
ulint space_id, /*!< in: space id */
ulint flags); /*!< in: tablespace flags (FSP_SPACE_FLAGS):
0, or table->flags if newer than COMPACT */
-
-/** Initializes the space header of a new created space and creates also the
-insert buffer tree root if space == 0.
+/** Initialize a tablespace header.
@param[in] space_id space id
@param[in] size current size in blocks
-@param[in,out] mtr min-transaction
-@return true on success, otherwise false. */
-bool
-fsp_header_init(
- ulint space_id,
- ulint size,
- mtr_t* mtr);
+@param[in,out] mtr mini-transaction */
+void
+fsp_header_init(ulint space_id, ulint size, mtr_t* mtr);
/**********************************************************************//**
Increases the space size field of a space. */
diff --git a/storage/innobase/include/fts0priv.h b/storage/innobase/include/fts0priv.h
index 80ebcf09d6d..f9d5d07a44c 100644
--- a/storage/innobase/include/fts0priv.h
+++ b/storage/innobase/include/fts0priv.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -215,13 +216,10 @@ fts_write_node(
fts_node_t* node) /*!< in: node columns */
MY_ATTRIBUTE((warn_unused_result));
-/** Check fts token
-1. for ngram token, check whether the token contains any words in stopwords
-2. for non-ngram token, check if it's stopword or less than fts_min_token_size
+/** Check if a fts token is a stopword or less than fts_min_token_size
or greater than fts_max_token_size.
@param[in] token token string
@param[in] stopwords stopwords rb tree
-@param[in] is_ngram is ngram parser
@param[in] cs token charset
@retval true if it is not stopword and length in range
@retval false if it is stopword or length not in range */
@@ -229,7 +227,6 @@ bool
fts_check_token(
const fts_string_t* token,
const ib_rbt_t* stopwords,
- bool is_ngram,
const CHARSET_INFO* cs);
/******************************************************************//**
diff --git a/storage/innobase/include/fts0types.h b/storage/innobase/include/fts0types.h
index c1db160602f..55a698e8b66 100644
--- a/storage/innobase/include/fts0types.h
+++ b/storage/innobase/include/fts0types.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -277,8 +277,6 @@ struct fts_doc_t {
st_mysql_ftparser* parser; /*!< fts plugin parser */
- bool is_ngram; /*!< Whether it is a ngram parser */
-
ib_rbt_t* stopwords; /*!< Stopwords */
};
diff --git a/storage/innobase/include/fts0types.ic b/storage/innobase/include/fts0types.ic
index 417a1010919..a8712751412 100644
--- a/storage/innobase/include/fts0types.ic
+++ b/storage/innobase/include/fts0types.ic
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -115,19 +116,14 @@ bool
fts_is_charset_cjk(
const CHARSET_INFO* cs)
{
- if (strcmp(cs->name, "gb2312_chinese_ci") == 0
- || strcmp(cs->name, "gbk_chinese_ci") == 0
- || strcmp(cs->name, "big5_chinese_ci") == 0
- || strcmp(cs->name, "gb18030_chinese_ci") == 0
- || strcmp(cs->name, "ujis_japanese_ci") == 0
- || strcmp(cs->name, "sjis_japanese_ci") == 0
- || strcmp(cs->name, "cp932_japanese_ci") == 0
- || strcmp(cs->name, "eucjpms_japanese_ci") == 0
- || strcmp(cs->name, "euckr_korean_ci") == 0) {
- return(true);
- } else {
- return(false);
- }
+ return cs == &my_charset_gb2312_chinese_ci
+ || cs == &my_charset_gbk_chinese_ci
+ || cs == &my_charset_big5_chinese_ci
+ || cs == &my_charset_ujis_japanese_ci
+ || cs == &my_charset_sjis_japanese_ci
+ || cs == &my_charset_cp932_japanese_ci
+ || cs == &my_charset_eucjpms_japanese_ci
+ || cs == &my_charset_euckr_korean_ci;
}
/** Select the FTS auxiliary index for the given character by range.
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h
index e718189062d..b3de1bf27f2 100644
--- a/storage/innobase/include/lock0lock.h
+++ b/storage/innobase/include/lock0lock.h
@@ -303,32 +303,6 @@ lock_rec_insert_check_and_lock(
MY_ATTRIBUTE((warn_unused_result));
/*********************************************************************//**
-Enqueues a waiting request for a lock which cannot be granted immediately.
-Checks for deadlocks.
-@return DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED, or
-DB_SUCCESS_LOCKED_REC; DB_SUCCESS_LOCKED_REC means that
-there was a deadlock, but another transaction was chosen as a victim,
-and we got the lock immediately: no need to wait then */
-dberr_t
-lock_rec_enqueue_waiting(
-/*=====================*/
- ulint type_mode,/*!< in: lock mode this
- transaction is requesting:
- LOCK_S or LOCK_X, possibly
- ORed with LOCK_GAP or
- LOCK_REC_NOT_GAP, ORed with
- LOCK_INSERT_INTENTION if this
- waiting lock request is set
- when performing an insert of
- an index record */
- const buf_block_t* block, /*!< in: buffer block containing
- the record */
- ulint heap_no,/*!< in: heap number of the record */
- dict_index_t* index, /*!< in: index of record */
- que_thr_t* thr, /*!< in: query thread */
- lock_prdt_t* prdt); /*!< in: Minimum Bounding Box */
-
-/*********************************************************************//**
Checks if locks of other transactions prevent an immediate modify (update,
delete mark, or delete unmark) of a clustered index record. If they do,
first tests if the query thread should anyway be suspended for some
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
index d1aae64227e..05e53e23f28 100644
--- a/storage/innobase/include/log0log.h
+++ b/storage/innobase/include/log0log.h
@@ -151,24 +151,24 @@ UNIV_INLINE
lsn_t
log_get_max_modified_age_async(void);
/*================================*/
-/******************************************************//**
-Initializes the log. */
+/** Initializes the redo logging subsystem. */
void
-log_init(void);
-/*==========*/
-/******************************************************************//**
-Inits a log group to the log system.
-@return true if success, false if not */
-MY_ATTRIBUTE((warn_unused_result))
+log_sys_init();
+
+/** Initialize the redo log.
+@param[in] n_files number of files
+@param[in] file_size file size in bytes */
+void
+log_init(ulint n_files, lsn_t file_size);
+/** Calculate the recommended highest values for lsn - last_checkpoint_lsn
+and lsn - buf_get_oldest_modification().
+@retval true on success
+@retval false if the smallest log group is too small to
+accommodate the number of OS threads in the database server */
bool
-log_group_init(
-/*===========*/
- ulint id, /*!< in: group id */
- ulint n_files, /*!< in: number of log files */
- lsn_t file_size, /*!< in: log file size in bytes */
- ulint space_id); /*!< in: space id of the file space
- which contains the log files of this
- group */
+log_set_capacity()
+ MY_ATTRIBUTE((warn_unused_result));
+
/******************************************************//**
Completes an i/o to a log file. */
void
@@ -552,16 +552,12 @@ Currently, this is only protected by log_sys->mutex. However, in the case
of log_write_up_to(), we will access some members only with the protection
of log_sys->write_mutex, which should affect nothing for now. */
struct log_group_t{
- /** log group identifier (always 0) */
- ulint id;
/** number of files in the group */
ulint n_files;
/** format of the redo log: e.g., LOG_HEADER_FORMAT_CURRENT */
ulint format;
/** individual log file size in bytes, including the header */
- lsn_t file_size
- /** file space which implements the log group */;
- ulint space_id;
+ lsn_t file_size;
/** corruption status */
log_group_state_t state;
/** lsn used to fix coordinates within the log group */
@@ -580,8 +576,6 @@ struct log_group_t{
byte* checkpoint_buf_ptr;
/** buffer for writing a checkpoint header */
byte* checkpoint_buf;
- /** list of log groups */
- UT_LIST_NODE_T(log_group_t) log_groups;
/** @return whether the redo log is encrypted */
bool is_encrypted() const
@@ -639,8 +633,8 @@ struct log_t{
max_checkpoint_age; this flag is
peeked at by log_free_check(), which
does not reserve the log mutex */
- UT_LIST_BASE_NODE_T(log_group_t)
- log_groups; /*!< log groups */
+ /** the redo log */
+ log_group_t log;
/** The fields involved in the log buffer flush @{ */
@@ -729,7 +723,7 @@ struct log_t{
/** @return whether the redo log is encrypted */
bool is_encrypted() const
{
- return(UT_LIST_GET_FIRST(log_groups)->is_encrypted());
+ return(log.is_encrypted());
}
};
diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h
index 74ea6c95036..784699279d4 100644
--- a/storage/innobase/include/log0recv.h
+++ b/storage/innobase/include/log0recv.h
@@ -41,6 +41,13 @@ Created 9/20/1997 Heikki Tuuri
/** @return whether recovery is currently running. */
#define recv_recovery_is_on() recv_recovery_on
+/** Find the latest checkpoint in the log header.
+@param[out] max_field LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2
+@return error code or DB_SUCCESS */
+dberr_t
+recv_find_max_checkpoint(ulint* max_field)
+ MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/** Apply the hashed log records to the page, if the page lsn is less than the
lsn of a log record.
@param just_read_in whether the page recently arrived to the I/O handler
diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic
index 34d375aa1e8..c89e4960480 100644
--- a/storage/innobase/include/mach0data.ic
+++ b/storage/innobase/include/mach0data.ic
@@ -827,13 +827,13 @@ mach_swap_byte_order(
dest += len;
switch (len & 0x7) {
- case 0: *--dest = *from++;
- case 7: *--dest = *from++;
- case 6: *--dest = *from++;
- case 5: *--dest = *from++;
- case 4: *--dest = *from++;
- case 3: *--dest = *from++;
- case 2: *--dest = *from++;
+ case 0: *--dest = *from++; /* fall through */
+ case 7: *--dest = *from++; /* fall through */
+ case 6: *--dest = *from++; /* fall through */
+ case 5: *--dest = *from++; /* fall through */
+ case 4: *--dest = *from++; /* fall through */
+ case 3: *--dest = *from++; /* fall through */
+ case 2: *--dest = *from++; /* fall through */
case 1: *--dest = *from;
}
}
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index e3396a4b7f7..b3a70edf8be 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -1,6 +1,6 @@
/***********************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2017, MariaDB Corporation.
@@ -90,6 +90,30 @@ typedef int os_file_t;
static const os_file_t OS_FILE_CLOSED = os_file_t(~0);
+/** File descriptor with optional PERFORMANCE_SCHEMA instrumentation */
+struct pfs_os_file_t
+{
+ /** Default constructor */
+ pfs_os_file_t(os_file_t file = OS_FILE_CLOSED) : m_file(file)
+#ifdef UNIV_PFS_IO
+ , m_psi(NULL)
+#endif
+ {}
+
+ /** The wrapped file handle */
+ os_file_t m_file;
+#ifdef UNIV_PFS_IO
+ /** PERFORMANCE_SCHEMA descriptor */
+ struct PSI_file *m_psi;
+#endif
+ /** Implicit type conversion.
+ @return the wrapped file handle */
+ operator os_file_t() const { return m_file; }
+ /** Assignment operator.
+ @param[in] file file handle to be assigned */
+ void operator=(os_file_t file) { m_file = file; }
+};
+
/** The next value should be smaller or equal to the smallest sector size used
on any disk. A log block is required to be a portion of disk which is written
so that if the start and the end of a block get written to disk, then the
@@ -585,7 +609,7 @@ A simple function to open or create a file.
@param[out] success true if succeed, false if error
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
-os_file_t
+pfs_os_file_t
os_file_create_simple_func(
const char* name,
ulint create_mode,
@@ -605,7 +629,7 @@ A simple function to open or create a file.
@param[out] success true if succeeded
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
-os_file_t
+pfs_os_file_t
os_file_create_simple_no_error_handling_func(
const char* name,
ulint create_mode,
@@ -643,7 +667,7 @@ Opens an existing file or creates a new.
@param[in] success true if succeeded
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
-os_file_t
+pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
@@ -696,6 +720,8 @@ extern mysql_pfs_key_t innodb_temp_file_key;
various file I/O operations with performance schema.
1) register_pfs_file_open_begin() and register_pfs_file_open_end() are
used to register file creation, opening, closing and renaming.
+2) register_pfs_file_rename_begin() and register_pfs_file_rename_end()
+are used to register file renaming
2) register_pfs_file_io_begin() and register_pfs_file_io_end() are
used to register actual file read, write and flush
3) register_pfs_file_close_begin() and register_pfs_file_close_end()
@@ -711,11 +737,23 @@ do { \
} \
} while (0)
-# define register_pfs_file_open_end(locker, file) \
+# define register_pfs_file_open_end(locker, file, result) \
do { \
if (locker != NULL) { \
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(\
- locker, file); \
+ file.m_psi = PSI_FILE_CALL(end_file_open_wait)( \
+ locker, result); \
+ } \
+} while (0)
+
+# define register_pfs_file_rename_begin(state, locker, key, op, name, \
+ src_file, src_line) \
+ register_pfs_file_open_begin(state, locker, key, op, name, \
+ src_file, src_line) \
+
+# define register_pfs_file_rename_end(locker, result) \
+do { \
+ if (locker != NULL) { \
+ PSI_FILE_CALL(end_file_open_wait)(locker, result); \
} \
} while (0)
@@ -741,8 +779,8 @@ do { \
# define register_pfs_file_io_begin(state, locker, file, count, op, \
src_file, src_line) \
do { \
- locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)( \
- state, file, op); \
+ locker = PSI_FILE_CALL(get_thread_file_stream_locker)( \
+ state, file.m_psi, op); \
if (locker != NULL) { \
PSI_FILE_CALL(start_file_wait)( \
locker, count, src_file, src_line); \
@@ -768,7 +806,9 @@ os_file_rename
os_aio
os_file_read
os_file_read_no_error_handling
+os_file_read_no_error_handling_int_fd
os_file_write
+os_file_write_int_fd
The wrapper functions have the prefix of "innodb_". */
@@ -804,11 +844,19 @@ The wrapper functions have the prefix of "innodb_". */
pfs_os_file_read_no_error_handling_func( \
type, file, buf, offset, n, o, __FILE__, __LINE__)
+# define os_file_read_no_error_handling_int_fd(type, file, buf, offset, n) \
+ pfs_os_file_read_no_error_handling_int_fd_func( \
+ type, file, buf, offset, n, __FILE__, __LINE__)
+
# define os_file_write(type, name, file, buf, offset, n) \
pfs_os_file_write_func(type, name, file, buf, offset, \
- n,__FILE__, __LINE__)
+ n, __FILE__, __LINE__)
+
+# define os_file_write_int_fd(type, name, file, buf, offset, n) \
+ pfs_os_file_write_int_fd_func(type, name, file, buf, offset, \
+ n, __FILE__, __LINE__)
-# define os_file_flush(file) \
+# define os_file_flush(file) \
pfs_os_file_flush_func(file, __FILE__, __LINE__)
# define os_file_rename(key, oldpath, newpath) \
@@ -836,7 +884,7 @@ os_file_create_simple() which opens or creates a file.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
@@ -867,7 +915,7 @@ monitor file creation/open.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
@@ -900,7 +948,7 @@ Add instrumentation to monitor file creation/open.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
@@ -923,7 +971,7 @@ A performance schema instrumented wrapper function for os_file_close().
UNIV_INLINE
bool
pfs_os_file_close_func(
- os_file_t file,
+ pfs_os_file_t file,
const char* src_file,
uint src_line);
@@ -943,7 +991,7 @@ UNIV_INLINE
dberr_t
pfs_os_file_read_func(
IORequest& type,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -968,7 +1016,7 @@ UNIV_INLINE
dberr_t
pfs_os_file_read_no_error_handling_func(
IORequest& type,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -1004,7 +1052,7 @@ pfs_os_aio_func(
IORequest& type,
ulint mode,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -1033,7 +1081,7 @@ dberr_t
pfs_os_file_write_func(
IORequest& type,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
const void* buf,
os_offset_t offset,
ulint n,
@@ -1052,7 +1100,7 @@ Flushes the write buffers of a given file to the disk.
UNIV_INLINE
bool
pfs_os_file_flush_func(
- os_file_t file,
+ pfs_os_file_t file,
const char* src_file,
uint src_line);
@@ -1144,9 +1192,12 @@ to original un-instrumented file I/O APIs */
# define os_file_read_no_error_handling(type, file, buf, offset, n, o) \
os_file_read_no_error_handling_func(type, file, buf, offset, n, o)
+# define os_file_read_no_error_handling_int_fd(type, file, buf, offset, n) \
+ os_file_read_no_error_handling_func(type, file, buf, offset, n, NULL)
# define os_file_write(type, name, file, buf, offset, n) \
os_file_write_func(type, name, file, buf, offset, n)
+# define os_file_write_int_fd os_file_write_func
# define os_file_flush(file) os_file_flush_func(file)
@@ -1402,7 +1453,7 @@ os_aio_func(
IORequest& type,
ulint mode,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -1538,19 +1589,6 @@ os_is_sparse_file_supported(
@return DB_SUCCESS or error code */
dberr_t
os_file_punch_hole(
- IORequest& type,
- os_file_t fh,
- os_offset_t off,
- os_offset_t len)
- MY_ATTRIBUTE((warn_unused_result));
-
-/** Free storage space associated with a section of the file.
-@param[in] fh Open file handle
-@param[in] off Starting offset (SEEK_SET)
-@param[in] len Size of the hole
-@return DB_SUCCESS or error code */
-dberr_t
-os_file_punch_hole(
os_file_t fh,
os_offset_t off,
os_offset_t len)
diff --git a/storage/innobase/include/os0file.ic b/storage/innobase/include/os0file.ic
index 807d3254b9d..07c2b6212ed 100644
--- a/storage/innobase/include/os0file.ic
+++ b/storage/innobase/include/os0file.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
@@ -43,7 +43,7 @@ os_file_create_simple() which opens or creates a file.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
@@ -64,11 +64,12 @@ pfs_os_file_create_simple_func(
? PSI_FILE_CREATE : PSI_FILE_OPEN,
name, src_file, src_line);
- os_file_t file = os_file_create_simple_func(
+ pfs_os_file_t file = os_file_create_simple_func(
name, create_mode, access_type, read_only, success);
- /* Regsiter the returning "file" value with the system */
- register_pfs_file_open_end(locker, file);
+ /* Register psi value for the file */
+ register_pfs_file_open_end(locker, file,
+ (*success == TRUE ? success : 0));
return(file);
}
@@ -92,7 +93,7 @@ monitor file creation/open.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
@@ -113,10 +114,11 @@ pfs_os_file_create_simple_no_error_handling_func(
? PSI_FILE_CREATE : PSI_FILE_OPEN,
name, src_file, src_line);
- os_file_t file = os_file_create_simple_no_error_handling_func(
+ pfs_os_file_t file = os_file_create_simple_no_error_handling_func(
name, create_mode, access_type, read_only, success);
- register_pfs_file_open_end(locker, file);
+ register_pfs_file_open_end(locker, file,
+ (*success == TRUE ? success : 0));
return(file);
}
@@ -142,7 +144,7 @@ Add instrumentation to monitor file creation/open.
@return own: handle to the file, not defined if error, error number
can be retrieved with os_file_get_last_error */
UNIV_INLINE
-os_file_t
+pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
@@ -164,10 +166,11 @@ pfs_os_file_create_func(
? PSI_FILE_CREATE : PSI_FILE_OPEN,
name, src_file, src_line);
- os_file_t file = os_file_create_func(
+ pfs_os_file_t file = os_file_create_func(
name, create_mode, purpose, type, read_only, success);
- register_pfs_file_open_end(locker, file);
+ register_pfs_file_open_end(locker, file,
+ (*success == TRUE ? success : 0));
return(file);
}
@@ -182,7 +185,7 @@ A performance schema instrumented wrapper function for os_file_close().
UNIV_INLINE
bool
pfs_os_file_close_func(
- os_file_t file,
+ pfs_os_file_t file,
const char* src_file,
uint src_line)
{
@@ -228,7 +231,7 @@ pfs_os_aio_func(
IORequest& type,
ulint mode,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -273,7 +276,7 @@ UNIV_INLINE
dberr_t
pfs_os_file_read_func(
IORequest& type,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -315,7 +318,7 @@ UNIV_INLINE
dberr_t
pfs_os_file_read_no_error_handling_func(
IORequest& type,
- os_file_t file,
+ pfs_os_file_t file,
void* buf,
os_offset_t offset,
ulint n,
@@ -337,6 +340,49 @@ pfs_os_file_read_no_error_handling_func(
return(result);
}
+/** NOTE! Please use the corresponding macro
+os_file_read_no_error_handling_int_fd() to request
+a synchronous read operation.
+@param[in,out] type read request
+@param[in] file file handle
+@param[out] buf buffer where to read
+@param[in] offset file offset where to read
+@param[in] n number of bytes to read
+@param[in] src_file caller file name
+@param[in] src_line caller line number
+@return whether the request was successful */
+UNIV_INLINE
+bool
+pfs_os_file_read_no_error_handling_int_fd_func(
+ IORequest& type,
+ int file,
+ void* buf,
+ os_offset_t offset,
+ ulint n,
+ const char* src_file,
+ uint src_line)
+{
+ PSI_file_locker_state state;
+
+ PSI_file_locker* locker = PSI_FILE_CALL(
+ get_thread_file_descriptor_locker)(
+ &state, file, PSI_FILE_READ);
+ if (locker != NULL) {
+ PSI_FILE_CALL(start_file_wait)(
+ locker, n,
+ __FILE__, __LINE__);
+ }
+ ulint fulfilled;
+ bool success = DB_SUCCESS == os_file_read_no_error_handling_func(
+ type, OS_FILE_FROM_FD(file), buf, offset, n, &fulfilled);
+
+ if (locker != NULL) {
+ PSI_FILE_CALL(end_file_wait)(locker, n);
+ }
+
+ return(success);
+}
+
/** NOTE! Please use the corresponding macro os_file_write(), not directly
this function!
This is the performance schema instrumented wrapper function for
@@ -350,13 +396,14 @@ os_file_write() which requests a synchronous write operation.
@param[in] n number of bytes to read
@param[in] src_file file name where func invoked
@param[in] src_line line where the func invoked
-@return DB_SUCCESS if request was successful */
+@return error code
+@retval DB_SUCCESS if the request was successfully fulfilled */
UNIV_INLINE
dberr_t
pfs_os_file_write_func(
IORequest& type,
const char* name,
- os_file_t file,
+ pfs_os_file_t file,
const void* buf,
os_offset_t offset,
ulint n,
@@ -378,6 +425,52 @@ pfs_os_file_write_func(
return(result);
}
+/** NOTE! Please use the corresponding macro os_file_write_int_fd(),
+not directly this function!
+This is the performance schema instrumented wrapper function for
+os_file_write_int_fd() which requests a synchronous write operation.
+@param[in,out] type write request
+@param[in] name file name
+@param[in] file file handle
+@param[in] buf buffer to write
+@param[in] offset file offset
+@param[in] n number of bytes
+@param[in] src_file file name where func invoked
+@param[in] src_line line where the func invoked
+@return whether the request was successful */
+UNIV_INLINE
+bool
+pfs_os_file_write_int_fd_func(
+ IORequest& type,
+ const char* name,
+ int file,
+ const void* buf,
+ os_offset_t offset,
+ ulint n,
+ const char* src_file,
+ uint src_line)
+{
+ PSI_file_locker_state state;
+ struct PSI_file_locker* locker;
+
+ locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(
+ &state, file, PSI_FILE_WRITE);
+ if (locker != NULL) {
+ PSI_FILE_CALL(start_file_wait)(
+ locker, n,
+ __FILE__, __LINE__);
+ }
+
+ bool success = DB_SUCCESS == os_file_write_func(
+ type, name, OS_FILE_FROM_FD(file), buf, offset, n);
+
+ if (locker != NULL) {
+ PSI_FILE_CALL(end_file_wait)(locker, n);
+ }
+
+ return(success);
+}
+
/** NOTE! Please use the corresponding macro os_file_flush(), not directly
this function!
This is the performance schema instrumented wrapper function for
@@ -390,7 +483,7 @@ Flushes the write buffers of a given file to the disk.
UNIV_INLINE
bool
pfs_os_file_flush_func(
- os_file_t file,
+ pfs_os_file_t file,
const char* src_file,
uint src_line)
{
@@ -436,7 +529,7 @@ pfs_os_file_rename_func(
bool result = os_file_rename_func(oldpath, newpath);
- register_pfs_file_open_end(locker, 0);
+ register_pfs_file_rename_end(locker, 0);
return(result);
}
diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h
index 6f521b5a2ec..071e7422894 100644
--- a/storage/innobase/include/os0thread.h
+++ b/storage/innobase/include/os0thread.h
@@ -151,23 +151,10 @@ os_thread_sleep(
/*============*/
ulint tm); /*!< in: time in microseconds */
-/**
-Initializes OS thread management data structures. */
-void
-os_thread_init();
-/*============*/
-
-/**
-Frees OS thread management data structures. */
-void
-os_thread_free();
-/*============*/
-
/*****************************************************************//**
Check if there are threads active.
@return true if the thread count > 0. */
bool
os_thread_active();
-/*==============*/
#endif
diff --git a/storage/innobase/include/page0zip.ic b/storage/innobase/include/page0zip.ic
index 5f754e1f993..fa03279f9bc 100644
--- a/storage/innobase/include/page0zip.ic
+++ b/storage/innobase/include/page0zip.ic
@@ -164,7 +164,8 @@ page_zip_rec_needs_ext(
ulint n_fields,
const page_size_t& page_size)
{
- ut_ad(rec_size > comp ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES);
+ ut_ad(rec_size
+ > ulint(comp ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES));
ut_ad(comp || !page_size.is_compressed());
#if UNIV_PAGE_SIZE_MAX > REC_MAX_DATA_SIZE
diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h
index 245fefae944..216e3a7655b 100644
--- a/storage/innobase/include/rem0cmp.h
+++ b/storage/innobase/include/rem0cmp.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -62,7 +63,7 @@ cmp_data_data(
ulint len1,
const byte* data2,
ulint len2)
- MY_ATTRIBUTE((nonnull, warn_unused_result));
+ MY_ATTRIBUTE((warn_unused_result));
/** Compare two data fields.
@param[in] dfield1 data field; must have type field set
diff --git a/storage/innobase/include/row0merge.h b/storage/innobase/include/row0merge.h
index 1b61c475c6f..50c3361a3f9 100644
--- a/storage/innobase/include/row0merge.h
+++ b/storage/innobase/include/row0merge.h
@@ -129,7 +129,6 @@ struct index_def_t {
index_field_t* fields; /*!< field definitions */
st_mysql_ftparser*
parser; /*!< fulltext parser plugin */
- bool is_ngram; /*!< true if it's ngram parser */
};
/** Structure for reporting duplicate records. */
@@ -195,7 +194,7 @@ row_merge_drop_temp_indexes(void);
/** Create temporary merge files in the given paramater path, and if
UNIV_PFS_IO defined, register the file descriptor with Performance Schema.
-@param[in] path location for creating temporary merge files.
+@param[in] path location for creating temporary merge files, or NULL
@return File descriptor */
int
row_merge_file_create_low(
@@ -398,13 +397,13 @@ row_merge_buf_empty(
/** Create a merge file in the given location.
@param[out] merge_file merge file structure
-@param[in] path location for creating temporary file
+@param[in] path location for creating temporary file, or NULL
@return file descriptor, or -1 on failure */
int
row_merge_file_create(
merge_file_t* merge_file,
const char* path)
- MY_ATTRIBUTE((warn_unused_result, nonnull));
+ MY_ATTRIBUTE((warn_unused_result, nonnull(1)));
/** Merge disk files.
@param[in] trx transaction
@@ -464,10 +463,9 @@ row_merge_file_destroy(
merge_file_t* merge_file) /*!< in/out: merge file structure */
MY_ATTRIBUTE((nonnull));
-/********************************************************************//**
-Read a merge block from the file system.
-@return TRUE if request was successful, FALSE if fail */
-ibool
+/** Read a merge block from the file system.
+@return whether the request was successful */
+bool
row_merge_read(
/*===========*/
int fd, /*!< in: file descriptor */
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index 7507c96ea5f..6164366628e 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -204,6 +204,7 @@ row_update_prebuilt_trx(
row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct
in MySQL handle */
trx_t* trx); /*!< in: transaction handle */
+
/*********************************************************************//**
Sets an AUTO_INC type lock on the table mentioned in prebuilt. The
AUTO_INC lock gives exclusive access to the auto-inc counter of the
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 9d8e736beb1..8f0df34af74 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2017, MariaDB Corporation.
diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h
index 4f2f4a312ff..47b42725541 100644
--- a/storage/innobase/include/srv0start.h
+++ b/storage/innobase/include/srv0start.h
@@ -1,7 +1,7 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation
+Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -38,43 +38,20 @@ struct dict_table_t;
only one buffer pool instance is used. */
#define BUF_POOL_SIZE_THRESHOLD (1024 * 1024 * 1024)
-/*********************************************************************//**
-Parse temporary tablespace configuration.
-@return true if ok, false on parse error */
-bool
-srv_parse_temp_data_file_paths_and_sizes(
-/*=====================================*/
- char* str); /*!< in/out: the data file path string */
-/*********************************************************************//**
-Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
-and srv_parse_log_group_home_dirs(). */
-void
-srv_free_paths_and_sizes(void);
-/*==========================*/
-/*********************************************************************//**
-Adds a slash or a backslash to the end of a string if it is missing
-and the string is not empty.
-@return string which has the separator if the string is not empty */
-char*
-srv_add_path_separator_if_needed(
-/*=============================*/
- char* str); /*!< in: null-terminated character string */
-
/****************************************************************//**
Starts Innobase and creates a new database if database files
are not found and the user wants.
@return DB_SUCCESS or error code */
dberr_t
-innobase_start_or_create_for_mysql(void);
-/*====================================*/
+innobase_start_or_create_for_mysql();
+
/** Shut down InnoDB. */
void
innodb_shutdown();
-/****************************************************************//**
-Shuts down background threads that can generate undo pages. */
+/** Shut down background threads that can generate undo log. */
void
-srv_shutdown_bg_undo_sources(void);
+srv_shutdown_bg_undo_sources();
/*************************************************************//**
Copy the file path component of the physical file to parameter. It will
@@ -128,6 +105,22 @@ extern bool srv_startup_is_before_trx_rollback_phase;
/** TRUE if a raw partition is in use */
extern ibool srv_start_raw_disk_in_use;
+/** Undo tablespaces starts with space_id. */
+extern ulint srv_undo_space_id_start;
+
+/** 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)
+{
+ return srv_undo_space_id_start > 0
+ && space_id >= srv_undo_space_id_start
+ && space_id < (srv_undo_space_id_start
+ + srv_undo_tablespaces_open);
+}
+
/** Shutdown state */
enum srv_shutdown_t {
SRV_SHUTDOWN_NONE = 0, /*!< Database running normally */
@@ -144,6 +137,9 @@ enum srv_shutdown_t {
SRV_SHUTDOWN_EXIT_THREADS/*!< Exit all threads */
};
+/** Whether any undo log records can be generated */
+extern bool srv_undo_sources;
+
/** At a shutdown this value climbs from SRV_SHUTDOWN_NONE to
SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */
extern enum srv_shutdown_t srv_shutdown_state;
diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h
index c3d413e71df..ec4503daa64 100644
--- a/storage/innobase/include/sync0types.h
+++ b/storage/innobase/include/sync0types.h
@@ -354,7 +354,6 @@ enum latch_id_t {
LATCH_ID_EVENT_MANAGER,
LATCH_ID_EVENT_MUTEX,
LATCH_ID_SYNC_ARRAY_MUTEX,
- LATCH_ID_THREAD_MUTEX,
LATCH_ID_ZIP_PAD_MUTEX,
LATCH_ID_OS_AIO_READ_MUTEX,
LATCH_ID_OS_AIO_WRITE_MUTEX,
@@ -1284,7 +1283,10 @@ struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter
{
compile_time_assert(!atomic || sizeof(Type) == sizeof(lint));
if (atomic) {
- return Type(my_atomic_addlint(&m_counter, i));
+ /* Silence MSVS warnings when instantiating
+ this template with atomic=false. */
+ return Type(my_atomic_addlint(reinterpret_cast<lint*>
+ (&m_counter), i));
} else {
return m_counter += i;
}
diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h
index 50304ce3631..3b4a195735b 100644
--- a/storage/innobase/include/trx0rec.h
+++ b/storage/innobase/include/trx0rec.h
@@ -188,28 +188,28 @@ transaction.
dberr_t
trx_undo_report_row_operation(
/*==========================*/
- ulint flags, /*!< in: if BTR_NO_UNDO_LOG_FLAG bit is
- set, does nothing */
- ulint op_type, /*!< in: TRX_UNDO_INSERT_OP or
- TRX_UNDO_MODIFY_OP */
que_thr_t* thr, /*!< in: query thread */
dict_index_t* index, /*!< in: clustered index */
const dtuple_t* clust_entry, /*!< in: in the case of an insert,
index entry to insert into the
- clustered index, otherwise NULL */
+ clustered index; in updates,
+ may contain a clustered index
+ record tuple that also contains
+ virtual columns of the table;
+ otherwise, NULL */
const upd_t* update, /*!< in: in the case of an update,
the update vector, otherwise NULL */
ulint cmpl_info, /*!< in: compiler info on secondary
index updates */
const rec_t* rec, /*!< in: case of an update or delete
marking, the record in the clustered
- index, otherwise NULL */
+ index; NULL if insert */
const ulint* offsets, /*!< in: rec_get_offsets(rec) */
roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the
inserted undo log record,
0 if BTR_NO_UNDO_LOG
flag was specified */
- MY_ATTRIBUTE((nonnull(3,4,10), warn_unused_result));
+ MY_ATTRIBUTE((nonnull(1,2,8), warn_unused_result));
/** status bit used for trx_undo_prev_version_build() */
@@ -341,10 +341,6 @@ record */
storage fields: used by purge to
free the external storage */
-/* Operation type flags used in trx_undo_report_row_operation */
-#define TRX_UNDO_INSERT_OP 1U
-#define TRX_UNDO_MODIFY_OP 2U
-
#include "trx0rec.ic"
#endif /* trx0rec_h */
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index 4c162526384..3078aa8faf1 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -110,9 +110,12 @@ void
trx_rseg_mem_free(trx_rseg_t* rseg);
/** Create a persistent rollback segment.
-@param[in] space_id system or undo tablespace id */
+@param[in] space_id system or undo tablespace id
+@return pointer to new rollback segment
+@retval NULL on failure */
trx_rseg_t*
-trx_rseg_create(ulint space_id);
+trx_rseg_create(ulint space_id)
+ MY_ATTRIBUTE((warn_unused_result));
/** Create the temporary rollback segments. */
void
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 75753b53467..6274dec9f9d 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2017, MariaDB Corporation.
+Copyright (c) 2015, 2017, 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
diff --git a/storage/innobase/include/trx0xa.h b/storage/innobase/include/trx0xa.h
index b333f32cd73..4d5adc68dcd 100644
--- a/storage/innobase/include/trx0xa.h
+++ b/storage/innobase/include/trx0xa.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
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
@@ -24,12 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#ifndef XA_H
#define XA_H
-/* Missing MySQL 5.7 header */
-#ifdef HAVE_XA_H
-#include "xa.h"
-#else
#include "handler.h"
-#endif
/*
* Transaction branch identification: XID and NULLXID:
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index ee759534301..88c13be5a8f 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -41,7 +41,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 7
-#define INNODB_VERSION_BUGFIX 14
+#define INNODB_VERSION_BUGFIX 18
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
@@ -121,14 +121,7 @@ HAVE_PSI_INTERFACE is defined. */
#ifdef HAVE_PSI_INTERFACE
# define UNIV_PFS_MUTEX
# define UNIV_PFS_RWLOCK
-/* For I/O instrumentation, performance schema rely
-on a native descriptor to identify the file, this
-descriptor could conflict with our OS level descriptor.
-Disable IO instrumentation on Windows until this is
-resolved */
-# ifndef _WIN32
-# define UNIV_PFS_IO
-# endif
+# define UNIV_PFS_IO
# define UNIV_PFS_THREAD
// JAN: TODO: MySQL 5.7 PSI
@@ -191,9 +184,9 @@ command. */
#define UNIV_ENABLE_UNIT_TEST_ROW_RAW_FORMAT_INT
*/
-#if defined HAVE_valgrind && defined HAVE_VALGRIND
+#if defined HAVE_valgrind && defined HAVE_VALGRIND_MEMCHECK_H
# define UNIV_DEBUG_VALGRIND
-#endif /* HAVE_VALGRIND */
+#endif
#ifdef DBUG_OFF
# undef UNIV_DEBUG
diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h
index 5a9022e8a77..955e7b026c7 100644
--- a/storage/innobase/include/ut0new.h
+++ b/storage/innobase/include/ut0new.h
@@ -235,8 +235,10 @@ struct ut_new_pfx_t {
#endif
};
-/** Allocator class for allocating memory from inside std::* containers. */
-template <class T>
+/** Allocator class for allocating memory from inside std::* containers.
+@tparam T type of allocated object
+@tparam oom_fatal whether to commit suicide when running out of memory */
+template <class T, bool oom_fatal = true>
class ut_allocator {
public:
typedef T* pointer;
@@ -249,13 +251,10 @@ public:
/** Default constructor. */
explicit
- ut_allocator(
- PSI_memory_key key = PSI_NOT_INSTRUMENTED)
- :
+ ut_allocator(PSI_memory_key key = PSI_NOT_INSTRUMENTED)
#ifdef UNIV_PFS_MEMORY
- m_key(key),
+ : m_key(key)
#endif /* UNIV_PFS_MEMORY */
- m_oom_fatal(true)
{
}
@@ -263,30 +262,10 @@ public:
template <class U>
ut_allocator(
const ut_allocator<U>& other)
- : m_oom_fatal(other.is_oom_fatal())
- {
#ifdef UNIV_PFS_MEMORY
- const PSI_memory_key other_key = other.get_mem_key(NULL);
-
- m_key = (other_key != mem_key_std)
- ? other_key
- : PSI_NOT_INSTRUMENTED;
+ : m_key(other.m_key)
#endif /* UNIV_PFS_MEMORY */
- }
-
- /** When out of memory (OOM) happens, report error and do not
- make it fatal.
- @return a reference to the allocator. */
- ut_allocator&
- set_oom_not_fatal() {
- m_oom_fatal = false;
- return(*this);
- }
-
- /** Check if allocation failure is a fatal error.
- @return true if allocation failure is fatal, false otherwise. */
- bool is_oom_fatal() const {
- return(m_oom_fatal);
+ {
}
/** Return the maximum number of objects that can be allocated by
@@ -364,7 +343,7 @@ public:
}
if (ptr == NULL) {
- ib::fatal_or_error(m_oom_fatal)
+ ib::fatal_or_error(oom_fatal)
<< "Cannot allocate " << total_bytes
<< " bytes of memory after "
<< alloc_max_retries << " retries over "
@@ -499,14 +478,13 @@ public:
}
if (pfx_new == NULL) {
- ib::fatal_or_error(m_oom_fatal)
+ ib::fatal_or_error(oom_fatal)
<< "Cannot reallocate " << total_bytes
<< " bytes of memory after "
<< alloc_max_retries << " retries over "
<< alloc_max_retries << " seconds. OS error: "
<< strerror(errno) << " (" << errno << "). "
<< OUT_OF_MEMORY_MSG;
- /* not reached */
return(NULL);
}
@@ -739,10 +717,6 @@ private:
void
operator=(
const ut_allocator<U>&);
-
- /** A flag to indicate whether out of memory (OOM) error is considered
- fatal. If true, it is fatal. */
- bool m_oom_fatal;
};
/** Compare two allocators of the same type.
@@ -882,9 +856,8 @@ ut_delete_array(
n_bytes, NULL, __FILE__, true, false))
#define ut_zalloc_nokey_nofatal(n_bytes) static_cast<void*>( \
- ut_allocator<byte>(PSI_NOT_INSTRUMENTED). \
- set_oom_not_fatal(). \
- allocate(n_bytes, NULL, __FILE__, true, false))
+ ut_allocator<byte, false>(PSI_NOT_INSTRUMENTED).allocate( \
+ n_bytes, NULL, __FILE__, true, false))
#define ut_realloc(ptr, n_bytes) static_cast<void*>( \
ut_allocator<byte>(PSI_NOT_INSTRUMENTED).reallocate( \
diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic
index 503c9482ea3..16dccb545d8 100644
--- a/storage/innobase/include/ut0rnd.ic
+++ b/storage/innobase/include/ut0rnd.ic
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -217,16 +218,22 @@ ut_fold_binary(
switch (len & 0x7) {
case 7:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
+ /* fall through */
case 6:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
+ /* fall through */
case 5:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
+ /* fall through */
case 4:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
+ /* fall through */
case 3:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
+ /* fall through */
case 2:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
+ /* fall through */
case 1:
fold = ut_fold_ulint_pair(fold, (ulint)(*str++));
}