Commit 124dc0d8 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25361 fixup: Fix integer type mismatch

InnoDB tablespace identifiers and page numbers are 32-bit numbers.
Let us use a 32-bit type for them in innochecksum.

The changes in commit 1918bdf3
broke the build on 32-bit Windows.

Thanks to Vicențiu Ciorbaru for an initial version of this fixup.
parent b30f26e3
/* /*
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -85,9 +85,9 @@ typedef void fil_space_t; ...@@ -85,9 +85,9 @@ typedef void fil_space_t;
/* Global variables */ /* Global variables */
static bool verbose; static bool verbose;
static bool just_count; static bool just_count;
static unsigned long long start_page; static uint32_t start_page;
static unsigned long long end_page; static uint32_t end_page;
static unsigned long long do_page; static uint32_t do_page;
static bool use_end_page; static bool use_end_page;
static bool do_one_page; static bool do_one_page;
static my_bool do_leaf; static my_bool do_leaf;
...@@ -99,9 +99,9 @@ static ulong logical_page_size; /* Page size when uncompressed. */ ...@@ -99,9 +99,9 @@ static ulong logical_page_size; /* Page size when uncompressed. */
ulong srv_page_size; ulong srv_page_size;
page_size_t univ_page_size(0, 0, false); page_size_t univ_page_size(0, 0, false);
/* Current page number (0 based). */ /* Current page number (0 based). */
unsigned long long cur_page_num; uint32_t cur_page_num;
/* Current space. */ /* Current space. */
unsigned long long cur_space; uint32_t cur_space;
/* Skip the checksum verification. */ /* Skip the checksum verification. */
static bool no_check; static bool no_check;
/* Enabled for strict checksum verification. */ /* Enabled for strict checksum verification. */
...@@ -494,11 +494,11 @@ is_page_corrupted( ...@@ -494,11 +494,11 @@ is_page_corrupted(
/* enable if page is corrupted. */ /* enable if page is corrupted. */
bool is_corrupted; bool is_corrupted;
/* use to store LSN values. */ /* use to store LSN values. */
ulint logseq; uint32_t logseq;
ulint logseqfield; uint32_t logseqfield;
ulint page_type = mach_read_from_2(buf+FIL_PAGE_TYPE); ulint page_type = mach_read_from_2(buf+FIL_PAGE_TYPE);
uint key_version = mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); uint32_t key_version = mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
ulint space_id = mach_read_from_4( uint32_t space_id = mach_read_from_4(
buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
if (mach_read_from_4(buf + FIL_PAGE_OFFSET) != cur_page_num if (mach_read_from_4(buf + FIL_PAGE_OFFSET) != cur_page_num
...@@ -511,8 +511,8 @@ is_page_corrupted( ...@@ -511,8 +511,8 @@ is_page_corrupted(
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, fprintf(log_file,
"page id mismatch space::" ULINTPF "page id mismatch space::" UINT32PF
" page::%llu \n", " page::" UINT32PF " \n",
space_id, cur_page_num); space_id, cur_page_num);
} }
...@@ -539,13 +539,14 @@ is_page_corrupted( ...@@ -539,13 +539,14 @@ is_page_corrupted(
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, fprintf(log_file,
"space::" ULINTPF " page::%llu" "space::" UINT32PF " page::" UINT32PF
"; log sequence number:first = " ULINTPF "; log sequence number:first = " UINT32PF
"; second = " ULINTPF "\n", "; second = " UINT32PF "\n",
space_id, cur_page_num, logseq, logseqfield); space_id, cur_page_num, logseq, logseqfield);
if (logseq != logseqfield) { if (logseq != logseqfield) {
fprintf(log_file, fprintf(log_file,
"Fail; space::" ULINTPF " page::%llu" "Fail; space::" UINT32PF
" page::" UINT32PF
" invalid (fails log " " invalid (fails log "
"sequence number check)\n", "sequence number check)\n",
space_id, cur_page_num); space_id, cur_page_num);
...@@ -567,9 +568,9 @@ is_page_corrupted( ...@@ -567,9 +568,9 @@ is_page_corrupted(
page_size); page_size);
if (is_corrupted && log_file) { if (is_corrupted && log_file) {
fprintf(log_file, fprintf(log_file,
"[page id: space=" ULINTPF "[page id: space=" UINT32PF
", page_number=%llu] may be corrupted;" ", page_number=" UINT32PF "] may be corrupted;"
" key_version=%u\n", " key_version=" UINT32PF "\n",
space_id, cur_page_num, space_id, cur_page_num,
mach_read_from_4( mach_read_from_4(
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
...@@ -680,8 +681,8 @@ update_checksum( ...@@ -680,8 +681,8 @@ update_checksum(
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, "page::%llu; Updated checksum =" fprintf(log_file, "page::" UINT32PF "; Updated checksum ="
" %u\n", cur_page_num, checksum); " " UINT32PF "\n", cur_page_num, checksum);
} }
} else { } else {
...@@ -711,8 +712,8 @@ update_checksum( ...@@ -711,8 +712,8 @@ update_checksum(
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, "page::%llu; Updated checksum field1" fprintf(log_file, "page::" UINT32PF "; Updated checksum field1"
" = %u\n", cur_page_num, checksum); " = " UINT32PF "\n", cur_page_num, checksum);
} }
if (write_check == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB if (write_check == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB
...@@ -725,8 +726,8 @@ update_checksum( ...@@ -725,8 +726,8 @@ update_checksum(
FIL_PAGE_END_LSN_OLD_CHKSUM,checksum); FIL_PAGE_END_LSN_OLD_CHKSUM,checksum);
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, "page::%llu; Updated checksum " fprintf(log_file, "page::" UINT32PF "; Updated checksum "
"field2 = %u\n", cur_page_num, checksum); "field2 = " UINT32PF "\n", cur_page_num, checksum);
} }
} }
...@@ -800,7 +801,7 @@ write_file( ...@@ -800,7 +801,7 @@ write_file(
if (page_size if (page_size
!= fwrite(buf, 1, page_size, file == stdin ? stdout : file)) { != fwrite(buf, 1, page_size, file == stdin ? stdout : file)) {
fprintf(stderr, "Failed to write page::%llu to %s: %s\n", fprintf(stderr, "Failed to write page::" UINT32PF " to %s: %s\n",
cur_page_num, filename, strerror(errno)); cur_page_num, filename, strerror(errno));
return(false); return(false);
...@@ -818,8 +819,8 @@ write_file( ...@@ -818,8 +819,8 @@ write_file(
} }
// checks using current xdes page whether the page is free // checks using current xdes page whether the page is free
static bool page_is_free(const byte *xdes, page_size_t page_size, static inline bool is_page_free(const byte *xdes, page_size_t page_size,
size_t page_no) uint32_t page_no)
{ {
const byte *des= const byte *des=
xdes + XDES_ARR_OFFSET + xdes + XDES_ARR_OFFSET +
...@@ -844,12 +845,10 @@ parse_page( ...@@ -844,12 +845,10 @@ parse_page(
bool is_encrypted) bool is_encrypted)
{ {
unsigned long long id; unsigned long long id;
ulint undo_page_type; uint16_t undo_page_type;
char str[20]={'\0'}; char str[20]={'\0'};
ulint n_recs; ulint n_recs;
ulint page_no; uint32_t page_no, left_page_no, right_page_no;
ulint left_page_no;
ulint right_page_no;
ulint data_bytes; ulint data_bytes;
bool is_leaf; bool is_leaf;
int size_range_id; int size_range_id;
...@@ -864,7 +863,7 @@ parse_page( ...@@ -864,7 +863,7 @@ parse_page(
switch (mach_read_from_2(page + FIL_PAGE_TYPE)) { switch (mach_read_from_2(page + FIL_PAGE_TYPE)) {
case FIL_PAGE_INDEX: { case FIL_PAGE_INDEX: {
uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); uint32_t key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
page_type.n_fil_page_index++; page_type.n_fil_page_index++;
/* If page is encrypted we can't read index header */ /* If page is encrypted we can't read index header */
...@@ -888,7 +887,7 @@ parse_page( ...@@ -888,7 +887,7 @@ parse_page(
is_leaf = (!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL))); is_leaf = (!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL)));
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tIndex page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tIndex page\t\t\t|"
"\tindex id=%llu,", cur_page_num, id); "\tindex id=%llu,", cur_page_num, id);
fprintf(file, fprintf(file,
...@@ -907,13 +906,13 @@ parse_page( ...@@ -907,13 +906,13 @@ parse_page(
size_range_id = SIZE_RANGES_FOR_PAGE + 1; size_range_id = SIZE_RANGES_FOR_PAGE + 1;
} }
if (per_page_details) { if (per_page_details) {
printf("index id=%llu page " ULINTPF " leaf %d n_recs " ULINTPF " data_bytes " ULINTPF printf("index id=%llu page " UINT32PF " leaf %d n_recs " ULINTPF " data_bytes " ULINTPF
"\n", id, page_no, is_leaf, n_recs, data_bytes); "\n", id, page_no, is_leaf, n_recs, data_bytes);
} }
/* update per-index statistics */ /* update per-index statistics */
{ {
per_index_stats &index = index_ids[id]; per_index_stats &index = index_ids[id];
if (page_is_free(xdes, page_size, page_no)) { if (is_page_free(xdes, page_size, page_no)) {
index.free_pages++; index.free_pages++;
return; return;
} }
...@@ -941,8 +940,8 @@ parse_page( ...@@ -941,8 +940,8 @@ parse_page(
index.pages_in_size_range[size_range_id] ++; index.pages_in_size_range[size_range_id] ++;
} }
} else { } else {
fprintf(file, "#::%llu\t\t|\t\tEncrypted Index page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tEncrypted Index page\t\t\t|"
"\tkey_version %u,%s\n", cur_page_num, key_version, str); "\tkey_version " UINT32PF ",%s\n", cur_page_num, key_version, str);
} }
break; break;
...@@ -952,7 +951,7 @@ parse_page( ...@@ -952,7 +951,7 @@ parse_page(
undo_page_type = mach_read_from_2(page + undo_page_type = mach_read_from_2(page +
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE); TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE);
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tUndo log page\t\t\t|", fprintf(file, "#::" UINT32PF "\t\t|\t\tUndo log page\t\t\t|",
cur_page_num); cur_page_num);
} }
if (undo_page_type == TRX_UNDO_INSERT) { if (undo_page_type == TRX_UNDO_INSERT) {
...@@ -1026,7 +1025,7 @@ parse_page( ...@@ -1026,7 +1025,7 @@ parse_page(
case FIL_PAGE_INODE: case FIL_PAGE_INODE:
page_type.n_fil_page_inode++; page_type.n_fil_page_inode++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tInode page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tInode page\t\t\t|"
"\t%s\n",cur_page_num, str); "\t%s\n",cur_page_num, str);
} }
break; break;
...@@ -1034,7 +1033,7 @@ parse_page( ...@@ -1034,7 +1033,7 @@ parse_page(
case FIL_PAGE_IBUF_FREE_LIST: case FIL_PAGE_IBUF_FREE_LIST:
page_type.n_fil_page_ibuf_free_list++; page_type.n_fil_page_ibuf_free_list++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tInsert buffer free list" fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert buffer free list"
" page\t|\t%s\n", cur_page_num, str); " page\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1042,7 +1041,7 @@ parse_page( ...@@ -1042,7 +1041,7 @@ parse_page(
case FIL_PAGE_TYPE_ALLOCATED: case FIL_PAGE_TYPE_ALLOCATED:
page_type.n_fil_page_type_allocated++; page_type.n_fil_page_type_allocated++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tFreshly allocated " fprintf(file, "#::" UINT32PF "\t\t|\t\tFreshly allocated "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1050,7 +1049,7 @@ parse_page( ...@@ -1050,7 +1049,7 @@ parse_page(
case FIL_PAGE_IBUF_BITMAP: case FIL_PAGE_IBUF_BITMAP:
page_type.n_fil_page_ibuf_bitmap++; page_type.n_fil_page_ibuf_bitmap++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tInsert Buffer " fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert Buffer "
"Bitmap\t\t|\t%s\n", cur_page_num, str); "Bitmap\t\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1058,15 +1057,15 @@ parse_page( ...@@ -1058,15 +1057,15 @@ parse_page(
case FIL_PAGE_TYPE_SYS: case FIL_PAGE_TYPE_SYS:
page_type.n_fil_page_type_sys++; page_type.n_fil_page_type_sys++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tSystem page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tSystem page\t\t\t|"
"\t%s\n",cur_page_num, str); "\t%s\n", cur_page_num, str);
} }
break; break;
case FIL_PAGE_TYPE_TRX_SYS: case FIL_PAGE_TYPE_TRX_SYS:
page_type.n_fil_page_type_trx_sys++; page_type.n_fil_page_type_trx_sys++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tTransaction system " fprintf(file, "#::" UINT32PF "\t\t|\t\tTransaction system "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1074,7 +1073,7 @@ parse_page( ...@@ -1074,7 +1073,7 @@ parse_page(
case FIL_PAGE_TYPE_FSP_HDR: case FIL_PAGE_TYPE_FSP_HDR:
page_type.n_fil_page_type_fsp_hdr++; page_type.n_fil_page_type_fsp_hdr++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tFile Space " fprintf(file, "#::" UINT32PF "\t\t|\t\tFile Space "
"Header\t\t|\t%s\n", cur_page_num, str); "Header\t\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1082,7 +1081,7 @@ parse_page( ...@@ -1082,7 +1081,7 @@ parse_page(
case FIL_PAGE_TYPE_XDES: case FIL_PAGE_TYPE_XDES:
page_type.n_fil_page_type_xdes++; page_type.n_fil_page_type_xdes++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tExtent descriptor " fprintf(file, "#::" UINT32PF "\t\t|\t\tExtent descriptor "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1090,7 +1089,7 @@ parse_page( ...@@ -1090,7 +1089,7 @@ parse_page(
case FIL_PAGE_TYPE_BLOB: case FIL_PAGE_TYPE_BLOB:
page_type.n_fil_page_type_blob++; page_type.n_fil_page_type_blob++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tBLOB page\t\t\t|\t%s\n", fprintf(file, "#::" UINT32PF "\t\t|\t\tBLOB page\t\t\t|\t%s\n",
cur_page_num, str); cur_page_num, str);
} }
break; break;
...@@ -1098,7 +1097,7 @@ parse_page( ...@@ -1098,7 +1097,7 @@ parse_page(
case FIL_PAGE_TYPE_ZBLOB: case FIL_PAGE_TYPE_ZBLOB:
page_type.n_fil_page_type_zblob++; page_type.n_fil_page_type_zblob++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tCompressed BLOB " fprintf(file, "#::" UINT32PF "\t\t|\t\tCompressed BLOB "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1106,7 +1105,7 @@ parse_page( ...@@ -1106,7 +1105,7 @@ parse_page(
case FIL_PAGE_TYPE_ZBLOB2: case FIL_PAGE_TYPE_ZBLOB2:
page_type.n_fil_page_type_zblob2++; page_type.n_fil_page_type_zblob2++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tSubsequent Compressed " fprintf(file, "#::" UINT32PF "\t\t|\t\tSubsequent Compressed "
"BLOB page\t|\t%s\n", cur_page_num, str); "BLOB page\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1114,7 +1113,7 @@ parse_page( ...@@ -1114,7 +1113,7 @@ parse_page(
case FIL_PAGE_PAGE_COMPRESSED: case FIL_PAGE_PAGE_COMPRESSED:
page_type.n_fil_page_type_page_compressed++; page_type.n_fil_page_type_page_compressed++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tPage compressed " fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed "
"page\t|\t%s\n", cur_page_num, str); "page\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1122,7 +1121,7 @@ parse_page( ...@@ -1122,7 +1121,7 @@ parse_page(
case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED: case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED:
page_type.n_fil_page_type_page_compressed_encrypted++; page_type.n_fil_page_type_page_compressed_encrypted++;
if (page_type_dump) { if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tPage compressed encrypted " fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed encrypted "
"page\t|\t%s\n", cur_page_num, str); "page\t|\t%s\n", cur_page_num, str);
} }
break; break;
...@@ -1278,14 +1277,14 @@ static struct my_option innochecksum_options[] = { ...@@ -1278,14 +1277,14 @@ static struct my_option innochecksum_options[] = {
{"count", 'c', "Print the count of pages in the file and exits.", {"count", 'c', "Print the count of pages in the file and exits.",
&just_count, &just_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, &just_count, &just_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"start_page", 's', "Start on this page number (0 based).", {"start_page", 's', "Start on this page number (0 based).",
&start_page, &start_page, 0, GET_ULL, REQUIRED_ARG, &start_page, &start_page, 0, GET_UINT, REQUIRED_ARG,
0, 0, ULLONG_MAX, 0, 1, 0}, 0, 0, FIL_NULL, 0, 1, 0},
{"end_page", 'e', "End at this page number (0 based).", {"end_page", 'e', "End at this page number (0 based).",
&end_page, &end_page, 0, GET_ULL, REQUIRED_ARG, &end_page, &end_page, 0, GET_UINT, REQUIRED_ARG,
0, 0, ULLONG_MAX, 0, 1, 0}, 0, 0, FIL_NULL, 0, 1, 0},
{"page", 'p', "Check only this page (0 based).", {"page", 'p', "Check only this page (0 based).",
&do_page, &do_page, 0, GET_ULL, REQUIRED_ARG, &do_page, &do_page, 0, GET_UINT, REQUIRED_ARG,
0, 0, ULLONG_MAX, 0, 1, 0}, 0, 0, FIL_NULL, 0, 1, 0},
{"strict-check", 'C', "Specify the strict checksum algorithm by the user.", {"strict-check", 'C', "Specify the strict checksum algorithm by the user.",
&strict_check, &strict_check, &innochecksum_algorithms_typelib, &strict_check, &strict_check, &innochecksum_algorithms_typelib,
GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
...@@ -1479,14 +1478,14 @@ bool check_encryption( ...@@ -1479,14 +1478,14 @@ bool check_encryption(
return false; return false;
} }
uint min_key_version = mach_read_from_4 uint32_t min_key_version = mach_read_from_4
(page + offset + MAGIC_SZ + 2 + iv_length); (page + offset + MAGIC_SZ + 2 + iv_length);
uint key_id = mach_read_from_4 uint32_t key_id = mach_read_from_4
(page + offset + MAGIC_SZ + 2 + iv_length + 4); (page + offset + MAGIC_SZ + 2 + iv_length + 4);
if (type == CRYPT_SCHEME_1 && is_log_enabled) { if (type == CRYPT_SCHEME_1 && is_log_enabled) {
fprintf(log_file,"Tablespace %s encrypted key_version %u key_id %u\n", fprintf(log_file,"Tablespace %s encrypted key_version " UINT32PF " key_id " UINT32PF "\n",
filename, min_key_version, key_id); filename, min_key_version, key_id);
} }
...@@ -1517,7 +1516,7 @@ int verify_checksum( ...@@ -1517,7 +1516,7 @@ int verify_checksum(
buf, page_size, is_encrypted, is_compressed); buf, page_size, is_encrypted, is_compressed);
if (is_corrupted) { if (is_corrupted) {
fprintf(stderr, "Fail: page::%llu invalid\n", fprintf(stderr, "Fail: page::" UINT32PF " invalid\n",
cur_page_num); cur_page_num);
(*mismatch_count)++; (*mismatch_count)++;
...@@ -1603,7 +1602,7 @@ int main( ...@@ -1603,7 +1602,7 @@ int main(
/* size of file (has to be 64 bits) */ /* size of file (has to be 64 bits) */
unsigned long long int size = 0; unsigned long long int size = 0;
/* number of pages in file */ /* number of pages in file */
ulint pages; uint32_t pages;
off_t offset = 0; off_t offset = 0;
/* count the no. of page corrupted. */ /* count the no. of page corrupted. */
...@@ -1810,7 +1809,7 @@ int main( ...@@ -1810,7 +1809,7 @@ int main(
} }
if (per_page_details) { if (per_page_details) {
printf("page %llu ", cur_page_num); printf("page " UINT32PF " ", cur_page_num);
} }
memcpy(xdes, buf, physical_page_size); memcpy(xdes, buf, physical_page_size);
...@@ -1819,29 +1818,29 @@ int main( ...@@ -1819,29 +1818,29 @@ int main(
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted); parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
} }
pages = (ulint) (size / page_size.physical()); pages = uint32_t(size / page_size.physical());
if (just_count) { if (just_count) {
if (read_from_stdin) { fprintf(read_from_stdin ? stderr : stdout,
fprintf(stderr, "Number of pages:" ULINTPF "\n", pages); "Number of pages:" UINT32PF "\n", pages);
} else {
printf("Number of pages:" ULINTPF "\n", pages);
}
continue; continue;
} else if (verbose && !read_from_stdin) { } else if (verbose && !read_from_stdin) {
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, "file %s = %llu bytes " fprintf(log_file, "file %s = %llu bytes "
"(" ULINTPF " pages)\n", filename, size, pages); "(" UINT32PF " pages)\n",
filename, size, pages);
if (do_one_page) { if (do_one_page) {
fprintf(log_file, "Innochecksum: " fprintf(log_file, "Innochecksum: "
"checking page::%llu;\n", "checking page::"
UINT32PF ";\n",
do_page); do_page);
} }
} }
} else { } else {
if (is_log_enabled) { if (is_log_enabled) {
fprintf(log_file, "Innochecksum: checking " fprintf(log_file, "Innochecksum: checking "
"pages in range::%llu to %llu\n", "pages in range::" UINT32PF
" to " UINT32PF "\n",
start_page, use_end_page ? start_page, use_end_page ?
end_page : (pages - 1)); end_page : (pages - 1));
} }
...@@ -1885,8 +1884,8 @@ int main( ...@@ -1885,8 +1884,8 @@ int main(
the desired page. */ the desired page. */
partial_page_read = false; partial_page_read = false;
offset = (off_t) start_page offset = off_t(ulonglong(start_page)
* (off_t) page_size.physical(); * page_size.physical());
#ifdef _WIN32 #ifdef _WIN32
if (_fseeki64(fil_in, offset, SEEK_SET)) { if (_fseeki64(fil_in, offset, SEEK_SET)) {
#else #else
...@@ -1931,12 +1930,7 @@ int main( ...@@ -1931,12 +1930,7 @@ int main(
count++; count++;
if (!bytes || feof(fil_in)) { if (!bytes || feof(fil_in)) {
fprintf(stderr, "Error: Unable " goto unexpected_eof;
"to seek to necessary "
"offset");
exit_status = 1;
goto my_exit;
} }
} }
} }
...@@ -1953,6 +1947,15 @@ int main( ...@@ -1953,6 +1947,15 @@ int main(
partial_page_read = false; partial_page_read = false;
if (!bytes && feof(fil_in)) { if (!bytes && feof(fil_in)) {
if (cur_page_num == start_page) {
unexpected_eof:
fputs("Error: Unable "
"to seek to necessary offset\n",
stderr);
exit_status = 1;
goto my_exit;
}
break; break;
} }
...@@ -1992,10 +1995,10 @@ int main( ...@@ -1992,10 +1995,10 @@ int main(
/* If no-check is enabled, skip the /* If no-check is enabled, skip the
checksum verification.*/ checksum verification.*/
if (!no_check if (!no_check &&
&& !page_is_free(xdes, page_size, cur_page_num) !is_page_free(xdes, page_size, cur_page_num) &&
&& !skip_page !skip_page &&
&& (exit_status = verify_checksum( (exit_status = verify_checksum(
buf, page_size, buf, page_size,
is_encrypted, is_compressed, is_encrypted, is_compressed,
&mismatch_count))) { &mismatch_count))) {
...@@ -2013,7 +2016,7 @@ int main( ...@@ -2013,7 +2016,7 @@ int main(
} }
if (per_page_details) { if (per_page_details) {
printf("page %llu ", cur_page_num); printf("page " UINT32PF " ", cur_page_num);
} }
if (page_get_page_no(buf) % physical_page_size == 0) { if (page_get_page_no(buf) % physical_page_size == 0) {
...@@ -2033,10 +2036,10 @@ int main( ...@@ -2033,10 +2036,10 @@ int main(
if (!lastt) { if (!lastt) {
lastt= now; lastt= now;
} else if (now - lastt >= 1 && is_log_enabled) { } else if (now - lastt >= 1 && is_log_enabled) {
fprintf(log_file, "page::%llu " fprintf(log_file, "page::" UINT32PF " "
"okay: %.3f%% done\n", "okay: %.3f%% done\n",
(cur_page_num - 1), (cur_page_num - 1),
(float) cur_page_num / pages * 100); (double) cur_page_num / pages * 100);
lastt = now; lastt = now;
} }
} }
......
...@@ -210,10 +210,10 @@ Filename::tab#.ibd ...@@ -210,10 +210,10 @@ Filename::tab#.ibd
# allow-mismatches,page,start-page,end-page # allow-mismatches,page,start-page,end-page
[9]: check the both short and long options "page" and "start-page" when [9]: check the both short and long options "page" and "start-page" when
# seek value is larger than file size. # seek value is larger than file size.
FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
[34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page. [34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page.
# innochecksum will fail with error code: 1 # innochecksum will fail with error code: 1
NOT FOUND /Incorrect unsigned integer value: '18446744073709551616'/ in my_restart.err NOT FOUND /Incorrect unsigned integer value: '18446744073709551616'/ in my_restart.err
......
...@@ -339,22 +339,19 @@ cat_file $MYSQLTEST_VARDIR/tmp/dump.txt; ...@@ -339,22 +339,19 @@ cat_file $MYSQLTEST_VARDIR/tmp/dump.txt;
--echo # seek value is larger than file size. --echo # seek value is larger than file size.
--error 1 --error 1
--exec $INNOCHECKSUM --page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --exec $INNOCHECKSUM --page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument; let SEARCH_PATTERN= Error: Unable to seek to necessary offset;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--error 1 --error 1
--exec $INNOCHECKSUM -p 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --exec $INNOCHECKSUM -p 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--error 1 --error 1
--exec $INNOCHECKSUM --start-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --exec $INNOCHECKSUM --start-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--error 1 --error 1
--exec $INNOCHECKSUM -s 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE --exec $INNOCHECKSUM -s 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--echo [34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page. --echo [34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2020, MariaDB Corporation. Copyright (c) 2013, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -776,8 +776,8 @@ buf_page_is_checksum_valid_crc32( ...@@ -776,8 +776,8 @@ buf_page_is_checksum_valid_crc32(
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" crc32 calculated = %u;" " crc32 calculated = " UINT32PF ";"
" recorded checksum field1 = " ULINTPF " recorded" " recorded checksum field1 = " ULINTPF " recorded"
" checksum field2 =" ULINTPF "\n", cur_page_num, " checksum field2 =" ULINTPF "\n", cur_page_num,
crc32, checksum_field1, checksum_field2); crc32, checksum_field1, checksum_field2);
...@@ -822,26 +822,26 @@ buf_page_is_checksum_valid_innodb( ...@@ -822,26 +822,26 @@ buf_page_is_checksum_valid_innodb(
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_INNODB) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" old style: calculated =" " old style: calculated ="
" " ULINTPF "; recorded = " ULINTPF "\n", " " ULINTPF "; recorded = " ULINTPF "\n",
cur_page_num, old_checksum, cur_page_num, old_checksum,
checksum_field2); checksum_field2);
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" new style: calculated =" " new style: calculated ="
" " ULINTPF "; crc32 = %u; recorded = " ULINTPF "\n", " " ULINTPF "; crc32 = " UINT32PF "; recorded = " ULINTPF "\n",
cur_page_num, new_checksum, cur_page_num, new_checksum,
buf_calc_page_crc32(read_buf), checksum_field1); buf_calc_page_crc32(read_buf), checksum_field1);
} }
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" old style: calculated =" " old style: calculated ="
" " ULINTPF "; recorded checksum = " ULINTPF "\n", " " ULINTPF "; recorded checksum = " ULINTPF "\n",
cur_page_num, old_checksum, cur_page_num, old_checksum,
checksum_field2); checksum_field2);
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" new style: calculated =" " new style: calculated ="
" " ULINTPF "; recorded checksum = " ULINTPF "\n", " " ULINTPF "; recorded checksum = " ULINTPF "\n",
cur_page_num, new_checksum, cur_page_num, new_checksum,
...@@ -909,7 +909,7 @@ buf_page_is_checksum_valid_none( ...@@ -909,7 +909,7 @@ buf_page_is_checksum_valid_none(
if (log_file if (log_file
&& srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) { && srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_STRICT_NONE) {
fprintf(log_file, fprintf(log_file,
"page::%llu; none checksum: calculated" "page::" UINT32PF "; none checksum: calculated"
" = %lu; recorded checksum_field1 = " ULINTPF " = %lu; recorded checksum_field1 = " ULINTPF
" recorded checksum_field2 = " ULINTPF "\n", " recorded checksum_field2 = " ULINTPF "\n",
cur_page_num, BUF_NO_CHECKSUM_MAGIC, cur_page_num, BUF_NO_CHECKSUM_MAGIC,
...@@ -1110,15 +1110,15 @@ buf_page_is_corrupted( ...@@ -1110,15 +1110,15 @@ buf_page_is_corrupted(
checksum_field1, checksum_field2)) { checksum_field1, checksum_field2)) {
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" old style: calculated = %u;" " old style: calculated = %u;"
" recorded = " ULINTPF ";\n", " recorded = " ULINTPF ";\n",
cur_page_num, cur_page_num,
buf_calc_page_old_checksum(read_buf), buf_calc_page_old_checksum(read_buf),
checksum_field2); checksum_field2);
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" new style: calculated = %u;" " new style: calculated = " UINT32PF ";"
" crc32 = %u; recorded = " ULINTPF ";\n", " crc32 = " UINT32PF "; recorded = " ULINTPF ";\n",
cur_page_num, cur_page_num,
buf_calc_page_new_checksum(read_buf), buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf), buf_calc_page_crc32(read_buf),
......
...@@ -458,7 +458,7 @@ in both 32-bit and 64-bit environments. */ ...@@ -458,7 +458,7 @@ in both 32-bit and 64-bit environments. */
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
extern bool strict_verify; extern bool strict_verify;
extern FILE* log_file; extern FILE* log_file;
extern unsigned long long cur_page_num; extern uint32_t cur_page_num;
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
typedef int64_t ib_int64_t; typedef int64_t ib_int64_t;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2014, 2020, MariaDB Corporation. Copyright (c) 2014, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -4983,9 +4983,9 @@ bool page_zip_verify_checksum(const byte *data, size_t size) ...@@ -4983,9 +4983,9 @@ bool page_zip_verify_checksum(const byte *data, size_t size)
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (log_file) { if (log_file) {
fprintf(log_file, "page::%llu;" fprintf(log_file, "page::" UINT32PF ";"
" %s checksum: calculated = %u;" " %s checksum: calculated = " UINT32PF ";"
" recorded = %u\n", cur_page_num, " recorded = " UINT32PF "\n", cur_page_num,
buf_checksum_algorithm_name( buf_checksum_algorithm_name(
static_cast<srv_checksum_algorithm_t>( static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm)), srv_checksum_algorithm)),
...@@ -4997,11 +4997,11 @@ bool page_zip_verify_checksum(const byte *data, size_t size) ...@@ -4997,11 +4997,11 @@ bool page_zip_verify_checksum(const byte *data, size_t size)
data, size, SRV_CHECKSUM_ALGORITHM_CRC32); data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
if (log_file) { if (log_file) {
fprintf(log_file, "page::%llu: crc32 checksum:" fprintf(log_file, "page::" UINT32PF ": crc32 checksum:"
" calculated = %u; recorded = %u\n", " calculated = " UINT32PF "; recorded = " UINT32PF "\n",
cur_page_num, crc32, stored); cur_page_num, crc32, stored);
fprintf(log_file, "page::%llu: none checksum:" fprintf(log_file, "page::" UINT32PF ": none checksum:"
" calculated = %lu; recorded = %u\n", " calculated = %lu; recorded = " UINT32PF "\n",
cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored); cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment