MySQL  8.0.12
Source Code Documentation
fil0fil.h File Reference

The low-level file system. More...

#include "univ.i"
#include "dict0types.h"
#include "fil0types.h"
#include "log0recv.h"
#include "page0size.h"
#include "ibuf0types.h"
#include "ut0new.h"
#include "sql/dd/object_id.h"
#include <list>
#include <vector>

Go to the source code of this file.

Classes

struct  fil_node_t
 File node of a tablespace or the log data space. More...
 
struct  fil_space_t
 Tablespace or log data space. More...
 
class  Fil_path
 Wrapper for a path to a directory that may or may not exist. More...
 
struct  fil_addr_t
 File space address. More...
 
class  Fil_iterator
 Iterate over the files in all the tablespaces. More...
 
struct  PageCallback
 Callback functor. More...
 

Macros

#define DOT_IBD   dot_ext[IBD]
 
#define DOT_CFG   dot_ext[CFG]
 
#define DOT_CFP   dot_ext[CFP]
 

Typedefs

using Filenames = std::vector< std::string, ut_allocator< std::string > >
 
using Space_ids = std::vector< space_id_t, ut_allocator< space_id_t > >
 
using fil_faddr_t = byte
 'type' definition in C: an address stored in a file page is a string of bytes More...
 
using page_type_t = uint16_t
 

Enumerations

enum  fil_type_t : uint8_t { FIL_TYPE_TEMPORARY = 1, FIL_TYPE_IMPORT = 2, FIL_TYPE_TABLESPACE = 4, FIL_TYPE_LOG = 8 }
 File types. More...
 
enum  Fil_state {
  Fil_state::MATCHES, Fil_state::MISSING, Fil_state::DELETED, Fil_state::MOVED,
  Fil_state::RENAMED
}
 Result of comparing a path. More...
 
enum  ib_file_suffix { NO_EXT = 0, IBD = 1, CFG = 2, CFP = 3 }
 Common InnoDB file extentions. More...
 

Functions

bool fil_type_is_data (fil_type_t type)
 Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT or FIL_TYPE_TABLESPACE. More...
 
std::ostream & operator<< (std::ostream &out, const fil_addr_t &obj)
 

Variables

const char general_space_name []
 This tablespace name is used internally during recovery to open a general tablespace before the data dictionary are recovered and available. More...
 
volatile bool recv_recovery_on
 true when applying redo log records during crash recovery; false otherwise. More...
 
constexpr size_t FIL_SPACE_MAGIC_N = 89472
 Value of fil_space_t::magic_n. More...
 
constexpr size_t FIL_NODE_MAGIC_N = 89389
 Value of fil_node_t::magic_n. More...
 
const char * dot_ext []
 Common InnoDB file extentions. More...
 
Fil_path MySQL_datadir_path
 The MySQL server –datadir value. More...
 
constexpr size_t FIL_IBD_FILE_INITIAL_SIZE = 7
 Initial size of a single-table tablespace in pages. More...
 
constexpr size_t FIL_IBD_FILE_INITIAL_SIZE_5_7 = 4
 An empty tablespace (CREATE TABLESPACE) has minimum of 4 pages and an empty CREATE TABLE (file_per_table) has 6 pages. More...
 
constexpr page_no_t FIL_NULL = std::numeric_limits<page_no_t>::max()
 'null' (undefined) page offset in the context of file spaces More...
 
constexpr page_no_t PAGE_NO_MAX = std::numeric_limits<page_no_t>::max() - 1
 Maximum Page Number, one less than FIL_NULL. More...
 
constexpr space_id_t SPACE_UNKNOWN = std::numeric_limits<space_id_t>::max()
 Unknown space id. More...
 
fil_addr_t fil_addr_null
 The null file address. More...
 
#define fil_page_type_is_index(page_type)
 Check whether the page type is index (Btree or Rtree or SDI) type. More...
 
