Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f8f8d2

Browse files
committed
Provide a clearer error message if the pg_control version number looks
wrong because of mismatched byte ordering.
1 parent1e98572 commit6f8f8d2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.291 2008/01/01 19:45:48 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.292 2008/01/21 11:17:46 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -3888,13 +3888,24 @@ ReadControlFile(void)
38883888
* of bytes. Complaining about wrong version will probably be more
38893889
* enlightening than complaining about wrong CRC.
38903890
*/
3891+
3892+
if (ControlFile->pg_control_version!=PG_CONTROL_VERSION&&ControlFile->pg_control_version %65536==0&&ControlFile->pg_control_version /65536!=0)
3893+
ereport(FATAL,
3894+
(errmsg("database files are incompatible with server"),
3895+
errdetail("The database cluster was initialized with PG_CONTROL_VERSION %d (0x%08x),"
3896+
" but the server was compiled with PG_CONTROL_VERSION %d (0x%08x).",
3897+
ControlFile->pg_control_version,ControlFile->pg_control_version,
3898+
PG_CONTROL_VERSION,PG_CONTROL_VERSION),
3899+
errhint("This could be a problem of mismatched byte ordering. It looks like you need to initdb.")));
3900+
38913901
if (ControlFile->pg_control_version!=PG_CONTROL_VERSION)
38923902
ereport(FATAL,
38933903
(errmsg("database files are incompatible with server"),
38943904
errdetail("The database cluster was initialized with PG_CONTROL_VERSION %d,"
38953905
" but the server was compiled with PG_CONTROL_VERSION %d.",
38963906
ControlFile->pg_control_version,PG_CONTROL_VERSION),
38973907
errhint("It looks like you need to initdb.")));
3908+
38983909
/* Now check the CRC. */
38993910
INIT_CRC32(crc);
39003911
COMP_CRC32(crc,

‎src/bin/pg_controldata/pg_controldata.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.35 2007/04/03 04:14:26 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.36 2008/01/21 11:17:46 petere Exp $
1010
*/
1111
#include"postgres.h"
1212

@@ -151,6 +151,11 @@ main(int argc, char *argv[])
151151

152152
printf(_("pg_control version number: %u\n"),
153153
ControlFile.pg_control_version);
154+
if (ControlFile.pg_control_version %65536==0&&ControlFile.pg_control_version /65536!=0)
155+
printf(_("WARNING: possible byte ordering mismatch\n"
156+
"The byte ordering used to store the pg_control file might not match the one\n"
157+
"used by this program. In that case the results below would be incorrect, and\n"
158+
"the PostgreSQL installation would be incompatible with this data directory.\n"));
154159
printf(_("Catalog version number: %u\n"),
155160
ControlFile.catalog_version_no);
156161
printf(_("Database system identifier: %s\n"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp