1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Version number now set in configure, available through Makefile.global

and config.h. Adjusted all referring code.

Scrapped pg_version and changed initdb accordingly. Integrated
src/utils/version.c into src/backend/utils/init/miscinit.c. Changed all
callers.

Set version number to `7.1devel'. (Non-numeric version suffixes now allowed.)
This commit is contained in:
Peter Eisentraut
2000-07-02 15:21:27 +00:00
parent 07dfe97731
commit 6fb9d2e347
23 changed files with 631 additions and 861 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.50 2000/06/14 18:17:46 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.51 2000/07/02 15:20:56 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,6 +24,7 @@
#include <grp.h>
#include <pwd.h>
#include <stdlib.h>
#include <errno.h>
#include "catalog/catname.h"
#include "catalog/pg_shadow.h"
@@ -520,3 +521,51 @@ SetPidFile(pid_t pid)
return (0);
}
/*
* Determine whether the PG_VERSION file in directory `path' indicates
* a data version compatible with the version of this program.
*
* If compatible, return. Otherwise, elog(FATAL).
*/
void
ValidatePgVersion(const char *path)
{
char full_path[MAXPGPATH];
FILE *file;
int ret;
long file_major, file_minor;
long my_major = 0, my_minor = 0;
char *endptr;
const char *version_string = PG_VERSION;
my_major = strtol(version_string, &endptr, 10);
if (*endptr == '.')
my_minor = strtol(endptr+1, NULL, 10);
snprintf(full_path, MAXPGPATH, "%s/PG_VERSION", path);
file = AllocateFile(full_path, "r");
if (!file)
{
if (errno == ENOENT)
elog(FATAL, "File %s is missing. This is not a valid data directory.", full_path);
else
elog(FATAL, "cannot open %s: %s", full_path, strerror(errno));
}
ret = fscanf(file, "%ld.%ld", &file_major, &file_minor);
if (ret == EOF)
elog(FATAL, "cannot read %s: %s", full_path, strerror(errno));
else if (ret != 2)
elog(FATAL, "`%s' does not have a valid format. You need to initdb.", full_path);
FreeFile(file);
if (my_major != file_major || my_minor != file_minor)
elog(FATAL, "The data directory was initalized by PostgreSQL version %ld.%ld, "
"which is not compatible with this verion %s.",
file_major, file_minor, version_string);
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.60 2000/06/28 03:32:43 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.61 2000/07/02 15:20:56 petere Exp $
*
*
*-------------------------------------------------------------------------
@@ -34,7 +34,6 @@
#include "utils/portal.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
#include "version.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
@@ -267,9 +266,7 @@ InitPostgres(const char *dbname)
elog(FATAL, "Database system not found. Data directory '%s' does not exist.",
DataDir);
ValidatePgVersion(DataDir, &reason);
if (reason != NULL)
elog(FATAL, reason);
ValidatePgVersion(DataDir);
/*-----------------
* Find oid and path of the database we're about to open. Since we're
@@ -300,9 +297,7 @@ InitPostgres(const char *dbname)
elog(FATAL, "Database \"%s\" does not exist. The data directory '%s' is missing.",
dbname, fullpath);
ValidatePgVersion(fullpath, &reason);
if (reason != NULL)
elog(FATAL, "%s", reason);
ValidatePgVersion(fullpath);
if (chdir(fullpath) == -1)
elog(FATAL, "Unable to change directory to '%s': %s", fullpath, strerror(errno));