#define fil_page_index_page_check(page)   fil_page_type_is_index(fil_page_get_type(page))
 Check whether the page is index page (either regular Btree index or Rtree index. More...
 
#define fil_block_check_type(block, type, mtr)   fil_page_check_type(block->page.id, block->frame, type, mtr)
 Check (and if needed, reset) the page type. More...
 
#define fil_space_get_sys_space()   (fil_space_t::s_sys_space)
 
constexpr page_type_t FIL_PAGE_INDEX = 17855
 File page types (values of FIL_PAGE_TYPE) More...
 
constexpr page_type_t FIL_PAGE_RTREE = 17854
 R-tree node. More...
 
constexpr page_type_t FIL_PAGE_SDI = 17853
 Tablespace SDI Index page. More...
 
constexpr page_type_t FIL_PAGE_UNDO_LOG = 2
 Undo log page. More...
 
constexpr page_type_t FIL_PAGE_INODE = 3
 Index node. More...
 
constexpr page_type_t FIL_PAGE_IBUF_FREE_LIST = 4
 Insert buffer free list. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ALLOCATED = 0
 Freshly allocated page. More...
 
constexpr page_type_t FIL_PAGE_IBUF_BITMAP = 5
 Insert buffer bitmap. More...
 
constexpr page_type_t FIL_PAGE_TYPE_SYS = 6
 System page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_TRX_SYS = 7
 Transaction system data. More...
 
constexpr page_type_t FIL_PAGE_TYPE_FSP_HDR = 8
 File space header. More...
 
constexpr page_type_t FIL_PAGE_TYPE_XDES = 9
 Extent descriptor page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_BLOB = 10
 Uncompressed BLOB page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB = 11
 First compressed BLOB page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZBLOB2 = 12
 Subsequent compressed BLOB page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_UNKNOWN = 13
 In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with this value when flushing pages. More...
 
constexpr page_type_t FIL_PAGE_COMPRESSED = 14
 Compressed page. More...
 
constexpr page_type_t FIL_PAGE_ENCRYPTED = 15
 Encrypted page. More...
 
constexpr page_type_t FIL_PAGE_COMPRESSED_AND_ENCRYPTED = 16
 Compressed and Encrypted page. More...
 
constexpr page_type_t FIL_PAGE_ENCRYPTED_RTREE = 17
 Encrypted R-tree page. More...
 
constexpr page_type_t FIL_PAGE_SDI_BLOB = 18
 Uncompressed SDI BLOB page. More...
 
constexpr page_type_t FIL_PAGE_SDI_ZBLOB = 19
 Commpressed SDI BLOB page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_UNUSED = 20
 Available for future use. More...
 
constexpr page_type_t FIL_PAGE_TYPE_RSEG_ARRAY = 21
 Rollback Segment Array page. More...
 
constexpr page_type_t FIL_PAGE_TYPE_LOB_INDEX = 22
 Index pages of uncompressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_LOB_DATA = 23
 Data pages of uncompressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_LOB_FIRST = 24
 The first page of an uncompressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FIRST = 25
 The first page of a compressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_DATA = 26
 Data pages of compressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_INDEX = 27
 Index pages of compressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG = 28
 Fragment pages of compressed LOB. More...
 
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY = 29
 Index pages of fragment pages (compressed LOB). More...
 
constexpr page_type_t FIL_PAGE_TYPE_LAST = FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY
 Used by i_s.cc to index into the text description. More...
 
ulint fil_n_log_flushes
 The number of fsyncs done to the log. More...
 
ulint fil_n_pending_log_flushes
 Number of pending redo log flushes. More...
 
ulint fil_n_pending_tablespace_flushes
 Number of pending tablespace flushes. More...
 
ulint fil_n_file_opened
 Number of files currently open. More...
 
fil_space_tfil_space_get (space_id_t space_id)
 Look up a tablespace. More...
 
rw_lock_tfil_space_get_latch (space_id_t id)
 Returns the latch of a file space. More...
 
fil_type_t fil_space_get_type (space_id_t space_id)
 Gets the type of a file space. More...
 
void fil_space_set_imported (space_id_t space_id)
 Note that a tablespace has been imported. More...
 
char * fil_node_create (const char *name, page_no_t size, fil_space_t *space, bool is_raw, bool atomic_write, page_no_t max_pages=PAGE_NO_MAX)
 Append a file to the chain of files of a space. More...
 
fil_space_tfil_space_create (const char *name, space_id_t space_id, ulint flags, fil_type_t purpose)
 Create a space memory object and put it to the fil_system hash table. More...
 
bool fil_assign_new_space_id (space_id_t *space_id)
 Assigns a new space id for a new single-table tablespace. More...
 
char * fil_space_get_first_path (space_id_t space_id)
 Returns the path from the first fil_node_t found with this space ID. More...
 
page_no_t fil_space_get_size (space_id_t space_id)
 Returns the size of the space in pages. More...
 
ulint fil_space_get_flags (space_id_t space_id)
 Returns the flags of the space. More...
 
void fil_space_set_flags (fil_space_t *space, ulint flags)
 Sets the flags of the tablespace. More...
 
bool fil_space_open (space_id_t space_id)
 Open each file of a tablespace if not already open. More...
 
void fil_space_close (space_id_t space_id)
 Close each file of a tablespace if open. More...
 
const page_size_t fil_space_get_page_size (space_id_t space_id, bool *found)
 Returns the page size of the space and whether it is compressed or not. More...
 
void fil_init (ulint max_n_open)
 Initializes the tablespace memory cache. More...
 
void fil_close ()
 Initializes the tablespace memory cache. More...
 
void fil_open_log_and_system_tablespace_files ()
 Opens all log files and system tablespace data files. More...
 
void fil_close_all_files ()
 Closes all open files. More...
 
void fil_close_log_files (bool free_all)
 Closes the redo log files. More...
 
void fil_set_max_space_id_if_bigger (space_id_t max_id)
 Sets the max tablespace id counter if the given number is bigger than the previous value. More...
 
dberr_t fil_write_flushed_lsn (lsn_t lsn)
 Write the flushed LSN to the page header of the first page in the system tablespace. More...
 
fil_space_tfil_space_acquire (space_id_t space_id)
 Acquire a tablespace when it could be dropped concurrently. More...
 
fil_space_tfil_space_acquire_silent (space_id_t space_id)
 Acquire a tablespace that may not exist. More...
 
void fil_space_release (fil_space_t *space)
 Release a tablespace acquired with fil_space_acquire(). More...
 
std::string fil_system_open_fetch (space_id_t space_id)
 Fetch the file name opened for a space_id during recovery from the file map. More...
 
bool fil_truncate_tablespace (space_id_t space_id, page_no_t size_in_pages)
 Truncate the tablespace to needed size. More...
 
dberr_t fil_close_tablespace (trx_t *trx, space_id_t space_id)
 Closes a single-table tablespace. More...
 
dberr_t fil_discard_tablespace (space_id_t space_id)
 Discards a single-table tablespace. More...
 
dberr_t fil_rename_tablespace_check (space_id_t space_id, const char *old_path, const char *new_path, bool is_discarded)
 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. More...
 
bool fil_rename_tablespace (space_id_t space_id, const char *old_path, const char *new_name, const char *new_path_in)
 Rename a single-table tablespace. More...
 
dberr_t fil_ibd_create (space_id_t space_id, const char *name, const char *path, ulint flags, page_no_t size)
 Create a tablespace file. More...
 
dberr_t fil_delete_tablespace (space_id_t space_id, buf_remove_t buf_remove)
 Deletes an IBD tablespace, either general or single-table. More...
 
dberr_t fil_ibd_open (bool validate, fil_type_t purpose, space_id_t space_id, ulint flags, const char *space_name, const char *table_name, const char *path_in, bool strict, bool old_space)
 Open a single-table tablespace and optionally check the space id is right in it. More...
 
bool fil_space_exists_in_mem (space_id_t space_id, const char *name, bool print_err, bool adjust_space, mem_heap_t *heap, table_id_t table_id)
 Returns true if a matching tablespace exists in the InnoDB tablespace memory cache. More...
 
void fil_extend_tablespaces_to_stored_len ()
 Extends all tablespaces to the size stored in the space header. More...
 
bool fil_space_extend (fil_space_t *space, page_no_t size)
 Try to extend a tablespace if it is smaller than the specified size. More...
 
bool fil_space_reserve_free_extents (space_id_t space_id, ulint n_free_now, ulint n_to_reserve)
 Tries to reserve free extents in a file space. More...
 
void fil_space_release_free_extents (space_id_t space_id, ulint n_reserved)
 Releases free extents in a file space. More...
 
ulint fil_space_get_n_reserved_extents (space_id_t space_id)
 Gets the number of reserved extents. More...
 
dberr_t fil_redo_io (const IORequest &type, const page_id_t &page_id, const page_size_t &page_size, ulint byte_offset, ulint len, void *buf)
 Read or write redo log data (synchronous buffered IO). More...
 
dberr_t fil_io (const IORequest &type, bool sync, const page_id_t &page_id, const page_size_t &page_size, ulint byte_offset, ulint len, void *buf, void *message)
 Read or write data. More...
 
void fil_aio_wait (ulint segment)
 Waits for an aio operation to complete. More...
 
void fil_flush (space_id_t space_id)
 Flushes to disk possible writes cached by the OS. More...
 
void fil_flush_file_redo ()
 Flush to disk the writes in file spaces of the given type possibly cached by the OS. More...
 
void fil_flush_file_spaces (uint8_t purpose)
 Flush to disk the writes in file spaces of the given type possibly cached by the OS. More...
 
bool fil_validate ()
 Checks the consistency of the tablespace cache. More...
 
bool fil_addr_is_null (const fil_addr_t &addr)
 Returns true if file address is undefined. More...
 
page_no_t fil_page_get_prev (const byte *page)
 Get the predecessor of a file page. More...
 
page_no_t fil_page_get_next (const byte *page)
 Get the successor of a file page. More...
 
void fil_page_set_type (byte *page, ulint type)
 Sets the file page type. More...
 
void fil_page_reset_type (const page_id_t &page_id, byte *page, ulint type, mtr_t *mtr)
 Reset the page type. More...
 
page_type_t fil_page_get_type (const byte *page)
 Get the file page type. More...
 
void fil_page_check_type (const page_id_t &page_id, byte *page, ulint type, mtr_t *mtr)
 Check (and if needed, reset) the page type. More...
 
void fil_space_inc_redo_skipped_count (space_id_t space_id)
 Increase redo skipped of a tablespace. More...
 
void fil_space_dec_redo_skipped_count (space_id_t space_id)
 Decrease redo skipped of a tablespace. More...
 
bool fil_space_is_redo_skipped (space_id_t space_id)
 Check whether a single-table tablespace is redo skipped. More...
 
bool fil_delete_file (const char *path)
 Delete the tablespace file and any related files like .cfg. More...
 
dberr_t fil_tablespace_iterate (dict_table_t *table, ulint n_io_buffers, PageCallback &callback)
 Iterate over all the pages in the tablespace. More...
 
bool fil_space_read_name_and_filepath (space_id_t space_id, char **name, char **filepath)
 Looks for a pre-existing fil_space_t with the given tablespace ID and, if found, returns the name and filepath in newly allocated buffers that the caller must free. More...
 
char * fil_path_to_space_name (const char *filename)
 Convert a file name to a tablespace name. More...
 
space_id_t fil_space_get_id_by_name (const char *name)
 Returns the space ID based on the tablespace name. More...
 
dberr_t fil_rename_precheck (const dict_table_t *old_table, const dict_table_t *new_table, const char *tmp_name)
 Check if swapping two .ibd files can be done without failure. More...
 
dberr_t fil_set_compression (dict_table_t *table, const char *algorithm)
 Set the compression type for the tablespace of a table. More...
 
Compression::Type fil_get_compression (space_id_t space_id)
 Get the compression type for the tablespace. More...
 
void fil_io_set_encryption (IORequest &req_type, const page_id_t &page_id, fil_space_t *space)
 Set encryption. More...
 
dberr_t fil_set_encryption (space_id_t space_id, Encryption::Type algorithm, byte *key, byte *iv)
 Set the encryption type for the tablespace. More...
 
bool fil_encryption_rotate ()
 Rotate the tablespace keys by new master key. More...
 
void fil_space_open_if_needed (fil_space_t *space)
 During crash recovery, open a tablespace if it had not been opened yet, to get valid size and flags. More...
 
void fil_no_punch_hole (fil_node_t *file)
 Note that the file system where the file resides doesn't support PUNCH HOLE. More...
 
bytefil_tablespace_redo_create (byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
 Redo a tablespace create. More...
 
bytefil_tablespace_redo_delete (byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
 Redo a tablespace drop. More...
 
bytefil_tablespace_redo_rename (byte *ptr, const byte *end, const page_id_t &page_id, ulint parsed_bytes, bool parse_only)
 Redo a tablespace rename. More...
 
bytefil_tablespace_redo_encryption (byte *ptr, const byte *end, space_id_t space_id)
 Parse and process an encryption redo record. More...
 
void fil_tablespace_open_init_for_recovery (bool recovery)
 Read the tablespace id to path mapping from the file. More...
 
bool fil_tablespace_lookup_for_recovery (space_id_t space_id)
 Lookup the space ID. More...
 
Fil_state fil_tablespace_path_equals (dd::Object_id dd_object_id, space_id_t space_id, const char *space_name, std::string old_path, std::string *new_path)
 Lookup the tablespace ID and return the path to the file. More...
 
bool fil_check_missing_tablespaces ()
 This function should be called after recovery has completed. More...
 
dberr_t fil_scan_for_tablespaces (const std::string &directories)
 Discover tablespaces by reading the header from .ibd files. More...
 
bool fil_tablespace_open_for_recovery (space_id_t space_id)
 Open the tabelspace and also get the tablespace filenames, space_id must already be known. More...
 
dberr_t fil_check_extend_space (fil_node_t *file)
 Callback to check tablespace size with space header size and extend Caller must own the Fil_shard mutex that the file belongs to. More...
 
bool fil_op_replay_rename_for_ddl (const page_id_t &page_id, const char *old_name, const char *new_name)
 Replay a file rename operation for ddl replay. More...
 
dberr_t fil_open_for_business (bool read_only_mode)
 Free the Tablespace_files instance. More...
 
bool fil_check_path (const std::string &path)
 Check if a path is known to InnoDB. More...
 
std::string fil_get_dirs ()
 Get the list of directories that InnoDB will search on startup. More...
 
dberr_t fil_rename_tablespace_by_name (const char *old_name, const char *new_name)
 Rename a tablespace by its name only. More...
 
void fil_free_scanned_files ()
 Free the data structures required for recovery. More...
 
void fil_space_update_name (fil_space_t *space, const char *name)
 Update the tablespace name. More...
 

Detailed Description

The low-level file system.

Created 10/25/1995 Heikki Tuuri

Macro Definition Documentation

◆ DOT_CFG

#define DOT_CFG   dot_ext[CFG]

◆ DOT_CFP

#define DOT_CFP   dot_ext[CFP]

◆ DOT_IBD

#define DOT_IBD   dot_ext[IBD]

◆ fil_block_check_type

#define fil_block_check_type (   block,
  type,
  mtr 
)    fil_page_check_type(block->page.id, block->frame, type, mtr)

Check (and if needed, reset) the page type.

Data files created before MySQL 5.1 may contain garbage in the FIL_PAGE_TYPE field. In MySQL 3.23.53, only undo log pages and index pages were tagged. Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.

Parameters
[in,out]blockblock with possibly invalid FIL_PAGE_TYPE
[in]typeexpected page type
[in,out]mtrmini-transaction

◆ fil_page_index_page_check

#define fil_page_index_page_check (   page)    fil_page_type_is_index(fil_page_get_type(page))

Check whether the page is index page (either regular Btree index or Rtree index.

◆ fil_page_type_is_index

#define fil_page_type_is_index (   page_type)
Value:
(page_type == FIL_PAGE_INDEX || page_type == FIL_PAGE_SDI || \
page_type == FIL_PAGE_RTREE)
constexpr page_type_t FIL_PAGE_INDEX
File page types (values of FIL_PAGE_TYPE)
Definition: fil0fil.h:780
constexpr page_type_t FIL_PAGE_RTREE
R-tree node.
Definition: fil0fil.h:783
constexpr page_type_t FIL_PAGE_SDI
Tablespace SDI Index page.
Definition: fil0fil.h:786

Check whether the page type is index (Btree or Rtree or SDI) type.

◆ fil_space_get_sys_space

#define fil_space_get_sys_space ( )    (fil_space_t::s_sys_space)
Returns
the system tablespace instance

Typedef Documentation

◆ fil_faddr_t

using fil_faddr_t = byte

'type' definition in C: an address stored in a file page is a string of bytes

◆ Filenames

using Filenames = std::vector<std::string, ut_allocator<std::string> >

◆ page_type_t

using page_type_t = uint16_t

◆ Space_ids

using Space_ids = std::vector<space_id_t, ut_allocator<space_id_t> >

Enumeration Type Documentation

◆ Fil_state

enum Fil_state
strong

Result of comparing a path.

Enumerator
MATCHES 

The path matches what was found during the scan.

MISSING 

No MLOG_FILE_DELETE record and the file could not be found.

DELETED 

A MLOG_FILE_DELETE was found, file was deleted.

MOVED 

Space ID matches but the paths don't match.

RENAMED 

Tablespace and/or filename was renamed.

The DDL log will handle this case.

◆ fil_type_t

enum fil_type_t : uint8_t

File types.

Enumerator
FIL_TYPE_TEMPORARY 

temporary tablespace (temporary undo log or tables)

FIL_TYPE_IMPORT 

a tablespace that is being imported (no logging until finished)

FIL_TYPE_TABLESPACE 

persistent tablespace (for system, undo log or tables)

FIL_TYPE_LOG 

redo log covering changes to files of FIL_TYPE_TABLESPACE

◆ ib_file_suffix

Common InnoDB file extentions.

Enumerator
NO_EXT 
IBD 
CFG 
CFP 

Function Documentation

◆ fil_addr_is_null()

bool fil_addr_is_null ( const fil_addr_t addr)

Returns true if file address is undefined.

Parameters
[in]addrFile address to check
Returns
true if undefined
Parameters
[in]addrAddress
Returns
true if undefined

◆ fil_aio_wait()

void fil_aio_wait ( ulint  segment)

Waits for an aio operation to complete.

This function is used to write the handler for completed requests. The aio array of pending requests is divided into segments (see os0file.cc for more info). The thread specifies which segment it wants to wait for.

Parameters
[in]segmentThe number of the segment in the AIO array to wait for

Waits for an aio operation to complete.

This function is used to write the handler for completed requests. The aio array of pending requests is divided into segments (see os0file.cc for more info). The thread specifies which segment it wants to wait for.

Parameters
[in]segmentThe number of the segment in the AIO array to wait for

◆ fil_assign_new_space_id()

bool fil_assign_new_space_id ( space_id_t space_id)

Assigns a new space id for a new single-table tablespace.

This works simply by incrementing the global counter. If 4 billion id's is not enough, we may need to recycle id's.

Parameters
[in,out]space_idNew space ID
Returns
true if assigned, false if not

This works simply by incrementing the global counter. If 4 billion id's is not enough, we may need to recycle id's.

Parameters
[out]space_idSet this to the new tablespace ID
Returns
true if assigned, false if not

◆ fil_check_extend_space()

dberr_t fil_check_extend_space ( fil_node_t file)

Callback to check tablespace size with space header size and extend Caller must own the Fil_shard mutex that the file belongs to.

Parameters
[in]filefile node
Returns
error code

Callback to check tablespace size with space header size and extend Caller must own the Fil_shard mutex that the file belongs to.

Caller must own the Fil_shard mutex that the file belongs to.

Parameters
[in]fileTablespace file
Returns
error code

◆ fil_check_missing_tablespaces()

bool fil_check_missing_tablespaces ( )

This function should be called after recovery has completed.

Check for tablespace files for which we did not see any MLOG_FILE_DELETE or MLOG_FILE_RENAME record. These could not be recovered

Returns
true if there were some filenames missing for which we had to ignore redo log records during the apply phase

◆ fil_check_path()

bool fil_check_path ( const std::string &  path)

Check if a path is known to InnoDB.

Parameters
[in]pathPath to check
Returns
true if path is known to InnoDB

◆ fil_close()

void fil_close ( )

Initializes the tablespace memory cache.

Initializes the tablespace memory cache.

◆ fil_close_all_files()

void fil_close_all_files ( )

Closes all open files.

There must not be any pending i/o's or not flushed modifications in the files.

◆ fil_close_log_files()

void fil_close_log_files ( bool  free_all)

Closes the redo log files.

There must not be any pending i/o's or not flushed modifications in the files.

Parameters
[in]free_allWhether to free the instances.

There must not be any pending i/o's or not flushed modifications in the files.

Parameters
[in]free_allIf set then free all instances

◆ fil_close_tablespace()

dberr_t fil_close_tablespace ( trx_t trx,
space_id_t  space_id 
)

Closes a single-table tablespace.

The tablespace must be cached in the memory cache. Free all pages used by the tablespace.

Parameters
[in,out]trxTransaction covering the close
[in]space_idTablespace ID
Returns
DB_SUCCESS or error

◆ fil_delete_file()

bool fil_delete_file ( const char *  path)

Delete the tablespace file and any related files like .cfg.

This should not be called for temporary tables.

Parameters
[in]pathFile path of the tablespace
Returns
true on success

This should not be called for temporary tables.

Parameters
[in]pathFile path of the IBD tablespace
Returns
true on success

◆ fil_delete_tablespace()

dberr_t fil_delete_tablespace ( space_id_t  space_id,
buf_remove_t  buf_remove 
)

Deletes an IBD tablespace, either general or single-table.

The tablespace must be cached in the memory cache. This will delete the datafile, fil_space_t & fil_node_t entries from the file_system_t cache.

Parameters
[in]space_idTablespace ID
[in]buf_removeSpecify the action to take on the pages for this table in the buffer pool.
Returns
DB_SUCCESS, DB_TABLESPCE_NOT_FOUND or DB_IO_ERROR

◆ fil_discard_tablespace()

dberr_t fil_discard_tablespace ( space_id_t  space_id)

Discards a single-table tablespace.

The tablespace must be cached in the memory cache. Discarding is like deleting a tablespace, but

  1. We do not drop the table from the data dictionary;
  2. We remove all insert buffer entries for the tablespace immediately; in DROP TABLE they are only removed gradually in the background;
  3. When the user does IMPORT TABLESPACE, the tablespace will have the same id as it originally had.
  4. Free all the pages in use by the tablespace if rename=true.
    Parameters
    [in]space_idTablespace ID
    Returns
    DB_SUCCESS or error
    The tablespace must be cached in the memory cache. Discarding is like deleting a tablespace, but
  1. We do not drop the table from the data dictionary;
  2. We remove all insert buffer entries for the tablespace immediately; in DROP TABLE they are only removed gradually in the background;
  3. Free all the pages in use by the tablespace.
    Parameters
    [in]space_idTablespace ID
    Returns
    DB_SUCCESS or error

◆ fil_encryption_rotate()

bool fil_encryption_rotate ( )

Rotate the tablespace keys by new master key.

Returns
true if the re-encrypt success
true if the re-encrypt succeeds

◆ fil_extend_tablespaces_to_stored_len()

void fil_extend_tablespaces_to_stored_len ( )

Extends all tablespaces to the size stored in the space header.

During the mysqlbackup –apply-log phase we extended the spaces on-demand so that log records could be appllied, but that may have left spaces still too small compared to the size stored in the space header.

◆ fil_flush()

void fil_flush ( space_id_t  space_id)

Flushes to disk possible writes cached by the OS.

If the space does not exist or is being dropped, does not do anything.

Parameters
[in]space_idTablespace ID (this can be a group of log files or a tablespace of the database)

If the space does not exist or is being dropped, does not do anything.

Parameters
[in]space_idFile space ID (this can be a group of log files or a tablespace of the database)

◆ fil_flush_file_redo()

void fil_flush_file_redo ( )

Flush to disk the writes in file spaces of the given type possibly cached by the OS.

◆ fil_flush_file_spaces()

void fil_flush_file_spaces ( uint8_t  purpose)

Flush to disk the writes in file spaces of the given type possibly cached by the OS.

Parameters
[in]purposeFIL_TYPE_TABLESPACE or FIL_TYPE_LOG, can be ORred.
[in]purposeFIL_TYPE_TABLESPACE or FIL_TYPE_LOG, can be ORred

◆ fil_free_scanned_files()

void fil_free_scanned_files ( )

Free the data structures required for recovery.

◆ fil_get_compression()

Compression::Type fil_get_compression ( space_id_t  space_id)

Get the compression type for the tablespace.

Parameters
[in]space_idSpace ID to check
Returns
the compression algorithm

Get the compression type for the tablespace.

Parameters
[in]space_idSpace ID to check
Returns
the compression algorithm

◆ fil_get_dirs()

std::string fil_get_dirs ( )

Get the list of directories that InnoDB will search on startup.

Returns
the list of directories 'dir1;dir2;....;dirN'

Get the list of directories that InnoDB will search on startup.

Returns
the list of directories 'dir1;dir2;....;dirN'

◆ fil_ibd_create()

dberr_t fil_ibd_create ( space_id_t  space_id,
const char *  name,
const char *  path,
ulint  flags,
page_no_t  size 
)

Create a tablespace file.

Parameters
[in]space_idTablespace ID
[in]nameTablespace name in dbname/tablename format. For general tablespaces, the 'dbname/' part may be missing.
[in]pathPath and filename of the datafile to create.
[in]flagsTablespace flags
[in]sizeInitial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE
Returns
DB_SUCCESS or error code

◆ fil_ibd_open()

dberr_t fil_ibd_open ( bool  validate,
fil_type_t  purpose,
space_id_t  space_id,
ulint  flags,
const char *  space_name,
const char *  table_name,
const char *  path_in,
bool  strict,
bool  old_space 
)

Open a single-table tablespace and optionally check the space id is right in it.

If not successful, print an error message to the error log. This function is used to open a tablespace when we start up mysqld, and also in IMPORT TABLESPACE. NOTE that we assume this operation is used either at the database startup or under the protection of the dictionary mutex, so that two users cannot race here.

The fil_node_t::handle will not be left open.

Parameters
[in]validatewhether we should validate the tablespace (read the first page of the file and check that the space id in it matches id)
[in]purposeFIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY
[in]space_idTablespace ID
[in]flagstablespace flags
[in]space_nametablespace name of the datafile If file-per-table, it is the table name in the databasename/tablename format
[in]table_nametable name in case need to build filename from it
[in]path_inexpected filepath, usually read from dictionary
[in]strictwhether to report error when open ibd failed
[in]old_spacewhether it is a 5.7 tablespace opening by upgrade
Returns
DB_SUCCESS or error code

If not successful, print an error message to the error log. This function is used to open a tablespace when we start up mysqld, and also in IMPORT TABLESPACE. NOTE that we assume this operation is used either at the database startup or under the protection of the dictionary mutex, so that two users cannot race here.

The fil_node_t::handle will not be left open.

Parameters
[in]validatewhether we should validate the tablespace (read the first page of the file and check that the space id in it matches id)
[in]purposeFIL_TYPE_TABLESPACE or FIL_TYPE_TEMPORARY
[in]space_idTablespace ID
[in]flagstablespace flags
[in]space_nametablespace name of the datafile If file-per-table, it is the table name in the databasename/tablename format
[in]table_nametable name in case if need to construct file path
[in]path_inexpected filepath, usually read from dictionary
[in]strictwhether to report error when open ibd failed
[in]old_spacewhether it is a 5.7 tablespace opening by upgrade
Returns
DB_SUCCESS or error code

◆ fil_init()

void fil_init ( ulint  max_n_open)

Initializes the tablespace memory cache.

Parameters
[in]max_n_openMax number of open files.
[in]max_n_openMaximum number of open files

◆ fil_io()

dberr_t fil_io ( const IORequest type,
bool  sync,
const page_id_t page_id,
const page_size_t page_size,
ulint  byte_offset,
ulint  len,
void *  buf,
void *  message 
)

Read or write data.

Parameters
[in]typeIO context
[in]syncIf true then do synchronous IO
[in]page_idpage id
[in]page_sizepage size
[in]byte_offsetremainder of offset in bytes; in aio this must be divisible by the OS block size
[in]lenhow many bytes to read or write; this must not cross a file boundary; in aio this must be a block size multiple
[in,out]bufbuffer where to store read data or from where to write; in aio this must be appropriately aligned
[in]messagemessage for aio handler if !sync, else ignored
Returns
error code
Return values
DB_SUCCESSon success
DB_TABLESPACE_DELETEDif the tablespace does not exist

Read or write data.

Parameters
[in]typeIO context
[in]syncIf true then do synchronous IO
[in]page_idpage id
[in]page_sizepage size
[in]byte_offsetremainder of offset in bytes; in aio this must be divisible by the OS block size
[in]lenhow many bytes to read or write; this must not cross a file boundary; in AIO this must be a block size multiple
[in,out]bufbuffer where to store read data or from where to write; in AIO this must be appropriately aligned
[in]messagemessage for AIO handler if !sync, else ignored
Returns
error code
Return values
DB_SUCCESSon success
DB_TABLESPACE_DELETEDif the tablespace does not exist

◆ fil_io_set_encryption()

void fil_io_set_encryption ( IORequest req_type,
const page_id_t page_id,
fil_space_t space 
)

Set encryption.

Parameters
[in,out]req_typeIO request
[in]page_idPage address for IO
[in,out]spaceTablespace instance

Set encryption.

Parameters
[in,out]req_typeIO request
[in]page_idpage id
[in]spacetable space

◆ fil_no_punch_hole()

void fil_no_punch_hole ( fil_node_t file)

Note that the file system where the file resides doesn't support PUNCH HOLE.

Parameters
[in,out]fileFile node to set

Called from AIO handlers when IO returns DB_IO_NO_PUNCH_HOLE

Parameters
[in,out]filefile to set

◆ fil_node_create()

char* fil_node_create ( const char *  name,
page_no_t  size,
fil_space_t space,
bool  is_raw,
bool  atomic_write,
page_no_t  max_pages 
)

Append a file to the chain of files of a space.

Parameters
[in]namefile name of a file that is not open
[in]sizefile size in entire database blocks
[in,out]spacetablespace from fil_space_create()
[in]is_rawwhether this is a raw device or partition
[in]atomic_writetrue if atomic write enabled
[in]max_pagesmaximum number of pages in file
Returns
pointer to the file name
Return values
nullptrif error

Append a file to the chain of files of a space.

File must be closed.

Parameters
[in]namefile name (file must be closed)
[in]sizefile size in database blocks, rounded downwards to an integer
[in,out]spacespace where to append
[in]is_rawtrue if a raw device or a raw disk partition
[in]atomic_writetrue if the file has atomic write enabled
[in]max_pagesmaximum number of pages in file
Returns
pointer to the file name
Return values
nullptrif error

◆ fil_op_replay_rename_for_ddl()

bool fil_op_replay_rename_for_ddl ( const page_id_t page_id,
const char *  old_name,
const char *  new_name 
)

Replay a file rename operation for ddl replay.

Parameters
[in]page_idSpace ID and first page number in the file
[in]old_nameold file name
[in]new_namenew file name
Returns
whether the operation was successfully applied (the name did not exist, or new_name did not exist and name was successfully renamed to new_name)

◆ fil_open_for_business()

dberr_t fil_open_for_business ( bool  read_only_mode)

Free the Tablespace_files instance.

Parameters
[in]read_only_modetrue if InnoDB is started in read only mode.
Returns
DB_SUCCESS if all OK

◆ fil_open_log_and_system_tablespace_files()

void fil_open_log_and_system_tablespace_files ( )

Opens all log files and system tablespace data files.

They stay open until the database server shutdown. This should be called at a server startup after the space objects for the log and the system tablespace have been created. The purpose of this operation is to make sure we never run out of file descriptors if we need to read from the insert buffer or to write to the log.

◆ fil_page_check_type()

void fil_page_check_type ( const page_id_t page_id,
byte page,
ulint  type,
mtr_t mtr 
)
inline

Check (and if needed, reset) the page type.

Data files created before MySQL 5.1 may contain garbage in the FIL_PAGE_TYPE field. In MySQL 3.23.53, only undo log pages and index pages were tagged. Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.

Parameters
[in]page_idpage number
[in,out]pagepage with possibly invalid FIL_PAGE_TYPE
[in]typeexpected page type
[in,out]mtrmini-transaction

◆ fil_page_get_next()

page_no_t fil_page_get_next ( const byte page)

Get the successor of a file page.

Parameters
[in]pageFile page
Returns
FIL_PAGE_NEXT

◆ fil_page_get_prev()

page_no_t fil_page_get_prev ( const byte page)

Get the predecessor of a file page.

Parameters
[in]pageFile page
Returns
FIL_PAGE_PREV

◆ fil_page_get_type()

page_type_t fil_page_get_type ( const byte page)
inline

Get the file page type.

Parameters
[in]pageFile page
Returns
page type

◆ fil_page_reset_type()

void fil_page_reset_type ( const page_id_t page_id,
byte page,
ulint  type,
mtr_t mtr 
)

Reset the page type.

Data files created before MySQL 5.1 may contain garbage in FIL_PAGE_TYPE. In MySQL 3.23.53, only undo log pages and index pages were tagged. Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.

Parameters
[in]page_idpage number
[in,out]pagepage with invalid FIL_PAGE_TYPE
[in]typeexpected page type
[in,out]mtrmini-transaction

◆ fil_page_set_type()

void fil_page_set_type ( byte page,
ulint  type 
)

Sets the file page type.

Parameters
[in,out]pageFile page
[in]typeFile page type to set
[in,out]pageFile page
[in]typePage type

◆ fil_path_to_space_name()

char* fil_path_to_space_name ( const char *  filename)

Convert a file name to a tablespace name.

Parameters
[in]filenamedirectory/databasename/tablename.ibd
Returns
database/tablename string, to be freed with ut_free()

Strip the file name prefix and suffix, leaving only databasename/tablename.

Parameters
[in]filenamedirectory/databasename/tablename.ibd
Returns
database/tablename string, to be freed with ut_free()

◆ fil_redo_io()

dberr_t fil_redo_io ( const IORequest type,
const page_id_t page_id,
const page_size_t page_size,
ulint  byte_offset,
ulint  len,
void *  buf 
)

Read or write redo log data (synchronous buffered IO).

Parameters
[in]typeIO context
[in]page_idwhere to read or write
[in]page_sizepage size
[in]byte_offsetremainder of offset in bytes
[in]lenthis must not cross a file boundary;
[in,out]bufbuffer where to store read data or from where to write
Return values
DB_SUCCESSif all OK

◆ fil_rename_precheck()

dberr_t fil_rename_precheck ( const dict_table_t old_table,
const dict_table_t new_table,
const char *  tmp_name 
)

Check if swapping two .ibd files can be done without failure.

Parameters
[in]old_tableold table
[in]new_tablenew table
[in]tmp_nametemporary table name
Returns
innodb error code

◆ fil_rename_tablespace()

bool fil_rename_tablespace ( space_id_t  space_id,
const char *  old_path,
const char *  new_name,
const char *  new_path_in 
)

Rename a single-table tablespace.

The tablespace must exist in the memory cache.

Parameters
[in]space_idTablespace ID
[in]old_pathOld file name
[in]new_nameNew tablespace name in the schema/name format
[in]new_path_inNew file name, or nullptr if it is located in The normal data directory
Returns
true if success

The tablespace must exist in the memory cache.

Parameters
[in]space_idTablespace ID
[in]old_pathOld file name
[in]new_nameNew tablespace name in the schema/name format
[in]new_path_inNew file name, or nullptr if it is located in the normal data directory
Returns
true if success

◆ fil_rename_tablespace_by_name()

dberr_t fil_rename_tablespace_by_name ( const char *  old_name,
const char *  new_name 
)

Rename a tablespace by its name only.

Parameters
[in]old_nameold tablespace name
[in]new_namenew tablespace name
Returns
DB_SUCCESS on success

◆ fil_rename_tablespace_check()

dberr_t fil_rename_tablespace_check ( space_id_t  space_id,
const char *  old_path,
const char *  new_path,
bool  is_discarded 
)

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.

Parameters
[in]space_idTablespace ID
[in]old_pathOld filepath
[in]new_pathNew filepath
[in]is_discardedWhether the tablespace is discarded
Returns
innodb error code
Parameters
[in]space_idtablespace id
[in]old_pathold filepath
[in]new_pathnew filepath
[in]is_discardedwhether the tablespace is discarded
Returns
innodb error code

◆ fil_scan_for_tablespaces()

dberr_t fil_scan_for_tablespaces ( const std::string &  directories)

Discover tablespaces by reading the header from .ibd files.

Parameters
[in]directoriesDirectories to scan
Returns
DB_SUCCESS if all goes well

◆ fil_set_compression()

dberr_t fil_set_compression ( dict_table_t table,
const char *  algorithm 
)

Set the compression type for the tablespace of a table.

Parameters
[in]tableTable that should be compressesed
[in]algorithmText representation of the algorithm
Returns
DB_SUCCESS or error code
Parameters
[in]tableThe table that should be compressed
[in]algorithmText representation of the algorithm
Returns
DB_SUCCESS or error code

◆ fil_set_encryption()

dberr_t fil_set_encryption ( space_id_t  space_id,
Encryption::Type  algorithm,
byte key,
byte iv 
)

Set the encryption type for the tablespace.

Parameters
[in]space_idSpace ID of tablespace for which to set
[in]algorithmEncryption algorithm
[in]keyEncryption key
[in]ivEncryption iv
Returns
DB_SUCCESS or error code

◆ fil_set_max_space_id_if_bigger()

void fil_set_max_space_id_if_bigger ( space_id_t  max_id)

Sets the max tablespace id counter if the given number is bigger than the previous value.

Parameters
[in]max_idMaximum known tablespace ID

◆ fil_space_acquire()

fil_space_t* fil_space_acquire ( space_id_t  space_id)

Acquire a tablespace when it could be dropped concurrently.

Used by background threads that do not necessarily hold proper locks for concurrency control.

Parameters
[in]space_idTablespace ID
Returns
the tablespace, or nullptr if missing or being deleted

◆ fil_space_acquire_silent()

fil_space_t* fil_space_acquire_silent ( space_id_t  space_id)

Acquire a tablespace that may not exist.

Used by background threads that do not necessarily hold proper locks for concurrency control.

Parameters
[in]space_idTablespace ID
Returns
the tablespace, or nullptr if missing or being deleted

◆ fil_space_close()

void fil_space_close ( space_id_t  space_id)

Close each file of a tablespace if open.

Parameters
[in]space_idTablespace ID
[in]space_idtablespace identifier

◆ fil_space_create()

fil_space_t* fil_space_create ( const char *  name,
space_id_t  space_id,
ulint  flags,
fil_type_t  purpose 
)

Create a space memory object and put it to the fil_system hash table.

The tablespace name is independent from the tablespace file-name. Error messages are issued to the server log.

Parameters
[in]nameTablespace name
[in]space_idTablespace ID
[in]flagstablespace flags
[in]purposetablespace purpose
Returns
pointer to created tablespace, to be filled in with fil_node_create()
Return values
nullptron failure (such as when the same tablespace exists)

The tablespace name is independent from the tablespace file-name. Error messages are issued to the server log.

Parameters
[in]nameTablespace name
[in]space_idTablespace ID
[in]flagsTablespace flags
[in]purposeTablespace purpose
Returns
pointer to created tablespace, to be filled in with fil_node_create()
Return values
nullptron failure (such as when the same tablespace exists)

◆ fil_space_dec_redo_skipped_count()

void fil_space_dec_redo_skipped_count ( space_id_t  space_id)

Decrease redo skipped of a tablespace.

Parameters
[in]space_idTablespace ID

Decrease redo skipped of a tablespace.

Parameters
[in]space_idTablespace id

◆ fil_space_exists_in_mem()

bool fil_space_exists_in_mem ( space_id_t  space_id,
const char *  name,
bool  print_err,
bool  adjust_space,
mem_heap_t heap,
table_id_t  table_id 
)

Returns true if a matching tablespace exists in the InnoDB tablespace memory cache.

Parameters
[in]space_idTablespace ID
[in]nameTablespace name used in fil_space_create().
[in]print_errdetailed error information to the error log if a matching tablespace is not found from memory.
[in]adjust_spaceWhether to adjust spaceid on mismatch
[in]heapHeap memory
[in]table_idtable id
Returns
true if a matching tablespace exists in the memory cache
Parameters
[in]space_idTablespace ID
[in]nameTablespace name used in space_create().
[in]print_errPrint detailed error information to the error log if a matching tablespace is not found from memory.
[in]adjust_spaceWhether to adjust space id on mismatch
[in]heapHeap memory
[in]table_idtable ID
Returns
true if a matching tablespace exists in the memory cache

◆ fil_space_extend()

bool fil_space_extend ( fil_space_t space,
page_no_t  size 
)

Try to extend a tablespace if it is smaller than the specified size.

Parameters
[in,out]spaceTablespace ID
[in]sizedesired size in pages
Returns
whether the tablespace is at least as big as requested
Parameters
[in,out]spacetablespace
[in]sizedesired size in pages
Returns
whether the tablespace is at least as big as requested

◆ fil_space_get()

fil_space_t* fil_space_get ( space_id_t  space_id)

Look up a tablespace.

The caller should hold an InnoDB table lock or a MDL that prevents the tablespace from being dropped during the operation, or the caller should be in single-threaded crash recovery mode (no user connections that could drop tablespaces). If this is not the case, fil_space_acquire() and fil_space_release() should be used instead.

Parameters
[in]space_idTablespace ID
Returns
tablespace, or nullptr if not found

◆ fil_space_get_first_path()

char* fil_space_get_first_path ( space_id_t  space_id)

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.

Parameters
[in]space_idTablespace ID
Returns
own: A copy of fil_node_t::path, nullptr if space ID is zero or not found.

◆ fil_space_get_flags()

ulint fil_space_get_flags ( space_id_t  space_id)

Returns the flags of the space.

The tablespace must be cached in the memory cache.

Parameters
[in]space_idTablespace ID for which to get the flags
Returns
flags, ULINT_UNDEFINED if space not found

◆ fil_space_get_id_by_name()

space_id_t fil_space_get_id_by_name ( const char *  name)

Returns the space ID based on the tablespace name.

The tablespace must be found in the tablespace memory cache. This call is made from external to this module, so the mutex is not owned.

Parameters
[in]nameTablespace name
Returns
space ID if tablespace found, SPACE_UNKNOWN if space not.

Returns the space ID based on the tablespace name.

The tablespace must be found in the tablespace memory cache.

Parameters
[in]nameTablespace name
Returns
space ID if tablespace found, SPACE_UNKNOWN if space not.

◆ fil_space_get_latch()

rw_lock_t* fil_space_get_latch ( space_id_t  space_id)

Returns the latch of a file space.

Parameters
[in]space_idTablespace ID
Returns
latch protecting storage allocation

◆ fil_space_get_n_reserved_extents()

ulint fil_space_get_n_reserved_extents ( space_id_t  space_id)

Gets the number of reserved extents.

If the database is silent, this number should be zero.

Parameters
[in]space_idTablespace ID
Returns
the number of reserved extents

◆ fil_space_get_page_size()

const page_size_t fil_space_get_page_size ( space_id_t  space_id,
bool found 
)

Returns the page size of the space and whether it is compressed or not.

The tablespace must be cached in the memory cache.

Parameters
[in]space_idTablespace ID
[out]foundtrue if tablespace was found
Returns
page size

◆ fil_space_get_size()

page_no_t fil_space_get_size ( space_id_t  space_id)

Returns the size of the space in pages.

The tablespace must be cached in the memory cache.

Parameters
[in]space_idTablespace ID
Returns
space size, 0 if space not found

◆ fil_space_get_type()

fil_type_t fil_space_get_type ( space_id_t  space_id)

Gets the type of a file space.

Parameters
[in]space_idTablespace ID
Returns
file type

◆ fil_space_inc_redo_skipped_count()

void fil_space_inc_redo_skipped_count ( space_id_t  space_id)

Increase redo skipped of a tablespace.

Parameters
[in]space_idTablespace ID

Increase redo skipped of a tablespace.

Parameters
[in]space_idTablespace ID

◆ fil_space_is_redo_skipped()

bool fil_space_is_redo_skipped ( space_id_t  space_id)

Check whether a single-table tablespace is redo skipped.

Parameters
[in]space_idTablespace ID
Returns
true if redo skipped
Parameters
[in]space_idTablespace id
Returns
true if redo skipped

◆ fil_space_open()

bool fil_space_open ( space_id_t  space_id)

Open each file of a tablespace if not already open.

Parameters
[in]space_idTablespace ID
Return values
trueif all file nodes were opened
falseon failure
Parameters
[in]space_idtablespace identifier
Return values
trueif all file nodes were opened
falseon failure

◆ fil_space_open_if_needed()

void fil_space_open_if_needed ( fil_space_t space)
inline

During crash recovery, open a tablespace if it had not been opened yet, to get valid size and flags.

Parameters
[in,out]spaceTablespace instance

◆ fil_space_read_name_and_filepath()

bool fil_space_read_name_and_filepath ( space_id_t  space_id,
char **  name,
char **  filepath 
)

Looks for a pre-existing fil_space_t with the given tablespace ID and, if found, returns the name and filepath in newly allocated buffers that the caller must free.

Parameters
[in]space_idThe tablespace ID to search for.
[out]nameName of the tablespace found.
[out]filepathThe filepath of the first datafile for thtablespace found.
Returns
true if tablespace is found, false if not.
Parameters
[in]space_idThe tablespace ID to search for.
[out]nameName of the tablespace found.
[out]filepathThe filepath of the first datafile for the tablespace.
Returns
true if tablespace is found, false if not.

◆ fil_space_release()

void fil_space_release ( fil_space_t space)

Release a tablespace acquired with fil_space_acquire().

Parameters
[in,out]spaceTablespace to release
[in,out]spacetablespace to release

◆ fil_space_release_free_extents()

void fil_space_release_free_extents ( space_id_t  space_id,
ulint  n_reserved 
)

Releases free extents in a file space.

Parameters
[in]space_idTablespace ID
[in]n_reservedHow many were reserved

◆ fil_space_reserve_free_extents()

bool fil_space_reserve_free_extents ( space_id_t  space_id,
ulint  n_free_now,
ulint  n_to_reserve 
)

Tries to reserve free extents in a file space.

Parameters
[in]space_idTablespace ID
[in]n_free_nowNumber of free extents now
[in]n_to_reserveHow many one wants to reserve
Returns
true if succeed

◆ fil_space_set_flags()

void fil_space_set_flags ( fil_space_t space,
ulint  flags 
)

Sets the flags of the tablespace.

The tablespace must be locked in MDL_EXCLUSIVE MODE.

Parameters
[in]spacetablespace in-memory struct
[in]flagstablespace flags

◆ fil_space_set_imported()

void fil_space_set_imported ( space_id_t  space_id)

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.

Parameters
[in]space_idTablespace ID

◆ fil_space_update_name()

void fil_space_update_name ( fil_space_t space,
const char *  name 
)

Update the tablespace name.

Incase, the new name and old name are same, no update done.

Parameters
[in,out]spacetablespace object on which name will be updated
[in]namenew name for tablespace

◆ fil_system_open_fetch()

std::string fil_system_open_fetch ( space_id_t  space_id)

Fetch the file name opened for a space_id during recovery from the file map.

Parameters
[in]space_idUndo tablespace ID
Returns
file name that was opened, empty string if space ID not found.

◆ fil_tablespace_iterate()

dberr_t fil_tablespace_iterate ( dict_table_t table,
ulint  n_io_buffers,
PageCallback callback 
)

Iterate over all the pages in the tablespace.

Parameters
tablethe table definiton in the server
n_io_buffersnumber of blocks to read and write together
callbackfunctor that will do the page updates
Returns
DB_SUCCESS or error code
Parameters
[in,out]tablethe table definiton in the server
[in]n_io_buffersnumber of blocks to read and write together
[in]callbackfunctor that will do the page updates
Returns
DB_SUCCESS or error code

Add an extra page for compressed page scratch area.

◆ fil_tablespace_lookup_for_recovery()

bool fil_tablespace_lookup_for_recovery ( space_id_t  space_id)

Lookup the space ID.

Parameters
[in]space_idTablespace ID to lookup
Returns
true if space ID is known and open

Lookup the space ID.

Parameters
[in]space_idTablespace ID to lookup
Returns
true if the space ID is known.

◆ fil_tablespace_open_for_recovery()

bool fil_tablespace_open_for_recovery ( space_id_t  space_id)

Open the tabelspace and also get the tablespace filenames, space_id must already be known.

Parameters
[in]space_idTablespace ID to lookup
Returns
true if open was successful

Open the tabelspace and also get the tablespace filenames, space_id must already be known.

Parameters
[in]space_idTablespace ID
Returns
true if the open was successful

◆ fil_tablespace_open_init_for_recovery()

void fil_tablespace_open_init_for_recovery ( bool  recovery)

Read the tablespace id to path mapping from the file.

Parameters
[in]recoverytrue if called from crash recovery

◆ fil_tablespace_path_equals()

Fil_state fil_tablespace_path_equals ( dd::Object_id  dd_object_id,
space_id_t  space_id,
const char *  space_name,
std::string  old_path,
std::string *  new_path 
)

Lookup the tablespace ID and return the path to the file.

The filename is ignored when testing for equality. Only the path up to the file name is considered for matching: e.g. ./test/a.ibd == ./test/b.ibd.

Parameters
[in]dd_object_idServer DD tablespace ID
[in]space_idTablespace ID to lookup
[in]space_nameTablespace name
[in]old_pathPath in the data dictionary
[out]new_pathNew path if scanned path not equal to path
Returns
status of the match.

◆ fil_tablespace_redo_create()

byte* fil_tablespace_redo_create ( byte ptr,
const byte end,
const page_id_t page_id,
ulint  parsed_bytes,
bool  parse_only 
)

Redo a tablespace create.

Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]page_idTablespace Id and first page in file
[in]parsed_bytesNumber of bytes parsed so far
[in]parse_onlyDon't apply the log if true
Returns
pointer to next redo log record
Return values
nullptrif this log record was truncated
Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]page_idTablespace Id and first page in file
[in]parsed_bytesNumber of bytes parsed so far
[in]parse_onlyDon't apply, parse only
Returns
pointer to next redo log record
Return values
nullptrif this log record was truncated

◆ fil_tablespace_redo_delete()

byte* fil_tablespace_redo_delete ( byte ptr,
const byte end,
const page_id_t page_id,
ulint  parsed_bytes,
bool  parse_only 
)

Redo a tablespace drop.

Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]page_idTablespace Id and first page in file
[in]parsed_bytesNumber of bytes parsed so far
[in]parse_onlyDon't apply the log if true
Returns
pointer to next redo log record
Return values
nullptrif this log record was truncated

Redo a tablespace drop.

Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]page_idTablespace Id and first page in file
[in]parsed_bytesNumber of bytes parsed so far
[in]parse_onlyDon't apply, parse only
Returns
pointer to next redo log record
Return values
nullptrif this log record was truncated

◆ fil_tablespace_redo_encryption()

byte* fil_tablespace_redo_encryption ( byte ptr,
const byte end,
space_id_t  space_id 
)

Parse and process an encryption redo record.

Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]space_idthe tablespace ID
Returns
log record end, nullptr if not a complete record

◆ fil_tablespace_redo_rename()

byte* fil_tablespace_redo_rename ( byte ptr,
const byte end,
const page_id_t page_id,
ulint  parsed_bytes,
bool  parse_only 
)

Redo a tablespace rename.

Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]page_idTablespace Id and first page in file
[in]parsed_bytesNumber of bytes parsed so far
[in]parse_onlyDon't apply the log if true
Returns
pointer to next redo log record
Return values
nullptrif this log record was truncated

This function doesn't do anything, simply parses the redo log record.

Parameters
[in]ptrredo log record
[in]endend of the redo log buffer
[in]page_idTablespace Id and first page in file
[in]parsed_bytesNumber of bytes parsed so far
[in]parse_onlyDon't apply, parse only
Returns
pointer to next redo log record
Return values
nullptrif this log record was truncated

