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

Commit6430e6e

Browse files
committed
Ensure that all startup paths (postmaster, standalone postgres, or
bootstrap) check for a valid PG_VERSION file before looking at anythingelse in the data directory. This fixes confusing error report whentrying to start current sources in a pre-7.1 data directory.Per trouble report from Rich Shepard 10/18/01.
1 parent3d51065 commit6430e6e

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.117 2001/09/29 04:02:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.118 2001/10/19 17:03:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -303,11 +303,13 @@ BootstrapMain(int argc, char *argv[])
303303
}
304304
SetDataDir(potential_DataDir);
305305
}
306+
307+
/* Validate we have been given a reasonable-looking DataDir */
306308
Assert(DataDir);
309+
ValidatePgVersion(DataDir);
307310

308311
if (IsUnderPostmaster)
309312
{
310-
311313
/*
312314
* Properly accept or ignore signals the postmaster might send us
313315
*/

‎src/backend/postmaster/postmaster.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.246 2001/10/1900:44:08 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.247 2001/10/1917:03:08 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -287,6 +287,9 @@ checkDataDir(const char *checkdir)
287287
ExitPostmaster(2);
288288
}
289289

290+
/* Look for PG_VERSION before looking for pg_control */
291+
ValidatePgVersion(checkdir);
292+
290293
snprintf(path,sizeof(path),"%s/global/pg_control",checkdir);
291294

292295
fp=AllocateFile(path,PG_BINARY_R);
@@ -299,10 +302,7 @@ checkDataDir(const char *checkdir)
299302
progname,checkdir,path,strerror(errno));
300303
ExitPostmaster(2);
301304
}
302-
303305
FreeFile(fp);
304-
305-
ValidatePgVersion(checkdir);
306306
}
307307

308308

@@ -2438,10 +2438,10 @@ SSDataBase(int xlop)
24382438

24392439
av[ac++]="-d";
24402440

2441-
sprintf(nbbuf,"-B%u",NBuffers);
2441+
sprintf(nbbuf,"-B%d",NBuffers);
24422442
av[ac++]=nbbuf;
24432443

2444-
sprintf(xlbuf,"-x%d",xlop);
2444+
sprintf(xlbuf,"-x%d",xlop);
24452445
av[ac++]=xlbuf;
24462446

24472447
av[ac++]="-p";

‎src/backend/tcop/postgres.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.235 2001/10/1900:44:08 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.236 2001/10/1917:03:08 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1583,6 +1583,12 @@ PostgresMain(int argc, char *argv[],
15831583
proc_exit(1);
15841584
}
15851585

1586+
/*
1587+
* Validate we have been given a reasonable-looking DataDir
1588+
* (if under postmaster, assume postmaster did this already).
1589+
*/
1590+
ValidatePgVersion(DataDir);
1591+
15861592
/*
15871593
* Create lockfile for data directory.
15881594
*/
@@ -1645,7 +1651,7 @@ PostgresMain(int argc, char *argv[],
16451651
if (!IsUnderPostmaster)
16461652
{
16471653
puts("\nPOSTGRES backend interactive interface ");
1648-
puts("$Revision: 1.235 $ $Date: 2001/10/1900:44:08 $\n");
1654+
puts("$Revision: 1.236 $ $Date: 2001/10/1917:03:08 $\n");
16491655
}
16501656

16511657
/*

‎src/backend/utils/init/miscinit.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.78 2001/10/12 02:08:34 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.79 2001/10/19 17:03:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -912,10 +912,8 @@ ValidatePgVersion(const char *path)
912912
}
913913

914914
ret=fscanf(file,"%ld.%ld",&file_major,&file_minor);
915-
if (ret==EOF)
916-
elog(FATAL,"cannot read %s: %m",full_path);
917-
elseif (ret!=2)
918-
elog(FATAL,"`%s' does not have a valid format. You need to initdb.",full_path);
915+
if (ret!=2)
916+
elog(FATAL,"File %s does not contain valid data. You need to initdb.",full_path);
919917

920918
FreeFile(file);
921919

‎src/backend/utils/init/postinit.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.93 2001/09/29 04:02:25 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.94 2001/10/19 17:03:08 tgl Exp $
1212
*
1313
*
1414
*-------------------------------------------------------------------------
@@ -221,13 +221,7 @@ InitPostgres(const char *dbname, const char *username)
221221
char*fullpath,
222222
datpath[MAXPGPATH];
223223

224-
/* Verify if DataDir is ok */
225-
if (access(DataDir,F_OK)==-1)
226-
elog(FATAL,"Database system not found.\n\t"
227-
"Data directory '%s' does not exist.",
228-
DataDir);
229-
230-
ValidatePgVersion(DataDir);
224+
/* Formerly we validated DataDir here, but now that's done earlier. */
231225

232226
/*
233227
* Find oid and path of the database we're about to open. Since

‎src/bin/initdb/initdb.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
2828
# Portions Copyright (c) 1994, Regents of the University of California
2929
#
30-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.139 2001/10/16 20:51:35 tgl Exp $
30+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.140 2001/10/19 17:03:08 tgl Exp $
3131
#
3232
#-------------------------------------------------------------------------
3333

@@ -463,13 +463,17 @@ $ECHO_N "creating template1 database in $PGDATA/base/1... "$ECHO_C
463463
rm -rf"$PGDATA"/base/1|| exit_nicely
464464
mkdir"$PGDATA"/base/1|| exit_nicely
465465

466+
# Top level PG_VERSION is checked by bootstrapper, so make it first
467+
echo"$short_version">"$PGDATA/PG_VERSION"|| exit_nicely
468+
466469
cat"$POSTGRES_BKI" \
467470
| sed -e"s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \
468471
-e"s/ENCODING/$MULTIBYTEID/g" \
469472
|"$PGPATH"/postgres -boot -x1$PGSQL_OPT$BACKEND_TALK_ARG template1 \
470473
|| exit_nicely
471474

472-
echo$short_version>"$PGDATA"/base/1/PG_VERSION|| exit_nicely
475+
# Make the per-database PGVERSION for template1 only after init'ing it
476+
echo"$short_version">"$PGDATA/base/1/PG_VERSION"|| exit_nicely
473477

474478
echo"ok"
475479

@@ -479,8 +483,6 @@ echo "ok"
479483

480484
$ECHO_N"creating configuration files..."$ECHO_C
481485

482-
echo$short_version>"$PGDATA/PG_VERSION"|| exit_nicely
483-
484486
cp"$PG_HBA_SAMPLE""$PGDATA"/pg_hba.conf|| exit_nicely
485487
cp"$PG_IDENT_SAMPLE""$PGDATA"/pg_ident.conf|| exit_nicely
486488
cp"$POSTGRESQL_CONF_SAMPLE""$PGDATA"/postgresql.conf|| exit_nicely

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp