mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Ensure that all startup paths (postmaster, standalone postgres, or
bootstrap) check for a valid PG_VERSION file before looking at anything else in the data directory. This fixes confusing error report when trying to start current sources in a pre-7.1 data directory. Per trouble report from Rich Shepard 10/18/01.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.117 2001/09/29 04:02:22 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.118 2001/10/19 17:03:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -303,11 +303,13 @@ BootstrapMain(int argc, char *argv[])
|
||||
}
|
||||
SetDataDir(potential_DataDir);
|
||||
}
|
||||
|
||||
/* Validate we have been given a reasonable-looking DataDir */
|
||||
Assert(DataDir);
|
||||
ValidatePgVersion(DataDir);
|
||||
|
||||
if (IsUnderPostmaster)
|
||||
{
|
||||
|
||||
/*
|
||||
* Properly accept or ignore signals the postmaster might send us
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.246 2001/10/19 00:44:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.247 2001/10/19 17:03:08 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -287,6 +287,9 @@ checkDataDir(const char *checkdir)
|
||||
ExitPostmaster(2);
|
||||
}
|
||||
|
||||
/* Look for PG_VERSION before looking for pg_control */
|
||||
ValidatePgVersion(checkdir);
|
||||
|
||||
snprintf(path, sizeof(path), "%s/global/pg_control", checkdir);
|
||||
|
||||
fp = AllocateFile(path, PG_BINARY_R);
|
||||
@@ -299,10 +302,7 @@ checkDataDir(const char *checkdir)
|
||||
progname, checkdir, path, strerror(errno));
|
||||
ExitPostmaster(2);
|
||||
}
|
||||
|
||||
FreeFile(fp);
|
||||
|
||||
ValidatePgVersion(checkdir);
|
||||
}
|
||||
|
||||
|
||||
@@ -2438,10 +2438,10 @@ SSDataBase(int xlop)
|
||||
|
||||
av[ac++] = "-d";
|
||||
|
||||
sprintf(nbbuf, "-B%u", NBuffers);
|
||||
sprintf(nbbuf, "-B%d", NBuffers);
|
||||
av[ac++] = nbbuf;
|
||||
|
||||
sprintf(xlbuf, "-x %d", xlop);
|
||||
sprintf(xlbuf, "-x%d", xlop);
|
||||
av[ac++] = xlbuf;
|
||||
|
||||
av[ac++] = "-p";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.235 2001/10/19 00:44:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.236 2001/10/19 17:03:08 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@@ -1583,6 +1583,12 @@ PostgresMain(int argc, char *argv[],
|
||||
proc_exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate we have been given a reasonable-looking DataDir
|
||||
* (if under postmaster, assume postmaster did this already).
|
||||
*/
|
||||
ValidatePgVersion(DataDir);
|
||||
|
||||
/*
|
||||
* Create lockfile for data directory.
|
||||
*/
|
||||
@@ -1645,7 +1651,7 @@ PostgresMain(int argc, char *argv[],
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.235 $ $Date: 2001/10/19 00:44:08 $\n");
|
||||
puts("$Revision: 1.236 $ $Date: 2001/10/19 17:03:08 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.78 2001/10/12 02:08:34 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.79 2001/10/19 17:03:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -912,10 +912,8 @@ ValidatePgVersion(const char *path)
|
||||
}
|
||||
|
||||
ret = fscanf(file, "%ld.%ld", &file_major, &file_minor);
|
||||
if (ret == EOF)
|
||||
elog(FATAL, "cannot read %s: %m", full_path);
|
||||
else if (ret != 2)
|
||||
elog(FATAL, "`%s' does not have a valid format. You need to initdb.", full_path);
|
||||
if (ret != 2)
|
||||
elog(FATAL, "File %s does not contain valid data. You need to initdb.", full_path);
|
||||
|
||||
FreeFile(file);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.93 2001/09/29 04:02:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.94 2001/10/19 17:03:08 tgl Exp $
|
||||
*
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
@@ -221,13 +221,7 @@ InitPostgres(const char *dbname, const char *username)
|
||||
char *fullpath,
|
||||
datpath[MAXPGPATH];
|
||||
|
||||
/* Verify if DataDir is ok */
|
||||
if (access(DataDir, F_OK) == -1)
|
||||
elog(FATAL, "Database system not found.\n\t"
|
||||
"Data directory '%s' does not exist.",
|
||||
DataDir);
|
||||
|
||||
ValidatePgVersion(DataDir);
|
||||
/* Formerly we validated DataDir here, but now that's done earlier. */
|
||||
|
||||
/*
|
||||
* Find oid and path of the database we're about to open. Since
|
||||
|
||||
Reference in New Issue
Block a user