54
51
/* command line argument to do page checks (that's it) */
55
52
/* another argument to specify page ranges... seek to right spot and go from there */
54
typedef uint32_t ulint;
55
typedef unsigned char uchar;
57
57
/* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */
58
static uint32_t mach_read_from_4(unsigned char *b)
58
static ulint mach_read_from_4(uchar *b)
60
return( ((uint32_t)(b[0]) << 24)
61
+ ((uint32_t)(b[1]) << 16)
62
+ ((uint32_t)(b[2]) << 8)
60
return( ((ulint)(b[0]) << 24)
61
+ ((ulint)(b[1]) << 16)
62
+ ((ulint)(b[2]) << 8)
68
ut_fold_uint32_t_pair(
69
69
/*===============*/
70
70
/* out: folded value */
71
uint32_t n1, /* in: uint32_t */
72
uint32_t n2) /* in: uint32_t */
71
ulint n1, /* in: ulint */
72
ulint n2) /* in: ulint */
74
74
return(((((n1 ^ n2 ^ UT_HASH_RANDOM_MASK2) << 8) + n1)
75
75
^ UT_HASH_RANDOM_MASK) + n2);
81
81
/* out: folded value */
82
unsigned char* str, /* in: string of bytes */
83
uint32_t len) /* in: length */
82
uchar* str, /* in: string of bytes */
83
ulint len) /* in: length */
88
88
for (i= 0; i < len; i++)
90
fold= ut_fold_uint32_t_pair(fold, (uint32_t)(*str));
90
fold= ut_fold_ulint_pair(fold, (ulint)(*str));
99
99
buf_calc_page_new_checksum(
100
100
/*=======================*/
101
101
/* out: checksum */
102
unsigned char* page) /* in: buffer page */
102
uchar* page) /* in: buffer page */
106
106
/* Since the fields FIL_PAGE_FILE_FLUSH_LSN and ..._ARCH_LOG_NO
107
107
are written outside the buffer pool to the first pages of data
120
120
return(checksum);
124
124
buf_calc_page_old_checksum(
125
125
/*=======================*/
126
126
/* out: checksum */
127
unsigned char* page) /* in: buffer page */
127
uchar* page) /* in: buffer page */
131
131
checksum= ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
139
139
int main(int argc, char **argv)
141
141
FILE *f; /* our input file */
142
unsigned char *p; /* storage of pages read */
142
uchar *p; /* storage of pages read */
143
143
int bytes; /* bytes read count */
144
uint32_t ct; /* current page number (0 based) */
144
ulint ct; /* current page number (0 based) */
145
145
int now; /* current time */
146
146
int lastt; /* last time */
147
uint32_t oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* uint32_ts for checksum storage */
147
ulint oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; /* ulints for checksum storage */
148
148
struct stat st; /* for stat, if you couldn't guess */
149
uint64_t size; /* size of file (has to be 64 bits) */
150
uint32_t pages; /* number of pages in file */
151
uint32_t start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
149
unsigned long long int size; /* size of file (has to be 64 bits) */
150
ulint pages; /* number of pages in file */
151
ulint start_page= 0, end_page= 0, use_end_page= 0; /* for starting and ending at certain pages */
153
153
int just_count= 0; /* if true, just print page count */
226
226
else if (verbose)
228
printf("file %s= %"PRIu64" bytes (%u pages)...\n", argv[1], size, pages);
228
printf("file %s= %llu bytes (%u pages)...\n", argv[1], size, pages);
229
229
printf("checking pages in range %u to %u\n", start_page, use_end_page ? end_page : (pages - 1));