Update to PostgreSQL 9.0.2

This commit is contained in:
Tom Lane 2010-12-28 19:13:08 -05:00
parent 6b84484ca5
commit 4753f3695e
11 changed files with 431 additions and 233 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
/postgresql-9.0.2.tar.bz2
/postgresql-9.0.2-US.pdf
/postgresql-8.4.6.tar.bz2
/postgresql-8.4.6-US.pdf

View File

@ -1,29 +1,21 @@
README.rpm-dist
-----------------------------------------------------------------------------
Version 8.4, for the PostgreSQL 8.4 RPM set.
Version 9.0, for the PostgreSQL 9.0 RPM set.
Devrim Gündüz <devrim@CommandPrompt.com>
-----------------------------------------------------------------------------
Contents:
0.) Quick note about '-i'
1.) Introduction and QuickStart
2.) PostgreSQL RPM packages and rationale
3.) Starting multiple postmasters
4.) Regression Testing
5.) Starting postmaster automatically on startup
6.) Grand Unified Configuration(GUC) File
7.) Logging set up
8.) Rebuilding from the source RPM
9.) Contrib files
10.) Further Information Resource
QUICK NOTE ABOUT '-i'
-----------------------------------------------------------------------------
The postmaster '-i' option is NOT used by default in the initscript shipped
with these RPMs. Please do NOT modify the initscript to add the '-i' back
in -- it will get overwritten on the next package upgrade. Rather, see the
section below on the Grand Unified Configuration file, which includes the
recommended way to get '-i' functionality.
2.) Upgrading an installation
3.) PostgreSQL RPM packages and rationale
4.) Starting multiple postmasters
5.) Regression Testing
6.) Starting postmaster automatically on startup
7.) Grand Unified Configuration(GUC) File
8.) Logging set up
9.) Rebuilding from the source RPM
10.) Contrib files
11.) Further Information Resource
INTRODUCTION
-----------------------------------------------------------------------------
@ -31,27 +23,14 @@ This document exists to explain the layout of the RPMs for PostgreSQL, to
describe various RPM specifics, and to document special features found
in the RPMset.
This document is written to be applicable to version 8.4 of PostgreSQL,
This document is written to be applicable to version 9.0 of PostgreSQL,
which is the current version of the RPMs as of this writing. More to the
point, versions prior to 8.4 are not documented here.
point, versions prior to 9.0 are not documented here.
Official PostgreSQL Global Development Group RPMs carry a 'PGDG after the
release number. Other RPMsets as distributed with Linux distributions may
have a different release number and initials.
If you want to stay up-to-date on the PostgreSQL core itself, you may
want to use PGDG set, instead of the binaries supplied by distribution.
These RPMs do not support any sort of major version upgrading process
other than that documented in the regular documentation. That is, you
must dump, upgrade,initdb, and restore your data if you are
performing a major version update. This is not needed for minor version
updates.
For major version upgrade, dump first, then remove the old server
subpackage, install the new package, and restore the data from dump.
This document is intended for use only with Red Hat, CentOS and Fedora.
This document is intended for use only with the RPMs supplied in Red Hat
Enterprise Linux, CentOS and Fedora. Note that there are also "PGDG"
RPMs available directly from the upstream PostgreSQL project. Those are
slightly different.
QUICKSTART
-----------------------------------------------------------------------------
@ -78,9 +57,43 @@ upgrading.
The user 'postgres' is created during installation of the server subpackage.
This user by default is UID and GID 26. The user has the default shell set to
bash, and the home directory set to /var/lib/pgsql. This user also has no
default password -- in order to be able to su to it from a non-root account
default password. If you want to be able to su to it from a non-root account
or login as 'postgres' you will need to set a password using passwd.
UPGRADING AN INSTALLATION
-----------------------------------------------------------------------------
For a minor-version upgrade (such as 9.0.1 to 9.0.2), just install the
new RPMs; there's usually nothing more to it than that. Upgrading
across a major release of PostgreSQL (for example, from 8.3.x to 8.4.x)
requires more effort.
If you are upgrading across more than one major release of PostgreSQL
(for example, from 8.3.x to 9.0.x), you will need to follow the "traditional"
dump and reload process to bring your data into the new version. That is:
*before* upgrading, run pg_dumpall to extract all your data into a SQL file.
Shut down the old postmaster, upgrade to the new version RPMs, initdb,
and run the dump file through psql to restore your data.
In some major releases, the RPMs also support in-place upgrade from the
immediately previous major release. Currently, you can upgrade in-place
from 8.4.x to 9.0.x. This is much faster than a dump and reload.
To do an in-place upgrade:
* shut down the old postmaster
* optionally make a backup of /var/lib/pgsql/data/
* install the new version's RPMs (install all the ones you had before,
plus postgresql-upgrade)
* as root, run "service postgresql upgrade"
* update the configuration files /var/lib/pgsql/data/*.conf with any
customizations you had before (your old configuration files are in
/var/lib/pgsql/data-old/)
* as root, run "service postgresql start"
* postgresql-upgrade can be removed after the update is complete
NOTE: The in-place upgrade process is new and relatively poorly tested,
so if your data is critical it's a really good idea to make a tarball
backup of /var/lib/pgsql/data/ before running the upgrade. This will
let you get back to where you were in case of disaster.
POSTGRESQL RPM PACKAGES AND RATIONALE.
-----------------------------------------------------------------------------
PostgreSQL is split up into multiple packages so that users can 'pick and
@ -88,13 +101,12 @@ choose' what pieces are needed, and what dependencies are required.
The RPMset is packaged in the following subpackages:
postgresql: Key clients and libraries, and documentation
postgresql: Key client programs and documentation
postgresql-libs: Client shared libraries
postgresql-server: Server executables and data files
postgresql-devel: Development libraries and include files
postgresql-python: The PyGreSQL client library
postgresql-tcl: Tcl client library (Pgtcl)
postgresql-test: The regression tests and associated files
postgresql-upgrade: Support files for upgrading from previous major version
postgresql-docs: Extra documentation, such as the tutorial files
postgresql-contrib: The contrib source tree, as well as selected binaries
postgresql-plperl: PL/Perl procedural language
@ -105,14 +117,10 @@ You have to install postgresql and postgresql-libs to do anything.
postgresql-server is needed unless you only plan to use the clients to work
with a remote PostgreSQL server. The others are optional.
Note that there is no postgresql-perl, postgresql-jdbc, postgresql-odbc, or
postgresql-tk package any longer. This is due to these portions being split
into separate source distributions.
While PyGreSQL was split out from the core PostgreSQL distribution, thanks to
Kaj's work it is still included as the python subpackage. Also, Pgtcl is
still included as the tcl subpackage, although it is not part of the core
distribution anymore.
Note that there are no postgresql-perl, postgresql-jdbc, postgresql-odbc,
postgresql-python, postgresql-tcl, or postgresql-tk subpackages any longer.
Those programs have been split off into separate source distributions.
They are still available, but in some cases not under those RPM names.
RPM FILE LOCATIONS.
-----------------------------------------------------------------------------
@ -142,7 +150,6 @@ Development Headers: /usr/include/pgsql
Other shared data: /usr/share/pgsql
Regression tests: /usr/lib/pgsql/test/regress (in the -test package)
or /usr/lib64/pgsql/test/regress
Documentation SGML: /usr/share/doc/postgresql-docs-x.y.z/sgml
While it may seem gratuitous to place these files in different locations, the
FHS requires it -- distributions should not ever touch /usr/local. It may
@ -171,15 +178,10 @@ As an example, let us create a secondary postmaster called, creatively enough,
here. Since $PGDATA/postgresql.conf will override many of these
settings, except PGDATA, you might be surprised on startup.
3.) create the target PGDATA.
4.) Initdb the targe PGDATA as documented in the main documentation.
Automatic initdb may or may not work for you, so a manual one is
preferred. This must be done as user 'postgres'
4.) Initdb the target PGDATA with 'service secondary initdb'.
5.) Edit postgresql.conf to change the port, address, tcpip settings, etc.
6.) Start the postmaster with 'service secondary start'.
Note that there may be problems with the standard symlink -- consider this
support experimental at this point in time.
REGRESSION TESTING
-------------------------------------------------------------------------------
If you install the postgresql-test RPM then you can run the PostgreSQL
@ -188,9 +190,8 @@ results that give you assurances that the installation is complete, and that
your database machine is up to the task.
To run the regression tests under the RPM installation, make sure that
postmaster has been started (if not, su to root and execute the
"/etc/rc.d/init.d/postgresql start" init script), cd to
/usr/lib/pgsql/test/regress (or /usr/lib64/pgsql/test/regress),
postmaster has been started (if not, su to root and do "service postgresql
start"), cd to /usr/lib/pgsql/test/regress (or /usr/lib64/pgsql/test/regress),
su to postgres, and execute "make check".
This command will start the regression tests and will both show the
results to the screen and store the results in the file regress.out.
@ -208,8 +209,8 @@ STARTING POSTMASTER AUTOMATICALLY AT SYSTEM STARTUP
-------------------------------------------------------------------------------
Fedora / Red Hat / CentOS use the System V Init package. A startup
script for PostgreSQL is provided in the server package, as
/etc/rc.d/init.d/postgresql. To start the postmaster, with sanity
checking, as root, run
/etc/rc.d/init.d/postgresql. To start the postmaster manually,
as root run
service postgresql start
To shut the postmaster down,
service postgresql stop
@ -281,7 +282,7 @@ uuid 1 #build contrib/uuid-ossp
To use these defines, invoke a rebuild like this:
rpmbuild --rebuild --define 'python 0' --define 'tcl 0' \
--define 'test 0' --define 'runselftest 0' --define 'kerberos 0' \
postgresql-8.4.0-1.src.rpm
postgresql-9.0.2-1.src.rpm
This line would disable the python, tcl, and test subpackages, disable the
regression test run during build, and disable kerberos support.

View File

@ -1,20 +0,0 @@
Upstream has a policy of only supporting one autoconf version with any
given PostgreSQL version; which is good for ensuring repeatable results
for PostgreSQL, but it's not very tenable in the Fedora/RHEL world.
Dike out the check.
diff -Naur postgresql-8.4.6.orig/configure.in postgresql-8.4.6/configure.in
--- postgresql-8.4.6.orig/configure.in 2009-09-03 20:36:50.000000000 -0400
+++ postgresql-8.4.6/configure.in 2009-09-04 13:03:07.000000000 -0400
@@ -19,10 +19,6 @@
AC_INIT([PostgreSQL], [8.4.6], [pgsql-bugs@postgresql.org])
-m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.61], [], [m4_fatal([Autoconf version 2.61 is required.
-Untested combinations of 'autoconf' and PostgreSQL versions are not
-recommended. You can remove the check from 'configure.in' but it is then
-your responsibility whether the result works or not.])])
AC_COPYRIGHT([Copyright (c) 1996-2009, PostgreSQL Global Development Group])
AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
AC_CONFIG_AUX_DIR(config)

View File

@ -1,10 +1,10 @@
Select stderr-based logging with a week's worth of daily logfiles.
Default to stderr-based logging with a week's worth of daily logfiles.
diff -Naur postgresql-8.4.0.orig/src/backend/utils/misc/postgresql.conf.sample postgresql-8.4.0/src/backend/utils/misc/postgresql.conf.sample
--- postgresql-8.4.0.orig/src/backend/utils/misc/postgresql.conf.sample 2009-04-22 20:23:45.000000000 -0400
+++ postgresql-8.4.0/src/backend/utils/misc/postgresql.conf.sample 2009-08-12 23:20:46.000000000 -0400
@@ -236,17 +236,17 @@
diff -Naur postgresql-9.0.1.orig/src/backend/utils/misc/postgresql.conf.sample postgresql-9.0.1/src/backend/utils/misc/postgresql.conf.sample
--- postgresql-9.0.1.orig/src/backend/utils/misc/postgresql.conf.sample 2010-10-01 10:25:44.000000000 -0400
+++ postgresql-9.0.1/src/backend/utils/misc/postgresql.conf.sample 2010-10-11 11:53:34.650971490 -0400
@@ -262,17 +262,17 @@
# requires logging_collector to be on.
# This is used when logging to stderr:
@ -26,7 +26,7 @@ diff -Naur postgresql-8.4.0.orig/src/backend/utils/misc/postgresql.conf.sample p
# same name as the new log file will be
# truncated rather than appended to.
# But such truncation only occurs on
@@ -254,9 +254,9 @@
@@ -280,9 +280,9 @@
# or size-driven rotation. Default is
# off, meaning append to existing files
# in all cases.

View File

@ -1,57 +0,0 @@
Back-ported patch from Postgres devel head: reset oom_adj to zero in any
postmaster child process. This allows us to disable OOM kill on the postmaster
(see the init script) without affecting OOM behavior for child processes.
diff -Naur postgresql-8.4.2.orig/src/backend/postmaster/fork_process.c postgresql-8.4.2/src/backend/postmaster/fork_process.c
--- postgresql-8.4.2.orig/src/backend/postmaster/fork_process.c 2009-01-01 12:23:46.000000000 -0500
+++ postgresql-8.4.2/src/backend/postmaster/fork_process.c 2010-01-11 12:28:17.000000000 -0500
@@ -12,7 +12,9 @@
#include "postgres.h"
#include "postmaster/fork_process.h"
+#include <fcntl.h>
#include <time.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
@@ -60,6 +62,38 @@
setitimer(ITIMER_PROF, &prof_itimer, NULL);
#endif
+ /*
+ * By default, Linux tends to kill the postmaster in out-of-memory
+ * situations, because it blames the postmaster for the sum of child
+ * process sizes *including shared memory*. (This is unbelievably
+ * stupid, but the kernel hackers seem uninterested in improving it.)
+ * Therefore it's often a good idea to protect the postmaster by
+ * setting its oom_adj value negative (which has to be done in a
+ * root-owned startup script). If you just do that much, all child
+ * processes will also be protected against OOM kill, which might not
+ * be desirable. You can then choose to build with LINUX_OOM_ADJ
+ * #defined to 0, or some other value that you want child processes
+ * to adopt here.
+ */
+#ifdef LINUX_OOM_ADJ
+ {
+ /*
+ * Use open() not stdio, to ensure we control the open flags.
+ * Some Linux security environments reject anything but O_WRONLY.
+ */
+ int fd = open("/proc/self/oom_adj", O_WRONLY, 0);
+
+ /* We ignore all errors */
+ if (fd >= 0)
+ {
+ char buf[16];
+
+ snprintf(buf, sizeof(buf), "%d\n", LINUX_OOM_ADJ);
+ (void) write(fd, buf, strlen(buf));
+ close(fd);
+ }
+ }
+#endif /* LINUX_OOM_ADJ */
}
return result;

View File

@ -7,10 +7,10 @@ So work around it by adding an rpath spec to plperl.so (only).
Per bug #162198.
diff -Naur postgresql-8.4.4.orig/src/pl/plperl/GNUmakefile postgresql-8.4.4/src/pl/plperl/GNUmakefile
--- postgresql-8.4.4.orig/src/pl/plperl/GNUmakefile 2010-05-13 12:40:36.000000000 -0400
+++ postgresql-8.4.4/src/pl/plperl/GNUmakefile 2010-05-14 11:50:27.000000000 -0400
@@ -38,6 +38,9 @@
diff -Naur postgresql-9.0.1.orig/src/pl/plperl/GNUmakefile postgresql-9.0.1/src/pl/plperl/GNUmakefile
--- postgresql-9.0.1.orig/src/pl/plperl/GNUmakefile 2010-10-01 10:25:44.000000000 -0400
+++ postgresql-9.0.1/src/pl/plperl/GNUmakefile 2010-10-11 11:50:19.933972244 -0400
@@ -40,6 +40,9 @@
SHLIB_LINK = $(perl_embed_ldflags)
@ -18,5 +18,5 @@ diff -Naur postgresql-8.4.4.orig/src/pl/plperl/GNUmakefile postgresql-8.4.4/src/
+SHLIB_LINK += $(rpath)
+
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl --load-language=plperlu
REGRESS = plperl plperl_trigger plperl_shared plperl_elog
REGRESS = plperl plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu
# if Perl can support two interpreters in one backend,

View File

@ -0,0 +1,72 @@
Patch pg_upgrade to not insist on useless baggage in the upgrade RPM,
as well as being more careful to check for things it does need.
diff -Naur postgresql-9.0.2.orig/contrib/pg_upgrade/exec.c postgresql-9.0.2/contrib/pg_upgrade/exec.c
--- postgresql-9.0.2.orig/contrib/pg_upgrade/exec.c 2010-12-13 21:55:50.000000000 -0500
+++ postgresql-9.0.2/contrib/pg_upgrade/exec.c 2010-12-28 16:56:05.734506648 -0500
@@ -14,7 +14,7 @@
static void check_data_dir(migratorContext *ctx, const char *pg_data);
-static void check_bin_dir(migratorContext *ctx, ClusterInfo *cluster);
+static void check_bin_dir(migratorContext *ctx, ClusterInfo *cluster, Cluster whichCluster);
static int check_exec(migratorContext *ctx, const char *dir, const char *cmdName);
static const char *validate_exec(const char *path);
@@ -99,7 +99,7 @@
check_ok(ctx);
prep_status(ctx, "Checking old bin directory (%s)", ctx->old.bindir);
- check_bin_dir(ctx, &ctx->old);
+ check_bin_dir(ctx, &ctx->old, CLUSTER_OLD);
check_ok(ctx);
prep_status(ctx, "Checking new data directory (%s)", ctx->new.pgdata);
@@ -107,7 +107,7 @@
check_ok(ctx);
prep_status(ctx, "Checking new bin directory (%s)", ctx->new.bindir);
- check_bin_dir(ctx, &ctx->new);
+ check_bin_dir(ctx, &ctx->new, CLUSTER_NEW);
check_ok(ctx);
}
@@ -158,12 +158,18 @@
* exit().
*/
static void
-check_bin_dir(migratorContext *ctx, ClusterInfo *cluster)
+check_bin_dir(migratorContext *ctx, ClusterInfo *cluster, Cluster whichCluster)
{
check_exec(ctx, cluster->bindir, "postgres");
- check_exec(ctx, cluster->bindir, "psql");
check_exec(ctx, cluster->bindir, "pg_ctl");
- check_exec(ctx, cluster->bindir, "pg_dumpall");
+ check_exec(ctx, cluster->bindir, "pg_resetxlog");
+ if (whichCluster == CLUSTER_NEW)
+ {
+ /* these are only needed in the new cluster */
+ check_exec(ctx, cluster->bindir, "pg_config");
+ check_exec(ctx, cluster->bindir, "psql");
+ check_exec(ctx, cluster->bindir, "pg_dumpall");
+ }
}
diff -Naur postgresql-9.0.2.orig/contrib/pg_upgrade/option.c postgresql-9.0.2/contrib/pg_upgrade/option.c
--- postgresql-9.0.2.orig/contrib/pg_upgrade/option.c 2010-12-13 21:55:50.000000000 -0500
+++ postgresql-9.0.2/contrib/pg_upgrade/option.c 2010-12-28 16:53:44.730531216 -0500
@@ -308,7 +308,11 @@
static void
get_pkglibdirs(migratorContext *ctx)
{
- ctx->old.libpath = get_pkglibdir(ctx, ctx->old.bindir);
+ /*
+ * we do not need to know the libpath in the old cluster, and might not
+ * have a working pg_config to ask for it anyway.
+ */
+ ctx->old.libpath = NULL;
ctx->new.libpath = get_pkglibdir(ctx, ctx->new.bindir);
}

View File

@ -11,11 +11,20 @@
# This script is slightly unusual in that the name of the daemon (postmaster)
# is not the same as the name of the subsystem (postgresql)
# PGVERSION is the full package version, e.g., 8.4.0
# PGVERSION is the full package version, e.g., 9.0.2
# Note: the specfile inserts the correct value during package build
PGVERSION=xxxx
# PGMAJORVERSION is major version, e.g., 8.4 (this should match PG_VERSION)
# PGMAJORVERSION is major version, e.g., 9.0 (this should match PG_VERSION)
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
# PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades
# Note: the specfile inserts the correct value during package build
PREVMAJORVERSION=xxxx
# PREVPGENGINE is the directory containing the previous postmaster executable
# Note: the specfile inserts the correct value during package build
PREVPGENGINE=xxxx
# PGDOCDIR is the directory containing the package's documentation
# Note: the specfile inserts the correct value during package build
PGDOCDIR=xxxx
# Source function library.
. /etc/rc.d/init.d/functions
@ -76,35 +85,27 @@ start(){
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
then
# Check version of existing PGDATA
if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
then
: A-OK
elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
then
SYSDOCDIR="(Your System's documentation directory)"
if [ -d "/usr/doc/postgresql-$PGVERSION" ]
then
SYSDOCDIR=/usr/doc
fi
if [ -d "/usr/share/doc/postgresql-$PGVERSION" ]
then
SYSDOCDIR=/usr/share/doc
fi
if [ -d "/usr/doc/packages/postgresql-$PGVERSION" ]
then
SYSDOCDIR=/usr/doc/packages
fi
if [ -d "/usr/share/doc/packages/postgresql-$PGVERSION" ]
then
SYSDOCDIR=/usr/share/doc/packages
fi
echo
echo $"An old version of the database format was found."
echo $"You need to upgrade the data format before using PostgreSQL."
echo $"See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
echo $"Use \"service postgresql upgrade\" to upgrade to version $PGMAJORVERSION."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
else
echo
echo $"An old version of the database format was found."
echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
fi
else
# No existing PGDATA! Warn the user to initdb it.
echo
echo "$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first."
echo $"$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first."
echo_failure
echo
exit 1
@ -163,18 +164,11 @@ reload(){
$SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
}
initdb(){
if [ -f "$PGDATA/PG_VERSION" ]
then
echo -n "Data directory is not empty!"
echo_failure
echo
script_result=1
else
echo -n $"Initializing database: "
# code shared between initdb and upgrade actions
perform_initdb(){
if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
then
mkdir -p "$PGDATA" || exit 1
mkdir -p "$PGDATA" || return 1
chown postgres:postgres "$PGDATA"
chmod go-rwx "$PGDATA"
fi
@ -184,7 +178,7 @@ initdb(){
# Make sure the startup-time log file is OK, too
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
then
touch "$PGLOG" || exit 1
touch "$PGLOG" || return 1
chown postgres:postgres "$PGLOG"
chmod go-rwx "$PGLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
@ -199,6 +193,22 @@ initdb(){
chmod go-rwx "$PGDATA/pg_log"
if [ -f "$PGDATA/PG_VERSION" ]
then
return 0
fi
return 1
}
initdb(){
if [ -f "$PGDATA/PG_VERSION" ]
then
echo -n $"Data directory is not empty!"
echo_failure
echo
script_result=1
else
echo -n $"Initializing database: "
if perform_initdb
then
echo_success
else
@ -209,6 +219,79 @@ initdb(){
fi
}
upgrade(){
# must see previous version in PG_VERSION
if [ ! -f "$PGDATA/PG_VERSION" -o \
x`cat "$PGDATA/PG_VERSION"` != x"$PREVMAJORVERSION" ]
then
echo
echo $"Cannot upgrade because database is not of version $PREVMAJORVERSION."
echo_failure
echo
exit 1
fi
if [ ! -x "$PGENGINE/pg_upgrade" ]
then
echo
echo $"Please install the postgresql-upgrade RPM."
echo_failure
echo
exit 5
fi
# Make sure service is stopped
stop
echo -n $"Upgrading database: "
# Set up log file for pg_upgrade
PGUPLOG=/var/lib/pgsql/pgupgrade.log
rm -f "$PGUPLOG"
touch "$PGUPLOG" || exit 1
chown postgres:postgres "$PGUPLOG"
chmod go-rwx "$PGUPLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGUPLOG"
# Move old DB to PGDATAOLD
PGDATAOLD="${PGDATA}-old"
rm -rf "$PGDATAOLD"
mv "$PGDATA" "$PGDATAOLD" || exit 1
# Create empty new-format database
if perform_initdb
then
# Do the upgrade
$SU -l postgres -c "$PGENGINE/pg_upgrade \
'--old-bindir=$PREVPGENGINE' \
'--new-bindir=$PGENGINE' \
'--old-datadir=$PGDATAOLD' \
'--new-datadir=$PGDATA' \
--link \
'--old-port=$PGPORT' '--new-port=$PGPORT' \
--user=postgres" >> "$PGUPLOG" 2>&1 < /dev/null
if [ $? -ne 0 ]
then
# pg_upgrade failed
script_result=1
fi
else
# initdb failed
script_result=1
fi
if [ $script_result -eq 0 ]
then
echo_success
else
# Clean up after failure
rm -rf "$PGDATA"
mv "$PGDATAOLD" "$PGDATA"
echo_failure
fi
echo
echo $"See $PGUPLOG for details."
}
# See how we were called.
case "$1" in
start)
@ -236,8 +319,11 @@ case "$1" in
initdb)
initdb
;;
upgrade)
upgrade
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|initdb}"
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|initdb|upgrade}"
exit 2
esac

194
postgresql.spec Executable file → Normal file
View File

@ -34,6 +34,7 @@
%{!?tcldevel:%global tcldevel 1}
%{!?test:%global test 1}
%{!?upgrade:%global upgrade 1}
%{!?plpython:%global plpython 1}
%{!?pltcl:%global pltcl 1}
%{!?plperl:%global plperl 1}
@ -51,37 +52,43 @@
Summary: PostgreSQL client programs
Name: postgresql
%global majorversion 8.4
Version: 8.4.6
%global majorversion 9.0
Version: 9.0.2
Release: 1%{?dist}
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
# recognizes it as an independent license, so we do as well.
License: PostgreSQL
Group: Applications/Databases
Url: http://www.postgresql.org/
Url: http://www.postgresql.org/
# This SRPM includes a copy of the previous major release, which is needed for
# in-place upgrade of an old database. In most cases it will not be critical
# that this be kept up with the latest minor release of the previous series.
%global prevversion 8.4.6
%global prevmajorversion 8.4
Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
# The PDF file is generated by generate-pdf.sh, which see for comments
Source1: postgresql-%{version}-US.pdf
# generate-pdf.sh is not used during RPM build, but include for documentation
Source2: generate-pdf.sh
Source3: postgresql.init
Source4: Makefile.regress
Source5: pg_config.h
Source6: README.rpm-dist
Source3: ftp://ftp.postgresql.org/pub/source/v%{prevversion}/postgresql-%{prevversion}.tar.bz2
Source4: postgresql.init
Source5: Makefile.regress
Source6: pg_config.h
Source7: ecpg_config.h
Source8: README.rpm-dist
Source14: postgresql.pam
Source15: postgresql-bashprofile
Source16: filter-requires-perl-Pg.sh
# Comments for these patches are in the patch files.
Patch1: rpm-pgsql.patch
Patch2: postgresql-ac-version.patch
Patch3: postgresql-logging.patch
Patch4: postgresql-oom-adj.patch
Patch6: postgresql-perl-rpath.patch
Patch2: postgresql-logging.patch
Patch3: postgresql-perl-rpath.patch
Patch4: postgresql-upgrade-fixes.patch
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex autoconf gawk
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
BuildRequires: perl(ExtUtils::Embed), perl-devel
# for /sbin/ldconfig
Requires(post): glibc initscripts
@ -134,14 +141,14 @@ BuildRequires: systemtap-sdt-devel
%endif
# main package requires -libs subpackage
Requires: postgresql-libs = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
PostgreSQL is an advanced Object-Relational database management system
(DBMS) that supports almost all SQL constructs (including
transactions, subselects and user-defined types and functions). The
transactions, sub-selects and user-defined types and functions). The
postgresql package includes the client programs and libraries that
you'll need to access a PostgreSQL DBMS server. These PostgreSQL
client programs are programs that directly manipulate the internal
@ -171,6 +178,7 @@ PostgreSQL server.
Summary: The programs needed to create and run a PostgreSQL server
Group: Applications/Databases
Requires: %{name} = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
Requires(pre): /usr/sbin/useradd
Requires(post): chkconfig
Requires(preun): chkconfig
@ -183,7 +191,7 @@ The postgresql-server package includes the programs needed to create
and run a PostgreSQL server, which will in turn allow you to create
and maintain PostgreSQL databases. PostgreSQL is an advanced
Object-Relational database management system (DBMS) that supports
almost all SQL constructs (including transactions, subselects and
almost all SQL constructs (including transactions, sub-selects and
user-defined types and functions). You should install
postgresql-server if you want to create and maintain your own
PostgreSQL databases and/or your own PostgreSQL server. You also need
@ -193,7 +201,7 @@ to install the postgresql package.
%package docs
Summary: Extra documentation for PostgreSQL
Group: Applications/Databases
Requires: postgresql = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
%description docs
The postgresql-docs package includes some additional documentation for
@ -204,7 +212,8 @@ and source files for the PostgreSQL tutorial.
%package contrib
Summary: Contributed modules distributed with PostgreSQL
Group: Applications/Databases
Requires: postgresql = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
%description contrib
The postgresql-contrib package contains contributed packages that are
@ -214,7 +223,8 @@ included in the PostgreSQL distribution.
%package devel
Summary: PostgreSQL development header files and libraries
Group: Development/Libraries
Requires: postgresql = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
%description devel
The postgresql-devel package contains the header files and libraries
@ -223,11 +233,27 @@ with a PostgreSQL database management server and the ecpg Embedded C
Postgres preprocessor. You need to install this package if you want to
develop applications which will interact with a PostgreSQL server.
%if %upgrade
%package upgrade
Summary: Support for upgrading from the previous major release of PostgreSQL
Group: Applications/Databases
Requires: %{name}-server = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
%description upgrade
PostgreSQL is an advanced Object-Relational database management
system. The postgresql-upgrade package includes the pg_upgrade utility
and supporting files needed for upgrading a database from the previous
major version of PostgreSQL.
%endif
%if %plperl
%package plperl
Summary: The Perl procedural language for PostgreSQL
Group: Applications/Databases
Requires: postgresql-server = %{version}-%{release}
Requires: %{name}-server = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
%description plperl
@ -240,7 +266,7 @@ procedural language for the backend.
%package plpython
Summary: The Python procedural language for PostgreSQL
Group: Applications/Databases
Requires: postgresql-server = %{version}-%{release}
Requires: %{name}-server = %{version}-%{release}
%description plpython
PostgreSQL is an advanced Object-Relational database management
@ -252,7 +278,7 @@ procedural language for the backend.
%package pltcl
Summary: The Tcl procedural language for PostgreSQL
Group: Applications/Databases
Requires: postgresql-server = %{version}-%{release}
Requires: %{name}-server = %{version}-%{release}
%description pltcl
PostgreSQL is an advanced Object-Relational database management
@ -264,7 +290,7 @@ procedural language for the backend.
%package test
Summary: The test suite distributed with PostgreSQL
Group: Applications/Databases
Requires: postgresql-server = %{version}-%{release}
Requires: %{name}-server = %{version}-%{release}
%description test
PostgreSQL is an advanced Object-Relational database management
@ -281,12 +307,16 @@ system, including regression tests and benchmarks.
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch6 -p1
autoconf
# We used to run autoconf here, but there's no longer any real need to,
# since Postgres ships with a reasonably modern configure script.
cp -p %{SOURCE1} .
%if %upgrade
tar xfj %{SOURCE3}
%endif
# remove .gitignore files to ensure none get into the RPMs (bug #642210)
find . -type f -name .gitignore | xargs rm
@ -310,9 +340,9 @@ CFLAGS=`echo $CFLAGS|xargs -n 1|grep -v ffast-math|xargs -n 100`
CFLAGS="$CFLAGS -DLINUX_OOM_ADJ=0"
# let's try removing this kluge, it may just be a workaround for bz#520916
# # use -O1 on sparc64 and alpha
# %ifarch sparc64 alpha
# %%ifarch sparc64 alpha
# CFLAGS=`echo $CFLAGS| sed -e "s|-O2|-O1|g" `
# %endif
# %%endif
%configure --disable-rpath \
%if %beta
@ -362,8 +392,7 @@ CFLAGS="$CFLAGS -DLINUX_OOM_ADJ=0"
--sysconfdir=/etc/sysconfig/pgsql \
--datadir=/usr/share/pgsql
make %{?_smp_mflags} all
make %{?_smp_mflags} -C contrib all
make %{?_smp_mflags} world
# Have to hack makefile to put correct path into tutorial scripts
sed "s|C=\`pwd\`;|C=%{_libdir}/pgsql/tutorial;|" < src/tutorial/Makefile > src/tutorial/GNUmakefile
@ -384,20 +413,36 @@ rm -f src/tutorial/GNUmakefile
popd
%endif
%if %upgrade
pushd postgresql-%{prevversion}
# The upgrade build can be pretty stripped-down, but make sure that
# any options that affect on-disk file layout match the previous
# major release! Also, note we intentionally do not use %%configure
# here, because we *don't* want its ideas about installation paths.
./configure --build=%{_build} --host=%{_host} \
--prefix=%{_libdir}/pgsql/postgresql-%{prevmajorversion} \
--disable-rpath \
--with-system-tzdata=/usr/share/zoneinfo
make %{?_smp_mflags} all
popd
%endif
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
make -C contrib DESTDIR=$RPM_BUILD_ROOT install
make DESTDIR=$RPM_BUILD_ROOT install-world
# multilib header hack; note pg_config.h is installed in two places!
# we only apply this to known Red Hat multilib arches, per bug #177564
case `uname -i` in
i386 | x86_64 | ppc | ppc64 | s390 | s390x | sparc | sparc64 )
mv $RPM_BUILD_ROOT/usr/include/pg_config.h $RPM_BUILD_ROOT/usr/include/pg_config_`uname -i`.h
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/include/
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/usr/include/
mv $RPM_BUILD_ROOT/usr/include/pgsql/server/pg_config.h $RPM_BUILD_ROOT/usr/include/pgsql/server/pg_config_`uname -i`.h
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/include/pgsql/server/
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/usr/include/pgsql/server/
mv $RPM_BUILD_ROOT/usr/include/ecpg_config.h $RPM_BUILD_ROOT/usr/include/ecpg_config_`uname -i`.h
install -m 644 %{SOURCE7} $RPM_BUILD_ROOT/usr/include/
;;
@ -408,8 +453,13 @@ esac
install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
cp src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
# prep the initscript, including insertion of some values it needs
install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
sed 's/^PGVERSION=.*$/PGVERSION=%{version}/' <%{SOURCE3} >postgresql.init
sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
-e 's|^PREVPGENGINE=.*$|PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin|' \
-e 's|^PGDOCDIR=.*$|PGDOCDIR=%{_docdir}/%{name}-%{version}|' \
<%{SOURCE4} >postgresql.init
install -m 755 postgresql.init $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
%if %pam
@ -430,6 +480,49 @@ install -m 644 %{SOURCE15} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile
install -d -m 700 $RPM_BUILD_ROOT/etc/sysconfig/pgsql
%if %upgrade
pushd postgresql-%{prevversion}
make DESTDIR=$RPM_BUILD_ROOT install
popd
# remove stuff we don't actually need for upgrade purposes
pushd $RPM_BUILD_ROOT%{_libdir}/pgsql/postgresql-%{prevmajorversion}
rm bin/clusterdb
rm bin/createdb
rm bin/createlang
rm bin/createuser
rm bin/dropdb
rm bin/droplang
rm bin/dropuser
rm bin/ecpg
rm bin/initdb
rm bin/pg_config
rm bin/pg_controldata
rm bin/pg_dump
rm bin/pg_dumpall
rm bin/pg_restore
rm bin/psql
rm bin/reindexdb
rm bin/vacuumdb
rm -rf include
rm lib/dict_snowball.so
rm lib/libecpg*
rm lib/libpg*
rm lib/libpq*
rm -rf lib/pgxs
rm lib/plpgsql.so
rm -rf share/doc
rm -rf share/man
rm -rf share/tsearch_data
rm share/*.bki
rm share/*description
rm share/*.sample
rm share/*.sql
rm share/*.txt
popd
%endif
%if %test
# tests. There are many files included here that are unnecessary,
# but include them anyway for completeness. We replace the original
@ -440,13 +533,13 @@ install -d -m 700 $RPM_BUILD_ROOT/etc/sysconfig/pgsql
strip *.so
rm -f GNUmakefile Makefile *.o
popd
cp %{SOURCE4} $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
cp %{SOURCE5} $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
chmod 0644 $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
%endif
# Fix some more documentation
# gzip doc/internals.ps
cp %{SOURCE6} README.rpm-dist
cp %{SOURCE8} README.rpm-dist
mv $RPM_BUILD_ROOT%{_docdir}/pgsql/html doc
rm -rf $RPM_BUILD_ROOT%{_docdir}/pgsql
@ -461,14 +554,14 @@ cat ecpglib6-%{majorversion}.lang >libs.lst
cat initdb-%{majorversion}.lang >server.lst
%find_lang libpq5-%{majorversion}
cat libpq5-%{majorversion}.lang >>libs.lst
%find_lang pg_config-%{majorversion}
cat pg_config-%{majorversion}.lang >>devel.lst
%find_lang pg_controldata-%{majorversion}
cat pg_controldata-%{majorversion}.lang >>server.lst
%find_lang pg_ctl-%{majorversion}
cat pg_ctl-%{majorversion}.lang >>server.lst
%find_lang pg_config-%{majorversion}
cat pg_config-%{majorversion}.lang >main.lst
%find_lang pg_dump-%{majorversion}
cat pg_dump-%{majorversion}.lang >main.lst
cat pg_dump-%{majorversion}.lang >>main.lst
%find_lang pg_resetxlog-%{majorversion}
cat pg_resetxlog-%{majorversion}.lang >>server.lst
%find_lang pgscripts-%{majorversion}
@ -549,6 +642,7 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/dropdb
%{_bindir}/droplang
%{_bindir}/dropuser
%{_bindir}/pg_config
%{_bindir}/pg_dump
%{_bindir}/pg_dumpall
%{_bindir}/pg_restore
@ -562,6 +656,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/dropdb.*
%{_mandir}/man1/droplang.*
%{_mandir}/man1/dropuser.*
%{_mandir}/man1/pg_config.*
%{_mandir}/man1/pg_dump.*
%{_mandir}/man1/pg_dumpall.*
%{_mandir}/man1/pg_restore.*
@ -599,6 +694,7 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/pgsql/ltree.so
%{_libdir}/pgsql/moddatetime.so
%{_libdir}/pgsql/pageinspect.so
%{_libdir}/pgsql/passwordcheck.so
%{_libdir}/pgsql/pg_buffercache.so
%{_libdir}/pgsql/pg_freespacemap.so
%{_libdir}/pgsql/pg_trgm.so
@ -613,6 +709,7 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/pgsql/test_parser.so
%{_libdir}/pgsql/timetravel.so
%{_libdir}/pgsql/tsearch2.so
%{_libdir}/pgsql/unaccent.so
%if %uuid
%{_libdir}/pgsql/uuid-ossp.so
%endif
@ -621,9 +718,11 @@ rm -rf $RPM_BUILD_ROOT
%endif
%{_datadir}/pgsql/contrib/
%{_bindir}/oid2name
%{_bindir}/pg_archivecleanup
%{_bindir}/pg_standby
%{_bindir}/pgbench
%{_bindir}/vacuumlo
%{_mandir}/man3/dblink*
%doc contrib/spi/*.example
%files libs -f libs.lst
@ -667,7 +766,9 @@ rm -rf $RPM_BUILD_ROOT
%attr(700,postgres,postgres) %dir /var/lib/pgsql/data
%attr(700,postgres,postgres) %dir /var/lib/pgsql/backups
%attr(644,postgres,postgres) %config(noreplace) /var/lib/pgsql/.bash_profile
%{_libdir}/pgsql/libpqwalreceiver.so
%{_libdir}/pgsql/*_and_*.so
%{_libdir}/pgsql/euc2004_sjis2004.so
%{_datadir}/pgsql/conversion_create.sql
%{_datadir}/pgsql/information_schema.sql
%{_datadir}/pgsql/snowball_create.sql
@ -677,14 +778,21 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root)
/usr/include/*
%{_bindir}/ecpg
%{_bindir}/pg_config
%{_libdir}/libpq.so
%{_libdir}/libecpg.so
%{_libdir}/libecpg_compat.so
%{_libdir}/libpgtypes.so
%{_libdir}/pgsql/pgxs/
%{_mandir}/man1/ecpg.*
%{_mandir}/man1/pg_config.*
%{_mandir}/man3/SPI_*
%if %upgrade
%files upgrade
%defattr(-,root,root)
%{_bindir}/pg_upgrade
%{_libdir}/pgsql/pg_upgrade_support.so
%{_libdir}/pgsql/postgresql-%{prevmajorversion}
%endif
%if %plperl
%files plperl -f plperl.lst
@ -706,6 +814,7 @@ rm -rf $RPM_BUILD_ROOT
%files plpython -f plpython.lst
%defattr(-,root,root)
%{_libdir}/pgsql/plpython.so
%{_libdir}/pgsql/plpython2.so
%endif
%if %test
@ -716,6 +825,11 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
* Tue Dec 28 2010 Tom Lane <tgl@redhat.com> 9.0.2-1
- Update to PostgreSQL 9.0.2 (major version bump)
- Create infrastructure for in-place database upgrade using pg_upgrade
Resolves: #398221
* Thu Dec 16 2010 Tom Lane <tgl@redhat.com> 8.4.6-1
- Update to PostgreSQL 8.4.6, for various fixes described at
http://www.postgresql.org/docs/8.4/static/release-8-4-6.html

View File

@ -8,10 +8,10 @@ However, datadir and sysconfdir are already set up in the specfile's
configure call, so we do not have to append anything to them.
diff -Naur postgresql-8.4.3.orig/src/Makefile.global.in postgresql-8.4.3/src/Makefile.global.in
--- postgresql-8.4.3.orig/src/Makefile.global.in 2009-06-22 23:46:00.000000000 -0400
+++ postgresql-8.4.3/src/Makefile.global.in 2010-03-13 22:18:12.000000000 -0500
@@ -54,8 +54,7 @@
diff -Naur postgresql-9.0.1.orig/src/Makefile.global.in postgresql-9.0.1/src/Makefile.global.in
--- postgresql-9.0.1.orig/src/Makefile.global.in 2010-10-01 10:25:44.000000000 -0400
+++ postgresql-9.0.1/src/Makefile.global.in 2010-10-11 11:52:05.224975308 -0400
@@ -55,8 +55,7 @@
# Installation directories
#
# These are set by the equivalent --xxxdir configure options. We
@ -21,7 +21,7 @@ diff -Naur postgresql-8.4.3.orig/src/Makefile.global.in postgresql-8.4.3/src/Mak
#
# In a PGXS build, we cannot use the values inserted into Makefile.global
# by configure, since the installation tree may have been relocated.
@@ -73,45 +72,23 @@
@@ -74,45 +73,23 @@
bindir := @bindir@
datadir := @datadir@

View File

@ -1,2 +1,3 @@
fc79ef32b602f75f2ccd37647bc008e9 postgresql-9.0.2.tar.bz2
7b72c6603a9567c356dedb7bfb658a36 postgresql-9.0.2-US.pdf
fcc3daaf2292fa6bf1185ec45e512db6 postgresql-8.4.6.tar.bz2
9c5e14846e614da71807d5a09a2232dc postgresql-8.4.6-US.pdf