Fix cross-version compatibility checks of pg_verify_checksums
authorMichael Paquier <[email protected]>
Wed, 13 Mar 2019 00:51:02 +0000 (09:51 +0900)
committerMichael Paquier <[email protected]>
Wed, 13 Mar 2019 00:51:02 +0000 (09:51 +0900)
pg_verify_checksums performs a read of the control file, and the data it
fetches should be from a data folder compatible with the major version
of Postgres the binary has been compiled with, but we never actually
checked that compatibility.

Reported-by: Sergei Kornilov
Author: Michael Paquier
Reviewed-by: Sergei Kornilov
Discussion: https://postgr.es/m/155231347133.16480.11453587097036807558[email protected]
Back-through: 11

src/bin/pg_verify_checksums/pg_verify_checksums.c

index 511262ab5ff13a5d4040d60df14a3b5788f23e81..4c7c055b31437c24daa6304679f3faf58426e03a 100644 (file)
@@ -316,6 +316,13 @@ main(int argc, char *argv[])
        exit(1);
    }
 
+   if (ControlFile->pg_control_version != PG_CONTROL_VERSION)
+   {
+       fprintf(stderr, _("%s: cluster is not compatible with this version of pg_verify_checksums\n"),
+               progname);
+       exit(1);
+   }
+
    if (ControlFile->state != DB_SHUTDOWNED &&
        ControlFile->state != DB_SHUTDOWNED_IN_RECOVERY)
    {