◆ fil_truncate_tablespace()

bool fil_truncate_tablespace ( space_id_t  space_id,
page_no_t  size_in_pages 
)

Truncate the tablespace to needed size.

Parameters
[in]space_idId of tablespace to truncate
[in]size_in_pagesTruncate size.
Returns
true if truncate was successful.
Parameters
[in]space_idTablespace ID to truncate
[in]size_in_pagesTruncate size.
Returns
true if truncate was successful.

◆ fil_type_is_data()

bool fil_type_is_data ( fil_type_t  type)
inline

Check if fil_type is any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT or FIL_TYPE_TABLESPACE.

Parameters
[in]typevariable of type fil_type_t
Returns
true if any of FIL_TYPE_TEMPORARY, FIL_TYPE_IMPORT or FIL_TYPE_TABLESPACE

◆ fil_validate()

bool fil_validate ( )

Checks the consistency of the tablespace cache.

Returns
true if ok

◆ fil_write_flushed_lsn()

dberr_t fil_write_flushed_lsn ( lsn_t  lsn)

Write the flushed LSN to the page header of the first page in the system tablespace.

Parameters
[in]lsnFlushed LSN
Returns
DB_SUCCESS or error number
Parameters
[in]lsnflushed LSN
Returns
DB_SUCCESS or error number

