diff options
Diffstat (limited to 'storage/innobase/include/fil0fil.h')
-rw-r--r-- | storage/innobase/include/fil0fil.h | 568 |
1 files changed, 251 insertions, 317 deletions
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 7837020fec4..65198f78988 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -42,7 +42,7 @@ Created 10/25/1995 Heikki Tuuri #include <mutex> struct unflushed_spaces_tag_t; -struct rotation_list_tag_t; +struct default_encrypt_tag_t; struct space_list_tag_t; struct named_spaces_tag_t; @@ -81,14 +81,14 @@ enum srv_flush_t extern ulong srv_file_flush_method; /** Undo tablespaces starts with space_id. */ -extern ulint srv_undo_space_id_start; +extern uint32_t srv_undo_space_id_start; /** The number of UNDO tablespaces that are open and ready to use. */ -extern ulint srv_undo_tablespaces_open; +extern uint32_t srv_undo_tablespaces_open; /** Check whether given space id is undo tablespace id @param[in] space_id space id to check @return true if it is undo tablespace else false. */ -inline bool srv_is_undo_tablespace(ulint space_id) +inline bool srv_is_undo_tablespace(uint32_t space_id) { return srv_undo_space_id_start > 0 && space_id >= srv_undo_space_id_start && @@ -335,7 +335,7 @@ enum fil_encryption_t }; struct fil_space_t final : ilist_node<unflushed_spaces_tag_t>, - ilist_node<rotation_list_tag_t>, + ilist_node<default_encrypt_tag_t>, ilist_node<space_list_tag_t>, ilist_node<named_spaces_tag_t> #else @@ -351,8 +351,6 @@ struct fil_space_t final latch.destroy(); } - ulint id; /*!< space id */ - /** fil_system.spaces chain node */ fil_space_t *hash; lsn_t max_lsn; @@ -362,6 +360,8 @@ struct fil_space_t final Protected by log_sys.mutex. If and only if this is nonzero, the tablespace will be in named_spaces. */ + /** tablespace identifier */ + uint32_t id; /** whether undo tablespace truncation is in progress */ bool is_being_truncated; fil_type_t purpose;/*!< purpose */ @@ -530,7 +530,7 @@ public: @param id tablespace identifier @return tablespace @retval nullptr if no tablespace was found */ - static fil_space_t *check_pending_operations(ulint id); + static fil_space_t *check_pending_operations(uint32_t id); private: MY_ATTRIBUTE((warn_unused_result)) @@ -675,92 +675,78 @@ public: freed_ranges.clear(); } #endif /* !UNIV_INNOCHECKSUM */ - /** FSP_SPACE_FLAGS and FSP_FLAGS_MEM_ flags; - check fsp0types.h to more info about flags. */ - ulint flags; - - /** Determine if full_crc32 is used for a data file - @param[in] flags tablespace flags (FSP_SPACE_FLAGS) - @return whether the full_crc32 algorithm is active */ - static bool full_crc32(ulint flags) { - return flags & FSP_FLAGS_FCRC32_MASK_MARKER; - } - /** Determine if full_crc32 is used along with compression */ - static bool is_full_crc32_compressed(ulint flags) + /** FSP_SPACE_FLAGS and FSP_FLAGS_MEM_ flags; + check fsp0types.h to more info about flags. */ + uint32_t flags; + + /** Determine if full_crc32 is used for a data file + @param[in] flags tablespace flags (FSP_SPACE_FLAGS) + @return whether the full_crc32 algorithm is active */ + static bool full_crc32(uint32_t flags) + { return flags & FSP_FLAGS_FCRC32_MASK_MARKER; } + /** @return whether innodb_checksum_algorithm=full_crc32 is active */ + bool full_crc32() const { return full_crc32(flags); } + /** Determine if full_crc32 is used along with PAGE_COMPRESSED */ + static bool is_full_crc32_compressed(uint32_t flags) { - if (full_crc32(flags)) - { - ulint algo= FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags); - DBUG_ASSERT(algo <= PAGE_ALGORITHM_LAST); - return algo > 0; + if (!full_crc32(flags)) + return false; + auto algo= FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags); + DBUG_ASSERT(algo <= PAGE_ALGORITHM_LAST); + return algo != 0; + } + /** Determine the logical page size. + @param flags tablespace flags (FSP_SPACE_FLAGS) + @return the logical page size + @retval 0 if the flags are invalid */ + static unsigned logical_size(uint32_t flags) + { + switch (full_crc32(flags) + ? FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags) + : FSP_FLAGS_GET_PAGE_SSIZE(flags)) { + case 3: return 4096; + case 4: return 8192; + case 5: return full_crc32(flags) ? 16384 : 0; + case 0: return full_crc32(flags) ? 0 : 16384; + case 6: return 32768; + case 7: return 65536; + default: return 0; } - - return false; } - /** @return whether innodb_checksum_algorithm=full_crc32 is active */ - bool full_crc32() const { return full_crc32(flags); } - /** Determine the logical page size. - @param flags tablespace flags (FSP_FLAGS) - @return the logical page size - @retval 0 if the flags are invalid */ - static unsigned logical_size(ulint flags) { - - ulint page_ssize = 0; - - if (full_crc32(flags)) { - page_ssize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags); - } else { - page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags); - } - - switch (page_ssize) { - case 3: return 4096; - case 4: return 8192; - case 5: - { ut_ad(full_crc32(flags)); return 16384; } - case 0: - { ut_ad(!full_crc32(flags)); return 16384; } - case 6: return 32768; - case 7: return 65536; - default: return 0; - } - } - /** Determine the ROW_FORMAT=COMPRESSED page size. - @param flags tablespace flags (FSP_FLAGS) - @return the ROW_FORMAT=COMPRESSED page size - @retval 0 if ROW_FORMAT=COMPRESSED is not used */ - static unsigned zip_size(ulint flags) { - - if (full_crc32(flags)) { - return 0; - } + /** Determine the ROW_FORMAT=COMPRESSED page size. + @param flags tablespace flags (FSP_SPACE_FLAGS) + @return the ROW_FORMAT=COMPRESSED page size + @retval 0 if ROW_FORMAT=COMPRESSED is not used */ + static unsigned zip_size(uint32_t flags) + { + if (full_crc32(flags)) + return 0; + const uint32_t zip_ssize= FSP_FLAGS_GET_ZIP_SSIZE(flags); + return zip_ssize ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize : 0; + } + /** Determine the physical page size. + @param flags tablespace flags (FSP_SPACE_FLAGS) + @return the physical page size */ + static unsigned physical_size(uint32_t flags) + { + if (full_crc32(flags)) + return logical_size(flags); - ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags); - return zip_ssize - ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize : 0; - } - /** Determine the physical page size. - @param flags tablespace flags (FSP_FLAGS) - @return the physical page size */ - static unsigned physical_size(ulint flags) { + const uint32_t zip_ssize= FSP_FLAGS_GET_ZIP_SSIZE(flags); + return zip_ssize + ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize + : unsigned(srv_page_size); + } - if (full_crc32(flags)) { - return logical_size(flags); - } + /** @return the ROW_FORMAT=COMPRESSED page size + @retval 0 if ROW_FORMAT=COMPRESSED is not used */ + unsigned zip_size() const { return zip_size(flags); } + /** @return the physical page size */ + unsigned physical_size() const { return physical_size(flags); } - ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags); - return zip_ssize - ? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize - : unsigned(srv_page_size); - } - /** @return the ROW_FORMAT=COMPRESSED page size - @retval 0 if ROW_FORMAT=COMPRESSED is not used */ - unsigned zip_size() const { return zip_size(flags); } - /** @return the physical page size */ - unsigned physical_size() const { return physical_size(flags); } - /** Check whether the compression enabled in tablespace. + /** Check whether PAGE_COMPRESSED is enabled. @param[in] flags tablespace flags */ - static bool is_compressed(ulint flags) + static bool is_compressed(uint32_t flags) { return is_full_crc32_compressed(flags) || FSP_FLAGS_HAS_PAGE_COMPRESSION(flags); @@ -768,187 +754,151 @@ public: /** @return whether the compression enabled for the tablespace. */ bool is_compressed() const { return is_compressed(flags); } - /** Get the compression algorithm for full crc32 format. - @param[in] flags tablespace flags - @return algorithm type of tablespace */ - static ulint get_compression_algo(ulint flags) - { - return full_crc32(flags) - ? FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags) - : 0; - } - /** @return the page_compressed algorithm - @retval 0 if not page_compressed */ - ulint get_compression_algo() const { - return fil_space_t::get_compression_algo(flags); - } - /** Determine if the page_compressed page contains an extra byte - for exact compressed stream length - @param[in] flags tablespace flags - @return whether the extra byte is needed */ - static bool full_crc32_page_compressed_len(ulint flags) - { - DBUG_ASSERT(full_crc32(flags)); - switch (get_compression_algo(flags)) { - case PAGE_LZ4_ALGORITHM: - case PAGE_LZO_ALGORITHM: - case PAGE_SNAPPY_ALGORITHM: - return true; - } - return false; - } - - /** Whether the full checksum matches with non full checksum flags. - @param[in] flags flags present - @param[in] expected expected flags - @return true if it is equivalent */ - static bool is_flags_full_crc32_equal(ulint flags, ulint expected) - { - ut_ad(full_crc32(flags)); - ulint fcrc32_psize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags); - - if (full_crc32(expected)) { - /* The data file may have been created with a - different innodb_compression_algorithm. But - we only support one innodb_page_size for all files. */ - return fcrc32_psize - == FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected); - } - - ulint non_fcrc32_psize = FSP_FLAGS_GET_PAGE_SSIZE(expected); - - if (!non_fcrc32_psize) { - if (fcrc32_psize != 5) { - return false; - } - } else if (fcrc32_psize != non_fcrc32_psize) { - return false; - } - - return true; - } - /** Whether old tablespace flags match full_crc32 flags. - @param[in] flags flags present - @param[in] expected expected flags - @return true if it is equivalent */ - static bool is_flags_non_full_crc32_equal(ulint flags, ulint expected) - { - ut_ad(!full_crc32(flags)); - - if (!full_crc32(expected)) { - return false; - } - - ulint non_fcrc32_psize = FSP_FLAGS_GET_PAGE_SSIZE(flags); - ulint fcrc32_psize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE( - expected); - - if (!non_fcrc32_psize) { - if (fcrc32_psize != 5) { - return false; - } - } else if (fcrc32_psize != non_fcrc32_psize) { - return false; - } - - return true; - } - /** Whether both fsp flags are equivalent */ - static bool is_flags_equal(ulint flags, ulint expected) - { - if (!((flags ^ expected) & ~(1U << FSP_FLAGS_POS_RESERVED))) { - return true; - } - - return full_crc32(flags) - ? is_flags_full_crc32_equal(flags, expected) - : is_flags_non_full_crc32_equal(flags, expected); - } - /** Validate the tablespace flags for full crc32 format. - @param[in] flags the content of FSP_SPACE_FLAGS - @return whether the flags are correct in full crc32 format */ - static bool is_fcrc32_valid_flags(ulint flags) - { - ut_ad(flags & FSP_FLAGS_FCRC32_MASK_MARKER); - const ulint page_ssize = physical_size(flags); - if (page_ssize < 3 || page_ssize & 8) { - return false; - } - - flags >>= FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO; - - return flags <= PAGE_ALGORITHM_LAST; - } - /** Validate the tablespace flags. - @param[in] flags content of FSP_SPACE_FLAGS - @param[in] is_ibd whether this is an .ibd file - (not system tablespace) - @return whether the flags are correct. */ - static bool is_valid_flags(ulint flags, bool is_ibd) - { - DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", - return false;); - - if (full_crc32(flags)) { - return is_fcrc32_valid_flags(flags); - } + /** Get the compression algorithm for full crc32 format. + @param flags contents of FSP_SPACE_FLAGS + @return PAGE_COMPRESSED algorithm of full_crc32 tablespace + @retval 0 if not PAGE_COMPRESSED or not full_crc32 */ + static unsigned get_compression_algo(uint32_t flags) + { + return full_crc32(flags) + ? FSP_FLAGS_FCRC32_GET_COMPRESSED_ALGO(flags) + : 0; + } + /** @return the page_compressed algorithm + @retval 0 if not page_compressed */ + unsigned get_compression_algo() const { return get_compression_algo(flags); } + /** Determine if the page_compressed page contains an extra byte + for exact compressed stream length + @param flags contents of FSP_SPACE_FLAGS + @return whether the extra byte is needed */ + static bool full_crc32_page_compressed_len(uint32_t flags) + { + DBUG_ASSERT(full_crc32(flags)); + switch (get_compression_algo(flags)) { + case PAGE_LZ4_ALGORITHM: + case PAGE_LZO_ALGORITHM: + case PAGE_SNAPPY_ALGORITHM: + return true; + } + return false; + } - if (flags == 0) { - return true; - } + /** Whether the full checksum matches with non full checksum flags. + @param flags contents of FSP_SPACE_FLAGS + @param expected expected flags + @return true if it is equivalent */ + static bool is_flags_full_crc32_equal(uint32_t flags, uint32_t expected) + { + ut_ad(full_crc32(flags)); + uint32_t fcrc32_psize= FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags); + + if (full_crc32(expected)) + /* The data file may have been created with a + different innodb_compression_algorithm. But + we only support one innodb_page_size for all files. */ + return fcrc32_psize == FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected); + + uint32_t non_fcrc32_psize = FSP_FLAGS_GET_PAGE_SSIZE(expected); + if (!non_fcrc32_psize) + return fcrc32_psize == 5; + return fcrc32_psize == non_fcrc32_psize; + } - if (flags & ~FSP_FLAGS_MASK) { - return false; - } + /** Whether old tablespace flags match full_crc32 flags. + @param flags contents of FSP_SPACE_FLAGS + @param expected expected flags + @return true if it is equivalent */ + static bool is_flags_non_full_crc32_equal(uint32_t flags, uint32_t expected) + { + ut_ad(!full_crc32(flags)); + if (!full_crc32(expected)) + return false; - if ((flags & (FSP_FLAGS_MASK_POST_ANTELOPE - | FSP_FLAGS_MASK_ATOMIC_BLOBS)) - == FSP_FLAGS_MASK_ATOMIC_BLOBS) { - /* If the "atomic blobs" flag (indicating - ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED) flag - is set, then the "post Antelope" - (ROW_FORMAT!=REDUNDANT) flag must also be set. */ - return false; - } + uint32_t non_fcrc32_psize= FSP_FLAGS_GET_PAGE_SSIZE(flags); + uint32_t fcrc32_psize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected); - /* Bits 10..14 should be 0b0000d where d is the DATA_DIR flag - of MySQL 5.6 and MariaDB 10.0, which we ignore. - In the buggy FSP_SPACE_FLAGS written by MariaDB 10.1.0 to 10.1.20, - bits 10..14 would be nonzero 0bsssaa where sss is - nonzero PAGE_SSIZE (3, 4, 6, or 7) - and aa is ATOMIC_WRITES (not 0b11). */ - if (FSP_FLAGS_GET_RESERVED(flags) & ~1U) { - return false; - } + if (!non_fcrc32_psize) + return fcrc32_psize == 5; + return fcrc32_psize == non_fcrc32_psize; + } - const ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags); - if (ssize == 1 || ssize == 2 || ssize == 5 || ssize & 8) { - /* the page_size is not between 4k and 64k; - 16k should be encoded as 0, not 5 */ - return false; - } + /** Whether both fsp flags are equivalent */ + static bool is_flags_equal(uint32_t flags, uint32_t expected) + { + if (!((flags ^ expected) & ~(1U << FSP_FLAGS_POS_RESERVED))) + return true; + return full_crc32(flags) + ? is_flags_full_crc32_equal(flags, expected) + : is_flags_non_full_crc32_equal(flags, expected); + } - const ulint zssize = FSP_FLAGS_GET_ZIP_SSIZE(flags); - if (zssize == 0) { - /* not ROW_FORMAT=COMPRESSED */ - } else if (zssize > (ssize ? ssize : 5)) { - /* Invalid KEY_BLOCK_SIZE */ - return false; - } else if (~flags & (FSP_FLAGS_MASK_POST_ANTELOPE - | FSP_FLAGS_MASK_ATOMIC_BLOBS)) { - /* both these flags should be set for - ROW_FORMAT=COMPRESSED */ - return false; - } + /** Validate the tablespace flags for full crc32 format. + @param flags contents of FSP_SPACE_FLAGS + @return whether the flags are correct in full crc32 format */ + static bool is_fcrc32_valid_flags(uint32_t flags) + { + ut_ad(flags & FSP_FLAGS_FCRC32_MASK_MARKER); + const ulint page_ssize= physical_size(flags); + if (page_ssize < 3 || page_ssize & 8) + return false; + flags >>= FSP_FLAGS_FCRC32_POS_COMPRESSED_ALGO; + return flags <= PAGE_ALGORITHM_LAST; + } + /** Validate the tablespace flags. + @param flags contents of FSP_SPACE_FLAGS + @param is_ibd whether this is an .ibd file (not system tablespace) + @return whether the flags are correct */ + static bool is_valid_flags(uint32_t flags, bool is_ibd) + { + DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", return false;); + if (full_crc32(flags)) + return is_fcrc32_valid_flags(flags); - /* The flags do look valid. But, avoid misinterpreting - buggy MariaDB 10.1 format flags for - PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL={0,2,3} - as valid-looking PAGE_SSIZE if this is known to be - an .ibd file and we are using the default innodb_page_size=16k. */ - return(ssize == 0 || !is_ibd - || srv_page_size != UNIV_PAGE_SIZE_ORIG); - } + if (flags == 0) + return true; + if (~FSP_FLAGS_MASK & flags) + return false; + + if (FSP_FLAGS_MASK_ATOMIC_BLOBS == + (flags & (FSP_FLAGS_MASK_POST_ANTELOPE | FSP_FLAGS_MASK_ATOMIC_BLOBS))) + /* If the "atomic blobs" flag (indicating + ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED) flag is set, then the + ROW_FORMAT!=REDUNDANT flag must also be set. */ + return false; + + /* Bits 10..14 should be 0b0000d where d is the DATA_DIR flag + of MySQL 5.6 and MariaDB 10.0, which we ignore. + In the buggy FSP_SPACE_FLAGS written by MariaDB 10.1.0 to 10.1.20, + bits 10..14 would be nonzero 0bsssaa where sss is + nonzero PAGE_SSIZE (3, 4, 6, or 7) + and aa is ATOMIC_WRITES (not 0b11). */ + if (FSP_FLAGS_GET_RESERVED(flags) & ~1U) + return false; + + const uint32_t ssize= FSP_FLAGS_GET_PAGE_SSIZE(flags); + if (ssize == 1 || ssize == 2 || ssize == 5 || ssize & 8) + /* the page_size is not between 4k and 64k; + 16k should be encoded as 0, not 5 */ + return false; + + const uint32_t zssize= FSP_FLAGS_GET_ZIP_SSIZE(flags); + if (zssize == 0) + /* not ROW_FORMAT=COMPRESSED */; + else if (zssize > (ssize ? ssize : 5)) + /* Invalid KEY_BLOCK_SIZE */ + return false; + else if (~flags & + (FSP_FLAGS_MASK_POST_ANTELOPE | FSP_FLAGS_MASK_ATOMIC_BLOBS)) + /* both these flags must set for ROW_FORMAT=COMPRESSED */ + return false; + + /* The flags do look valid. But, avoid misinterpreting + buggy MariaDB 10.1 format flags for + PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL={0,2,3} + as valid-looking PAGE_SSIZE if this is known to be + an .ibd file and we are using the default innodb_page_size=16k. */ + return(ssize == 0 || !is_ibd || srv_page_size != UNIV_PAGE_SIZE_ORIG); + } #ifndef UNIV_INNOCHECKSUM MY_ATTRIBUTE((warn_unused_result)) @@ -960,7 +910,7 @@ public: @param mode encryption mode @return pointer to created tablespace, to be filled in with add() @retval nullptr on failure (such as when the same tablespace exists) */ - static fil_space_t *create(ulint id, ulint flags, + static fil_space_t *create(uint32_t id, uint32_t flags, fil_type_t purpose, fil_space_crypt_t *crypt_data, fil_encryption_t mode= FIL_ENCRYPTION_DEFAULT); @@ -969,7 +919,7 @@ public: @param id tablespace identifier @return tablespace @retval nullptr if the tablespace is missing or inaccessible */ - static fil_space_t *get(ulint id); + static fil_space_t *get(uint32_t id); /** Add/remove the free page in the freed ranges list. @param[in] offset page number to be added @@ -1417,14 +1367,12 @@ or the caller should be in single-threaded crash recovery mode Normally, fil_space_t::get() should be used instead. @param[in] id tablespace ID @return tablespace, or NULL if not found */ -fil_space_t* -fil_space_get( - ulint id) - MY_ATTRIBUTE((warn_unused_result)); +fil_space_t *fil_space_get(uint32_t id) + MY_ATTRIBUTE((warn_unused_result)); -/** The tablespace memory cache; also the totality of logs (the log -data space) is stored here; below we talk about tablespaces */ -struct fil_system_t { +/** The tablespace memory cache */ +struct fil_system_t +{ /** Constructor. @@ -1483,12 +1431,8 @@ public: ulint n_open; /** last time we noted n_open exceeding the limit; protected by mutex */ time_t n_open_exceeded_time; - ulint max_assigned_id;/*!< maximum space id in the existing - tables, or assigned during the time - mysqld has been up; at an InnoDB - startup we scan the data dictionary - and set here the maximum of the - space id's of the tables there */ + /** maximum persistent tablespace id that has ever been assigned */ + uint32_t max_assigned_id; /** nonzero if fil_node_open_file_low() should avoid moving the tablespace to the end of space_list, for FIFO policy of try_to_close() */ ulint freeze_space_list; @@ -1501,13 +1445,13 @@ public: the latest redo log checkpoint. Protected only by log_sys.mutex. */ - /** List of all file spaces need key rotation */ - ilist<fil_space_t, rotation_list_tag_t> default_encrypt_tables; + /** list of all ENCRYPTED=DEFAULT tablespaces that need + to be converted to the current value of innodb_encrypt_tables */ + ilist<fil_space_t, default_encrypt_tag_t> default_encrypt_tables; - bool space_id_reuse_warned; - /*!< whether fil_space_t::create() - has issued a warning about - potential space_id reuse */ + /** whether fil_space_t::create() has issued a warning about + potential space_id reuse */ + bool space_id_reuse_warned; /** Return the next tablespace from default_encrypt_tables list. @param space previous tablespace (nullptr to start from the start) @@ -1629,36 +1573,27 @@ 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. @return true if assigned, false if not */ -bool -fil_assign_new_space_id( -/*====================*/ - ulint* space_id); /*!< in/out: space id */ +bool fil_assign_new_space_id(uint32_t *space_id); /** Frees a space object from the tablespace memory cache. Closes the files in the chain but does not delete them. There must not be any pending i/o's or flushes on the files. -@param[in] id tablespace identifier -@param[in] x_latched whether the caller holds X-mode space->latch +@param id tablespace identifier +@param x_latched whether the caller holds exclusive fil_space_t::latch @return true if success */ -bool -fil_space_free( - ulint id, - bool x_latched); +bool fil_space_free(uint32_t id, bool x_latched); /** Set the recovered size of a tablespace in pages. @param id tablespace ID @param size recovered size in pages @param flags tablespace flags */ -void fil_space_set_recv_size_and_flags(ulint id, uint32_t size, +void fil_space_set_recv_size_and_flags(uint32_t id, uint32_t size, uint32_t flags); /*******************************************************************//** Sets the max tablespace id counter if the given number is bigger than the previous value. */ -void -fil_set_max_space_id_if_bigger( -/*===========================*/ - ulint max_id);/*!< in: maximum known id */ +void fil_set_max_space_id_if_bigger(uint32_t max_id); /** Write the flushed LSN to the page header of the first page in the system tablespace. @@ -1674,12 +1609,12 @@ MY_ATTRIBUTE((warn_unused_result)) @param id tablespace identifier @return detached file handle (to be closed by the caller) @return OS_FILE_CLOSED if no file existed */ -pfs_os_file_t fil_delete_tablespace(ulint id); +pfs_os_file_t fil_delete_tablespace(uint32_t id); /** Close a single-table tablespace on failed IMPORT TABLESPACE. The tablespace must be cached in the memory cache. Free all pages used by the tablespace. */ -void fil_close_tablespace(ulint id); +void fil_close_tablespace(uint32_t id); /*******************************************************************//** Allocates and builds a file name from a path, a table or tablespace name @@ -1709,10 +1644,10 @@ must be >= FIL_IBD_FILE_INITIAL_SIZE @retval NULL on error */ fil_space_t* fil_ibd_create( - ulint space_id, + uint32_t space_id, const table_name_t name, const char* path, - ulint flags, + uint32_t flags, uint32_t size, fil_encryption_t mode, uint32_t key_id, @@ -1723,7 +1658,7 @@ fil_ibd_create( (Typically when upgrading from MariaDB 10.1.0..10.1.20.) @param[in,out] space tablespace @param[in] flags desired tablespace flags */ -void fsp_flags_try_adjust(fil_space_t* space, ulint flags); +void fsp_flags_try_adjust(fil_space_t *space, uint32_t flags); /********************************************************************//** Tries to open a single-table tablespace and optionally checks the space id is @@ -1756,8 +1691,8 @@ fil_space_t* fil_ibd_open( unsigned validate, fil_type_t purpose, - ulint id, - ulint flags, + uint32_t id, + uint32_t flags, fil_space_t::name_type name, const char* path_in, dberr_t* err = NULL) @@ -1782,12 +1717,8 @@ enum fil_load_status { @param[out] space the tablespace, or NULL on error @return status of the operation */ enum fil_load_status -fil_ibd_load( - ulint space_id, - const char* filename, - fil_space_t*& space) - MY_ATTRIBUTE((warn_unused_result)); - +fil_ibd_load(uint32_t space_id, const char *filename, fil_space_t *&space) + MY_ATTRIBUTE((warn_unused_result)); /** Determine if a matching tablespace exists in the InnoDB tablespace memory cache. Note that if we have not done a crash recovery at the database @@ -1796,7 +1727,8 @@ startup, there may be many tablespaces which are not yet in the memory cache. @param[in] table_flags table flags @return the tablespace @retval NULL if no matching tablespace exists in the memory cache */ -fil_space_t *fil_space_for_table_exists_in_mem(ulint id, ulint table_flags); +fil_space_t *fil_space_for_table_exists_in_mem(uint32_t id, + uint32_t table_flags); /** Try to extend a tablespace if it is smaller than the specified size. @param[in,out] space tablespace @@ -1827,12 +1759,11 @@ fil_delete_file( /*============*/ const char* path); /*!< in: filepath of the ibd tablespace */ -/*******************************************************************//** -Returns the table space by a given id, NULL if not found. */ -fil_space_t* -fil_space_get_by_id( -/*================*/ - ulint id); /*!< in: space id */ +/** Look up a tablespace. +@param tablespace identifier +@return tablespace +@retval nullptr if not found */ +fil_space_t *fil_space_get_by_id(uint32_t id); /** Note that a non-predefined persistent tablespace has been modified by redo log. @@ -1871,6 +1802,9 @@ inline bool fil_names_write_if_was_clean(fil_space_t* space) return(was_clean); } + +bool fil_comp_algo_loaded(ulint comp_algo); + /** On a log checkpoint, reset fil_names_dirty_and_write() flags and write out FILE_MODIFY and FILE_CHECKPOINT if needed. @param[in] lsn checkpoint LSN |