MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fil0fil.cc File Reference
#include "fil0fil.h"
#include <debug_sync.h>
#include <my_dbug.h>
#include "mem0mem.h"
#include "hash0hash.h"
#include "os0file.h"
#include "mach0data.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "log0recv.h"
#include "fsp0fsp.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "dict0dict.h"
#include "page0page.h"
#include "page0zip.h"
#include "trx0sys.h"
#include "row0mysql.h"
#include "buf0lru.h"
#include "ibuf0ibuf.h"
#include "sync0sync.h"
#include "os0sync.h"
Include dependency graph for fil0fil.cc:

Go to the source code of this file.

Classes

struct  fil_node_t
struct  fil_space_t
struct  fil_system_t
struct  fsp_open_info
struct  Check
struct  fil_iterator_t

Macros

#define FIL_NODE_MAGIC_N   89389
#define FIL_SPACE_MAGIC_N   89472
#define fil_is_user_tablespace_id(i)   ((i) > srv_undo_tablespaces_open)
#define fil_buffering_disabled(s)

Functions

UNIV_INLINE ibool fil_space_belongs_in_lru (const fil_space_t *space)
UNIV_INLINE dberr_t fil_read (bool sync, ulint space_id, ulint zip_size, ulint block_offset, ulint byte_offset, ulint len, void *buf, void *message)
UNIV_INLINE dberr_t fil_write (bool sync, ulint space_id, ulint zip_size, ulint block_offset, ulint byte_offset, ulint len, void *buf, void *message)
UNIV_INLINE fil_space_tfil_space_get_by_id (ulint id)
UNIV_INLINE fil_space_tfil_space_get_by_name (const char *name)
UNIV_INTERN ib_int64_t fil_space_get_version (ulint id)
UNIV_INTERN rw_lock_tfil_space_get_latch (ulint id, ulint *flags)
UNIV_INTERN ulint fil_space_get_type (ulint id)
UNIV_INTERN char * fil_node_create (const char *name, ulint size, ulint id, ibool is_raw)
UNIV_INTERN ibool fil_space_create (const char *name, ulint id, ulint flags, ulint purpose)
UNIV_INTERN ibool fil_assign_new_space_id (ulint *space_id)
UNIV_INLINE fil_space_tfil_space_get_space (ulint id)
UNIV_INTERN char * fil_space_get_first_path (ulint id)
UNIV_INTERN ulint fil_space_get_size (ulint id)
UNIV_INTERN ulint fil_space_get_flags (ulint id)
UNIV_INTERN ulint fil_space_get_zip_size (ulint id)
UNIV_INTERN ibool fil_check_adress_in_tablespace (ulint id, ulint page_no)
UNIV_INTERN void fil_init (ulint hash_size, ulint max_n_open)
UNIV_INTERN void fil_open_log_and_system_tablespace_files (void)
UNIV_INTERN void fil_close_all_files (void)
UNIV_INTERN void fil_close_log_files (bool free)
UNIV_INTERN void fil_set_max_space_id_if_bigger (ulint max_id)
static ulint lsn_t ulint
arch_log_no 
__attribute__ ((unused)))
UNIV_INTERN dberr_t fil_write_flushed_lsn_to_data_files (lsn_t lsn, ulint arch_log_no)
UNIV_INTERN const char * fil_read_first_page (os_file_t data_file, ibool one_read_already, ulint *flags, ulint *space_id, lsn_t *min_flushed_lsn, lsn_t *max_flushed_lsn)
UNIV_INTERN ibool fil_inc_pending_ops (ulint id)
UNIV_INTERN void fil_decr_pending_ops (ulint id)
UNIV_INTERN byte * fil_op_log_parse_or_replay (byte *ptr, byte *end_ptr, ulint type, ulint space_id, ulint log_flags)
UNIV_INTERN dberr_t fil_close_tablespace (trx_t *trx, ulint id)
UNIV_INTERN dberr_t fil_delete_tablespace (ulint id, buf_remove_t buf_remove)
UNIV_INTERN ibool fil_tablespace_is_being_deleted (ulint id)
UNIV_INTERN dberr_t fil_discard_tablespace (ulint id)
UNIV_INTERN char * fil_make_ibd_name (const char *name, bool is_full_path)
UNIV_INTERN char * fil_make_isl_name (const char *name)
UNIV_INTERN ibool fil_rename_tablespace (const char *old_name_in, ulint id, const char *new_name, const char *new_path_in)
UNIV_INTERN dberr_t fil_create_link_file (const char *tablename, const char *filepath)
UNIV_INTERN void fil_delete_link_file (const char *tablename)
UNIV_INTERN char * fil_read_link_file (const char *name)
UNIV_INTERN ibool fil_open_linked_file (const char *tablename, char **remote_filepath, os_file_t *remote_file)
UNIV_INTERN dberr_t fil_create_new_single_table_tablespace (ulint space_id, const char *tablename, const char *dir_path, ulint flags, ulint flags2, ulint size)
UNIV_INTERN dberr_t fil_open_single_table_tablespace (bool validate, bool fix_dict, ulint id, ulint flags, const char *tablename, const char *path_in)
UNIV_INTERN dberr_t fil_load_single_table_tablespaces (void)
UNIV_INTERN ibool fil_tablespace_deleted_or_being_deleted_in_mem (ulint id, ib_int64_t version)
UNIV_INTERN ibool fil_tablespace_exists_in_mem (ulint id)
UNIV_INTERN ibool fil_space_for_table_exists_in_mem (ulint id, const char *name, ibool mark_space, ibool print_error_if_does_not_exist, bool adjust_space, mem_heap_t *heap, table_id_t table_id)
UNIV_INTERN ulint fil_get_space_id_for_table (const char *tablename)
UNIV_INTERN ibool fil_extend_space_to_desired_size (ulint *actual_size, ulint space_id, ulint size_after_extend)
UNIV_INTERN ibool fil_space_reserve_free_extents (ulint id, ulint n_free_now, ulint n_to_reserve)
UNIV_INTERN void fil_space_release_free_extents (ulint id, ulint n_reserved)
UNIV_INTERN ulint fil_space_get_n_reserved_extents (ulint id)
UNIV_INTERN dberr_t fil_io (ulint type, bool sync, ulint space_id, ulint zip_size, ulint block_offset, ulint byte_offset, ulint len, void *buf, void *message)
UNIV_INTERN void fil_aio_wait (ulint segment)
UNIV_INTERN void fil_flush (ulint space_id)
UNIV_INTERN void fil_flush_file_spaces (ulint purpose)
UNIV_INTERN ibool fil_validate (void)
UNIV_INTERN ibool fil_addr_is_null (fil_addr_t addr)
UNIV_INTERN ulint fil_page_get_prev (const byte *page)
UNIV_INTERN ulint fil_page_get_next (const byte *page)
UNIV_INTERN void fil_page_set_type (byte *page, ulint type)
UNIV_INTERN ulint fil_page_get_type (const byte *page)
UNIV_INTERN void fil_close (void)
UNIV_INTERN dberr_t fil_tablespace_iterate (dict_table_t *table, ulint n_io_buffers, PageCallback &callback)
UNIV_INTERN void fil_delete_file (const char *ibd_name)
UNIV_INTERN dberr_t fil_get_space_names (space_name_list_t &space_name_list)
UNIV_INTERN void fil_mtr_rename_log (ulint old_space_id, const char *old_name, ulint new_space_id, const char *new_name, const char *tmp_name, mtr_t *mtr)

