Skip to content
Permalink
Browse files

MDEV-12488 Remove type mismatch in InnoDB printf-like calls

This is a reduced version of an originally much larger patch.
We will keep the definition of the ulint, lint data types unchanged,
and we will not be replacing fprintf() calls with ib_logf().

On Windows, use the standard format strings instead of nonstandard
extensions.

This patch fixes some errors in format strings.
Most notably, an IMPORT TABLESPACE error message in InnoDB was
displaying the number of columns instead of the mismatching flags.
  • Loading branch information...
dr-m committed Apr 21, 2017
1 parent d34a67b commit 87b6df31c4ae97c09dc67e370978112fe39764bb
@@ -360,12 +360,13 @@ int main(int argc, char **argv)
{
if (verbose)
printf("Number of pages: ");
printf("%lu\n", pages);
printf(ULINTPF "\n", pages);
goto ok;
}
else if (verbose)
{
printf("file %s = %llu bytes (%lu pages)...\n", filename, size, (ulong)pages);
printf("file %s = %llu bytes (" ULINTPF " pages)...\n",
filename, size, pages);
if (do_one_page)
printf("InnoChecksum; checking page %lu\n", do_page);
else
@@ -421,7 +422,8 @@ int main(int argc, char **argv)
if (compressed) {
/* compressed pages */
if (!page_zip_verify_checksum(buf, physical_page_size)) {
fprintf(stderr, "Fail; page %lu invalid (fails compressed page checksum).\n", ct);
fprintf(stderr, "Fail; page " ULINTPF
" invalid (fails compressed page checksum).\n", ct);
if (!skip_corrupt)
goto error;
}
@@ -431,10 +433,14 @@ int main(int argc, char **argv)
logseq= mach_read_from_4(buf + FIL_PAGE_LSN + 4);
logseqfield= mach_read_from_4(buf + logical_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM + 4);
if (debug)
printf("page %lu: log sequence number: first = %lu; second = %lu\n", ct, logseq, logseqfield);
printf("page " ULINTPF
": log sequence number: first = " ULINTPF
"; second = " ULINTPF "\n",
ct, logseq, logseqfield);
if (logseq != logseqfield)
{
fprintf(stderr, "Fail; page %lu invalid (fails log sequence number check)\n", ct);
fprintf(stderr, "Fail; page " ULINTPF
" invalid (fails log sequence number check)\n", ct);
if (!skip_corrupt)
goto error;
}
@@ -443,10 +449,14 @@ int main(int argc, char **argv)
oldcsum= buf_calc_page_old_checksum(buf);
oldcsumfield= mach_read_from_4(buf + logical_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM);
if (debug)
printf("page %lu: old style: calculated = %lu; recorded = %lu\n", ct, oldcsum, oldcsumfield);
printf("page " ULINTPF
": old style: calculated = " ULINTPF
"; recorded = " ULINTPF "\n",
ct, oldcsum, oldcsumfield);
if (oldcsumfield != mach_read_from_4(buf + FIL_PAGE_LSN) && oldcsumfield != oldcsum)
{
fprintf(stderr, "Fail; page %lu invalid (fails old style checksum)\n", ct);
fprintf(stderr, "Fail; page " ULINTPF
" invalid (fails old style checksum)\n", ct);
if (!skip_corrupt)
goto error;
}
@@ -456,11 +466,14 @@ int main(int argc, char **argv)
crc32= buf_calc_page_crc32(buf);
csumfield= mach_read_from_4(buf + FIL_PAGE_SPACE_OR_CHKSUM);
if (debug)
printf("page %lu: new style: calculated = %lu; crc32 = %lu; recorded = %lu\n",
printf("page " ULINTPF
": new style: calculated = " ULINTPF
"; crc32 = " ULINTPF "; recorded = " ULINTPF "\n",
ct, csum, crc32, csumfield);
if (csumfield != 0 && crc32 != csumfield && csum != csumfield)
{
fprintf(stderr, "Fail; page %lu invalid (fails innodb and crc32 checksum)\n", ct);
fprintf(stderr, "Fail; page " ULINTPF
" invalid (fails innodb and crc32 checksum)\n", ct);
if (!skip_corrupt)
goto error;
}
@@ -479,7 +492,8 @@ int main(int argc, char **argv)
if (!lastt) lastt= now;
if (now - lastt >= 1)
{
printf("page %lu okay: %.3f%% done\n", (ct - 1), (float) ct / pages * 100);
printf("page " ULINTPF " okay: %.3f%% done\n",
(ct - 1), (float) ct / pages * 100);
lastt= now;
}
}

This file was deleted.

@@ -580,7 +580,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table 't1'
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@@ -592,7 +592,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table 't1'
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x0)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@@ -766,7 +766,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table 't1'
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@@ -778,7 +778,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table 't1'
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@@ -955,7 +955,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table 't1'
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@@ -967,7 +967,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table 't1'
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x21)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@@ -419,13 +419,12 @@ the word size of the machine, that is on a 32-bit platform 32 bits, and on a
macro ULINTPF. */


#ifdef __WIN__
#ifdef _WIN32
/* Use the integer types and formatting strings defined in Visual Studio. */
# define UINT32PF "%I32u"
# define INT64PF "%I64d"
# define UINT64PF "%I64u"
# define UINT64PFx "%016I64x"
# define DBUG_LSN_PF "%llu"
# define UINT32PF "%u"
# define INT64PF "%lld"
# define UINT64PF "%llu"
# define UINT64PFx "%016llx"
typedef __int64 ib_int64_t;
typedef unsigned __int64 ib_uint64_t;
typedef unsigned __int32 ib_uint32_t;
@@ -435,13 +434,12 @@ typedef unsigned __int32 ib_uint32_t;
# define INT64PF "%" PRId64
# define UINT64PF "%" PRIu64
# define UINT64PFx "%016" PRIx64
# define DBUG_LSN_PF UINT64PF
typedef int64_t ib_int64_t;
typedef uint64_t ib_uint64_t;
typedef uint32_t ib_uint32_t;
# endif /* __WIN__ */
#endif

# define IB_ID_FMT UINT64PF
#define IB_ID_FMT UINT64PF

#ifdef _WIN64
typedef unsigned __int64 ulint;
@@ -1702,7 +1702,7 @@ recv_recover_page_func(
}

DBUG_PRINT("ib_log",
("apply " DBUG_LSN_PF ": %u len %u "
("apply " LSN_PF ": %u len %u "
"page %u:%u", recv->start_lsn,
(unsigned) recv->type,
(unsigned) recv->len,
@@ -2350,7 +2350,7 @@ recv_parse_log_recs(
recv_sys->recovered_lsn = new_recovered_lsn;

DBUG_PRINT("ib_log",
("scan " DBUG_LSN_PF ": log rec %u len %u "
("scan " LSN_PF ": log rec %u len %u "
"page %u:%u", old_lsn,
(unsigned) type, (unsigned) len,
(unsigned) space, (unsigned) page_no));
@@ -2441,7 +2441,7 @@ recv_parse_log_recs(
#endif /* UNIV_LOG_DEBUG */

DBUG_PRINT("ib_log",
("scan " DBUG_LSN_PF ": multi-log rec %u "
("scan " LSN_PF ": multi-log rec %u "
"len %u page %u:%u",
recv_sys->recovered_lsn,
(unsigned) type, (unsigned) len,

0 comments on commit 87b6df3

Please sign in to comment.
You can’t perform that action at this time.