diff options
Diffstat (limited to 'storage/innobase/include/fsp0fsp.ic')
-rw-r--r-- | storage/innobase/include/fsp0fsp.ic | 161 |
1 files changed, 152 insertions, 9 deletions
diff --git a/storage/innobase/include/fsp0fsp.ic b/storage/innobase/include/fsp0fsp.ic index c92111a9d89..498f9000888 100644 --- a/storage/innobase/include/fsp0fsp.ic +++ b/storage/innobase/include/fsp0fsp.ic @@ -23,6 +23,8 @@ File space management Created 12/18/1995 Heikki Tuuri *******************************************************/ +#ifndef UNIV_INNOCHECKSUM + /***********************************************************************//** Checks if a page address is an extent descriptor page address. @return TRUE if a descriptor page */ @@ -37,17 +39,111 @@ fsp_descr_page( ut_ad(ut_is_2pow(zip_size)); if (!zip_size) { - return(UNIV_UNLIKELY((page_no & (UNIV_PAGE_SIZE - 1)) - == FSP_XDES_OFFSET)); + return((page_no & (UNIV_PAGE_SIZE - 1)) == FSP_XDES_OFFSET); } - return(UNIV_UNLIKELY((page_no & (zip_size - 1)) == FSP_XDES_OFFSET)); + return((page_no & (zip_size - 1)) == FSP_XDES_OFFSET); } + +/********************************************************************//** +Validate and return the tablespace flags, which are stored in the +tablespace header at offset FSP_SPACE_FLAGS. They should be 0 for +ROW_FORMAT=COMPACT and ROW_FORMAT=REDUNDANT. The newer row formats, +COMPRESSED and DYNAMIC, use a file format > Antelope so they should +have a file format number plus the DICT_TF_COMPACT bit set. +@return Same as input after validating it as FSP_SPACE_FLAGS. +If there is an error, trigger assertion failure. */ +UNIV_INLINE +ulint +fsp_flags_validate( +/*===============*/ + ulint flags) /*!< in: tablespace flags */ +{ + ulint post_antelope = FSP_FLAGS_GET_POST_ANTELOPE(flags); + ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags); + ulint atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(flags); + ulint page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags); + ulint unused = FSP_FLAGS_GET_UNUSED(flags); + + /* Make sure there are no bits that we do not know about. */ + ut_a(unused == 0); + + /* fsp_flags is zero unless atomic_blobs is set. */ + ut_a(flags != 1); + if (post_antelope) { + /* The Antelope row formats REDUNDANT and COMPACT did + not use tablespace flags, so this flag and the entire + 4-byte field is zero for Antelope row formats. */ + ut_a(atomic_blobs); + } + + if (!atomic_blobs) { + /* Barracuda row formats COMPRESSED and DYNAMIC build on + the page structure introduced for the COMPACT row format + by allowing long fields to be broken into prefix and + externally stored parts. */ + ut_a(!post_antelope); + ut_a(zip_ssize == 0); + } else { + ut_a(post_antelope); + + /* Validate the zip shift size is within allowed range. */ + ut_a(zip_ssize <= PAGE_ZIP_SSIZE_MAX); + } + + /* The page size field can be used for any row type, or it may + be zero for an original 16k page size. + Validate the page shift size is within allowed range. */ + ut_a(page_ssize <= UNIV_PAGE_SSIZE_MAX); + ut_a((UNIV_PAGE_SIZE == UNIV_PAGE_SIZE_ORIG) || (page_ssize)); + +#if UNIV_FORMAT_MAX != UNIV_FORMAT_B +# error "UNIV_FORMAT_MAX != UNIV_FORMAT_B, Add more validations." +#endif + + /* Return the flags sent in if we did not fail an assert. */ + return(flags); +} + +/********************************************************************//** +Determine if the tablespace is compressed from dict_table_t::flags. +@return TRUE if compressed, FALSE if not compressed */ +UNIV_INLINE +ibool +fsp_flags_is_compressed( +/*====================*/ + ulint flags) /*!< in: tablespace flags */ +{ + return(FSP_FLAGS_GET_ZIP_SSIZE(flags) != 0); +} + +#endif /* !UNIV_INNOCHECKSUM */ + +/********************************************************************//** +Extract the zip size from tablespace flags. +@return compressed page size of the file-per-table tablespace in bytes, +or zero if the table is not compressed. */ +UNIV_INLINE +ulint +fsp_flags_get_zip_size( +/*===================*/ + ulint flags) /*!< in: tablespace flags */ +{ + ulint zip_size = 0; + ulint ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags); + + /* Convert from a 'log2 minus 9' to a page size in bytes. */ + if (ssize) { + zip_size = ((UNIV_ZIP_SIZE_MIN >> 1) << ssize); + + ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX); + } + + return(zip_size); +} + /********************************************************************//** Extract the page size from tablespace flags. -This feature, storing the page_ssize into the tablespace flags, is added -to InnoDB 5.6.4. This is here only to protect against a crash if a newer -database is opened with this code branch. @return page size of the tablespace in bytes */ UNIV_INLINE ulint @@ -60,14 +156,61 @@ fsp_flags_get_page_size( /* Convert from a 'log2 minus 9' to a page size in bytes. */ if (UNIV_UNLIKELY(ssize)) { - page_size = (512 << ssize); + page_size = ((UNIV_ZIP_SIZE_MIN >> 1) << ssize); - ut_ad(page_size <= UNIV_PAGE_SIZE); + ut_ad(page_size <= UNIV_PAGE_SIZE_MAX); } else { /* If the page size was not stored, then it is the original 16k. */ - page_size = UNIV_PAGE_SIZE; + page_size = UNIV_PAGE_SIZE_ORIG; } return(page_size); } + +#ifndef UNIV_INNOCHECKSUM + +/********************************************************************//** +Add the page size to the tablespace flags. +@return tablespace flags after page size is added */ +UNIV_INLINE +ulint +fsp_flags_set_page_size( +/*====================*/ + ulint flags, /*!< in: tablespace flags */ + ulint page_size) /*!< in: page size in bytes */ +{ + ulint ssize = 0; + ulint shift; + + /* Page size should be > UNIV_PAGE_SIZE_MIN */ + ut_ad(page_size >= UNIV_PAGE_SIZE_MIN); + ut_ad(page_size <= UNIV_PAGE_SIZE_MAX); + + if (page_size == UNIV_PAGE_SIZE_ORIG) { + ut_ad(0 == FSP_FLAGS_GET_PAGE_SSIZE(flags)); + return(flags); + } + + for (shift = UNIV_PAGE_SIZE_SHIFT_MAX; + shift >= UNIV_PAGE_SIZE_SHIFT_MIN; + shift--) { + ulint mask = (1 << shift); + if (page_size & mask) { + ut_ad(!(page_size & ~mask)); + ssize = shift - UNIV_ZIP_SIZE_SHIFT_MIN + 1; + break; + } + } + + ut_ad(ssize); + ut_ad(ssize <= UNIV_PAGE_SSIZE_MAX); + + flags = FSP_FLAGS_SET_PAGE_SSIZE(flags, ssize); + + ut_ad(flags == fsp_flags_validate(flags)); + + return(flags); +} + +#endif /* !UNIV_INNOCHECKSUM */ |