Hi all, (related folks in CC) Sergei Kornilov has reported here an issue with pg_checksums: https://www.postgresql.org/message-id/[email protected]
If the block size the tool is compiled with does not match the data folder block size, then users would get incorrect checksums failures, which is confusing. As pg_checksum_block() uses directly the block size, this cannot really be made dynamic yet, so we had better issue an error on that. Michael Banck has sent a patch for that: https://www.postgresql.org/message-id/[email protected] The error message proposed is like that: + if (ControlFile->blcksz != BLCKSZ) + { + fprintf(stderr, _("%s: data directory block size %d is different to compiled-in block size %d.\n"), + progname, ControlFile->blcksz, BLCKSZ); + exit(1); + } Still I think that we could do better. Here is a proposal of message which looks more natural to me, and more consistent with what xlog.c complains about: database files are incompatible with pg_checksums. The database cluster was initialized with BLCKSZ %d, but pg_checksums was compiled with BLCKSZ %d. Has somebody a better wording for that? Attached is a proposal of patch. -- Michael
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
index 5d4083fa9f..423c036c0f 100644
--- a/src/bin/pg_checksums/pg_checksums.c
+++ b/src/bin/pg_checksums/pg_checksums.c
@@ -327,6 +327,15 @@ main(int argc, char *argv[])
exit(1);
}
+ if (ControlFile->blcksz != BLCKSZ)
+ {
+ fprintf(stderr, _("%s: database files are incompatible with pg_checksums.\n"),
+ progname);
+ fprintf(stderr, _("%s: The database cluster was initialized with BLCKSZ %u, but pg_checksums was compiled with BLCKSZ %u."),
+ progname, ControlFile->blcksz, BLCKSZ);
+ exit(1);
+ }
+
if (ControlFile->state != DB_SHUTDOWNED &&
ControlFile->state != DB_SHUTDOWNED_IN_RECOVERY)
{
signature.asc
Description: PGP signature
