mirror of https://github.com/postgres/postgres
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.)REL7_1_STABLE
parent
07dfe97731
commit
6fb9d2e347
@ -1,43 +0,0 @@ |
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile for src/bin/pg_version
|
||||
#
|
||||
# Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/Makefile,v 1.7 2000/06/27 00:31:29 petere Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
subdir = src/bin/pg_version
|
||||
top_builddir = ../../..
|
||||
include ../../Makefile.global |
||||
|
||||
OBJS= pg_version.o $(top_builddir)/src/utils/version.o $(STRERROR2)
|
||||
|
||||
all: pg_version$(X) |
||||
|
||||
pg_version$(X): $(OBJS) |
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
$(top_builddir)/src/utils/version.o: $(top_srcdir)/src/utils/version.c $(top_builddir)/src/include/version.h |
||||
$(MAKE) -C $(top_builddir)/src/utils version.o
|
||||
|
||||
install: all installdirs |
||||
$(INSTALL_PROGRAM) pg_version$(X) $(bindir)/pg_version$(X)
|
||||
|
||||
installdirs: |
||||
$(mkinstalldirs) $(bindir)
|
||||
|
||||
uninstall: |
||||
rm -f $(bindir)/pg_version$(X)
|
||||
|
||||
depend dep: |
||||
$(CC) -MM $(CFLAGS) *.c >depend
|
||||
|
||||
clean distclean maintainer-clean: |
||||
rm -f pg_version$(X) pg_version.o
|
||||
|
||||
ifeq (depend,$(wildcard depend)) |
||||
include depend |
||||
endif |
@ -1,46 +0,0 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_version.c |
||||
* |
||||
* |
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* |
||||
* IDENTIFICATION |
||||
* $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.12 2000/01/26 05:57:40 momjian Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
|
||||
#include "version.h" /* interface to SetPgVersion */ |
||||
|
||||
|
||||
|
||||
int |
||||
main(int argc, char **argv) |
||||
{ |
||||
int retcode; /* our eventual return code */ |
||||
char *reason; /* Reason that SetPgVersion failed, NULL
|
||||
* if it didn't. */ |
||||
|
||||
if (argc < 2) |
||||
{ |
||||
fprintf(stderr, "pg_version: missing argument\n"); |
||||
exit(1); |
||||
} |
||||
SetPgVersion(argv[1], &reason); |
||||
if (reason) |
||||
{ |
||||
fprintf(stderr, |
||||
"pg_version is unable to create the PG_VERSION file. " |
||||
"SetPgVersion gave this reason: %s\n", |
||||
reason); |
||||
retcode = 10; |
||||
} |
||||
else |
||||
retcode = 0; |
||||
return retcode; |
||||
} |
@ -1,25 +0,0 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* version.h.in |
||||
* this file contains the interface to version.c. |
||||
* Also some parameters. |
||||
* |
||||
* $Header: /cvsroot/pgsql/src/include/Attic/version.h.in,v 1.9 2000/06/12 22:36:10 momjian Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef VERSION_H |
||||
#define VERSION_H |
||||
|
||||
void ValidatePgVersion(const char *path, char **reason_p); |
||||
void SetPgVersion(const char *path, char **reason_p); |
||||
|
||||
#define PG_RELEASE "7" |
||||
#define PG_VERSION "1" |
||||
#define PG_SUBVERSION "0" |
||||
|
||||
#define PG_VERFILE "PG_VERSION" |
||||
|
||||
#define PG_VERSION_STR "PostgreSQL " PG_RELEASE "." PG_VERSION "." PG_SUBVERSION " on @host@, compiled by @CC@ @CC_VERSION@" |
||||
|
||||
#endif |
@ -1,149 +0,0 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* version.c |
||||
* Routines to handle Postgres version number. |
||||
* |
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* |
||||
* IDENTIFICATION |
||||
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.17 2000/06/14 18:18:01 petere Exp $ |
||||
* |
||||
* STANDALONE CODE - do not use error routines as this code is not linked |
||||
* with any... |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#include <sys/types.h> |
||||
#include <sys/file.h> |
||||
#include <fcntl.h> /* For open() flags */ |
||||
#include <sys/stat.h> |
||||
#include <ctype.h> |
||||
#include <unistd.h> |
||||
#include <errno.h> |
||||
|
||||
#include "postgres.h" |
||||
|
||||
#include "storage/fd.h" /* for O_ */ |
||||
|
||||
#include "version.h" |
||||
|
||||
|
||||
static void |
||||
PathSetVersionFilePath(const char *path, char *filepathbuf) |
||||
{ |
||||
/*----------------------------------------------------------------------------
|
||||
PathSetVersionFilePath |
||||
|
||||
Destructively change "filepathbuf" to contain the concatenation of "path" |
||||
and the name of the version file name. |
||||
----------------------------------------------------------------------------*/ |
||||
if ((strlen(path) + 1 + strlen(PG_VERFILE)) >= MAXPGPATH) |
||||
*filepathbuf = '\0'; |
||||
else |
||||
sprintf(filepathbuf, "%s%c%s", path, SEP_CHAR, PG_VERFILE); |
||||
} |
||||
|
||||
|
||||
|
||||
void |
||||
ValidatePgVersion(const char *path, char **reason_p) |
||||
{ |
||||
/*----------------------------------------------------------------------------
|
||||
Determine whether the PG_VERSION file in directory <path> indicates |
||||
a data version compatible with the version of this program. |
||||
|
||||
If compatible, return <*reason_p> == NULL. Otherwise, malloc space, |
||||
fill it with a text string explaining how it isn't compatible (or why |
||||
we can't tell), and return a pointer to that space as <*reason_p>. |
||||
-----------------------------------------------------------------------------*/ |
||||
int fd; |
||||
int nread; |
||||
char myversion[32]; |
||||
char version[32]; |
||||
char full_path[MAXPGPATH]; |
||||
|
||||
PathSetVersionFilePath(path, full_path); |
||||
|
||||
sprintf(myversion, "%s.%s\n", PG_RELEASE, PG_VERSION); |
||||
|
||||
if ((fd = open(full_path, O_RDONLY | PG_BINARY, 0)) == -1) |
||||
{ |
||||
*reason_p = malloc(100 + strlen(full_path)); |
||||
sprintf(*reason_p, "File '%s' does not exist or no read permission.", full_path); |
||||
} |
||||
else |
||||
{ |
||||
nread = read(fd, version, sizeof(version) - 1); |
||||
if (nread < 4 || |
||||
!isdigit((int)version[0]) || |
||||
version[nread - 1] != '\n') |
||||
{ |
||||
*reason_p = malloc(100 + strlen(full_path)); |
||||
sprintf(*reason_p, "File '%s' does not have a valid format " |
||||
"for a PG_VERSION file.", full_path); |
||||
} |
||||
else |
||||
{ |
||||
version[nread] = '\0'; |
||||
if (strcmp(version, myversion) != 0) |
||||
{ |
||||
*reason_p = malloc(200 + strlen(full_path)); |
||||
sprintf(*reason_p, |
||||
"Version number in file '%s' should be %s, " |
||||
"not %s.", |
||||
full_path, myversion, version); |
||||
} |
||||
else |
||||
*reason_p = NULL; |
||||
} |
||||
close(fd); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
void |
||||
SetPgVersion(const char *path, char **reason_p) |
||||
{ |
||||
/*---------------------------------------------------------------------------
|
||||
Create the PG_VERSION file in the directory <path>. |
||||
|
||||
If we fail, allocate storage, fill it with a text string explaining why, |
||||
and return a pointer to that storage as <*reason_p>. If we succeed, |
||||
return *reason_p = NULL. |
||||
---------------------------------------------------------------------------*/ |
||||
int fd; |
||||
char version[32]; |
||||
char full_path[MAXPGPATH]; |
||||
|
||||
PathSetVersionFilePath(path, full_path); |
||||
|
||||
sprintf(version, "%s.%s\n", PG_RELEASE, PG_VERSION); |
||||
|
||||
fd = open(full_path, O_WRONLY | O_CREAT | O_EXCL | PG_BINARY, 0666); |
||||
if (fd < 0) |
||||
{ |
||||
*reason_p = malloc(100 + strlen(full_path)); |
||||
sprintf(*reason_p, |
||||
"Unable to create file '%s', errno from open(): %s (%d).", |
||||
full_path, strerror(errno), errno); |
||||
} |
||||
else |
||||
{ |
||||
int rc; /* return code from some function we call */ |
||||
|
||||
rc = write(fd, version, strlen(version)); |
||||
if (rc != strlen(version)) |
||||
{ |
||||
*reason_p = malloc(100 + strlen(full_path)); |
||||
sprintf(*reason_p, |
||||
"Failed to write to file '%s', after it was already " |
||||
"open. Errno from write(): %s (%d)", |
||||
full_path, strerror(errno), errno); |
||||
} |
||||
else |
||||
*reason_p = NULL; |
||||
close(fd); |
||||
} |
||||
} |
Loading…
Reference in new issue