1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2017, 2019, MariaDB Corporation.
5 
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17 
18 *****************************************************************************/
19 
20 /**************************************************//**
21 @file buf/buf0checksum.h
22 Buffer pool checksum functions, also linked from /extra/innochecksum.cc
23 
24 Created Aug 11, 2011 Vasil Dimov
25 *******************************************************/
26 
27 #ifndef buf0checksum_h
28 #define buf0checksum_h
29 
30 #include "buf0types.h"
31 
32 /** Calculate the CRC32 checksum of a page. The value is stored to the page
33 when it is written to a file and also checked for a match when reading from
34 the file. Note that we must be careful to calculate the same value on all
35 architectures.
36 @param[in]	page			buffer page (srv_page_size bytes)
37 @return	CRC-32C */
38 uint32_t buf_calc_page_crc32(const byte* page);
39 
40 /** Calculate a checksum which is stored to the page when it is written
41 to a file. Note that we must be careful to calculate the same value on
42 32-bit and 64-bit architectures.
43 @param[in]	page	file page (srv_page_size bytes)
44 @return checksum */
45 uint32_t
46 buf_calc_page_new_checksum(const byte* page);
47 
48 /** In MySQL before 4.0.14 or 4.1.1 there was an InnoDB bug that
49 the checksum only looked at the first few bytes of the page.
50 This calculates that old checksum.
51 NOTE: we must first store the new formula checksum to
52 FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
53 because this takes that field as an input!
54 @param[in]	page	file page (srv_page_size bytes)
55 @return checksum */
56 uint32_t
57 buf_calc_page_old_checksum(const byte* page);
58 
59 /** Return a printable string describing the checksum algorithm.
60 @param[in]	algo	algorithm
61 @return algorithm name */
62 const char*
63 buf_checksum_algorithm_name(srv_checksum_algorithm_t algo);
64 
65 extern ulong	srv_checksum_algorithm;
66 
67 #endif /* buf0checksum_h */
68