diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-06-03 13:10:18 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-06-04 09:47:06 +0300 |
commit | f7002c05ae4e4a09bc6859ccc568064cfd6bb268 (patch) | |
tree | 423b925b2328db28ce2bffcdf9f59c5772921fbe /storage/innobase/include/fsp0pagecompress.ic | |
parent | cd70bed05e506ce1ca3535ada265c4d09f633b49 (diff) | |
download | mariadb-git-f7002c05ae4e4a09bc6859ccc568064cfd6bb268.tar.gz |
MDEV-8250: InnoDB: Page compressed tables are not compressed and compressed+encrypted tables cause crash
Analysis: Problem is that both encrypted tables and compressed tables use
FIL header offset FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION to store
required metadata. Furhermore, for only compressed tables currently
code skips compression.
Fixes:
- Only encrypted pages store key_version to FIL header offset FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
no need to fix
- Only compressed pages store compression algorithm to FIL header offset FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
no need to fix as they have different page type FIL_PAGE_PAGE_COMPRESSED
- Compressed and encrypted pages now use a new page type FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED and
key_version is stored on FIL header offset FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION and compression
method is stored after FIL header similar way as compressed size, so that first
FIL_PAGE_COMPRESSED_SIZE is stored followed by FIL_PAGE_COMPRESSION_METHOD
- Fix buf_page_encrypt_before_write function to really compress pages if compression is enabled
- Fix buf_page_decrypt_after_read function to really decompress pages if compression is used
- Small style fixes
Diffstat (limited to 'storage/innobase/include/fsp0pagecompress.ic')
-rw-r--r-- | storage/innobase/include/fsp0pagecompress.ic | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/storage/innobase/include/fsp0pagecompress.ic b/storage/innobase/include/fsp0pagecompress.ic index 4d4ee1c376a..1ac80defd89 100644 --- a/storage/innobase/include/fsp0pagecompress.ic +++ b/storage/innobase/include/fsp0pagecompress.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013,2014 SkySQL Ab. All Rights Reserved. +Copyright (C) 2013, 2015, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -67,7 +67,7 @@ UNIV_INLINE ibool fil_page_is_index_page( /*===================*/ - byte *buf) /*!< in: page */ + byte* buf) /*!< in: page */ { return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_INDEX); } @@ -79,12 +79,24 @@ UNIV_INLINE ibool fil_page_is_compressed( /*===================*/ - byte *buf) /*!< in: page */ + byte* buf) /*!< in: page */ { return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED); } /*******************************************************************//** +Find out wheather the page is page compressed +@return true if page is page compressed, false if not */ +UNIV_INLINE +ibool +fil_page_is_compressed_encrypted( +/*=============================*/ + byte* buf) /*!< in: page */ +{ + return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); +} + +/*******************************************************************//** Returns the page compression level of the space, or 0 if the space is not compressed. The tablespace must be cached in the memory cache. @return page compression level, ULINT_UNDEFINED if space not found */ @@ -136,7 +148,7 @@ UNIV_INLINE const char* fil_get_compression_alg_name( /*=========================*/ - ulint comp_alg) /*!<in: compression algorithm number */ + ulint comp_alg) /*!<in: compression algorithm number */ { switch(comp_alg) { case PAGE_UNCOMPRESSED: @@ -190,8 +202,10 @@ UNIV_INLINE ibool fil_page_is_lzo_compressed( /*=======================*/ - byte *buf) /*!< in: page */ + byte* buf) /*!< in: page */ { - return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED && - mach_read_from_8(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) == PAGE_LZO_ALGORITHM); + return((mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED && + mach_read_from_8(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) == PAGE_LZO_ALGORITHM) || + (mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED && + mach_read_from_2(buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE) == PAGE_LZO_ALGORITHM)); } |