MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
buf0checksum.cc
Go to the documentation of this file.
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 it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
8
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc.,
15
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17
*****************************************************************************/
18
19
/**************************************************/
26
#include "univ.i"
27
#include "
fil0fil.h
"
/* FIL_* */
28
#include "
ut0crc32.h
"
/* ut_crc32() */
29
#include "
ut0rnd.h
"
/* ut_fold_binary() */
30
31
#ifndef UNIV_INNOCHECKSUM
32
33
#include "
srv0srv.h
"
/* SRV_CHECKSUM_* */
34
#include "
buf0types.h
"
35
40
UNIV_INTERN ulong
srv_checksum_algorithm
=
SRV_CHECKSUM_ALGORITHM_INNODB
;
41
42
#endif
/* !UNIV_INNOCHECKSUM */
43
44
/********************************************************************/
49
UNIV_INTERN
50
ib_uint32_t
51
buf_calc_page_crc32
(
52
/*================*/
53
const
byte*
page
)
54
{
55
ib_uint32_t checksum;
56
57
/* Since the field FIL_PAGE_FILE_FLUSH_LSN, and in versions <= 4.1.x
58
FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, are written outside the buffer pool
59
to the first pages of data files, we have to skip them in the page
60
checksum calculation.
61
We must also skip the field FIL_PAGE_SPACE_OR_CHKSUM where the
62
checksum is stored, and also the last 8 bytes of page because
63
there we store the old formula checksum. */
64
65
checksum = ut_crc32(page +
FIL_PAGE_OFFSET
,
66
FIL_PAGE_FILE_FLUSH_LSN
-
FIL_PAGE_OFFSET
)
67
^ ut_crc32(page +
FIL_PAGE_DATA
,
68
UNIV_PAGE_SIZE -
FIL_PAGE_DATA
69
-
FIL_PAGE_END_LSN_OLD_CHKSUM
);
70
71
return
(checksum);
72
}
73
74
/********************************************************************/
79
UNIV_INTERN
80
ulint
81
buf_calc_page_new_checksum
(
82
/*=======================*/
83
const
byte*
page
)
84
{
85
ulint checksum;
86
87
/* Since the field FIL_PAGE_FILE_FLUSH_LSN, and in versions <= 4.1.x
88
FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, are written outside the buffer pool
89
to the first pages of data files, we have to skip them in the page
90
checksum calculation.
91
We must also skip the field FIL_PAGE_SPACE_OR_CHKSUM where the
92
checksum is stored, and also the last 8 bytes of page because
93
there we store the old formula checksum. */
94
95
checksum =
ut_fold_binary
(page +
FIL_PAGE_OFFSET
,
96
FIL_PAGE_FILE_FLUSH_LSN
-
FIL_PAGE_OFFSET
)
97
+
ut_fold_binary
(page +
FIL_PAGE_DATA
,
98
UNIV_PAGE_SIZE -
FIL_PAGE_DATA
99
-
FIL_PAGE_END_LSN_OLD_CHKSUM
);
100
checksum = checksum & 0xFFFFFFFFUL;
101
102
return
(checksum);
103
}
104
105
/********************************************************************/
113
UNIV_INTERN
114
ulint
115
buf_calc_page_old_checksum
(
116
/*=======================*/
117
const
byte*
page
)
118
{
119
ulint checksum;
120
121
checksum =
ut_fold_binary
(page,
FIL_PAGE_FILE_FLUSH_LSN
);
122
123
checksum = checksum & 0xFFFFFFFFUL;
124
125
return
(checksum);
126
}
127
128
#ifndef UNIV_INNOCHECKSUM
129
130
/********************************************************************/
133
UNIV_INTERN
134
const
char
*
135
buf_checksum_algorithm_name
(
136
/*========================*/
137
srv_checksum_algorithm_t
algo)
138
{
139
switch
(algo) {
140
case
SRV_CHECKSUM_ALGORITHM_CRC32
:
141
case
SRV_CHECKSUM_ALGORITHM_STRICT_CRC32
:
142
return
(
"crc32"
);
143
case
SRV_CHECKSUM_ALGORITHM_INNODB
:
144
case
SRV_CHECKSUM_ALGORITHM_STRICT_INNODB
:
145
return
(
"innodb"
);
146
case
SRV_CHECKSUM_ALGORITHM_NONE
:
147
case
SRV_CHECKSUM_ALGORITHM_STRICT_NONE
:
148
return
(
"none"
);
149
}
150
151
ut_error
;
152
return
(NULL);
153
}
154
155
#endif
/* !UNIV_INNOCHECKSUM */
storage
innobase
buf
buf0checksum.cc
Generated on Sat Nov 9 2013 01:26:27 for MySQL 5.6.14 Source Code Document by
1.8.1.2