diff options
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/buf0checksum.h | 13 | ||||
-rw-r--r-- | storage/innobase/include/fil0pagecompress.h | 58 | ||||
-rw-r--r-- | storage/innobase/include/fsp0pagecompress.h | 4 | ||||
-rw-r--r-- | storage/innobase/include/fsp0pagecompress.ic | 2 |
4 files changed, 60 insertions, 17 deletions
diff --git a/storage/innobase/include/buf0checksum.h b/storage/innobase/include/buf0checksum.h index 6818345f965..7834ad4d292 100644 --- a/storage/innobase/include/buf0checksum.h +++ b/storage/innobase/include/buf0checksum.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, 2018, MariaDB Corporation. 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 @@ -80,4 +81,16 @@ buf_checksum_algorithm_name( extern ulong srv_checksum_algorithm; +/** Calculates the CRC32 checksum of a page compressed page. The value is +stored to the page when it is written to a file and also checked for +a match when reading from the file. Checksum is calculated from +actual payload of the compressed page and some header fields. + +@param[in] page buffer page (UNIV_PAGE_SIZE bytes) +@return checksum */ +UNIV_INTERN +uint32_t +buf_calc_compressed_crc32( + const byte* page); + #endif /* buf0checksum_h */ diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h index 03e16699ce3..bd1395b4835 100644 --- a/storage/innobase/include/fil0pagecompress.h +++ b/storage/innobase/include/fil0pagecompress.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2017 MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2018 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 @@ -19,6 +19,8 @@ this program; if not, write to the Free Software Foundation, Inc., #ifndef fil0pagecompress_h #define fil0pagecompress_h +#ifndef UNIV_INNOCHECKSUM + #include "fsp0fsp.h" #include "fsp0pagecompress.h" @@ -68,23 +70,26 @@ fil_compress_page( ulint* out_len); /*!< out: actual length of compressed page */ -/****************************************************************//** +/** For page compressed pages decompress the page after actual read -operation. */ +operation. +@param[in,out] page_buf Preallocated temporal buffer where + compression is done and then copied + to the buffer. +@param[in,out] buf Compressed page and after suggesful + decompression operation uncompressed page + is copied here. +@param[in] len Length of output buffer. +@param[out] write_size Actual payload size of the compressed data. +@return true when operation succeeded or false when failed */ UNIV_INTERN -void +bool fil_decompress_page( -/*================*/ - byte* page_buf, /*!< in: preallocated buffer or NULL */ - byte* buf, /*!< out: buffer from which to read; in aio - this must be appropriately aligned */ - ulong len, /*!< in: length of output buffer.*/ - ulint* write_size, /*!< in/out: Actual payload size of - the compressed data. */ - bool return_error=false); - /*!< in: true if only an error should - be produced when decompression fails. - By default this parameter is false. */ + byte* page_buf, + byte* buf, + ulong len, + ulint* write_size) + MY_ATTRIBUTE((warn_unused_result)); /****************************************************************//** Get space id from fil node @@ -129,4 +134,25 @@ ibool fil_page_is_lzo_compressed( /*=======================*/ byte* buf); /*!< in: page */ -#endif +#endif /* !UNIV_INNOCHECKSUM */ + +/** +Verify that stored post compression checksum matches calculated +checksum. Note that old format did not have a checksum and +in that case either original pre-compression page checksum will +fail after decompression or page decompression fails. + +@param[in,out] page page frame +@param[in] space_id Tablespace identifier +@param[in] offset Page offset +@return true if post compression checksum matches, false otherwise */ +UNIV_INTERN +bool +fil_verify_compression_checksum( + const byte* page, + ulint space_id, + ulint offset) + MY_ATTRIBUTE((warn_unused_result)); + +#endif /* fil0pagecompress_h */ + diff --git a/storage/innobase/include/fsp0pagecompress.h b/storage/innobase/include/fsp0pagecompress.h index c623d11c326..00645616556 100644 --- a/storage/innobase/include/fsp0pagecompress.h +++ b/storage/innobase/include/fsp0pagecompress.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2018, 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 @@ -38,6 +38,7 @@ Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com #define PAGE_SNAPPY_ALGORITHM 6 #define PAGE_ALGORITHM_LAST PAGE_SNAPPY_ALGORITHM +#ifndef UNIV_INNOCHECKSUM /**********************************************************************//** Reads the page compression level from the first page of a tablespace. @return page compression level, or 0 if uncompressed */ @@ -67,6 +68,7 @@ atomic_writes_t fsp_flags_get_atomic_writes( /*========================*/ ulint flags); /*!< in: tablespace flags */ +#endif /* !UNIV_INNOCHECKSUM */ #ifndef UNIV_NONINL #include "fsp0pagecompress.ic" diff --git a/storage/innobase/include/fsp0pagecompress.ic b/storage/innobase/include/fsp0pagecompress.ic index 14f968e319e..0e9a574eef6 100644 --- a/storage/innobase/include/fsp0pagecompress.ic +++ b/storage/innobase/include/fsp0pagecompress.ic @@ -25,6 +25,7 @@ Created 11/12/2013 Jan Lindström jan.lindstrom@mariadb.com ***********************************************************************/ +#ifndef UNIV_INNOCHECKSUM /********************************************************************//** Determine the tablespace is page compression level from dict_table_t::flags. @return page compression level or 0 if not compressed*/ @@ -84,6 +85,7 @@ fil_page_is_compressed_encrypted( { return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); } +#endif /*!UNIV_INNOCHECKSUM */ /****************************************************************//** Get the name of the compression algorithm used for page |