From: Peter Eisentraut Date: Mon, 21 Jan 2008 11:17:46 +0000 (+0000) Subject: Provide a clearer error message if the pg_control version number looks X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=6b640afb5ff683b798ac84b0792121ed86eb0c06;p=users%2Fbernd%2Fpostgres.git Provide a clearer error message if the pg_control version number looks wrong because of mismatched byte ordering. --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index ade0327fd4..ba8a3b6616 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -3888,6 +3888,16 @@ ReadControlFile(void) * of bytes. Complaining about wrong version will probably be more * enlightening than complaining about wrong CRC. */ + + if (ControlFile->pg_control_version != PG_CONTROL_VERSION && ControlFile->pg_control_version % 65536 == 0 && ControlFile->pg_control_version / 65536 != 0) + ereport(FATAL, + (errmsg("database files are incompatible with server"), + errdetail("The database cluster was initialized with PG_CONTROL_VERSION %d (0x%08x)," + " but the server was compiled with PG_CONTROL_VERSION %d (0x%08x).", + ControlFile->pg_control_version, ControlFile->pg_control_version, + PG_CONTROL_VERSION, PG_CONTROL_VERSION), + errhint("This could be a problem of mismatched byte ordering. It looks like you need to initdb."))); + if (ControlFile->pg_control_version != PG_CONTROL_VERSION) ereport(FATAL, (errmsg("database files are incompatible with server"), @@ -3895,6 +3905,7 @@ ReadControlFile(void) " but the server was compiled with PG_CONTROL_VERSION %d.", ControlFile->pg_control_version, PG_CONTROL_VERSION), errhint("It looks like you need to initdb."))); + /* Now check the CRC. */ INIT_CRC32(crc); COMP_CRC32(crc, diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index 92652ab426..f466784c50 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -151,6 +151,11 @@ main(int argc, char *argv[]) printf(_("pg_control version number: %u\n"), ControlFile.pg_control_version); + if (ControlFile.pg_control_version % 65536 == 0 && ControlFile.pg_control_version / 65536 != 0) + printf(_("WARNING: possible byte ordering mismatch\n" + "The byte ordering used to store the pg_control file might not match the one\n" + "used by this program. In that case the results below would be incorrect, and\n" + "the PostgreSQL installation would be incompatible with this data directory.\n")); printf(_("Catalog version number: %u\n"), ControlFile.catalog_version_no); printf(_("Database system identifier: %s\n"),