📄 fil0fil.h
字号:
of InnoDB *//***********************************************************************Creates a new single-table tablespace to a database directory of MySQL.Database directories are under the 'datadir' of MySQL. The datadir is thedirectory of a running mysqld program. We can refer to it by simply thepath '.'. Tables created with CREATE TEMPORARY TABLE we place in the tempdir of the mysqld server. */ulintfil_create_new_single_table_tablespace(/*===================================*/ /* out: DB_SUCCESS or error code */ ulint* space_id, /* in/out: space id; if this is != 0, then this is an input parameter, otherwise output */ const char* tablename, /* in: the table name in the usual databasename/tablename format of InnoDB, or a dir path to a temp table */ ibool is_temp, /* in: TRUE if a table created with CREATE TEMPORARY TABLE */ ulint size); /* in: the initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE *//************************************************************************Tries to open a single-table tablespace and optionally checks the space id isright in it. If does not succeed, prints an error message to the .err log. Thisfunction is used to open a tablespace when we start up mysqld, and also inIMPORT TABLESPACE.NOTE that we assume this operation is used either at the database startupor under the protection of the dictionary mutex, so that two users cannotrace here. This operation does not leave the file associated with thetablespace open, but closes it after we have looked at the space id in it. */iboolfil_open_single_table_tablespace(/*=============================*/ /* out: TRUE if success */ ibool check_space_id, /* in: should we check that the space id in the file is right; 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 */ ulint id, /* in: space id */ const char* name); /* in: table name in the databasename/tablename format *//************************************************************************It is possible, though very improbable, that the lsn's in the tablespace to beimported have risen above the current system lsn, if a lengthy purge, ibufmerge, or rollback was performed on a backup taken with ibbackup. If that isthe case, reset page lsn's in the file. We assume that mysqld was shut downafter it performed these cleanup operations on the .ibd file, so that it atthe shutdown stamped the latest lsn to the FIL_PAGE_FILE_FLUSH_LSN in thefirst page of the .ibd file, and we can determine whether we need to reset thelsn's just by looking at that flush lsn. */iboolfil_reset_too_high_lsns(/*====================*/ /* out: TRUE if success */ const char* name, /* in: table name in the databasename/tablename format */ dulint current_lsn); /* in: reset lsn's if the lsn stamped to FIL_PAGE_FILE_FLUSH_LSN in the first page is too high *//************************************************************************At the server startup, if we need crash recovery, scans the databasedirectories under the MySQL datadir, looking for .ibd files. Those files aresingle-table tablespaces. We need to know the space id in each of them so thatwe know into which file we should look to check the contents of a page storedin the doublewrite buffer, also to know where to apply log records where thespace id is != 0. */ulintfil_load_single_table_tablespaces(void);/*===================================*/ /* out: DB_SUCCESS or error number *//************************************************************************If we need crash recovery, and we have calledfil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(),we can call this function to print an error message of orphaned .ibd filesfor which there is not a data dictionary entry with a matching table nameand space id. */voidfil_print_orphaned_tablespaces(void);/*================================*//***********************************************************************Returns TRUE if a single-table tablespace does not exist in the memory cache,or is being deleted there. */iboolfil_tablespace_deleted_or_being_deleted_in_mem(/*===========================================*/ /* out: TRUE if does not exist or is being\ deleted */ ulint id, /* in: space id */ ib_longlong version);/* in: tablespace_version should be this; if you pass -1 as the value of this, then this parameter is ignored *//***********************************************************************Returns TRUE if a single-table tablespace exists in the memory cache. */iboolfil_tablespace_exists_in_mem(/*=========================*/ /* out: TRUE if exists */ ulint id); /* in: space id *//***********************************************************************Returns TRUE if a matching tablespace exists in the InnoDB tablespace memorycache. 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. */iboolfil_space_for_table_exists_in_mem(/*==============================*/ /* out: TRUE if a matching tablespace exists in the memory cache */ ulint id, /* in: space id */ const char* name, /* in: table name in the standard 'databasename/tablename' format or the dir path to a temp table */ ibool is_temp, /* in: TRUE if created with CREATE TEMPORARY TABLE */ ibool mark_space, /* in: 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 */ ibool print_error_if_does_not_exist); /* in: print detailed error information to the .err log if a matching tablespace is not found from memory *//**************************************************************************Tries to extend a data file so that it would accommodate the number of pagesgiven. The tablespace must be cached in the memory cache. If the space is bigenough already, does nothing. */iboolfil_extend_space_to_desired_size(/*=============================*/ /* out: TRUE if success */ ulint* actual_size, /* out: size of the space after extension; if we ran out of disk space this may be lower than the desired size */ ulint space_id, /* in: space id */ ulint size_after_extend);/* in: desired size in pages after the extension; if the current space size is bigger than this already, the function does nothing */#ifdef UNIV_HOTBACKUP/************************************************************************Extends all tablespaces to the size stored in the space header. During theibbackup --apply-log phase we extended the spaces on-demand so that log recordscould be appllied, but that may have left spaces still too small compared tothe size stored in the space header. */voidfil_extend_tablespaces_to_stored_len(void);/*======================================*/#endif/***********************************************************************Tries to reserve free extents in a file space. */iboolfil_space_reserve_free_extents(/*===========================*/ /* out: TRUE if succeed */ ulint id, /* in: space id */ ulint n_free_now, /* in: number of free extents now */ ulint n_to_reserve); /* in: how many one wants to reserve *//***********************************************************************Releases free extents in a file space. */voidfil_space_release_free_extents(/*===========================*/ ulint id, /* in: space id */ ulint n_reserved); /* in: how many one reserved *//***********************************************************************Gets the number of reserved extents. If the database is silent, this numbershould be zero. */ulintfil_space_get_n_reserved_extents(/*=============================*/ ulint id); /* in: space id *//************************************************************************Reads or writes data. This operation is asynchronous (aio). */ulintfil_io(/*===*/ /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do i/o on a tablespace which does not exist */ ulint type, /* in: 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! */ ibool sync, /* in: TRUE if synchronous aio is desired */ ulint space_id, /* in: space id */ ulint block_offset, /* in: offset in number of blocks */ ulint byte_offset, /* in: remainder of offset in bytes; in aio this must be divisible by the OS block size */ ulint len, /* in: how many bytes to read or write; this must not cross a file boundary; in aio this must be a block size multiple */ void* buf, /* in/out: buffer where to store read data or from where to write; in aio this must be appropriately aligned */ void* message); /* in: message for aio handler if non-sync aio used, else ignored *//************************************************************************Reads data from a space to a buffer. Remember that the possible incompleteblocks at the end of file are ignored: they are not taken into account whencalculating the byte offset within a space. */ulintfil_read(/*=====*/ /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do i/o on a tablespace which does not exist */ ibool sync, /* in: TRUE if synchronous aio is desired */ ulint space_id, /* in: space id */ ulint block_offset, /* in: offset in number of blocks */ ulint byte_offset, /* in: remainder of offset in bytes; in aio this must be divisible by the OS block size */ ulint len, /* in: how many bytes to read; this must not cross a file boundary; in aio this must be a block size multiple */ void* buf, /* in/out: buffer where to store data read; in aio this must be appropriately aligned */ void* message); /* in: message for aio handler if non-sync aio used, else ignored *//************************************************************************Writes data to a space from a buffer. Remember that the possible incompleteblocks at the end of file are ignored: they are not taken into account whencalculating the byte offset within a space. */ulintfil_write(/*======*/ /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do i/o on a tablespace which does not exist */ ibool sync, /* in: TRUE if synchronous aio is desired */ ulint space_id, /* in: space id */ ulint block_offset, /* in: offset in number of blocks */ ulint byte_offset, /* in: remainder of offset in bytes; in aio this must be divisible by the OS block size */ ulint len, /* in: how many bytes to write; this must not cross a file boundary; in aio this must be a block size multiple */ void* buf, /* in: buffer from which to write; in aio this must be appropriately aligned */ void* message); /* in: message for aio handler if non-sync aio used, else ignored *//**************************************************************************Waits for an aio operation to complete. This function is used to write thehandler for completed requests. The aio array of pending requests is dividedinto segments (see os0file.c for more info). The thread specifies whichsegment it wants to wait for. */voidfil_aio_wait(/*=========*/ ulint segment); /* in: the number of the segment in the aio array to wait for */ /**************************************************************************Flushes to disk possible writes cached by the OS. If the space does not existor is being dropped, does not do anything. */voidfil_flush(/*======*/ ulint space_id); /* in: file space id (this can be a group of log files or a tablespace of the database) *//**************************************************************************Flushes to disk writes in file spaces of the given type possibly cached bythe OS. */voidfil_flush_file_spaces(/*==================*/ ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG *//**********************************************************************Checks the consistency of the tablespace cache. */iboolfil_validate(void);/*==============*/ /* out: TRUE if ok *//************************************************************************Returns TRUE if file address is undefined. */iboolfil_addr_is_null(/*=============*/ /* out: TRUE if undefined */ fil_addr_t addr); /* in: address *//************************************************************************Accessor functions for a file page */ulintfil_page_get_prev(byte* page);ulintfil_page_get_next(byte* page);/*************************************************************************Sets the file page type. */voidfil_page_set_type(/*==============*/ byte* page, /* in: file page */ ulint type); /* in: type *//*************************************************************************Gets the file page type. */ulintfil_page_get_type(/*==============*/ /* out: type; NOTE that if the type has not been written to page, the return value not defined */ byte* page); /* in: file page */typedef struct fil_space_struct fil_space_t;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -