summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/ref/pg_checksums.sgml4
-rw-r--r--src/bin/pg_checksums/pg_checksums.c17
2 files changed, 21 insertions, 0 deletions
diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml
index 95043aa329c..e9e393495df 100644
--- a/doc/src/sgml/ref/pg_checksums.sgml
+++ b/doc/src/sgml/ref/pg_checksums.sgml
@@ -247,5 +247,9 @@ PostgreSQL documentation
remains unchanged, and <application>pg_checksums</application> can be
re-run to perform the same operation.
</para>
+ <para>
+ The target cluster must have the same major version as
+ <application>pg_checksums</application>.
+ </para>
</refsect1>
</refentry>
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
index f20be82862a..46cb2f36efa 100644
--- a/src/bin/pg_checksums/pg_checksums.c
+++ b/src/bin/pg_checksums/pg_checksums.c
@@ -25,6 +25,7 @@
#include "common/logging.h"
#include "common/relpath.h"
#include "fe_utils/option_utils.h"
+#include "fe_utils/version.h"
#include "getopt_long.h"
#include "pg_getopt.h"
#include "storage/bufpage.h"
@@ -448,6 +449,8 @@ main(int argc, char *argv[])
int c;
int option_index;
bool crc_ok;
+ uint32 major_version;
+ char *version_str;
pg_logging_init(argv[0]);
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_checksums"));
@@ -543,6 +546,20 @@ main(int argc, char *argv[])
exit(1);
}
+ /*
+ * Retrieve the contents of this cluster's PG_VERSION. We require
+ * compatibility with the same major version as the one this tool is
+ * compiled with.
+ */
+ major_version = GET_PG_MAJORVERSION_NUM(get_pg_version(DataDir, &version_str));
+ if (major_version != PG_MAJORVERSION_NUM)
+ {
+ pg_log_error("data directory is of wrong version");
+ pg_log_error_detail("File \"%s\" contains \"%s\", which is not compatible with this program's version \"%s\".",
+ "PG_VERSION", version_str, PG_MAJORVERSION);
+ exit(1);
+ }
+
/* Read the control file and check compatibility */
ControlFile = get_controlfile(DataDir, &crc_ok);
if (!crc_ok)