◆ operator<<()

std::ostream& operator<< ( std::ostream &  out,
const fil_addr_t obj 
)
inline

Variable Documentation

◆ dot_ext

const char* dot_ext[]

Common InnoDB file extentions.

◆ fil_addr_null

fil_addr_t fil_addr_null

The null file address.

◆ FIL_IBD_FILE_INITIAL_SIZE

constexpr size_t FIL_IBD_FILE_INITIAL_SIZE = 7

Initial size of a single-table tablespace in pages.

◆ FIL_IBD_FILE_INITIAL_SIZE_5_7

constexpr size_t FIL_IBD_FILE_INITIAL_SIZE_5_7 = 4

An empty tablespace (CREATE TABLESPACE) has minimum of 4 pages and an empty CREATE TABLE (file_per_table) has 6 pages.

Minimum of these two is 4

◆ fil_n_file_opened

ulint fil_n_file_opened

Number of files currently open.

◆ fil_n_log_flushes

ulint fil_n_log_flushes

The number of fsyncs done to the log.

◆ fil_n_pending_log_flushes

ulint fil_n_pending_log_flushes

Number of pending redo log flushes.

◆ fil_n_pending_tablespace_flushes

ulint fil_n_pending_tablespace_flushes

Number of pending tablespace flushes.

◆ FIL_NODE_MAGIC_N

constexpr size_t FIL_NODE_MAGIC_N = 89389

◆ FIL_NULL

constexpr page_no_t FIL_NULL = std::numeric_limits<page_no_t>::max()

'null' (undefined) page offset in the context of file spaces

◆ FIL_PAGE_COMPRESSED

constexpr page_type_t FIL_PAGE_COMPRESSED = 14

Compressed page.

◆ FIL_PAGE_COMPRESSED_AND_ENCRYPTED

constexpr page_type_t FIL_PAGE_COMPRESSED_AND_ENCRYPTED = 16

Compressed and Encrypted page.

◆ FIL_PAGE_ENCRYPTED

constexpr page_type_t FIL_PAGE_ENCRYPTED = 15

Encrypted page.

◆ FIL_PAGE_ENCRYPTED_RTREE

constexpr page_type_t FIL_PAGE_ENCRYPTED_RTREE = 17

Encrypted R-tree page.

◆ FIL_PAGE_IBUF_BITMAP

constexpr page_type_t FIL_PAGE_IBUF_BITMAP = 5

Insert buffer bitmap.

◆ FIL_PAGE_IBUF_FREE_LIST

constexpr page_type_t FIL_PAGE_IBUF_FREE_LIST = 4

