summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-03-27 16:31:10 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-03-29 22:02:05 +0300
commit4cad42392a2c498a2be92a77b21b1ec4027c9ea9 (patch)
treeb1f652d9f6488acb87d5cb206a2867f84124ee4c /storage/innobase/include
parentc02c329a8e9e024c1dc2399284b29a13d8d85783 (diff)
downloadmariadb-git-4cad42392a2c498a2be92a77b21b1ec4027c9ea9.tar.gz
MDEV-12266: Change dict_table_t::space to fil_space_t*
InnoDB always keeps all tablespaces in the fil_system cache. The fil_system.LRU is only for closing file handles; the fil_space_t and fil_node_t for all data files will remain in main memory. Between startup to shutdown, they can only be created and removed by DDL statements. Therefore, we can let dict_table_t::space point directly to the fil_space_t. dict_table_t::space_id: A numeric tablespace ID for the corner cases where we do not have a tablespace. The most prominent examples are ALTER TABLE...DISCARD TABLESPACE or a missing or corrupted file. There are a few functional differences; most notably: (1) DROP TABLE will delete matching .ibd and .cfg files, even if they were not attached to the data dictionary. (2) Some error messages will report file names instead of numeric IDs. There still are many functions that use numeric tablespace IDs instead of fil_space_t*, and many functions could be converted to fil_space_t member functions. Also, Tablespace and Datafile should be merged with fil_space_t and fil_node_t. page_id_t and buf_page_get_gen() could use fil_space_t& instead of a numeric ID, and after moving to a single buffer pool (MDEV-15058), buf_pool_t::page_hash could be moved to fil_space_t::page_hash. FilSpace: Remove. Only few calls to fil_space_acquire() will remain, and gradually they should be removed. mtr_t::set_named_space_id(ulint): Renamed from set_named_space(), to prevent accidental calls to this slower function. Very few callers remain. fseg_create(), fsp_reserve_free_extents(): Take fil_space_t* as a parameter instead of a space_id. fil_space_t::rename(): Wrapper for fil_rename_tablespace_check(), fil_name_write_rename(), fil_rename_tablespace(). Mariabackup passes the parameter log=false; InnoDB passes log=true. dict_mem_table_create(): Take fil_space_t* instead of space_id as parameter. dict_process_sys_tables_rec_and_mtr_commit(): Replace the parameter 'status' with 'bool cached'. dict_get_and_save_data_dir_path(): Avoid copying the fil_node_t::name. fil_ibd_open(): Return the tablespace. fil_space_t::set_imported(): Replaces fil_space_set_imported(). truncate_t: Change many member function parameters to fil_space_t*, and remove page_size parameters. row_truncate_prepare(): Merge to its only caller. row_drop_table_from_cache(): Assert that the table is persistent. dict_create_sys_indexes_tuple(): Write SYS_INDEXES.SPACE=FIL_NULL if the tablespace has been discarded. row_import_update_discarded_flag(): Remove a constant parameter.
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/btr0btr.h6
-rw-r--r--storage/innobase/include/btr0bulk.h11
-rw-r--r--storage/innobase/include/btr0sea.ic6
-rw-r--r--storage/innobase/include/buf0buf.h14
-rw-r--r--storage/innobase/include/buf0flu.h8
-rw-r--r--storage/innobase/include/buf0lru.h1
-rw-r--r--storage/innobase/include/dict0crea.h16
-rw-r--r--storage/innobase/include/dict0dict.h33
-rw-r--r--storage/innobase/include/dict0dict.ic33
-rw-r--r--storage/innobase/include/dict0load.h16
-rw-r--r--storage/innobase/include/dict0mem.h40
-rw-r--r--storage/innobase/include/dict0types.h30
-rw-r--r--storage/innobase/include/fil0fil.h233
-rw-r--r--storage/innobase/include/fsp0fsp.h31
-rw-r--r--storage/innobase/include/fsp0sysspace.h8
-rw-r--r--storage/innobase/include/fsp0types.h11
-rw-r--r--storage/innobase/include/ibuf0ibuf.h13
-rw-r--r--storage/innobase/include/mtr0mtr.h14
-rw-r--r--storage/innobase/include/row0import.h24
-rw-r--r--storage/innobase/include/row0row.h2
-rw-r--r--storage/innobase/include/row0trunc.h30
-rw-r--r--storage/innobase/include/trx0rseg.h10
22 files changed, 165 insertions, 425 deletions
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 336ee68ee59..a4f93280ff1 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -355,8 +355,7 @@ btr_node_ptr_get_child_page_no(
/** Create the root node for a new index tree.
@param[in] type type of the index
-@param[in] space space where created
-@param[in] page_size page size
+@param[in,out] space tablespace where created
@param[in] index_id index id
@param[in] index index, or NULL when applying TRUNCATE
log record during recovery
@@ -367,8 +366,7 @@ record during recovery
ulint
btr_create(
ulint type,
- ulint space,
- const page_size_t& page_size,
+ fil_space_t* space,
index_id_t index_id,
dict_index_t* index,
const btr_create_t* btr_redo_create_info,
diff --git a/storage/innobase/include/btr0bulk.h b/storage/innobase/include/btr0bulk.h
index 1567c98c386..0f0051131a6 100644
--- a/storage/innobase/include/btr0bulk.h
+++ b/storage/innobase/include/btr0bulk.h
@@ -284,9 +284,8 @@ public:
m_flush_observer(observer)
{
ut_ad(m_flush_observer != NULL);
-#ifdef UNIV_DEBUG
- fil_space_inc_redo_skipped_count(m_index->table->space);
-#endif /* UNIV_DEBUG */
+ ut_d(my_atomic_addlint(
+ &m_index->table->space->redo_skipped_count, 1));
}
/** Destructor */
@@ -294,10 +293,8 @@ public:
{
mem_heap_free(m_heap);
UT_DELETE(m_page_bulks);
-
-#ifdef UNIV_DEBUG
- fil_space_dec_redo_skipped_count(m_index->table->space);
-#endif /* UNIV_DEBUG */
+ ut_d(my_atomic_addlint(
+ &m_index->table->space->redo_skipped_count, -1));
}
/** Initialization
diff --git a/storage/innobase/include/btr0sea.ic b/storage/innobase/include/btr0sea.ic
index 23024f7f7f6..fba97835395 100644
--- a/storage/innobase/include/btr0sea.ic
+++ b/storage/innobase/include/btr0sea.ic
@@ -168,9 +168,10 @@ rw_lock_t*
btr_get_search_latch(const dict_index_t* index)
{
ut_ad(index != NULL);
+ ut_ad(index->table->space->id == index->table->space_id);
ulint ifold = ut_fold_ulint_pair(ulint(index->id),
- index->table->space);
+ index->table->space_id);
return(btr_search_latches[ifold % btr_ahi_parts]);
}
@@ -184,9 +185,10 @@ hash_table_t*
btr_get_search_table(const dict_index_t* index)
{
ut_ad(index != NULL);
+ ut_ad(index->table->space->id == index->table->space_id);
ulint ifold = ut_fold_ulint_pair(ulint(index->id),
- index->table->space);
+ index->table->space_id);
return(btr_search_sys->hash_tables[ifold % btr_ahi_parts]);
}
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 32b964c406d..4c2f04996da 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -267,18 +267,8 @@ public:
m_fold = src.fold();
}
- /** Reset the values from a (space, page_no).
- @param[in] space tablespace id
- @param[in] page_no page number */
- inline void reset(ulint space, ulint page_no)
- {
- m_space = static_cast<ib_uint32_t>(space);
- m_page_no = static_cast<ib_uint32_t>(page_no);
- m_fold = ULINT_UNDEFINED;
-
- ut_ad(space <= 0xFFFFFFFFU);
- ut_ad(page_no <= 0xFFFFFFFFU);
- }
+ /** Reset the object. */
+ void reset() { m_space= ~0U; m_page_no= ~0U; m_fold= ULINT_UNDEFINED; }
/** Reset the page number only.
@param[in] page_no page number */
diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h
index 76fa65c70f4..198f122e5a4 100644
--- a/storage/innobase/include/buf0flu.h
+++ b/storage/innobase/include/buf0flu.h
@@ -345,12 +345,12 @@ flushed to disk before any redo logged operations go to the index. */
class FlushObserver {
public:
/** Constructor
- @param[in] space_id table space id
+ @param[in,out] space tablespace
@param[in] trx trx instance
@param[in] stage performance schema accounting object,
used by ALTER TABLE. It is passed to log_preflush_pool_modified_pages()
for accounting. */
- FlushObserver(ulint space_id, trx_t* trx, ut_stage_alter_t* stage);
+ FlushObserver(fil_space_t* space, trx_t* trx, ut_stage_alter_t* stage);
/** Deconstructor */
~FlushObserver();
@@ -397,8 +397,8 @@ public:
buf_pool_t* buf_pool,
buf_page_t* bpage);
private:
- /** Table space id */
- const ulint m_space_id;
+ /** Tablespace */
+ fil_space_t* m_space;
/** Trx instance */
trx_t* const m_trx;
diff --git a/storage/innobase/include/buf0lru.h b/storage/innobase/include/buf0lru.h
index f6a7695a2b5..547a09ae319 100644
--- a/storage/innobase/include/buf0lru.h
+++ b/storage/innobase/include/buf0lru.h
@@ -33,6 +33,7 @@ Created 11/5/1995 Heikki Tuuri
// Forward declaration
struct trx_t;
+struct fil_space_t;
/******************************************************************//**
Returns TRUE if less than 25 % of the buffer pool is available. This can be
diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h
index 64bab80b6e0..dc48aa59809 100644
--- a/storage/innobase/include/dict0crea.h
+++ b/storage/innobase/include/dict0crea.h
@@ -144,22 +144,6 @@ dict_create_index_tree_in_mem(
dict_index_t* index, /*!< in/out: index */
const trx_t* trx); /*!< in: InnoDB transaction handle */
-/*******************************************************************//**
-Truncates the index tree but don't update SYSTEM TABLES.
-@return DB_SUCCESS or error */
-dberr_t
-dict_truncate_index_tree_in_mem(
-/*============================*/
- dict_index_t* index); /*!< in/out: index */
-
-/*******************************************************************//**
-Drops the index tree but don't update SYS_INDEXES table. */
-void
-dict_drop_index_tree_in_mem(
-/*========================*/
- const dict_index_t* index, /*!< in: index */
- ulint page_no);/*!< in: index page-no */
-
/****************************************************************//**
Creates the foreign key constraints system tables inside InnoDB
at server bootstrap or server start if they are not found or are
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index c503a3f0bce..af8684ff08d 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -986,14 +986,8 @@ ulint
dict_table_extent_size(
const dict_table_t* table);
-/** Get the table page size.
-@param[in] table table
-@return compressed page size, or 0 if not compressed */
-UNIV_INLINE
-const page_size_t
-dict_table_page_size(
- const dict_table_t* table)
- MY_ATTRIBUTE((warn_unused_result));
+/** Get the table page size. */
+#define dict_table_page_size(table) page_size_t(table->space->flags)
/*********************************************************************//**
Obtain exclusive locks on all index trees of the table. This is to prevent
@@ -1419,15 +1413,6 @@ dict_index_build_data_tuple(
MY_ATTRIBUTE((nonnull, warn_unused_result));
/*********************************************************************//**
-Gets the space id of the root of the index tree.
-@return space id */
-UNIV_INLINE
-ulint
-dict_index_get_space(
-/*=================*/
- const dict_index_t* index) /*!< in: index */
- MY_ATTRIBUTE((nonnull, warn_unused_result));
-/*********************************************************************//**
Gets the page number of the root of the index tree.
@return page number */
UNIV_INLINE
@@ -1819,18 +1804,10 @@ dict_set_corrupted_index_cache_only(
Flags a table with specified space_id corrupted in the table dictionary
cache.
@return TRUE if successful */
-ibool
-dict_set_corrupted_by_space(
-/*========================*/
- ulint space_id); /*!< in: space ID */
+bool dict_set_corrupted_by_space(const fil_space_t* space);
-/** Flag a table with specified space_id encrypted in the data dictionary
-cache
-@param[in] space_id Tablespace id */
-UNIV_INTERN
-void
-dict_set_encrypted_by_space(
- ulint space_id);
+/** Flag a table encrypted in the data dictionary cache. */
+void dict_set_encrypted_by_space(const fil_space_t* space);
/** Sets merge_threshold in the SYS_INDEXES
@param[in,out] index index
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index 0787017317e..01710a0e93a 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -860,20 +860,6 @@ dict_tf_get_page_size(
return(page_size_t(zip_size, univ_page_size.logical(), true));
}
-/** Get the table page size.
-@param[in] table table
-@return a structure containing the compressed and uncompressed
-page sizes and a boolean indicating if the page is compressed */
-UNIV_INLINE
-const page_size_t
-dict_table_page_size(
- const dict_table_t* table)
-{
- ut_ad(table != NULL);
-
- return(dict_tf_get_page_size(table->flags));
-}
-
/*********************************************************************//**
Obtain exclusive locks on all index trees of the table. This is to prevent
accessing index trees while InnoDB is updating internal metadata for
@@ -1162,21 +1148,6 @@ dict_index_get_min_size(
}
/*********************************************************************//**
-Gets the space id of the root of the index tree.
-@return space id */
-UNIV_INLINE
-ulint
-dict_index_get_space(
-/*=================*/
- const dict_index_t* index) /*!< in: index */
-{
- ut_ad(index);
- ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
-
- return(index->table->space);
-}
-
-/*********************************************************************//**
Gets the page number of the root of the index tree.
@return page number */
UNIV_INLINE
@@ -1479,8 +1450,8 @@ bool
dict_table_is_file_per_table(
const dict_table_t* table) /*!< in: table to check */
{
- bool is_file_per_table =
- !is_system_tablespace(table->space);
+ bool is_file_per_table = table->space != fil_system.sys_space
+ && table->space != fil_system.temp_space;
/* If the table is file-per-table and it is not redundant, then
it should have the flags2 bit for DICT_TF2_USE_FILE_PER_TABLE. */
diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h
index 9ba42007568..8256ebb24cd 100644
--- a/storage/innobase/include/dict0load.h
+++ b/storage/innobase/include/dict0load.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, 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
@@ -57,15 +57,6 @@ enum dict_system_id_t {
SYS_NUM_SYSTEM_TABLES
};
-/** Status bit for dict_process_sys_tables_rec_and_mtr_commit() */
-enum dict_table_info_t {
- DICT_TABLE_LOAD_FROM_RECORD = 0,/*!< Directly populate a dict_table_t
- structure with information from
- a SYS_TABLES record */
- DICT_TABLE_LOAD_FROM_CACHE = 1 /*!< Check first whether dict_table_t
- is in the cache, if so, return it */
-};
-
/** Check each tablespace found in the data dictionary.
Look at each table defined in SYS_TABLES that has a space_id > 0.
If the tablespace is not yet in the fil_system cache, look up the
@@ -201,10 +192,7 @@ dict_process_sys_tables_rec_and_mtr_commit(
mem_heap_t* heap, /*!< in: temporary memory heap */
const rec_t* rec, /*!< in: SYS_TABLES record */
dict_table_t** table, /*!< out: dict_table_t to fill */
- dict_table_info_t status, /*!< in: status bit controls
- options such as whether we shall
- look for dict_table_t from cache
- first */
+ bool cached, /*!< in: whether to load from cache */
mtr_t* mtr); /*!< in/out: mini-transaction,
will be committed */
/********************************************************************//**
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 01755787bb7..abb2e6aaa15 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -306,8 +306,7 @@ dict_table_t*
dict_mem_table_create(
/*==================*/
const char* name, /*!< in: table name */
- ulint space, /*!< in: space where the clustered index
- of the table is placed */
+ fil_space_t* space, /*!< in: tablespace */
ulint n_cols, /*!< in: total number of columns
including virtual and non-virtual
columns */
@@ -545,36 +544,6 @@ private:
const char* m_name;
};
-/** Table name wrapper for pretty-printing */
-struct table_name_t
-{
- /** The name in internal representation */
- char* m_name;
-
- /** @return the end of the schema name */
- const char* dbend() const
- {
- const char* sep = strchr(m_name, '/');
- ut_ad(sep);
- return sep;
- }
-
- /** @return the length of the schema name, in bytes */
- size_t dblen() const { return dbend() - m_name; }
-
- /** Determine the filename-safe encoded table name.
- @return the filename-safe encoded table name */
- const char* basename() const { return dbend() + 1; }
-
- /** The start of the table basename suffix for partitioned tables */
- static const char part_suffix[4];
-
- /** Determine the partition or subpartition name suffix.
- @return the partition name
- @retval NULL if the table is not partitioned */
- const char* part() const { return strstr(basename(), part_suffix); }
-};
-
/** Data structure for a column in a table */
struct dict_col_t{
/*----------------------*/
@@ -1494,6 +1463,7 @@ struct dict_table_t {
page cannot be read or decrypted */
bool is_readable() const
{
+ ut_ad(file_unreadable || space);
return(UNIV_LIKELY(!file_unreadable));
}
@@ -1573,8 +1543,10 @@ struct dict_table_t {
/** NULL or the directory path specified by DATA DIRECTORY. */
char* data_dir_path;
- /** Space where the clustered index of the table is placed. */
- uint32_t space;
+ /** The tablespace of the table */
+ fil_space_t* space;
+ /** Tablespace ID */
+ ulint space_id;
/** Stores information about:
1 row format (redundant or compact),
diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h
index 6984351cc06..f9ecf9b341d 100644
--- a/storage/innobase/include/dict0types.h
+++ b/storage/innobase/include/dict0types.h
@@ -99,6 +99,36 @@ typedef ib_mutex_t DictSysMutex;
#define TEMP_TABLE_PREFIX "#sql"
#define TEMP_TABLE_PATH_PREFIX "/" TEMP_TABLE_PREFIX
+/** Table name wrapper for pretty-printing */
+struct table_name_t
+{
+ /** The name in internal representation */
+ char* m_name;
+
+ /** @return the end of the schema name */
+ const char* dbend() const
+ {
+ const char* sep = strchr(m_name, '/');
+ ut_ad(sep);
+ return sep;
+ }
+
+ /** @return the length of the schema name, in bytes */
+ size_t dblen() const { return dbend() - m_name; }
+
+ /** Determine the filename-safe encoded table name.
+ @return the filename-safe encoded table name */
+ const char* basename() const { return dbend() + 1; }
+
+ /** The start of the table basename suffix for partitioned tables */
+ static const char part_suffix[4];
+
+ /** Determine the partition or subpartition name suffix.
+ @return the partition name
+ @retval NULL if the table is not partitioned */
+ const char* part() const { return strstr(basename(), part_suffix); }
+};
+
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
/** Flag to control insert buffer debugging. */
extern uint ibuf_debug;
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index c111a0ef647..e4d803370ae 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -109,7 +109,8 @@ struct fil_space_t {
ulint redo_skipped_count;
/*!< reference count for operations who want
to skip redo log in the file space in order
- to make fsp_space_modify_check pass. */
+ to make fsp_space_modify_check pass.
+ Uses my_atomic_loadlint() and friends. */
#endif
fil_type_t purpose;/*!< purpose */
UT_LIST_BASE_NODE_T(fil_node_t) chain;
@@ -181,10 +182,6 @@ struct fil_space_t {
/** True if the device this filespace is on supports atomic writes */
bool atomic_write_supported;
- /** Release the reserved free extents.
- @param[in] n_reserved number of reserved extents */
- void release_free_extents(ulint n_reserved);
-
/** True if file system storing this tablespace supports
punch hole */
bool punch_hole;
@@ -205,6 +202,44 @@ struct fil_space_t {
&& srv_use_doublewrite_buf && buf_dblwr;
}
+ /** Try to reserve free extents.
+ @param[in] n_free_now current number of free extents
+ @param[in] n_to_reserve number of extents to reserve
+ @return whether the reservation succeeded */
+ bool reserve_free_extents(ulint n_free_now, ulint n_to_reserve)
+ {
+ ut_ad(rw_lock_own(&latch, RW_LOCK_X));
+ if (n_reserved_extents + n_to_reserve > n_free_now) {
+ return false;
+ }
+
+ n_reserved_extents += n_to_reserve;
+ return true;
+ }
+
+ /** Release the reserved free extents.
+ @param[in] n_reserved number of reserved extents */
+ void release_free_extents(ulint n_reserved)
+ {
+ if (!n_reserved) return;
+ ut_ad(rw_lock_own(&latch, RW_LOCK_X));
+ ut_a(n_reserved_extents >= n_reserved);
+ n_reserved_extents -= n_reserved;
+ }
+
+ /** Rename a file.
+ @param[in] name table name after renaming
+ @param[in] path tablespace file name after renaming
+ @param[in] log whether to write redo log
+ @return error code
+ @retval DB_SUCCESS on success */
+ dberr_t rename(const char* name, const char* path, bool log);
+
+ /** Note that the tablespace has been imported.
+ Initially, purpose=FIL_TYPE_IMPORT so that no redo log is
+ written while the space ID is being updated in each page. */
+ void set_imported();
+
/** Open each file. Only invoked on fil_system.temp_space.
@return whether all files were opened */
bool open();
@@ -586,16 +621,6 @@ fil_space_get_latch(
ulint id,
ulint* flags);
-/** Note that a tablespace has been imported.
-It is initially marked as FIL_TYPE_IMPORT so that no logging is
-done during the import process when the space ID is stamped to each page.
-Now we change it to FIL_SPACE_TABLESPACE to start redo and undo logging.
-NOTE: temporary tablespaces are never imported.
-@param[in] id tablespace identifier */
-void
-fil_space_set_imported(
- ulint id);
-
/** Append a file to the chain of files of a space.
@param[in] name file name of a file that is not open
@param[in] size file size in entire database blocks
@@ -657,16 +682,6 @@ fil_space_free(
ulint id,
bool x_latched);
-/** Returns the path from the first fil_node_t found with this space ID.
-The caller is responsible for freeing the memory allocated here for the
-value returned.
-@param[in] id Tablespace ID
-@return own: A copy of fil_node_t::path, NULL if space ID is zero
-or not found. */
-char*
-fil_space_get_first_path(
- ulint id);
-
/** Set the recovered size of a tablespace in pages.
@param id tablespace ID
@param size recovered size in pages */
@@ -821,68 +836,6 @@ fil_space_keyrotate_next(
fil_space_t* prev_space)
MY_ATTRIBUTE((warn_unused_result));
-/** Wrapper with reference-counting for a fil_space_t. */
-class FilSpace
-{
-public:
- /** Default constructor: Use this when reference counting
- is done outside this wrapper. */
- FilSpace() : m_space(NULL) {}
-
- /** Constructor: Look up the tablespace and increment the
- reference count if found.
- @param[in] space_id tablespace ID
- @param[in] silent whether not to display errors */
- explicit FilSpace(ulint space_id, bool silent = false)
- : m_space(fil_space_acquire_low(space_id, silent)) {}
-
- /** Assignment operator: This assumes that fil_space_acquire()
- has already been done for the fil_space_t. The caller must
- assign NULL if it calls fil_space_release().
- @param[in] space tablespace to assign */
- class FilSpace& operator=(fil_space_t* space)
- {
- /* fil_space_acquire() must have been invoked. */
- ut_ad(space == NULL || space->n_pending_ops > 0);
- m_space = space;
- return(*this);
- }
-
- /** Destructor - Decrement the reference count if a fil_space_t
- is still assigned. */
- ~FilSpace()
- {
- if (m_space != NULL) {
- fil_space_release(m_space);
- }
- }
-
- /** Implicit type conversion
- @return the wrapped object */
- operator const fil_space_t*() const
- {
- return(m_space);
- }
-
- /** Member accessor
- @return the wrapped object */
- const fil_space_t* operator->() const
- {
- return(m_space);
- }
-
- /** Explicit type conversion
- @return the wrapped object */
- const fil_space_t* operator()() const
- {
- return(m_space);
- }
-
-private:
- /** The wrapped pointer */
- fil_space_t* m_space;
-};
-
/********************************************************//**
Creates the database directory for a table if it does not exist yet. */
void
@@ -890,15 +843,6 @@ fil_create_directory_for_tablename(
/*===============================*/
const char* name); /*!< in: name in the standard
'databasename/tablename' format */
-/** Write redo log for renaming a file.
-@param[in] space_id tablespace id
-@param[in] old_name tablespace file name
-@param[in] new_name tablespace file name after renaming */
-void
-fil_name_write_rename(
- ulint space_id,
- const char* old_name,
- const char* new_name);
/** Replay a file rename operation if possible.
@param[in] space_id tablespace identifier
@param[in] first_page_no first page number in the file
@@ -938,13 +882,10 @@ fil_delete_tablespace(
);
/** Truncate the tablespace to needed size.
-@param[in] space_id id of tablespace to truncate
+@param[in,out] space tablespace truncate
@param[in] size_in_pages truncate size.
@return true if truncate was successful. */
-bool
-fil_truncate_tablespace(
- ulint space_id,
- ulint size_in_pages);
+bool fil_truncate_tablespace(fil_space_t* space, ulint size_in_pages);
/*******************************************************************//**
Prepare for truncating a single-table tablespace. The tablespace
@@ -967,36 +908,6 @@ fil_close_tablespace(
trx_t* trx, /*!< in/out: Transaction covering the close */
ulint id); /*!< in: space id */
-/** Test if a tablespace file can be renamed to a new filepath by checking
-if that the old filepath exists and the new filepath does not exist.
-@param[in] space_id tablespace id
-@param[in] old_path old filepath
-@param[in] new_path new filepath
-@param[in] is_discarded whether the tablespace is discarded
-@return innodb error code */
-dberr_t
-fil_rename_tablespace_check(
- ulint space_id,
- const char* old_path,
- const char* new_path,
- bool is_discarded);
-
-/** Rename a single-table tablespace.
-The tablespace must exist in the memory cache.
-@param[in] id tablespace identifier
-@param[in] old_path old file name
-@param[in] new_name new table name in the
-databasename/tablename format
-@param[in] new_path_in new file name,
-or NULL if it is located in the normal data directory
-@return true if success */
-bool
-fil_rename_tablespace(
- ulint id,
- const char* old_path,
- const char* new_name,
- const char* new_path_in);
-
/*******************************************************************//**
Allocates and builds a file name from a path, a table or tablespace name
and a suffix. The string must be freed by caller with ut_free().
@@ -1066,19 +977,22 @@ statement to update the dictionary tables if they are incorrect.
@param[in] purpose FIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY
@param[in] id tablespace ID
@param[in] flags expected FSP_SPACE_FLAGS
-@param[in] space_name tablespace name of the datafile
+@param[in] tablename table name
If file-per-table, it is the table name in the databasename/tablename format
@param[in] path_in expected filepath, usually read from dictionary
-@return DB_SUCCESS or error code */
-dberr_t
+@param[out] err DB_SUCCESS or error code
+@return tablespace
+@retval NULL if the tablespace could not be opened */
+fil_space_t*
fil_ibd_open(
- bool validate,
- bool fix_dict,
- fil_type_t purpose,
- ulint id,
- ulint flags,
- const char* tablename,
- const char* path_in)
+ bool validate,
+ bool fix_dict,
+ fil_type_t purpose,
+ ulint id,
+ ulint flags,
+ const table_name_t& tablename,
+ const char* path_in,
+ dberr_t* err = NULL)
MY_ATTRIBUTE((warn_unused_result));
enum fil_load_status {
@@ -1128,15 +1042,14 @@ startup, there may be many tablespaces which are not yet in the memory cache.
@param[in] print_error_if_does_not_exist
Print detailed error information to the
error log if a matching tablespace is not found from memory.
-@param[in] heap Heap memory
@param[in] table_flags table flags
-@return true if a matching tablespace exists in the memory cache */
-bool
+@return the tablespace
+@retval NULL if no matching tablespace exists in the memory cache */
+fil_space_t*
fil_space_for_table_exists_in_mem(
ulint id,
const char* name,
bool print_error_if_does_not_exist,
- mem_heap_t* heap,
ulint table_flags);
/** Try to extend a tablespace if it is smaller than the specified size.
@@ -1147,22 +1060,6 @@ bool
fil_space_extend(
fil_space_t* space,
ulint size);
-/*******************************************************************//**
-Tries to reserve free extents in a file space.
-@return true if succeed */
-bool
-fil_space_reserve_free_extents(
-/*===========================*/
- ulint id, /*!< in: space id */
- ulint n_free_now, /*!< in: number of free extents now */
- ulint n_to_reserve); /*!< in: how many one wants to reserve */
-/*******************************************************************//**
-Releases free extents in a file space. */
-void
-fil_space_release_free_extents(
-/*===========================*/
- ulint id, /*!< in: space id */
- ulint n_reserved); /*!< in: how many one reserved */
/** Reads or writes data. This operation could be asynchronous (aio).
@@ -1318,20 +1215,6 @@ Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
#define fil_block_check_type(block, type, mtr) \
fil_page_check_type(block->page.id, block->frame, type, mtr)
-#ifdef UNIV_DEBUG
-/** Increase redo skipped of a tablespace.
-@param[in] id space id */
-void
-fil_space_inc_redo_skipped_count(
- ulint id);
-
-/** Decrease redo skipped of a tablespace.
-@param[in] id space id */
-void
-fil_space_dec_redo_skipped_count(
- ulint id);
-#endif
-
/********************************************************************//**
Delete the tablespace file and any related files like .cfg.
This should not be called for temporary tables. */
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index e1bd0a5ce6e..888020c8f85 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -393,36 +393,21 @@ Creates a new segment.
if could not create segment because of lack of space */
buf_block_t*
fseg_create(
-/*========*/
- ulint space_id,/*!< in: space id */
+ fil_space_t* space, /*!< in,out: tablespace */
ulint page, /*!< in: page where the segment header is placed: if
this is != 0, the page must belong to another segment,
if this is 0, a new page will be allocated and it
will belong to the created segment */
ulint byte_offset, /*!< in: byte offset of the created segment header
on the page */
- mtr_t* mtr); /*!< in/out: mini-transaction */
-/**********************************************************************//**
-Creates a new segment.
-@return the block where the segment header is placed, x-latched, NULL
-if could not create segment because of lack of space */
-buf_block_t*
-fseg_create_general(
-/*================*/
- ulint space_id,/*!< in: space id */
- ulint page, /*!< in: page where the segment header is placed: if
- this is != 0, the page must belong to another segment,
- if this is 0, a new page will be allocated and it
- will belong to the created segment */
- ulint byte_offset, /*!< in: byte offset of the created segment header
- on the page */
- ibool has_done_reservation, /*!< in: TRUE if the caller has already
- done the reservation for the pages with
+ mtr_t* mtr,
+ bool has_done_reservation = false); /*!< in: whether the caller
+ has already done the reservation for the pages with
fsp_reserve_free_extents (at least 2 extents: one for
the inode and the other for the segment) then there is
no need to do the check for this individual
operation */
- mtr_t* mtr); /*!< in/out: mini-transaction */
+
/**********************************************************************//**
Calculates the number of pages reserved by a segment, and how many pages are
currently used.
@@ -484,7 +469,7 @@ fseg_alloc_free_page_general(
use several pages from the tablespace should call this function beforehand
and reserve enough free extents so that they certainly will be able
to do their operation, like a B-tree page split, fully. Reservations
-must be released with function fil_space_release_free_extents!
+must be released with function fil_space_t::release_free_extents()!
The alloc_type below has the following meaning: FSP_NORMAL means an
operation which will probably result in more space usage, like an
@@ -510,7 +495,7 @@ free pages available.
return true and the tablespace size is <
FSP_EXTENT_SIZE pages, then this can be 0,
otherwise it is n_ext
-@param[in] space_id tablespace identifier
+@param[in,out] space tablespace
@param[in] n_ext number of extents to reserve
@param[in] alloc_type page reservation type (FSP_BLOB, etc)
@param[in,out] mtr the mini transaction
@@ -521,7 +506,7 @@ free pages available.
bool
fsp_reserve_free_extents(
ulint* n_reserved,
- ulint space_id,
+ fil_space_t* space,
ulint n_ext,
fsp_reserve_t alloc_type,
mtr_t* mtr,
diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h
index efbd4fc3f24..de83e64d285 100644
--- a/storage/innobase/include/fsp0sysspace.h
+++ b/storage/innobase/include/fsp0sysspace.h
@@ -33,14 +33,6 @@ Created 2013-7-26 by Kevin Lewis
at a time. We have to make this public because it is a config variable. */
extern ulong sys_tablespace_auto_extend_increment;
-#ifdef UNIV_DEBUG
-/** Control if extra debug checks need to be done for temporary tablespace.
-Default = true that is disable such checks.
-This variable is not exposed to end-user but still kept as variable for
-developer to enable it during debug. */
-extern bool srv_skip_temp_table_checks_debug;
-#endif /* UNIV_DEBUG */
-
/** Data structure that contains the information about shared tablespaces.
Currently this can be the system tablespace or a temporary table tablespace */
class SysTablespace : public Tablespace
diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h
index c6b81986320..080311e010c 100644
--- a/storage/innobase/include/fsp0types.h
+++ b/storage/innobase/include/fsp0types.h
@@ -196,17 +196,6 @@ fsp_is_system_temporary(ulint space_id)
{
return(space_id == SRV_TMP_SPACE_ID);
}
-
-#ifdef UNIV_DEBUG
-/** Skip some of the sanity checks that are time consuming even in debug mode
-and can affect frequent verification runs that are done to ensure stability of
-the product.
-@return true if check should be skipped for given space. */
-bool
-fsp_skip_sanity_check(
- ulint space_id);
-#endif /* UNIV_DEBUG */
-
#endif /* !UNIV_INNOCHECKSUM */
/* @defgroup fsp_flags InnoDB Tablespace Flag Constants @{ */
diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h
index 6cff26635bd..446000a39de 100644
--- a/storage/innobase/include/ibuf0ibuf.h
+++ b/storage/innobase/include/ibuf0ibuf.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2017, MariaDB Corporation.
+Copyright (c) 2016, 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
@@ -421,14 +421,11 @@ void
ibuf_close(void);
/*============*/
-/******************************************************************//**
-Checks the insert buffer bitmaps on IMPORT TABLESPACE.
+/** Check the insert buffer bitmaps on IMPORT TABLESPACE.
+@param[in] trx transaction
+@param[in,out] space tablespace being imported
@return DB_SUCCESS or error code */
-dberr_t
-ibuf_check_bitmap_on_import(
-/*========================*/
- const trx_t* trx, /*!< in: transaction */
- ulint space_id) /*!< in: tablespace identifier */
+dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Updates free bits and buffered bits for bulk loaded page.
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 20d9d2066a0..79ff7638ab7 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -212,13 +212,6 @@ struct mtr_t {
~mtr_t() { }
- /** Release the free extents that was reserved using
- fsp_reserve_free_extents(). This is equivalent to calling
- fil_space_release_free_extents(). This is intended for use
- with index pages.
- @param[in] n_reserved number of reserved extents */
- void release_free_extents(ulint n_reserved);
-
/** Start a mini-transaction.
@param sync true if it is a synchronous mini-transaction
@param read_only true if read only mini-transaction */
@@ -308,7 +301,7 @@ struct mtr_t {
(needed for generating a MLOG_FILE_NAME record)
@param[in] space_id user or system tablespace ID
@return the tablespace */
- fil_space_t* set_named_space(ulint space_id)
+ fil_space_t* set_named_space_id(ulint space_id)
{
ut_ad(!m_impl.m_user_space_id);
ut_d(m_impl.m_user_space_id = space_id);
@@ -341,6 +334,11 @@ struct mtr_t {
@param[in] space tablespace
@return whether the mini-transaction is associated with the space */
bool is_named_space(ulint space) const;
+ /** Check the tablespace associated with the mini-transaction
+ (needed for generating a MLOG_FILE_NAME record)
+ @param[in] space tablespace
+ @return whether the mini-transaction is associated with the space */
+ bool is_named_space(const fil_space_t* space) const;
#endif /* UNIV_DEBUG */
/** Read 1 - 4 bytes from a file page buffered in the buffer pool.
diff --git a/storage/innobase/include/row0import.h b/storage/innobase/include/row0import.h
index c6dfca9d7e8..5eb5425b983 100644
--- a/storage/innobase/include/row0import.h
+++ b/storage/innobase/include/row0import.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2016, 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
@@ -47,21 +47,13 @@ row_import_for_mysql(
in MySQL */
MY_ATTRIBUTE((nonnull, warn_unused_result));
-/*****************************************************************//**
-Update the DICT_TF2_DISCARDED flag in SYS_TABLES.
-@return DB_SUCCESS or error code. */
-dberr_t
-row_import_update_discarded_flag(
-/*=============================*/
- trx_t* trx, /*!< in/out: transaction that
- covers the update */
- table_id_t table_id, /*!< in: Table for which we want
- to set the root table->flags2 */
- bool discarded, /*!< in: set MIX_LEN column bit
- to discarded, if true */
- bool dict_locked) /*!< in: Set to true if the
- caller already owns the
- dict_sys_t:: mutex. */
+/** Update the DICT_TF2_DISCARDED flag in SYS_TABLES.MIX_LEN.
+@param[in,out] trx dictionary transaction
+@param[in] table_id table identifier
+@param[in] discarded whether to set or clear the flag
+@return DB_SUCCESS or error code */
+dberr_t row_import_update_discarded_flag(trx_t* trx, table_id_t table_id,
+ bool discarded)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/*****************************************************************//**
diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h
index eb6690d1e0d..4f329f0d675 100644
--- a/storage/innobase/include/row0row.h
+++ b/storage/innobase/include/row0row.h
@@ -398,7 +398,7 @@ row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic)
{
mtr->start();
- switch (index->table->space) {
+ switch (index->table->space->id) {
case IBUF_SPACE_ID:
if (pessimistic
&& !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) {
diff --git a/storage/innobase/include/row0trunc.h b/storage/innobase/include/row0trunc.h
index 5f7b499502c..94b6b7046b4 100644
--- a/storage/innobase/include/row0trunc.h
+++ b/storage/innobase/include/row0trunc.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 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
@@ -181,9 +182,7 @@ public:
/** Create an index for a table.
@param[in] table_name table name, for which to create
the index
- @param[in] space_id space id where we have to
- create the index
- @param[in] page_size page size of the .ibd file
+ @param[in,out] space tablespace
@param[in] index_type type of index to truncate
@param[in] index_id id of index to truncate
@param[in] btr_redo_create_info control info for ::btr_create()
@@ -192,8 +191,7 @@ public:
@return root page no or FIL_NULL on failure */
inline ulint create_index(
const char* table_name,
- ulint space_id,
- const page_size_t& page_size,
+ fil_space_t* space,
ulint index_type,
index_id_t index_id,
const btr_create_t& btr_redo_create_info,
@@ -202,31 +200,27 @@ public:
/** Create the indexes for a table
@param[in] table_name table name, for which to create the
indexes
- @param[in] space_id space id where we have to create the
- indexes
- @param[in] page_size page size of the .ibd file
- @param[in] flags tablespace flags
+ @param[in,out] space tablespace
@param[in] format_flags page format flags
@return DB_SUCCESS or error code. */
inline dberr_t create_indexes(
const char* table_name,
- ulint space_id,
- const page_size_t& page_size,
- ulint flags,
+ fil_space_t* space,
ulint format_flags);
/** Check if index has been modified since TRUNCATE log snapshot
was recorded.
- @param space_id space_id where table/indexes resides.
+ @param[in] space tablespace
+ @param[in] root_page_no index root page number
@return true if modified else false */
- bool is_index_modified_since_logged(
- ulint space_id,
- ulint root_page_no) const;
+ inline bool is_index_modified_since_logged(
+ const fil_space_t* space,
+ ulint root_page_no) const;
/** Drop indexes for a table.
- @param space_id space_id where table/indexes resides.
+ @param[in,out] space tablespace
@return DB_SUCCESS or error code. */
- void drop_indexes(ulint space_id) const;
+ void drop_indexes(fil_space_t* space) const;
/**
Parses log record during recovery
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index ff8e8c864cf..65e5124a2db 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -69,17 +69,17 @@ ulint
trx_rsegf_undo_find_free(const trx_rsegf_t* rsegf);
/** Create a rollback segment header.
-@param[in] space system, undo, or temporary tablespace
+@param[in,out] space system, undo, or temporary tablespace
@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
trx_rseg_header_create(
- const fil_space_t* space,
- ulint rseg_id,
- buf_block_t* sys_header,
- mtr_t* mtr);
+ fil_space_t* space,
+ ulint rseg_id,
+ buf_block_t* sys_header,
+ mtr_t* mtr);
/** Initialize the rollback segments in memory at database startup. */
void