Variables

UNIV_INTERN const char * fil_path_to_mysql_datadir = "."
UNIV_INTERN ulint fil_n_log_flushes = 0
UNIV_INTERN ulint fil_n_pending_log_flushes = 0
UNIV_INTERN ulint fil_n_pending_tablespace_flushes = 0
UNIV_INTERN ulint fil_n_file_opened = 0
UNIV_INTERN fil_addr_t fil_addr_null = {FIL_NULL, 0}
static ulint sum_of_sizes
static ulint lsn_t lsn

Detailed Description

The tablespace memory cache

Created 10/25/1995 Heikki Tuuri

Definition in file fil0fil.cc.

Macro Definition Documentation

#define fil_buffering_disabled (   s)
Value:
((s)->purpose == FIL_TABLESPACE \
&& srv_unix_file_flush_method \

Determine if user has explicitly disabled fsync().

Definition at line 323 of file fil0fil.cc.

#define fil_is_user_tablespace_id (   i)    ((i) > srv_undo_tablespaces_open)

Determine if (i) is a user tablespace id or not.

Definition at line 319 of file fil0fil.cc.

#define FIL_NODE_MAGIC_N   89389

Value of fil_node_t::magic_n

Definition at line 181 of file fil0fil.cc.

#define FIL_SPACE_MAGIC_N   89472

Value of fil_space_t::magic_n

Definition at line 256 of file fil0fil.cc.

Function Documentation

__attribute__ ( (unused)  )
new

< in: archived log number to write

Switch to a different input buffer.

Parameters
new_bufferThe new input buffer.

Definition at line 1886 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN ibool fil_addr_is_null ( fil_addr_t  addr)

Returns TRUE if file address is undefined.

Returns
TRUE if undefined
Parameters
addrin: address

Definition at line 5879 of file fil0fil.cc.

Here is the caller graph for this function:

UNIV_INTERN 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
segmentin: the number of the segment in the aio array to wait for

Definition at line 5549 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_assign_new_space_id ( ulint *  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.

Returns
TRUE if assigned, FALSE if not
Parameters
space_idin/out: space id

Definition at line 1343 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_check_adress_in_tablespace ( ulint  id,
ulint  page_no 
)

Checks if the pair space, page_no refers to an existing page in a tablespace file space. The tablespace must be cached in the memory cache.

Returns
TRUE if the address is meaningful
Parameters
idin: space id
page_noin: page number

Definition at line 1659 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_close ( void  )

Closes the tablespace memory cache.

Definition at line 5943 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN void fil_close_all_files ( void  )

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

Definition at line 1775 of file fil0fil.cc.

Here is the caller graph for this function:

UNIV_INTERN void fil_close_log_files ( bool  free)

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

Parameters
freein: whether to free the memory object

Definition at line 1810 of file fil0fil.cc.

UNIV_INTERN dberr_t fil_close_tablespace ( trx_t trx,
ulint  id 
)

Closes a single-table tablespace. The tablespace must be cached in the memory cache. Free all pages used by the tablespace.

Returns
DB_SUCCESS or error
Parameters
trxin/out: Transaction covering the close
idin: space id

Definition at line 2620 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN dberr_t fil_create_link_file ( const char *  tablename,
const char *  filepath 
)

Creates a new InnoDB Symbolic Link (ISL) file. It is always created under the 'datadir' of MySQL. The datadir is the directory of a running mysqld program. We can refer to it by simply using the path '.'.

Returns
DB_SUCCESS or error code
Parameters
tablenamein: tablename
filepathin: pathname of tablespace

Definition at line 3172 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t fil_create_new_single_table_tablespace ( ulint  space_id,
const char *  tablename,
const char *  dir_path,
ulint  flags,
ulint  flags2,
ulint  size 
)

Creates a new single-table tablespace to a database directory of MySQL. Database directories are under the 'datadir' of MySQL. The datadir is the directory of a running mysqld program. We can refer to it by simply the path '.'. Tables created with CREATE TEMPORARY TABLE we place in the temp dir of the mysqld server.

Returns
DB_SUCCESS or error code
Parameters
space_idin: space id
tablenamein: the table name in the usual databasename/tablename format of InnoDB
dir_pathin: NULL or a dir path
flagsin: tablespace flags
flags2in: table flags2
sizein: the initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE

Definition at line 3355 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_decr_pending_ops ( ulint  id)

Decrements the count of pending operations.

Parameters
idin: space id

Definition at line 2144 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN void fil_delete_file ( const char *  ibd_name)

Delete the tablespace file and any related files like .cfg. This should not be called for temporary tables.

Parameters
ibd_namein: filepath of the ibd tablespace

Definition at line 6273 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_delete_link_file ( const char *  tablename)

Deletes an InnoDB Symbolic Link (ISL) file.

Parameters
tablenamein: name of table

Definition at line 3245 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t fil_delete_tablespace ( ulint  id,
buf_remove_t  buf_remove 
)

Deletes a single-table tablespace. The tablespace must be cached in the memory cache.

Returns
DB_SUCCESS or error
Parameters
idin: space id
buf_removein: specify the action to take on the tables pages in the buffer pool

Definition at line 2684 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t fil_discard_tablespace ( ulint  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;
  1. We remove all insert buffer entries for the tablespace immediately; in DROP TABLE they are only removed gradually in the background;
  1. Free all the pages in use by the tablespace.
    Returns
    DB_SUCCESS or error
Parameters
idin: space id

Definition at line 2852 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_extend_space_to_desired_size ( ulint *  actual_size,
ulint  space_id,
ulint  size_after_extend 
)

Tries to extend a data file so that it would accommodate the number of pages given. The tablespace must be cached in the memory cache. If the space is big enough already, does nothing.

Returns
TRUE if success
Parameters
actual_sizeout: size of the space after extension; if we ran out of disk space this may be lower than the desired size
space_idin: space id
size_after_extendin: desired size in pages after the extension; if the current space size is bigger than this already, the function does nothing

Definition at line 4847 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN void fil_flush ( ulint  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.

< prevent dropping of the space while we are flushing

Parameters
space_idin: file space id (this can be a group of log files or a tablespace of the database)

Definition at line 5617 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_flush_file_spaces ( ulint  purpose)

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

Parameters
purposein: FIL_TABLESPACE, FIL_LOG

Definition at line 5755 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_get_space_id_for_table ( const char *  tablename)

Checks if a single-table tablespace for a given table name exists in the tablespace memory cache.

Returns
space id, ULINT_UNDEFINED if not found
Parameters
tablenamein: table name in the standard 'databasename/tablename' format

Definition at line 4815 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t fil_get_space_names ( space_name_list_t &  space_name_list)

Iterate over all the spaces in the space list and fetch the tablespace names. It will return a copy of the name that must be freed by the caller using: delete[].

Returns
DB_SUCCESS if all OK.
Parameters
space_name_listin/out: List to append to

Definition at line 6298 of file fil0fil.cc.

UNIV_INTERN ibool fil_inc_pending_ops ( ulint  id)

Increments the count of pending operation, if space is not being deleted.

Returns
TRUE if being deleted, and operation should be skipped
Parameters
idin: space id

Definition at line 2110 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN void fil_init ( ulint  hash_size,
ulint  max_n_open 
)

Initializes the tablespace memory cache.

Parameters
hash_sizein: hash table size
max_n_openin: max number of open files

Definition at line 1676 of file fil0fil.cc.

UNIV_INTERN dberr_t fil_io ( ulint  type,
bool  sync,
ulint  space_id,
ulint  zip_size,
ulint  block_offset,
ulint  byte_offset,
ulint  len,
void *  buf,
void *  message 
)

Reads or writes data. This operation is asynchronous (aio).

Returns
DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do i/o on a tablespace which does not exist
Parameters
typein: OS_FILE_READ or OS_FILE_WRITE, ORed to OS_FILE_LOG, if a log i/o and ORed to OS_AIO_SIMULATED_WAKE_LATER if simulated aio and we want to post a batch of i/os; NOTE that a simulated batch may introduce hidden chances of deadlocks, because i/os are not actually handled until all have been posted: use with great caution!
syncin: true if synchronous aio is desired
space_idin: space id
zip_sizein: compressed page size in bytes; 0 for uncompressed pages
block_offsetin: offset in number of blocks
byte_offsetin: remainder of offset in bytes; in aio this must be divisible by the OS block size
lenin: how many bytes to read or write; this must not cross a file boundary; in aio this must be a block size multiple
bufin/out: buffer where to store read data or from where to write; in aio this must be appropriately aligned
messagein: message for aio handler if non-sync aio used, else ignored

Definition at line 5295 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t fil_load_single_table_tablespaces ( void  )

At the server startup, if we need crash recovery, scans the database directories under the MySQL datadir, looking for .ibd files. Those files are single-table tablespaces. We need to know the space id in each of them so that we know into which file we should look to check the contents of a page stored in the doublewrite buffer, also to know where to apply log records where the space id is != 0.

Returns
DB_SUCCESS or error number

Definition at line 4442 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN char* fil_make_ibd_name ( const char *  name,
bool  is_full_path 
)

Allocates a file name for a single-table tablespace. The string must be freed by caller with mem_free().

Returns
own: file name
Parameters
namein: table name or a dir path
is_full_pathin: TRUE if it is a dir path

Definition at line 2942 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN char* fil_make_isl_name ( const char *  name)

Allocates a file name for a tablespace ISL file (InnoDB Symbolic Link). The string must be freed by caller with mem_free().

Returns
own: file name
Parameters
namein: table name

Definition at line 2974 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_mtr_rename_log ( ulint  old_space_id,
const char *  old_name,
ulint  new_space_id,
const char *  new_name,
const char *  tmp_name,
mtr_t mtr 
)

Generate redo logs for swapping two .ibd files

Parameters
old_space_idin: tablespace id of the old table.
old_namein: old table name
new_space_idin: tablespace id of the new table
new_namein: new table name
tmp_namein: temp table name used while swapping
mtrin/out: mini-transaction

Definition at line 6341 of file fil0fil.cc.

UNIV_INTERN char* fil_node_create ( const char *  name,
ulint  size,
ulint  id,
ibool  is_raw 
)

Appends a new file to the chain of files of a space. File must be closed.

Returns
pointer to the file name, or NULL on error
Parameters
namein: file name (file must be closed)
sizein: file size in database blocks, rounded downwards to an integer
idin: space id where to append
is_rawin: TRUE if a raw device or a raw disk partition

Definition at line 632 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN byte* fil_op_log_parse_or_replay ( byte *  ptr,
byte *  end_ptr,
ulint  type,
ulint  space_id,
ulint  log_flags 
)

Parses the body of a log record written about an .ibd file operation. That is, the log record part after the standard (type, space id, page no) header of the log record.

If desired, also replays the delete or rename operation if the .ibd file exists and the space id in it matches. Replays the create operation if a file at that path does not exist yet. If the database directory for the file to be created does not exist, then we create the directory, too.

Note that ibbackup –apply-log sets fil_path_to_mysql_datadir to point to the datadir that we should use in replaying the file operations.

InnoDB recovery does not replay these fully since it always sets the space id to zero. But ibbackup does replay them. TODO: If remote tablespaces are used, ibbackup will only create tables in the default directory since MLOG_FILE_CREATE and MLOG_FILE_CREATE2 only know the tablename, not the path.

Returns
end of log record, or NULL if the record was not completely contained between ptr and end_ptr
Parameters
ptrin: buffer containing the log record body, or an initial segment of it, if the record does not fir completely between ptr and end_ptr
end_ptrin: buffer end
typein: the type of this log record
space_idin: the space id of the tablespace in question, or 0 if the log record should only be parsed but not replayed
log_flagsin: redo log flags (stored in the page number parameter)

Definition at line 2287 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN ibool fil_open_linked_file ( const char *  tablename,
char **  remote_filepath,
os_file_t remote_file 
)

Opens a handle to the file linked to in an InnoDB Symbolic Link file.

Returns
TRUE if remote linked tablespace file is found and opened.
Parameters
tablenamein: database/tablename
remote_filepathout: remote filepath
remote_fileout: remote file handle

Definition at line 3304 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_open_log_and_system_tablespace_files ( void  )

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.

Definition at line 1708 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN dberr_t fil_open_single_table_tablespace ( bool  validate,
bool  fix_dict,
ulint  id,
ulint  flags,
const char *  tablename,
const char *  path_in 
)

Tries to open a single-table tablespace and optionally checks that the space id in it is correct. If this does not succeed, print an error message to the .err log. This function is used to open a tablespace when we start mysqld after the dictionary has been booted, 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. This operation does not leave the file associated with the tablespace open, but closes it after we have looked at the space id in it.

If the validate boolean is set, we read the first page of the file and check that the space id in the file is what we expect. We assume that this function runs much faster if no check is made, since accessing the file inode probably is much faster (the OS caches them) than accessing the first page of the file. This boolean may be initially FALSE, but if a remote tablespace is found it will be changed to true.

If the fix_dict boolean is set, then it is safe to use an internal SQL statement to update the dictionary tables if they are incorrect.

Returns
DB_SUCCESS or error code
Parameters
validatein: Do we validate tablespace?
fix_dictin: Can we fix the dictionary?
idin: space id
flagsin: tablespace flags
tablenamein: table name in the databasename/tablename format
path_inin: tablespace filepath

Definition at line 3646 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_page_get_next ( const byte *  page)

Get the successor of a file page.

Returns
FIL_PAGE_NEXT
Parameters
pagein: file page

Definition at line 5903 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_page_get_prev ( const byte *  page)

Get the predecessor of a file page.

Returns
FIL_PAGE_PREV
Parameters
pagein: file page

Definition at line 5891 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_page_get_type ( const byte *  page)

Gets the file page type.

Returns
type; NOTE that if the type has not been written to page, the return value not defined
Parameters
pagein: file page

Definition at line 5930 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_page_set_type ( byte *  page,
ulint  type 
)

Sets the file page type.

Parameters
pagein/out: file page
typein: type

Definition at line 5914 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE dberr_t fil_read ( bool  sync,
ulint  space_id,
ulint  zip_size,
ulint  block_offset,
ulint  byte_offset,
ulint  len,
void *  buf,
void *  message 
)

Reads data from a space to a buffer. Remember that the possible incomplete blocks at the end of file are ignored: they are not taken into account when calculating the byte offset within a space.

Returns
DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do i/o on a tablespace which does not exist
Parameters
syncin: true if synchronous aio is desired
space_idin: space id
zip_sizein: compressed page size in bytes; 0 for uncompressed pages
block_offsetin: offset in number of blocks
byte_offsetin: remainder of offset in bytes; in aio this must be divisible by the OS block size
lenin: how many bytes to read; this must not cross a file boundary; in aio this must be a block size multiple
bufin/out: buffer where to store data read; in aio this must be appropriately aligned
messagein: message for aio handler if non-sync aio used, else ignored

Definition at line 420 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN const char* fil_read_first_page ( os_file_t  data_file,
ibool  one_read_already,
ulint *  flags,
ulint *  space_id,
lsn_t *  min_flushed_lsn,
lsn_t *  max_flushed_lsn 
)

Reads the flushed lsn, arch no, and tablespace flag fields from a data file at database startup.

Return values
NULLon success, or if innodb_force_recovery is set
Returns
pointer to an error message string
Parameters
data_filein: open data file
one_read_alreadyin: TRUE if min and max parameters below already contain sensible data
flagsout: tablespace flags
space_idout: tablespace ID
min_flushed_lsnout: min of flushed lsn values in data files
max_flushed_lsnout: max of flushed lsn values in data files

Definition at line 2026 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN char* fil_read_link_file ( const char *  name)

Reads an InnoDB Symbolic Link (ISL) file. It is always created under the 'datadir' of MySQL. The name is of the form {databasename}/{tablename}. and the isl file is expected to be in a '{databasename}' directory called '{tablename}.isl'. The caller must free the memory of the null-terminated path returned if it is not null.

Returns
own: filepath found in link file, NULL if not found.
Parameters
namein: tablespace name

Definition at line 3265 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_rename_tablespace ( const char *  old_name_in,
ulint  id,
const char *  new_name,
const char *  new_path_in 
)

Renames a single-table tablespace. The tablespace must be cached in the tablespace memory cache.

Returns
TRUE if success
Parameters
old_name_inin: old table name in the standard databasename/tablename format of InnoDB, or NULL if we do the rename based on the space id only
idin: space id
new_namein: new table name in the standard databasename/tablename format of InnoDB
new_path_inin: new full datafile path if the tablespace is remotely located, or NULL if it is located in the normal data directory.

Definition at line 2999 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_set_max_space_id_if_bigger ( ulint  max_id)

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

Parameters
max_idin: maximum known id

Definition at line 1853 of file fil0fil.cc.

Here is the caller graph for this function:

UNIV_INLINE ibool fil_space_belongs_in_lru ( const fil_space_t space)

Determines if a file node belongs to the least-recently-used list.

Returns
TRUE if the file belongs to fil_system->LRU mutex.
Parameters
spacein: file space

Definition at line 365 of file fil0fil.cc.

Here is the caller graph for this function:

UNIV_INTERN ibool fil_space_create ( const char *  name,
ulint  id,
ulint  flags,
ulint  purpose 
)

Creates a space memory object and puts it to the 'fil system' hash table. If there is an error, prints an error message to the .err log.

Returns
TRUE if success
Parameters
namein: space name
idin: space id
flagsin: tablespace flags
purposein: FIL_TABLESPACE, or FIL_LOG if log

Definition at line 1231 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_space_for_table_exists_in_mem ( ulint  id,
const char *  name,
ibool  mark_space,
ibool  print_error_if_does_not_exist,
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. Note that if we have not done a crash recovery at the database startup, there may be many tablespaces which are not yet in the memory cache.

Returns
TRUE if a matching tablespace exists in the memory cache
Parameters
idin: space id
namein: table name used in fil_space_create(). Either the standard 'dbname/tablename' format or table->dir_path_of_temp_table
mark_spacein: in crash recovery, at database startup we mark all spaces which have an associated table in the InnoDB data dictionary, so that we can print a warning about orphaned tablespaces
print_error_if_does_not_existin: print detailed error information to the .err log if a matching tablespace is not found from memory
adjust_spacein: whether to adjust space id when find table space mismatch
heapin: heap memory
table_idin: table id

Definition at line 4652 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE fil_space_t* fil_space_get_by_id ( ulint  id)

Returns the table space by a given id, NULL if not found.

Parameters
idin: space id

Definition at line 476 of file fil0fil.cc.

Here is the caller graph for this function:

UNIV_INLINE fil_space_t* fil_space_get_by_name ( const char *  name)

Returns the table space by a given name, NULL if not found.

Parameters
namein: space name

Definition at line 496 of file fil0fil.cc.

Here is the caller graph for this function:

UNIV_INTERN char* fil_space_get_first_path ( ulint  id)

Returns the path from the first fil_node_t found for the space ID sent. The caller is responsible for freeing the memory allocated here for the value returned.

Returns
own: A copy of fil_node_t::path, NULL if space ID is zero or not found.
Parameters
idin: space id

Definition at line 1538 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_space_get_flags ( ulint  id)

Returns the flags of the space. The tablespace must be cached in the memory cache.

Returns
flags, ULINT_UNDEFINED if space not found
Parameters
idin: space id

Definition at line 1601 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN rw_lock_t* fil_space_get_latch ( ulint  id,
ulint *  flags 
)

Returns the latch of a file space.

Returns
latch protecting storage allocation
Parameters
idin: space id
flagsout: tablespace flags

Definition at line 549 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_space_get_n_reserved_extents ( ulint  id)

Gets the number of reserved extents. If the database is silent, this number should be zero.

Parameters
idin: space id

Definition at line 5137 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_space_get_size ( ulint  id)

Returns the size of the space in pages. The tablespace must be cached in the memory cache.

Returns
space size, 0 if space not found
Parameters
idin: space id

Definition at line 1576 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE fil_space_t* fil_space_get_space ( ulint  id)

Returns a pointer to the file_space_t that is in the memory cache associated with a space id. The caller must lock fil_system->mutex.

Returns
file_space_t pointer, NULL if space not found
Parameters
idin: space id

Definition at line 1477 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_space_get_type ( ulint  id)

Returns the type of a file space.

Returns
FIL_TABLESPACE or FIL_LOG
Parameters
idin: space id

Definition at line 578 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ib_int64_t fil_space_get_version ( ulint  id)

Returns the version number of a tablespace, -1 if not found.

Returns
version number, -1 if the tablespace does not exist in the memory cache
Parameters
idin: space id

Definition at line 522 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint fil_space_get_zip_size ( ulint  id)

Returns the compressed page size of the space, or 0 if the space is not compressed. The tablespace must be cached in the memory cache.

Returns
compressed page size, ULINT_UNDEFINED if space not found
Parameters
idin: space id

Definition at line 1637 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void fil_space_release_free_extents ( ulint  id,
ulint  n_reserved 
)

Releases free extents in a file space.

Parameters
idin: space id
n_reservedin: how many one reserved

Definition at line 5111 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN ibool fil_space_reserve_free_extents ( ulint  id,
ulint  n_free_now,
ulint  n_to_reserve 
)

Tries to reserve free extents in a file space.

Returns
TRUE if succeed
Parameters
idin: space id
n_free_nowin: number of free extents now
n_to_reservein: how many one wants to reserve

Definition at line 5078 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN ibool fil_tablespace_deleted_or_being_deleted_in_mem ( ulint  id,
ib_int64_t  version 
)

Returns TRUE if a single-table tablespace does not exist in the memory cache, or is being deleted there.

Returns
TRUE if does not exist or is being deleted
Parameters
idin: space id
versionin: tablespace_version should be this; if you pass -1 as the value of this, then this parameter is ignored

Definition at line 4567 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INTERN ibool fil_tablespace_exists_in_mem ( ulint  id)

Returns TRUE if a single-table tablespace exists in the memory cache.

Returns
TRUE if exists
Parameters
idin: space id

Definition at line 4605 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_tablespace_is_being_deleted ( ulint  id)

Returns TRUE if a single-table tablespace is being deleted.

Returns
TRUE if being deleted
Parameters
idin: space id

Definition at line 2818 of file fil0fil.cc.

Here is the call graph for this function:

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

Iterate over all the pages in the tablespace.

Parameters
table- the table definiton in the server
n_io_buffers- number of blocks to read and write together
callback- functor that will do the page updates
Returns
DB_SUCCESS or error code

Add an extra page for compressed page scratch area.

Definition at line 6114 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool fil_validate ( void  )

Checks the consistency of the tablespace cache.

Returns
TRUE if ok

Definition at line 5817 of file fil0fil.cc.

Here is the call graph for this function:

UNIV_INLINE dberr_t fil_write ( bool  sync,
ulint  space_id,
ulint  zip_size,
ulint  block_offset,
ulint  byte_offset,
ulint  len,
void *  buf,
void *  message 
)

Writes data to a space from a buffer. Remember that the possible incomplete blocks at the end of file are ignored: they are not taken into account when calculating the byte offset within a space.

Returns
DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do i/o on a tablespace which does not exist
Parameters
syncin: true if synchronous aio is desired
space_idin: space id
zip_sizein: compressed page size in bytes; 0 for uncompressed pages
block_offsetin: offset in number of blocks
byte_offsetin: remainder of offset in bytes; in aio this must be divisible by the OS block size
lenin: how many bytes to write; this must not cross a file boundary; in aio this must be a block size multiple
bufin: buffer from which to write; in aio this must be appropriately aligned
messagein: message for aio handler if non-sync aio used, else ignored

Definition at line 449 of file fil0fil.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t fil_write_flushed_lsn_to_data_files ( lsn_t  lsn,
ulint  arch_log_no 
)

Writes the flushed lsn and the latest archived log number to the page header of the first page of each data file in the system tablespace.

Returns
DB_SUCCESS or error number
Parameters
lsnin: lsn to write
arch_log_noin: latest archived log file number

Definition at line 1916 of file fil0fil.cc.

Here is the caller graph for this function:

Variable Documentation

UNIV_INTERN fil_addr_t fil_addr_null = {FIL_NULL, 0}

The null file address

Definition at line 131 of file fil0fil.cc.

UNIV_INTERN ulint fil_n_file_opened = 0

Number of files currently open

Definition at line 128 of file fil0fil.cc.

UNIV_INTERN ulint fil_n_log_flushes = 0

The number of fsyncs done to the log

Definition at line 120 of file fil0fil.cc.

UNIV_INTERN ulint fil_n_pending_log_flushes = 0

Number of pending redo log flushes

Definition at line 123 of file fil0fil.cc.

UNIV_INTERN ulint fil_n_pending_tablespace_flushes = 0

Number of pending tablespace flushes

Definition at line 125 of file fil0fil.cc.

UNIV_INTERN const char* fil_path_to_mysql_datadir = "."
When mysqld is run, the default directory "." is the mysqld datadir,

but in the MySQL Embedded Server Library and ibbackup it is not the default directory, and we must set the base file path explicitly

Definition at line 117 of file fil0fil.cc.

ulint lsn_t lsn

in: lsn to write

Definition at line 1884 of file fil0fil.cc.

ulint sum_of_sizes

< in: space to write to in: combined size of previous files in space, in database pages

Definition at line 1884 of file fil0fil.cc.