1 /***************************************************************************** 2 3 Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, for more details. 20 21 You should have received a copy of the GNU General Public License along with 22 this program; if not, write to the Free Software Foundation, Inc., 23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 24 25 *****************************************************************************/ 26 27 /**************************************************//** 28 @file buf/buf0checksum.h 29 Buffer pool checksum functions, also linked from /extra/innochecksum.cc 30 31 Created Aug 11, 2011 Vasil Dimov 32 *******************************************************/ 33 34 #ifndef buf0checksum_h 35 #define buf0checksum_h 36 37 #include "univ.i" 38 39 #include "buf0types.h" 40 41 /** Magic value to use instead of checksums when they are disabled */ 42 #define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL 43 44 /********************************************************************//** 45 Calculates a page CRC32 which is stored to the page when it is written 46 to a file. Note that we must be careful to calculate the same value on 47 32-bit and 64-bit architectures. 48 @return checksum */ 49 UNIV_INTERN 50 ib_uint32_t 51 buf_calc_page_crc32( 52 /*================*/ 53 const byte* page); /*!< in: buffer page */ 54 55 /********************************************************************//** 56 Calculates a page checksum which is stored to the page when it is written 57 to a file. Note that we must be careful to calculate the same value on 58 32-bit and 64-bit architectures. 59 @return checksum */ 60 UNIV_INTERN 61 ulint 62 buf_calc_page_new_checksum( 63 /*=======================*/ 64 const byte* page); /*!< in: buffer page */ 65 66 /********************************************************************//** 67 In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only 68 looked at the first few bytes of the page. This calculates that old 69 checksum. 70 NOTE: we must first store the new formula checksum to 71 FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum 72 because this takes that field as an input! 73 @return checksum */ 74 UNIV_INTERN 75 ulint 76 buf_calc_page_old_checksum( 77 /*=======================*/ 78 const byte* page); /*!< in: buffer page */ 79 80 /********************************************************************//** 81 Return a printable string describing the checksum algorithm. 82 @return algorithm name */ 83 UNIV_INTERN 84 const char* 85 buf_checksum_algorithm_name( 86 /*========================*/ 87 srv_checksum_algorithm_t algo); /*!< in: algorithm */ 88 89 extern ulong srv_checksum_algorithm; 90 91 #endif /* buf0checksum_h */ 92