Insert buffer free list.

◆ FIL_PAGE_INDEX

constexpr page_type_t FIL_PAGE_INDEX = 17855

File page types (values of FIL_PAGE_TYPE)

B-tree node

◆ FIL_PAGE_INODE

constexpr page_type_t FIL_PAGE_INODE = 3

Index node.

◆ FIL_PAGE_RTREE

constexpr page_type_t FIL_PAGE_RTREE = 17854

R-tree node.

◆ FIL_PAGE_SDI

constexpr page_type_t FIL_PAGE_SDI = 17853

Tablespace SDI Index page.

◆ FIL_PAGE_SDI_BLOB

constexpr page_type_t FIL_PAGE_SDI_BLOB = 18

Uncompressed SDI BLOB page.

◆ FIL_PAGE_SDI_ZBLOB

constexpr page_type_t FIL_PAGE_SDI_ZBLOB = 19

Commpressed SDI BLOB page.

◆ FIL_PAGE_TYPE_ALLOCATED

constexpr page_type_t FIL_PAGE_TYPE_ALLOCATED = 0

Freshly allocated page.

◆ FIL_PAGE_TYPE_BLOB

constexpr page_type_t FIL_PAGE_TYPE_BLOB = 10

Uncompressed BLOB page.

◆ FIL_PAGE_TYPE_FSP_HDR

constexpr page_type_t FIL_PAGE_TYPE_FSP_HDR = 8

File space header.

◆ FIL_PAGE_TYPE_LAST

constexpr page_type_t FIL_PAGE_TYPE_LAST = FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY

Used by i_s.cc to index into the text description.

◆ FIL_PAGE_TYPE_LOB_DATA

constexpr page_type_t FIL_PAGE_TYPE_LOB_DATA = 23

Data pages of uncompressed LOB.

◆ FIL_PAGE_TYPE_LOB_FIRST

constexpr page_type_t FIL_PAGE_TYPE_LOB_FIRST = 24

The first page of an uncompressed LOB.

◆ FIL_PAGE_TYPE_LOB_INDEX

constexpr page_type_t FIL_PAGE_TYPE_LOB_INDEX = 22

Index pages of uncompressed LOB.

◆ FIL_PAGE_TYPE_RSEG_ARRAY

constexpr page_type_t FIL_PAGE_TYPE_RSEG_ARRAY = 21

Rollback Segment Array page.

◆ FIL_PAGE_TYPE_SYS

constexpr page_type_t FIL_PAGE_TYPE_SYS = 6

System page.

◆ FIL_PAGE_TYPE_TRX_SYS

constexpr page_type_t FIL_PAGE_TYPE_TRX_SYS = 7

Transaction system data.

◆ FIL_PAGE_TYPE_UNKNOWN

constexpr page_type_t FIL_PAGE_TYPE_UNKNOWN = 13

In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with this value when flushing pages.

◆ FIL_PAGE_TYPE_UNUSED

constexpr page_type_t FIL_PAGE_TYPE_UNUSED = 20

Available for future use.

◆ FIL_PAGE_TYPE_XDES

constexpr page_type_t FIL_PAGE_TYPE_XDES = 9

Extent descriptor page.

◆ FIL_PAGE_TYPE_ZBLOB

constexpr page_type_t FIL_PAGE_TYPE_ZBLOB = 11

First compressed BLOB page.

◆ FIL_PAGE_TYPE_ZBLOB2

constexpr page_type_t FIL_PAGE_TYPE_ZBLOB2 = 12

Subsequent compressed BLOB page.

◆ FIL_PAGE_TYPE_ZLOB_DATA

constexpr page_type_t FIL_PAGE_TYPE_ZLOB_DATA = 26

Data pages of compressed LOB.

◆ FIL_PAGE_TYPE_ZLOB_FIRST

constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FIRST = 25

The first page of a compressed LOB.

◆ FIL_PAGE_TYPE_ZLOB_FRAG

constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG = 28

Fragment pages of compressed LOB.

◆ FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY

constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY = 29

Index pages of fragment pages (compressed LOB).

◆ FIL_PAGE_TYPE_ZLOB_INDEX

constexpr page_type_t FIL_PAGE_TYPE_ZLOB_INDEX = 27

Index pages of compressed LOB.

This page contains an array of z_index_entry_t objects.

◆ FIL_PAGE_UNDO_LOG

constexpr page_type_t FIL_PAGE_UNDO_LOG = 2

Undo log page.

◆ FIL_SPACE_MAGIC_N

constexpr size_t FIL_SPACE_MAGIC_N = 89472

◆ general_space_name

const char general_space_name[]

This tablespace name is used internally during recovery to open a general tablespace before the data dictionary are recovered and available.

◆ MySQL_datadir_path

Fil_path MySQL_datadir_path

The MySQL server –datadir value.

The MySQL server –datadir value.

◆ PAGE_NO_MAX

constexpr page_no_t PAGE_NO_MAX = std::numeric_limits<page_no_t>::max() - 1

Maximum Page Number, one less than FIL_NULL.

◆ recv_recovery_on

volatile bool recv_recovery_on

true when applying redo log records during crash recovery; false otherwise.

Note that this is false while a background thread is rolling back incomplete transactions.

◆ SPACE_UNKNOWN

constexpr space_id_t SPACE_UNKNOWN = std::numeric_limits<space_id_t>::max()

Unknown space id.