Automatic import for version 9.2.1-1.1C

This commit is contained in:
Rosa 2013-10-01 00:21:23 +04:00
commit cc136d405a
20 changed files with 12748 additions and 0 deletions

2
.abf.yml Normal file
View file

@ -0,0 +1,2 @@
sources:
"postgresql-9.2.1.tar.bz2": cea9601b3acd1484fd98441b49a15ea1c42057ec

9116
1c_FULL_92-0.22 Executable file

File diff suppressed because it is too large Load diff

67
Makefile.regress Normal file
View file

@ -0,0 +1,67 @@
#
# Simplified makefile for running the PostgreSQL regression tests
# in an RPM installation
#
# maximum simultaneous connections for parallel tests
MAXCONNOPT =
ifdef MAX_CONNECTIONS
MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS)
endif
# locale
NOLOCALE =
ifdef NO_LOCALE
NOLOCALE += --no-locale
endif
srcdir := .
REGRESS_OPTS += --dlpath=.
pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
pg_regress_installcheck = ./pg_regress --inputdir=$(srcdir) --psqldir='/usr/bin' $(pg_regress_locale_flags)
# Test input and expected files. These are created by pg_regress itself, so we
# don't have a rule to create them. We do need rules to clean them however.
ifile_list := $(subst .source,, $(notdir $(wildcard $(srcdir)/input/*.source)))
input_files := $(foreach file, $(ifile_list), sql/$(file).sql)
ofile_list := $(subst .source,, $(notdir $(wildcard $(srcdir)/output/*.source)))
output_files := $(foreach file, $(ofile_list), expected/$(file).out)
abs_srcdir := $(shell pwd)
abs_builddir := $(shell pwd)
check: installcheck-parallel
installcheck: cleandirs
$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/serial_schedule $(EXTRA_TESTS)
installcheck-parallel: cleandirs
$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
# The tests command the server to write into testtablespace and results.
# On a SELinux-enabled system this will fail unless we mark those directories
# as writable by the server.
cleandirs:
-rm -rf testtablespace results
mkdir testtablespace results
[ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_db_t testtablespace results
# old interfaces follow...
runcheck: check
runtest: installcheck
runtest-parallel: installcheck-parallel
##
## Clean up
##
clean distclean maintainer-clean:
rm -f $(output_files) $(input_files)
rm -rf testtablespace
rm -rf results tmp_check log
rm -f regression.diffs regression.out regress.out run_check.out

322
README.rpm-dist Normal file
View file

@ -0,0 +1,322 @@
README.rpm-dist
-----------------------------------------------------------------------------
Version 9.2, for the PostgreSQL 9.2 RPM set.
Devrim Gündüz <devrim@gunduz.org>
-----------------------------------------------------------------------------
Contents:
1.) Introduction and QuickStart
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
-----------------------------------------------------------------------------
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 9.2 of PostgreSQL,
which is the current version of the RPMs as of this writing. More to the
point, versions prior to 9.2 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.
QUICKSTART
-----------------------------------------------------------------------------
For a fresh installation, you will need to initialize the cluster first. Run:
service postgresql-9.2 initdb
as root, and it will prepare a new database cluster for you. Then you will
need to start PostgreSQL. Again as root, run:
service postgresql-9.2 start
This command will start a postmaster that willl listen on localhost and Unix
socket 5432 only. Edit /var/lib/pgsql/9.2/data/postgresql.conf and pg_hba.conf
if you want to allow remote access -- see the section on Grand Unified
Configuration.
You will probably also want to do
chkconfig postgresql-9.2 on
so that the postmaster is automatically started during future reboots.
The file /var/lib/pgsql/9.2/.bash_profile is packaged to help with the
setting of environment variables. You may edit this file, and it won't be
overwritten during an upgrade. However, enhancements and bugfixes may
be added to this file, so be sure to check .bash_profile.rpmnew after
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. 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.2.1 to 9.2.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 9.0.x to 9.2.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 9.1.x to 9.2.x. This is much faster than a dump and reload.
To do an in-place upgrade, just run:
$ service postgresql-9.2 upgrade
Please note that 9.1 and 9.2 contrib RPMs needs to be installed for this
feature to work.
POSTGRESQL RPM PACKAGES AND RATIONALE.
-----------------------------------------------------------------------------
PostgreSQL is split up into multiple packages so that users can 'pick and
choose' what pieces are needed, and what dependencies are required.
The RPMset is packaged in the following subpackages:
postgresql92: Key clients and libraries, and documentation
postgresql92-server: Server executables and data files
postgresql92-devel: Development libraries and include files
postgresql92-test: The regression tests and associated files
postgresql92-libs: Client shared libraries
postgresql92-docs: Extra documentation, such as the tutorial files
postgresql92-contrib: The contrib source tree, as well as selected binaries
postgresql92-plperl: PL/Perl procedural language
postgresql92-plpython: PL/Python procedural language
postgresql92-pltcl: PL/Tcl procedural language
postgresql92-jdbc, postgresql92-python, postgresql92-tcl and postgresql92-odbc have
been splitted into seperate (s)rpms.
You have to install postgresql and postgresql92-libs to do anything.
postgresql92-server is needed unless you only plan to use the clients to work
with a remote PostgreSQL server. The others are optional.
postgresql92-python package includes PyGreSQL, and Pgtcl is distributed
via postgresql92-tcl package.
RPM FILE LOCATIONS.
-----------------------------------------------------------------------------
To be in compliance with the Linux FHS, the PostgreSQL RPMs install files in
a manner not consistent with most of the PostgreSQL documentation. According
to the standard PostgreSQL documentation, PostgreSQL is installed under the
directory /usr/local/pgsql, with executables, source, and data existing in
various subdirectories.
Different distributions have different ideas of some of these file locations.
In particular, the documentation directory can be /usr/doc, /usr/doc/packages,
/usr/share/doc, /usr/share/doc/packages, or some other similar path.
However, the Red Hat / CentOS / Fedora RPM's install the files like
this:
Executables: /usr/bin and /usr/pgsql-9.2/bin
Libraries: /usr/pgsql-9.2/lib
Documentation: /usr/pgsql-9.2/doc
Contrib documentation: /usr/pgsql-9.2/doc
Source: not installed
Data: /var/lib/pgsql/9.2/data
Backup area: /var/lib/pgsql/9.2/backups
Templates: /usr/share/pgsql
Procedural Languages: /usr/pgsql-9.2/lib
Development Headers: /usr/pgsql-9.2/include
Other shared data: /usr/pgsql-9.2/share
Regression tests: /usr/lib/pgsql/test/regress (in the -test package)
or /usr/lib64/pgsql/test/regress
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
also seem like more work to keep track of where everything is -- but, that's
the beauty of RPM -- you don't have to keep track of the files, RPM does it
for you.
These RPMs are designed to be LSB-compliant -- if you find this not to be the
case, please let us know by way of the pgsqlrpms-hackers@pgfoundry.org
mailing list.
-------------------------------------------------------------------------------
MULTIPLE POSTMASTERS (For the same PostgreSQL version)
-------------------------------------------------------------------------------
The postgresql-server RPM contains an 'initscript' that is used to start the
postmaster. The current version of this script has logic to be able to start
multiple postmasters, with different data areas, listening on different ports,
etc. To use this functionality requires root access.
As an example, let us create a secondary postmaster called, creatively enough,
'secondary'. Here are the steps:
1.) create a hard link in /etc/rc.d/init.d (or equivalent location)
to postgresql-9.2 named 'secondary-9.2' : ln postgresql secondary Pick
a name not already used in /etc/rc.d/init.d!
2.) create a file in /etc/sysconfig/pgsql named secondary. This file is
a shell script -- typically you would define PGDATA, PGPORT, and PGOPTS
here. Since $PGDATA/postgresql.conf will override many of these
settings, except PGDATA, you might be surprised on startup.
3.) run service secondary-9.2 initdb
4.) Edit postgresql.conf to change the port, address, etc.
5.) Start the postmaster with 'service secondary-9.2 start'.
Note that there may be problems with the standard symlink -- consider this
support experimental at this point in time.
When doing a major-version upgrade of a secondary postmaster, mention the
service name in the postgresql-setup command, for example 'postgresql-setup
upgrade secondary'. This will let postgresql-setup find the correct data
directory from the service file.
REGRESSION TESTING
-------------------------------------------------------------------------------
If you install the postgresql-test RPM then you can run the PostgreSQL
regression tests. These tests stress your database installation and produce
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 the
postmaster has been started (if not, su to root and do "systemctl start
postgresql.service"), cd to /usr/lib/pgsql/test/regress (or
/usr/lib64/pgsql/test/regress on a 64-bit machine), 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.
If any tests fail, see the file regression.diffs in that directory for details,
and read the "Regression Tests" section of the PostgreSQL documentation to
find out whether the differences are actually significant. If you need help
interpreting the results, contact the pgsql-general list at
postgresql.org.
After testing, say "make clean" to remove the files generated by the test
script.
STARTING POSTMASTER AUTOMATICALLY AT SYSTEM STARTUP
-------------------------------------------------------------------------------
Fedora / Red Hat / CentOS use the systemd package to manage server startup.
A systemd unit file for PostgreSQL is provided in the server package, as
/lib/systemd/system/postgresql.service. To start the postmaster manually,
as root run
systemctl start postgresql.service
To shut the postmaster down,
systemctl stop postgresql.service
These two commands only change the postmaster's current status. If you
want the postmaster to be started automatically during future system startups,
run
systemctl enable postgresql.service
To undo that again,
systemctl disable postgresql.service
See "man systemctl" for other possible subcommands.
GRAND UNIFIED CONFIGURATION (GUC) FILE
-------------------------------------------------------------------------------
The PostgreSQL server has many tunable parameters -- the file
/var/lib/pgsql/9.2/data/postgresql.conf is the master configuration file for the
whole system.
The RPM ships with a mostly-default file -- you will need to tune the
parameters for your installation. In particular, you might want to allow
nonlocal TCP/IP socket connections -- in order to allow these, you will need
to edit the postgresql.conf file. The line in question contains the string
'listen_addresses' -- you need to both uncomment the line and set the value
to '*' to get the postmaster to accept nonlocal connections. You'll also need
to adjust pg_hba.conf appropriately.
LOGGING SET UP
-------------------------------------------------------------------------------
By default, the postmaster's stderr log is directed into files placed in a
pg_log subdirectory of the data directory (ie, /var/lib/pgsql/9.2/data/pg_log).
The out-of-the-box configuration rotates among seven files, one for each
day of the week. You can adjust this by changing postgresql.conf settings.
REBUILDING FROM SOURCE RPM
-------------------------------------------------------------------------------
If your distribution is not supported by the binary RPMs from PostgreSQL.org,
you will need to rebuild from the source RPM. Download the .src.rpm for this
release. You will need to be root to rebuild, unless you have set up
a non-root build environment (which is the recommended method anyway).
Install the source RPM with rpm -i, then cd to the rpm building area
(which is /usr/src/redhat by default). You will have to have a full
development environment to rebuild the full RPM set.
This release of the RPMset includes the ability to conditionally build
sets of packages. The parameters, their defaults, and the meanings are:
beta 0 #build with cassert and do not strip the binaries
python 1 #build the postgresql-python package.
tcl 1 #build the postgresql-tcl package.
test 1 #build the postgresql-test package.
plpython 1 #build the PL/Python procedural language package.
pltcl 1 #build the PL/Tcl procedural language package.
plperl 1 #build the PL/Perl procedural language package.
ssl 1 #use OpenSSL support.
kerberos 1 #use Kerberos 5 support.
nls 1 #build with national language support.
ldap 1 #build with LDAP support.
pam 1 #build with PAM support.
runselftest 1 #do "make check" during the build.
sdt 1 #build with SystemTap support.
xml 1 #build with XML support
pgfts 1 #build with --enable-thread-safety
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-9.2.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.
You might need to disable runselftest if there is an installed version of
PostgreSQL that is a different major version from what you are trying to
build. The self test tends to pick up the installed libpq.so shared library
in place of the one being built :-(, so if that isn't compatible the test will
fail. Also, you can't use runselftest when doing the build as root.
More of these conditionals will be added in the future.
CONTRIB FILES
-------------------------------------------------------------------------------
The contents of the contrib tree are packaged into the -contrib subpackage
and are processed with make and make install. There is documentation in
/usr/share/doc/postgresql-contrib-VERSION for these modules. Most of the
modules are in /usr/lib/pgsql (or /usr/lib64/pgsql) for loadable
modules, and binaries are in /usr/bin. In the future these files may be
split out, depending upon function and dependencies.
MORE INFORMATION
-------------------------------------------------------------------------------
You can get more information at http://www.postgresql.org and
http://yum.postgresql.org
Please help make this packaging better -- let us know if you find problems, or
better ways of doing things. You can reach us by e-mail at
pgsqlrpms-hackers@pgfoundry.org
-------------------------------------------------------------------------------

118
applock-1c-9.2.patch Executable file
View file

@ -0,0 +1,118 @@
--- ../postgresql-9.2.0.orig/doc/src/sgml/ref/lock.sgml 2011-09-09 01:13:28.000000000 +0400
+++ ./doc/src/sgml/ref/lock.sgml 2011-09-14 21:05:06.902050800 +0400
@@ -27,6 +27,7 @@
ACCESS SHARE | ROW SHARE | ROW EXCLUSIVE | SHARE UPDATE EXCLUSIVE
| SHARE | SHARE ROW EXCLUSIVE | EXCLUSIVE | ACCESS EXCLUSIVE
+ | APPLICATION SHARE | APPLICATION EXCLUSIVE
</synopsis>
</refsynopsisdiv>
--- ../postgresql-9.2.0.orig/src/backend/parser/gram.y 2011-09-09 01:13:28.000000000 +0400
+++ ./src/backend/parser/gram.y 2011-09-14 21:38:48.694882400 +0400
@@ -488,7 +488,7 @@
/* ordinary key words in alphabetical order */
%token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
- AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
+ AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY APPLICATION ARRAY AS ASC
ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUTHORIZATION
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
@@ -8139,6 +8139,8 @@
lock_type: ACCESS SHARE { $$ = AccessShareLock; }
| ROW SHARE { $$ = RowShareLock; }
| ROW EXCLUSIVE { $$ = RowExclusiveLock; }
+ | APPLICATION SHARE { $$ = ApplicationShareLock; }
+ | APPLICATION EXCLUSIVE { $$ = ApplicationExclusiveLock; }
| SHARE UPDATE EXCLUSIVE { $$ = ShareUpdateExclusiveLock; }
| SHARE { $$ = ShareLock; }
| SHARE ROW EXCLUSIVE { $$ = ShareRowExclusiveLock; }
@@ -11828,6 +11830,7 @@
| ALSO
| ALTER
| ALWAYS
+ | APPLICATION
| ASSERTION
| ASSIGNMENT
| AT
--- --- ../postgresql-9.2.0.orig/src/backend/storage/lmgr/lock.c Thu Aug 23 22:06:50 2012 UTC
+++ ./src/backend/storage/lmgr/lock.c Mon Sep 10 07:35:10 2012 UTC
@@ -96,8 +96,14 @@
(1 << AccessShareLock) | (1 << RowShareLock) |
(1 << RowExclusiveLock) | (1 << ShareUpdateExclusiveLock) |
(1 << ShareLock) | (1 << ShareRowExclusiveLock) |
- (1 << ExclusiveLock) | (1 << AccessExclusiveLock)
+ (1 << ExclusiveLock) | (1 << AccessExclusiveLock),
+
+ /* ApplicationShareLock*/
+ (1 << ApplicationExclusiveLock),
+
+ /* ApplicationExclusiveLock*/
+ (1 << ApplicationExclusiveLock | 1 << ApplicationShareLock)
};
/* Names of lock modes, for debug printouts */
@@ -111,7 +117,9 @@
"ShareLock",
"ShareRowExclusiveLock",
"ExclusiveLock",
- "AccessExclusiveLock"
+ "AccessExclusiveLock",
+ "ApplicationShareLock",
+ "ApplicationExclusiveLock"
};
#ifndef LOCK_DEBUG
@@ -119,7 +127,7 @@
#endif
static const LockMethodData default_lockmethod = {
- AccessExclusiveLock, /* highest valid lock mode number */
+ ApplicationExclusiveLock, /* highest valid lock mode number */
LockConflicts,
lock_mode_names,
#ifdef LOCK_DEBUG
@@ -130,7 +138,7 @@
};
static const LockMethodData user_lockmethod = {
- AccessExclusiveLock, /* highest valid lock mode number */
+ ApplicationExclusiveLock, /* highest valid lock mode number */
LockConflicts,
lock_mode_names,
#ifdef LOCK_DEBUG
--- ../postgresql-9.2.0.orig/src/include/parser/kwlist.h 2011-09-09 01:13:28.000000000 +0400
+++ ./src/include/parser/kwlist.h 2011-09-14 19:40:30.858423500 +0400
@@ -42,6 +42,7 @@
PG_KEYWORD("analyze", ANALYZE, RESERVED_KEYWORD)
PG_KEYWORD("and", AND, RESERVED_KEYWORD)
PG_KEYWORD("any", ANY, RESERVED_KEYWORD)
+PG_KEYWORD("application", APPLICATION, UNRESERVED_KEYWORD)
PG_KEYWORD("array", ARRAY, RESERVED_KEYWORD)
PG_KEYWORD("as", AS, RESERVED_KEYWORD)
PG_KEYWORD("asc", ASC, RESERVED_KEYWORD)
--- ../postgresql-9.2.0_orig/src/include/storage/lock.h 2011-09-09 01:13:28.000000000 +0400
+++ ./src/include/storage/lock.h 2011-09-14 19:40:30.905223600 +0400
@@ -87,7 +87,7 @@
typedef int LOCKMODE;
/* MAX_LOCKMODES cannot be larger than the # of bits in LOCKMASK */
-#define MAX_LOCKMODES 10
+#define MAX_LOCKMODES 12
#define LOCKBIT_ON(lockmode) (1 << (lockmode))
#define LOCKBIT_OFF(lockmode) (~(1 << (lockmode)))
@@ -156,6 +156,9 @@
#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM
* FULL, and unqualified LOCK TABLE */
+#define ApplicationShareLock 9 /* requested explicitly */
+#define ApplicationExclusiveLock 10 /* requested explicitly */
+
/*
* LOCKTAG is the key information needed to look up a LOCK item in the

29
ecpg_config.h Normal file
View file

@ -0,0 +1,29 @@
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "ecpg_config_x86_64.h"
#elif defined(__i386__)
#include "ecpg_config_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "ecpg_config_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "ecpg_config_ppc.h"
#elif defined(__s390x__)
#include "ecpg_config_s390x.h"
#elif defined(__s390__)
#include "ecpg_config_s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "ecpg_config_sparc64.h"
#elif defined(__sparc__)
#include "ecpg_config_sparc.h"
#endif

3
filter-requires-perl-Pg.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
/usr/lib/rpm/perl.req $* | grep -v 'perl(Pg'

800
online_analyze.patch Executable file
View file

@ -0,0 +1,800 @@
diff -urN ../postgresql-9.2.0.orig/contrib/online_analyze/COPYRIGHT ./contrib/online_analyze/COPYRIGHT
--- ../postgresql-9.2.0.orig/contrib/online_analyze/COPYRIGHT Thu Jan 01 04:00:00 1970
+++ ./contrib/online_analyze/COPYRIGHT Tue Sep 25 17:13:16 2012
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011 Teodor Sigaev <teodor@sigaev.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
diff -urN ../postgresql-9.2.0.orig/contrib/online_analyze/Makefile ./contrib/online_analyze/Makefile
--- ../postgresql-9.2.0.orig/contrib/online_analyze/Makefile Thu Jan 01 04:00:00 1970
+++ ./contrib/online_analyze/Makefile Tue Sep 25 17:13:16 2012
@@ -0,0 +1,16 @@
+MODULE_big = online_analyze
+OBJS = online_analyze.o
+#DATA_built = online_analyze.sql
+DOCS = README.online_analyze
+#REGRESS = online_analyze
+
+ifdef USE_PGXS
+PGXS := $(shell pg_config --pgxs)
+include $(PGXS)
+else
+subdir = contrib/online_analyze
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
+
diff -urN ../postgresql-9.2.0.orig/contrib/online_analyze/online_analyze.c ./contrib/online_analyze/online_analyze.c
--- ../postgresql-9.2.0.orig/contrib/online_analyze/online_analyze.c Thu Jan 01 04:00:00 1970
+++ ./contrib/online_analyze/online_analyze.c Tue Sep 25 17:13:16 2012
@@ -0,0 +1,703 @@
+/*
+ * Copyright (c) 2011 Teodor Sigaev <teodor@sigaev.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "postgres.h"
+
+#include "pgstat.h"
+#include "catalog/namespace.h"
+#include "commands/vacuum.h"
+#include "executor/executor.h"
+#include "nodes/nodes.h"
+#include "nodes/parsenodes.h"
+#include "storage/bufmgr.h"
+#include "utils/builtins.h"
+#include "utils/lsyscache.h"
+#include "utils/guc.h"
+#if PG_VERSION_NUM >= 90200
+#include "catalog/pg_class.h"
+#include "nodes/primnodes.h"
+#include "tcop/utility.h"
+#include "utils/rel.h"
+#include "utils/relcache.h"
+#include "utils/timestamp.h"
+#endif
+
+#ifdef PG_MODULE_MAGIC
+PG_MODULE_MAGIC;
+#endif
+
+static bool online_analyze_enable = true;
+static bool online_analyze_verbose = true;
+static double online_analyze_scale_factor = 0.1;
+static int online_analyze_threshold = 50;
+static double online_analyze_min_interval = 10000;
+
+static ExecutorEnd_hook_type oldExecutorEndHook = NULL;
+#if PG_VERSION_NUM >= 90200
+static ProcessUtility_hook_type oldProcessUtilityHook = NULL;
+#endif
+
+typedef enum
+{
+ OATT_ALL = 0x03,
+ OATT_PERSISTENT = 0x01,
+ OATT_TEMPORARY = 0x02,
+ OATT_NONE = 0x00
+} OnlineAnalyzeTableType;
+
+static const struct config_enum_entry online_analyze_table_type_options[] =
+{
+ {"all", OATT_ALL, false},
+ {"persistent", OATT_PERSISTENT, false},
+ {"temporary", OATT_TEMPORARY, false},
+ {"none", OATT_NONE, false},
+ {NULL, 0, false},
+};
+
+static int online_analyze_table_type = (int)OATT_ALL;
+
+typedef struct TableList {
+ int nTables;
+ Oid *tables;
+ char *tableStr;
+} TableList;
+
+static TableList excludeTables = {0, NULL, NULL};
+static TableList includeTables = {0, NULL, NULL};
+
+static int
+oid_cmp(const void *a, const void *b)
+{
+ if (*(Oid*)a == *(Oid*)b)
+ return 0;
+ return (*(Oid*)a > *(Oid*)b) ? 1 : -1;
+}
+
+static const char *
+tableListAssign(const char * newval, bool doit, TableList *tbl)
+{
+ char *rawname;
+ List *namelist;
+ ListCell *l;
+ Oid *newOids = NULL;
+ int nOids = 0,
+ i = 0;
+
+ rawname = pstrdup(newval);
+
+ if (!SplitIdentifierString(rawname, ',', &namelist))
+ goto cleanup;
+
+ if (doit)
+ {
+ nOids = list_length(namelist);
+ newOids = malloc(sizeof(Oid) * (nOids+1));
+ if (!newOids)
+ elog(ERROR,"could not allocate %d bytes", (int)(sizeof(Oid) * (nOids+1)));
+ }
+
+ foreach(l, namelist)
+ {
+ char *curname = (char *) lfirst(l);
+#if PG_VERSION_NUM >= 90200
+ Oid relOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
+ NoLock, true);
+#else
+ Oid relOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
+ true);
+#endif
+
+ if (relOid == InvalidOid)
+ {
+#if PG_VERSION_NUM >= 90100
+ if (doit == false)
+#endif
+ elog(WARNING,"'%s' does not exist", curname);
+ continue;
+ }
+ else if ( get_rel_relkind(relOid) != RELKIND_RELATION )
+ {
+#if PG_VERSION_NUM >= 90100
+ if (doit == false)
+#endif
+ elog(WARNING,"'%s' is not an table", curname);
+ continue;
+ }
+ else if (doit)
+ {
+ newOids[i++] = relOid;
+ }
+ }
+
+ if (doit)
+ {
+ tbl->nTables = i;
+ if (tbl->tables)
+ free(tbl->tables);
+ tbl->tables = newOids;
+ if (tbl->nTables > 1)
+ qsort(tbl->tables, tbl->nTables, sizeof(tbl->tables[0]), oid_cmp);
+ }
+
+ pfree(rawname);
+ list_free(namelist);
+
+ return newval;
+
+cleanup:
+ if (newOids)
+ free(newOids);
+ pfree(rawname);
+ list_free(namelist);
+ return NULL;
+}
+
+#if PG_VERSION_NUM >= 90100
+static bool
+excludeTablesCheck(char **newval, void **extra, GucSource source)
+{
+ char *val;
+
+ val = (char*)tableListAssign(*newval, false, &excludeTables);
+
+ if (val)
+ {
+ *newval = val;
+ return true;
+ }
+
+ return false;
+}
+
+static void
+excludeTablesAssign(const char *newval, void *extra)
+{
+ tableListAssign(newval, true, &excludeTables);
+}
+
+static bool
+includeTablesCheck(char **newval, void **extra, GucSource source)
+{
+ char *val;
+
+ val = (char*)tableListAssign(*newval, false, &includeTables);
+
+ if (val)
+ {
+ *newval = val;
+ return true;
+ }
+
+ return false;
+}
+
+static void
+includeTablesAssign(const char *newval, void *extra)
+{
+ tableListAssign(newval, true, &excludeTables);
+}
+
+#else /* PG_VERSION_NUM < 90100 */
+
+static const char *
+excludeTablesAssign(const char * newval, bool doit, GucSource source)
+{
+ return tableListAssign(newval, doit, &excludeTables);
+}
+
+static const char *
+includeTablesAssign(const char * newval, bool doit, GucSource source)
+{
+ return tableListAssign(newval, doit, &includeTables);
+}
+
+#endif
+
+static const char*
+tableListShow(TableList *tbl)
+{
+ char *val, *ptr;
+ int i,
+ len;
+
+ len = 1 /* \0 */ + tbl->nTables * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
+ ptr = val = palloc(len);
+ *ptr ='\0';
+ for(i=0; i<tbl->nTables; i++)
+ {
+ char *relname = get_rel_name(tbl->tables[i]);
+ Oid nspOid = get_rel_namespace(tbl->tables[i]);
+ char *nspname = get_namespace_name(nspOid);
+
+ if ( relname == NULL || nspOid == InvalidOid || nspname == NULL )
+ continue;
+
+ ptr += snprintf(ptr, len - (ptr - val), "%s%s.%s",
+ (i==0) ? "" : ", ",
+ nspname, relname);
+ }
+
+ return val;
+}
+
+static const char*
+excludeTablesShow(void)
+{
+ return tableListShow(&excludeTables);
+}
+
+static const char*
+includeTablesShow(void)
+{
+ return tableListShow(&includeTables);
+}
+
+static bool
+matchOid(TableList *tbl, Oid oid)
+{
+ Oid *StopLow = tbl->tables,
+ *StopHigh = tbl->tables + tbl->nTables,
+ *StopMiddle;
+
+ /* Loop invariant: StopLow <= val < StopHigh */
+ while (StopLow < StopHigh)
+ {
+ StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
+
+ if (*StopMiddle == oid)
+ return true;
+ else if (*StopMiddle < oid)
+ StopLow = StopMiddle + 1;
+ else
+ StopHigh = StopMiddle;
+ }
+
+ return false;
+}
+
+static void
+makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
+{
+ PgStat_StatTabEntry *tabentry;
+ TimestampTz now = GetCurrentTimestamp();
+
+ if (relOid == InvalidOid)
+ return;
+
+ if (get_rel_relkind(relOid) != RELKIND_RELATION)
+ return;
+
+ tabentry = pgstat_fetch_stat_tabentry(relOid);
+
+#if PG_VERSION_NUM >= 90000
+#define changes_since_analyze(t) ((t)->changes_since_analyze)
+#else
+#define changes_since_analyze(t) ((t)->n_live_tuples + (t)->n_dead_tuples - (t)->last_anl_tuples)
+#endif
+
+ if (
+ tabentry == NULL /* a new table */ ||
+ (
+ /* do not analyze too often, if both stamps are exceeded the go */
+ TimestampDifferenceExceeds(tabentry->analyze_timestamp, now, online_analyze_min_interval) &&
+ TimestampDifferenceExceeds(tabentry->autovac_analyze_timestamp, now, online_analyze_min_interval) &&
+ /* be in sync with relation_needs_vacanalyze */
+ ((double)(changes_since_analyze(tabentry) + naffected)) >=
+ online_analyze_scale_factor * ((double)(tabentry->n_dead_tuples + tabentry->n_live_tuples)) +
+ (double)online_analyze_threshold
+ )
+ )
+ {
+ VacuumStmt vacstmt;
+ TimestampTz startStamp, endStamp;
+
+ memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
+
+ /*
+ * includeTables overwrites excludeTables
+ */
+ switch(online_analyze_table_type)
+ {
+ case OATT_ALL:
+ if (matchOid(&excludeTables, relOid) == true && matchOid(&includeTables, relOid) == false)
+ return;
+ break;
+ case OATT_NONE:
+ if (matchOid(&includeTables, relOid) == false)
+ return;
+ break;
+ case OATT_TEMPORARY:
+ case OATT_PERSISTENT:
+ default:
+ {
+ Relation rel;
+ OnlineAnalyzeTableType reltype;
+
+ rel = RelationIdGetRelation(relOid);
+ reltype =
+#if PG_VERSION_NUM >= 90100
+ (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
+#else
+ (rel->rd_istemp || rel->rd_islocaltemp)
+#endif
+ ? OATT_TEMPORARY : OATT_PERSISTENT;
+ RelationClose(rel);
+
+ /*
+ * skip analyze if relation's type doesn't not match online_analyze_table_type
+ */
+ if ((online_analyze_table_type & reltype) == 0 || matchOid(&excludeTables, relOid) == true)
+ {
+ if (matchOid(&includeTables, relOid) == false)
+ return;
+ }
+ }
+ break;
+ }
+
+ vacstmt.type = T_VacuumStmt;
+ vacstmt.freeze_min_age = -1;
+ vacstmt.freeze_table_age = -1; /* ??? */
+ vacstmt.relation = NULL;
+ vacstmt.va_cols = NIL;
+
+#if PG_VERSION_NUM >= 90000
+ vacstmt.options = VACOPT_ANALYZE;
+ if (online_analyze_verbose)
+ vacstmt.options |= VACOPT_VERBOSE;
+#else
+ vacstmt.vacuum = vacstmt.full = false;
+ vacstmt.analyze = true;
+ vacstmt.verbose = online_analyze_verbose;
+#endif
+
+ if (online_analyze_verbose)
+ startStamp = GetCurrentTimestamp();
+
+ analyze_rel(relOid, &vacstmt, GetAccessStrategy(BAS_VACUUM)
+#if (PG_VERSION_NUM < 90004) && (PG_VERSION_NUM >= 90000)
+ , true
+#endif
+ );
+
+ if (online_analyze_verbose)
+ {
+ long secs;
+ int microsecs;
+
+ endStamp = GetCurrentTimestamp();
+ TimestampDifference(startStamp, endStamp, &secs, &microsecs);
+ elog(INFO, "analyze \"%s\" took %.02f seconds",
+ get_rel_name(relOid), ((double)secs) + ((double)microsecs)/1.0e6);
+ }
+
+
+ if (tabentry == NULL)
+ {
+ /* new table */
+ pgstat_clear_snapshot();
+ }
+ else
+ {
+ /* update last analyze timestamp in local memory of backend */
+ tabentry->analyze_timestamp = now;
+ }
+ }
+#if PG_VERSION_NUM >= 90000
+ else if (tabentry != NULL)
+ {
+ tabentry->changes_since_analyze += naffected;
+ }
+#endif
+}
+
+extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
+void
+onlineAnalyzeHooker(QueryDesc *queryDesc)
+{
+ uint32 naffected = 0;
+
+ if (queryDesc->estate)
+ naffected = queryDesc->estate->es_processed;
+
+ if (online_analyze_enable && queryDesc->plannedstmt &&
+ (queryDesc->operation == CMD_INSERT ||
+ queryDesc->operation == CMD_UPDATE ||
+ queryDesc->operation == CMD_DELETE
+#if PG_VERSION_NUM < 90200
+ || (queryDesc->operation == CMD_SELECT && queryDesc->plannedstmt->intoClause)
+#endif
+ ))
+ {
+#if PG_VERSION_NUM < 90200
+ if (queryDesc->operation == CMD_SELECT)
+ {
+ Oid relOid = RangeVarGetRelid(queryDesc->plannedstmt->intoClause->rel, true);
+
+ makeAnalyze(relOid, queryDesc->operation, naffected);
+ }
+ else
+#endif
+ if (queryDesc->plannedstmt->resultRelations &&
+ queryDesc->plannedstmt->rtable)
+ {
+ ListCell *l;
+
+ foreach(l, queryDesc->plannedstmt->resultRelations)
+ {
+ int n = lfirst_int(l);
+ RangeTblEntry *rte = list_nth(queryDesc->plannedstmt->rtable, n-1);
+
+ if (rte->rtekind == RTE_RELATION)
+ makeAnalyze(rte->relid, queryDesc->operation, naffected);
+ }
+ }
+ }
+
+ if (oldExecutorEndHook)
+ oldExecutorEndHook(queryDesc);
+ else
+ standard_ExecutorEnd(queryDesc);
+}
+
+#if PG_VERSION_NUM >= 90200
+static void
+onlineAnalyzeHookerUtility(Node *parsetree, const char *queryString,
+ ParamListInfo params, bool isTopLevel,
+ DestReceiver *dest, char *completionTag) {
+ RangeVar *tblname = NULL;
+
+ if (IsA(parsetree, CreateTableAsStmt) && ((CreateTableAsStmt*)parsetree)->into)
+ tblname = (RangeVar*)copyObject(((CreateTableAsStmt*)parsetree)->into->rel);
+
+ if (oldProcessUtilityHook)
+ oldProcessUtilityHook(parsetree, queryString, params, isTopLevel, dest, completionTag);
+ else
+ standard_ProcessUtility(parsetree, queryString, params, isTopLevel, dest, completionTag);
+
+ if (tblname) {
+ Oid tblOid = RangeVarGetRelid(tblname, NoLock, true);
+
+ makeAnalyze(tblOid, CMD_INSERT, 0);
+ }
+}
+#endif
+
+void _PG_init(void);
+void
+_PG_init(void)
+{
+ oldExecutorEndHook = ExecutorEnd_hook;
+
+ ExecutorEnd_hook = onlineAnalyzeHooker;
+
+#if PG_VERSION_NUM >= 90200
+ oldProcessUtilityHook = ProcessUtility_hook;
+
+ ProcessUtility_hook = onlineAnalyzeHookerUtility;
+#endif
+
+
+ DefineCustomBoolVariable(
+ "online_analyze.enable",
+ "Enable on-line analyze",
+ "Enables analyze of table directly after insert/update/delete/select into",
+ &online_analyze_enable,
+#if PG_VERSION_NUM >= 80400
+ online_analyze_enable,
+#endif
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ DefineCustomBoolVariable(
+ "online_analyze.verbose",
+ "Verbosity of on-line analyze",
+ "Make ANALYZE VERBOSE after table's changes",
+ &online_analyze_verbose,
+#if PG_VERSION_NUM >= 80400
+ online_analyze_verbose,
+#endif
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ DefineCustomRealVariable(
+ "online_analyze.scale_factor",
+ "fraction of table size to start on-line analyze",
+ "fraction of table size to start on-line analyze",
+ &online_analyze_scale_factor,
+#if PG_VERSION_NUM >= 80400
+ online_analyze_scale_factor,
+#endif
+ 0.0,
+ 1.0,
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ DefineCustomIntVariable(
+ "online_analyze.threshold",
+ "min number of row updates before on-line analyze",
+ "min number of row updates before on-line analyze",
+ &online_analyze_threshold,
+#if PG_VERSION_NUM >= 80400
+ online_analyze_threshold,
+#endif
+ 0,
+ 0x7fffffff,
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ DefineCustomRealVariable(
+ "online_analyze.min_interval",
+ "minimum time interval between analyze call (in milliseconds)",
+ "minimum time interval between analyze call (in milliseconds)",
+ &online_analyze_min_interval,
+#if PG_VERSION_NUM >= 80400
+ online_analyze_min_interval,
+#endif
+ 0.0,
+ 1e30,
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ DefineCustomEnumVariable(
+ "online_analyze.table_type",
+ "Type(s) of table for online analyze: all(default), persistent, temporary, none",
+ NULL,
+ &online_analyze_table_type,
+#if PG_VERSION_NUM >= 80400
+ online_analyze_table_type,
+#endif
+ online_analyze_table_type_options,
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ DefineCustomStringVariable(
+ "online_analyze.exclude_tables",
+ "List of tables which will not online analyze",
+ NULL,
+ &excludeTables.tableStr,
+#if PG_VERSION_NUM >= 80400
+ "",
+#endif
+ PGC_USERSET,
+ 0,
+#if PG_VERSION_NUM >= 90100
+ excludeTablesCheck,
+ excludeTablesAssign,
+#else
+ excludeTablesAssign,
+#endif
+ excludeTablesShow
+ );
+
+ DefineCustomStringVariable(
+ "online_analyze.include_tables",
+ "List of tables which will online analyze",
+ NULL,
+ &includeTables.tableStr,
+#if PG_VERSION_NUM >= 80400
+ "",
+#endif
+ PGC_USERSET,
+ 0,
+#if PG_VERSION_NUM >= 90100
+ includeTablesCheck,
+ includeTablesAssign,
+#else
+ includeTablesAssign,
+#endif
+ includeTablesShow
+ );
+}
+
+void _PG_fini(void);
+void
+_PG_fini(void)
+{
+ ExecutorEnd_hook = oldExecutorEndHook;
+#if PG_VERSION_NUM >= 90200
+ ProcessUtility_hook = oldProcessUtilityHook;
+#endif
+
+ if (excludeTables.tables)
+ free(excludeTables.tables);
+ if (includeTables.tables)
+ free(includeTables.tables);
+
+ excludeTables.tables = includeTables.tables = NULL;
+ excludeTables.nTables = includeTables.nTables = 0;
+}
diff -urN ../postgresql-9.2.0.orig/contrib/online_analyze/README.online_analyze ./contrib/online_analyze/README.online_analyze
--- ../postgresql-9.2.0.orig/contrib/online_analyze/README.online_analyze Thu Jan 01 04:00:00 1970
+++ ./contrib/online_analyze/README.online_analyze Tue Sep 25 17:13:16 2012
@@ -0,0 +1,36 @@
+Module makes an analyze call immediately after INSERT/UPDATE/DELETE/SELECT INTO
+for affected table(s).
+
+Supported versionsi of PostgreSQL: 8.4.*, 9.0.*, 9.1.*
+
+Usage: LOAD 'online_analyze';
+
+Custom variables (defaults values are shown):
+online_analyze.enable = on
+ Enables on-line analyze
+
+online_analyze.verbose = on
+ Execute ANALYZE VERBOSE
+
+online_analyze.scale_factor = 0.1
+ Fraction of table size to start on-line analyze (similar to
+ autovacuum_analyze_scale_factor)
+
+online_analyze.threshold = 50
+ Min number of row updates before on-line analyze (similar to
+ autovacuum_analyze_threshold)
+
+online_analyze.min_interval = 10000
+ Minimum time interval between analyze call per table (in milliseconds)
+
+online_analyze.table_type = "all"
+ Type(s) of table for online analyze: all, persistent, temporary, none
+
+online_analyze.exclude_tables = ""
+ List of tables which will not online analyze
+
+online_analyze.include_tables = ""
+ List of tables which will online analyze
+ online_analyze.include_tables overwrites online_analyze.exclude_tables.
+
+Author: Teodor Sigaev <teodor@sigaev.ru>

29
pg_config.h Normal file
View file

@ -0,0 +1,29 @@
/*
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
* we need to arrange that header files that appear in both RPMs are
* identical. Hence, this file is architecture-independent and calls
* in an arch-dependent file that will appear in just one RPM.
*
* To avoid breaking arches not explicitly supported by Red Hat, we
* use this indirection file *only* on known multilib arches.
*
* Note: this may well fail if user tries to use gcc's -I- option.
* But that option is deprecated anyway.
*/
#if defined(__x86_64__)
#include "pg_config_x86_64.h"
#elif defined(__i386__)
#include "pg_config_i386.h"
#elif defined(__ppc64__) || defined(__powerpc64__)
#include "pg_config_ppc64.h"
#elif defined(__ppc__) || defined(__powerpc__)
#include "pg_config_ppc.h"
#elif defined(__s390x__)
#include "pg_config_s390x.h"
#elif defined(__s390__)
#include "pg_config_s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "pg_config_sparc64.h"
#elif defined(__sparc__)
#include "pg_config_sparc.h"
#endif

671
plantuner.patch Executable file
View file

@ -0,0 +1,671 @@
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner\COPYRIGHT ./contrib/plantuner/COPYRIGHT
--- ../postgresql-9.2.0.orig/contrib/plantuner/COPYRIGHT Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/COPYRIGHT Mon Sep 17 20:00:32 2012
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2009 Teodor Sigaev <teodor@sigaev.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner/expected/plantuner.out ./contrib/plantuner/expected/plantuner.out
--- ../postgresql-9.2.0.orig/contrib/plantuner/expected/plantuner.out Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/expected/plantuner.out Mon Sep 17 20:00:32 2012
@@ -0,0 +1,49 @@
+LOAD 'plantuner';
+SHOW plantuner.disable_index;
+ plantuner.disable_index
+-------------------------
+
+(1 row)
+
+CREATE TABLE wow (i int, j int);
+CREATE INDEX i_idx ON wow (i);
+CREATE INDEX j_idx ON wow (j);
+SET enable_seqscan=off;
+SELECT * FROM wow;
+ i | j
+---+---
+(0 rows)
+
+SET plantuner.disable_index="i_idx, j_idx";
+SELECT * FROM wow;
+ i | j
+---+---
+(0 rows)
+
+SHOW plantuner.disable_index;
+ plantuner.disable_index
+----------------------------
+ public.i_idx, public.j_idx
+(1 row)
+
+SET plantuner.disable_index="i_idx, nonexistent, public.j_idx, wow";
+WARNING: 'nonexistent' does not exist
+WARNING: 'wow' is not an index
+SHOW plantuner.disable_index;
+ plantuner.disable_index
+----------------------------
+ public.i_idx, public.j_idx
+(1 row)
+
+SET plantuner.enable_index="i_idx";
+SHOW plantuner.enable_index;
+ plantuner.enable_index
+------------------------
+ public.i_idx
+(1 row)
+
+SELECT * FROM wow;
+ i | j
+---+---
+(0 rows)
+
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner/Makefile ./contrib/plantuner/Makefile
--- ../postgresql-9.2.0.orig/contrib/plantuner/Makefile Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/Makefile Mon Sep 17 20:00:32 2012
@@ -0,0 +1,15 @@
+MODULE_big = plantuner
+DOCS = README.plantuner
+REGRESS = plantuner
+OBJS=plantuner.o
+
+ifdef USE_PGXS
+PGXS = $(shell pg_config --pgxs)
+include $(PGXS)
+else
+subdir = contrib/plantuner
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner/plantuner.c ./contrib/plantuner/plantuner.c
--- ../postgresql-9.2.0.orig/contrib/plantuner/plantuner.c Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/plantuner.c Mon Sep 17 20:00:32 2012
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2009 Teodor Sigaev <teodor@sigaev.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <postgres.h>
+
+#include <fmgr.h>
+#include <access/heapam.h>
+#include <catalog/namespace.h>
+#include <catalog/pg_class.h>
+#include <nodes/pg_list.h>
+#include <optimizer/plancat.h>
+#include <storage/bufmgr.h>
+#include <utils/builtins.h>
+#include <utils/guc.h>
+#include <utils/lsyscache.h>
+#include <utils/rel.h>
+
+PG_MODULE_MAGIC;
+
+static int nDisabledIndexes = 0;
+static Oid *disabledIndexes = NULL;
+static char *disableIndexesOutStr = "";
+
+static int nEnabledIndexes = 0;
+static Oid *enabledIndexes = NULL;
+static char *enableIndexesOutStr = "";
+
+get_relation_info_hook_type prevHook = NULL;
+static bool fix_empty_table = false;
+
+
+static const char *
+indexesAssign(const char * newval, bool doit, GucSource source, bool isDisable)
+{
+ char *rawname;
+ List *namelist;
+ ListCell *l;
+ Oid *newOids = NULL;
+ int nOids = 0,
+ i = 0;
+
+ rawname = pstrdup(newval);
+
+ if (!SplitIdentifierString(rawname, ',', &namelist))
+ goto cleanup;
+
+ if (doit)
+ {
+ nOids = list_length(namelist);
+ newOids = malloc(sizeof(Oid) * (nOids+1));
+ if (!newOids)
+ elog(ERROR,"could not allocate %d bytes", (int)(sizeof(Oid) * (nOids+1)));
+ }
+
+ foreach(l, namelist)
+ {
+ char *curname = (char *) lfirst(l);
+#if PG_VERSION_NUM >= 90200
+ Oid indexOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
+ NoLock, true);
+#else
+ Oid indexOid = RangeVarGetRelid(makeRangeVarFromNameList(stringToQualifiedNameList(curname)),
+ true);
+#endif
+
+ if (indexOid == InvalidOid)
+ {
+#if PG_VERSION_NUM >= 90100
+ if (doit == false)
+#endif
+ elog(WARNING,"'%s' does not exist", curname);
+ continue;
+ }
+ else if ( get_rel_relkind(indexOid) != RELKIND_INDEX )
+ {
+#if PG_VERSION_NUM >= 90100
+ if (doit == false)
+#endif
+ elog(WARNING,"'%s' is not an index", curname);
+ continue;
+ }
+ else if (doit)
+ {
+ newOids[i++] = indexOid;
+ }
+ }
+
+ if (doit)
+ {
+ if (isDisable)
+ {
+ nDisabledIndexes = nOids;
+ disabledIndexes = newOids;
+ }
+ else
+ {
+ nEnabledIndexes = nOids;
+ enabledIndexes = newOids;
+ }
+ }
+
+ pfree(rawname);
+ list_free(namelist);
+
+ return newval;
+
+cleanup:
+ if (newOids)
+ free(newOids);
+ pfree(rawname);
+ list_free(namelist);
+ return NULL;
+}
+
+static const char *
+assignDisabledIndexes(const char * newval, bool doit, GucSource source)
+{
+ return indexesAssign(newval, doit, source, true);
+}
+
+static const char *
+assignEnabledIndexes(const char * newval, bool doit, GucSource source)
+{
+ return indexesAssign(newval, doit, source, false);
+}
+
+#if PG_VERSION_NUM >= 90100
+
+static bool
+checkDisabledIndexes(char **newval, void **extra, GucSource source)
+{
+ char *val;
+
+ val = (char*)indexesAssign(*newval, false, source, true);
+
+ if (val)
+ {
+ *newval = val;
+ return true;
+ }
+
+ return false;
+}
+
+static bool
+checkEnabledIndexes(char **newval, void **extra, GucSource source)
+{
+ char *val;
+
+ val = (char*)indexesAssign(*newval, false, source, false);
+
+ if (val)
+ {
+ *newval = val;
+ return true;
+ }
+
+ return false;
+}
+
+static void
+assignDisabledIndexesNew(const char *newval, void *extra)
+{
+ assignDisabledIndexes(newval, true, PGC_S_USER /* doesn't matter */);
+}
+
+static void
+assignEnabledIndexesNew(const char *newval, void *extra)
+{
+ assignEnabledIndexes(newval, true, PGC_S_USER /* doesn't matter */);
+}
+
+#endif
+
+static void
+indexFilter(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel) {
+ int i;
+
+ for(i=0;i<nDisabledIndexes;i++)
+ {
+ ListCell *l;
+
+ foreach(l, rel->indexlist)
+ {
+ IndexOptInfo *info = (IndexOptInfo*)lfirst(l);
+
+ if (disabledIndexes[i] == info->indexoid)
+ {
+ int j;
+
+ for(j=0; j<nEnabledIndexes; j++)
+ if (enabledIndexes[j] == info->indexoid)
+ break;
+
+ if (j >= nEnabledIndexes)
+ rel->indexlist = list_delete_ptr(rel->indexlist, info);
+
+ break;
+ }
+ }
+ }
+}
+
+static void
+execPlantuner(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel) {
+ Relation relation;
+
+ relation = heap_open(relationObjectId, NoLock);
+ if (relation->rd_rel->relkind == RELKIND_RELATION)
+ {
+ if (fix_empty_table && RelationGetNumberOfBlocks(relation) == 0)
+ {
+ /*
+ * estimate_rel_size() could be too pessimistic for particular
+ * workload
+ */
+ rel->pages = 0.0;
+ rel->tuples = 0.0;
+ }
+
+ indexFilter(root, relationObjectId, inhparent, rel);
+ }
+ heap_close(relation, NoLock);
+
+ /*
+ * Call next hook if it exists
+ */
+ if (prevHook)
+ prevHook(root, relationObjectId, inhparent, rel);
+}
+
+static const char*
+IndexFilterShow(Oid* indexes, int nIndexes)
+{
+ char *val, *ptr;
+ int i,
+ len;
+
+ len = 1 /* \0 */ + nIndexes * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
+ ptr = val = palloc(len);
+
+ *ptr =(char)'\0';
+ for(i=0; i<nIndexes; i++)
+ {
+ char *relname = get_rel_name(indexes[i]);
+ Oid nspOid = get_rel_namespace(indexes[i]);
+ char *nspname = get_namespace_name(nspOid);
+
+ if ( relname == NULL || nspOid == InvalidOid || nspname == NULL )
+ continue;
+
+ ptr += snprintf(ptr, len - (ptr - val), "%s%s.%s",
+ (i==0) ? "" : ", ",
+ nspname,
+ relname);
+ }
+
+ return val;
+}
+
+static const char*
+disabledIndexFilterShow(void)
+{
+ return IndexFilterShow(disabledIndexes, nDisabledIndexes);
+}
+
+static const char*
+enabledIndexFilterShow(void)
+{
+ return IndexFilterShow(enabledIndexes, nEnabledIndexes);
+}
+
+void _PG_init(void);
+void
+_PG_init(void)
+{
+ DefineCustomStringVariable(
+ "plantuner.forbid_index",
+ "List of forbidden indexes (deprecated)",
+ "Listed indexes will not be used in queries (deprecated, use plantuner.disable_index)",
+ &disableIndexesOutStr,
+ "",
+ PGC_USERSET,
+ 0,
+#if PG_VERSION_NUM >= 90100
+ checkDisabledIndexes,
+ assignDisabledIndexesNew,
+#else
+ assignDisabledIndexes,
+#endif
+ disabledIndexFilterShow
+ );
+
+ DefineCustomStringVariable(
+ "plantuner.disable_index",
+ "List of disabled indexes",
+ "Listed indexes will not be used in queries",
+ &disableIndexesOutStr,
+ "",
+ PGC_USERSET,
+ 0,
+#if PG_VERSION_NUM >= 90100
+ checkDisabledIndexes,
+ assignDisabledIndexesNew,
+#else
+ assignDisabledIndexes,
+#endif
+ disabledIndexFilterShow
+ );
+
+ DefineCustomStringVariable(
+ "plantuner.enable_index",
+ "List of enabled indexes (overload plantuner.disable_index)",
+ "Listed indexes which could be used in queries even they are listed in plantuner.disable_index",
+ &enableIndexesOutStr,
+ "",
+ PGC_USERSET,
+ 0,
+#if PG_VERSION_NUM >= 90100
+ checkEnabledIndexes,
+ assignEnabledIndexesNew,
+#else
+ assignEnabledIndexes,
+#endif
+ enabledIndexFilterShow
+ );
+
+ DefineCustomBoolVariable(
+ "plantuner.fix_empty_table",
+ "Sets to zero estimations for empty tables",
+ "Sets to zero estimations for empty or newly created tables",
+ &fix_empty_table,
+#if PG_VERSION_NUM >= 80400
+ fix_empty_table,
+#endif
+ PGC_USERSET,
+#if PG_VERSION_NUM >= 80400
+ GUC_NOT_IN_SAMPLE,
+#if PG_VERSION_NUM >= 90100
+ NULL,
+#endif
+#endif
+ NULL,
+ NULL
+ );
+
+ if (get_relation_info_hook != execPlantuner )
+ {
+ prevHook = get_relation_info_hook;
+ get_relation_info_hook = execPlantuner;
+ }
+}
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner/README.plantuner ./contrib/plantuner/README.plantuner
--- ../postgresql-9.2.0.orig/contrib/plantuner/README.plantuner Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/README.plantuner Mon Sep 17 20:00:32 2012
@@ -0,0 +1,96 @@
+Plantuner - enable planner hints
+
+ contrib/plantuner is a contribution module for PostgreSQL 8.4+, which
+ enable planner hints.
+
+ All work was done by Teodor Sigaev (teodor@sigaev.ru) and Oleg Bartunov
+ (oleg@sai.msu.su).
+
+ Sponsor: Nomao project (http://www.nomao.com)
+
+Motivation
+
+ Whether somebody think it's bad or not, but sometime it's very
+ interesting to be able to control planner (provide hints, which tells
+ optimizer to ignore its algorithm in part), which is currently
+ impossible in POstgreSQL. Oracle, for example, has over 120 hints, SQL
+ Server also provides hints.
+
+ This first version of plantuner provides a possibility to hide
+ specified indexes from PostgreSQL planner, so it will not use them.
+
+ There are many situation, when developer want to temporarily disable
+ specific index(es), without dropping them, or to instruct planner to
+ use specific index.
+
+ Next, for some workload PostgreSQL could be too pessimistic for
+ newly created tables and assumes much more rows in table than
+ it actually has. If plantuner.fix_empty_table GUC variable is set
+ to true then module will set to zero number of pages/tuples of
+ table which hasn't blocks in file.
+
+Installation
+
+ * Get latest source of plantuner from CVS Repository
+ * gmake && gmake install && gmake installcheck
+
+Syntax
+ plantuner.forbid_index (deprecated)
+ plantuner.disable_index
+ List of indexes invisible to planner
+ plantuner.enable_index
+ List of indexes visible to planner even they are hided
+ by plantuner.disable_index.
+
+Usage
+
+ To enable the module you can either load shared library 'plantuner' in
+ psql session or specify 'shared_preload_libraries' option in
+ postgresql.conf.
+=# LOAD 'plantuner';
+=# create table test(id int);
+=# create index id_idx on test(id);
+=# create index id_idx2 on test(id);
+=# \d test
+ Table "public.test"
+ Column | Type | Modifiers
+--------+---------+-----------
+ id | integer |
+Indexes:
+ "id_idx" btree (id)
+ "id_idx2" btree (id)
+=# explain select id from test where id=1;
+ QUERY PLAN
+-----------------------------------------------------------------------
+ Bitmap Heap Scan on test (cost=4.34..15.03 rows=12 width=4)
+ Recheck Cond: (id = 1)
+ -> Bitmap Index Scan on id_idx2 (cost=0.00..4.34 rows=12 width=0)
+ Index Cond: (id = 1)
+(4 rows)
+=# set enable_seqscan=off;
+=# set plantuner.disable_index='id_idx2';
+=# explain select id from test where id=1;
+ QUERY PLAN
+----------------------------------------------------------------------
+ Bitmap Heap Scan on test (cost=4.34..15.03 rows=12 width=4)
+ Recheck Cond: (id = 1)
+ -> Bitmap Index Scan on id_idx (cost=0.00..4.34 rows=12 width=0)
+ Index Cond: (id = 1)
+(4 rows)
+=# set plantuner.disable_index='id_idx2,id_idx';
+=# explain select id from test where id=1;
+ QUERY PLAN
+-------------------------------------------------------------------------
+ Seq Scan on test (cost=10000000000.00..10000000040.00 rows=12 width=4)
+ Filter: (id = 1)
+(2 rows)
+=# set plantuner.enable_index='id_idx';
+=# explain select id from test where id=1;
+ QUERY PLAN
+-----------------------------------------------------------------------
+ Bitmap Heap Scan on test (cost=4.34..15.03 rows=12 width=4)
+ Recheck Cond: (id = 1)
+ -> Bitmap Index Scan on id_idx (cost=0.00..4.34 rows=12 width=0)
+ Index Cond: (id = 1)
+(4 rows)
+
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner/results/plantuner.out ./contrib/plantuner/results/plantuner.out
--- ../postgresql-9.2.0.orig/contrib/plantuner/results/plantuner.out Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/results/plantuner.out Tue Sep 18 11:59:30 2012
@@ -0,0 +1,49 @@
+LOAD 'plantuner';
+SHOW plantuner.disable_index;
+ plantuner.disable_index
+-------------------------
+
+(1 row)
+
+CREATE TABLE wow (i int, j int);
+CREATE INDEX i_idx ON wow (i);
+CREATE INDEX j_idx ON wow (j);
+SET enable_seqscan=off;
+SELECT * FROM wow;
+ i | j
+---+---
+(0 rows)
+
+SET plantuner.disable_index="i_idx, j_idx";
+SELECT * FROM wow;
+ i | j
+---+---
+(0 rows)
+
+SHOW plantuner.disable_index;
+ plantuner.disable_index
+----------------------------
+ public.i_idx, public.j_idx
+(1 row)
+
+SET plantuner.disable_index="i_idx, nonexistent, public.j_idx, wow";
+WARNING: 'nonexistent' does not exist
+WARNING: 'wow' is not an index
+SHOW plantuner.disable_index;
+ plantuner.disable_index
+----------------------------
+ public.i_idx, public.j_idx
+(1 row)
+
+SET plantuner.enable_index="i_idx";
+SHOW plantuner.enable_index;
+ plantuner.enable_index
+------------------------
+ public.i_idx
+(1 row)
+
+SELECT * FROM wow;
+ i | j
+---+---
+(0 rows)
+
diff -urN ../postgresql-9.2.0.orig/contrib/plantuner/sql/plantuner.sql ./contrib/plantuner/sql/plantuner.sql
--- ../postgresql-9.2.0.orig/contrib/plantuner/sql/plantuner.sql Thu Jan 01 04:00:00 1970
+++ ./contrib/plantuner/sql/plantuner.sql Mon Sep 17 20:00:32 2012
@@ -0,0 +1,27 @@
+LOAD 'plantuner';
+
+SHOW plantuner.disable_index;
+
+CREATE TABLE wow (i int, j int);
+CREATE INDEX i_idx ON wow (i);
+CREATE INDEX j_idx ON wow (j);
+
+SET enable_seqscan=off;
+
+SELECT * FROM wow;
+
+SET plantuner.disable_index="i_idx, j_idx";
+
+SELECT * FROM wow;
+
+SHOW plantuner.disable_index;
+
+SET plantuner.disable_index="i_idx, nonexistent, public.j_idx, wow";
+
+SHOW plantuner.disable_index;
+
+SET plantuner.enable_index="i_idx";
+
+SHOW plantuner.enable_index;
+
+SELECT * FROM wow;

101
postgresql-1c-9.2.patch Executable file
View file

@ -0,0 +1,101 @@
--- ../postgresql-9.2.0.orig/contrib/Makefile 2011-09-09 01:13:28.000000000 +0400
+++ ./contrib/Makefile 2011-09-14 19:41:07.961287200 +0400
@@ -48,7 +48,12 @@
test_parser \
tsearch2 \
unaccent \
- vacuumlo
+ vacuumlo \
+ mchar \
+ fulleq \
+ fasttrun \
+ online_analyze \
+ plantuner
ifeq ($(with_openssl),yes)
SUBDIRS += sslinfo
--- ../postgresql-9.2.0.orig/src/backend/libpq/pg_hba.conf.sample Thu Aug 23 22:06:50 2012 UTC
+++ ./src/backend/libpq/pg_hba.conf.sample Mon Sep 10 07:25:38 2012 UTC
@@ -79,11 +79,12 @@
@remove-line-for-nolocal@# "local" is for Unix domain socket connections only
@remove-line-for-nolocal@local all all @authmethodlocal@
# IPv4 local connections:
-host all all 127.0.0.1/32 @authmethodhost@
+#host all all 127.0.0.1/32 @authmethodhost@
+host all all 0.0.0.0/0 @authmethodhost@
# IPv6 local connections:
-host all all ::1/128 @authmethodhost@
+host all all ::1/128 @authmethodhost@
# Allow replication connections from localhost, by a user with the
# replication privilege.
@remove-line-for-nolocal@#local replication @default_username@ @authmethodlocal@
-#host replication @default_username@ 127.0.0.1/32 @authmethodhost@
-#host replication @default_username@ ::1/128 @authmethodhost@
+#host replication @default_username@ 127.0.0.1/32 @authmethodhost@
+#host replication @default_username@ ::1/128 @authmethodhost@
--- ../postgresql-9.2.0.orig/src/backend/utils/misc/postgresql.conf.sample Thu Sep 6 21:26:18 2012 UTC
+++ ./src/backend/utils/misc/postgresql.conf.sample Tue Sep 11 13:37:37 2012 UTC
@@ -56,7 +56,7 @@
# - Connection Settings -
-#listen_addresses = 'localhost' # what IP address(es) to listen on;
+listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
@@ -132,7 +132,7 @@
#max_files_per_process = 1000 # min 25
# (change requires restart)
-#shared_preload_libraries = '' # (change requires restart)
+shared_preload_libraries = 'online_analyze, plantuner' # (change requires restart)
# - Cost-Based Vacuum Delay -
@@ -263,7 +263,7 @@
#cpu_tuple_cost = 0.01 # same scale as above
#cpu_index_tuple_cost = 0.005 # same scale as above
#cpu_operator_cost = 0.0025 # same scale as above
-#effective_cache_size = 128MB
+effective_cache_size = 512MB
# - Genetic Query Optimizer -
@@ -528,7 +528,7 @@
#------------------------------------------------------------------------------
#deadlock_timeout = 1s
-#max_locks_per_transaction = 64 # min 10
+max_locks_per_transaction = 150 # min 10
# (change requires restart)
# Note: Each lock table slot uses ~270 bytes of shared memory, and there are
# max_locks_per_transaction * (max_connections + max_prepared_transactions)
@@ -546,11 +546,11 @@
#array_nulls = on
#backslash_quote = safe_encoding # on, off, or safe_encoding
#default_with_oids = off
-#escape_string_warning = on
+escape_string_warning = off
#lo_compat_privileges = off
#quote_all_identifiers = off
#sql_inheritance = on
-#standard_conforming_strings = on
+standard_conforming_strings = off
#synchronize_seqscans = on
# - Other Platforms and Clients -
@@ -570,4 +570,10 @@
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------
-# Add settings for extensions here
+online_analyze.threshold = 50
+online_analyze.scale_factor = 0.1
+online_analyze.enable = on
+online_analyze.verbose = off
+online_analyze.min_interval = 10000
+online_analyze.table_type = 'temporary'
+plantuner.fix_empty_table = true

BIN
postgresql-9.2-A4.pdf Normal file

Binary file not shown.

1
postgresql-9.2-libs.conf Normal file
View file

@ -0,0 +1 @@
/usr/pgsql-9.2/lib/

984
postgresql-9.2.spec Executable file
View file

@ -0,0 +1,984 @@
# Conventions for PostgreSQL Global Development Group RPM releases:
# Official PostgreSQL Development Group RPMS have a PGDG after the release number.
# Integer releases are stable -- 0.1.x releases are Pre-releases, and x.y are
# test releases.
# Pre-releases are those that are built from CVS snapshots or pre-release
# tarballs from postgresql.org. Official beta releases are not
# considered pre-releases, nor are release candidates, as their beta or
# release candidate status is reflected in the version of the tarball. Pre-
# releases' versions do not change -- the pre-release tarball of 7.0.3, for
# example, has the same tarball version as the final official release of 7.0.3:
# but the tarball is different.
# Test releases are where PostgreSQL itself is not in beta, but certain parts of
# the RPM packaging (such as the spec file, the initscript, etc) are in beta.
# Pre-release RPM's should not be put up on the public ftp.postgresql.org server
# -- only test releases or full releases should be.
# This is the PostgreSQL Global Development Group Official RPMset spec file,
# or a derivative thereof.
# Copyright 2003-2012 Devrim GÜNDÜZ <devrim@gunduz.org>
# and others listed.
# Major Contributors:
# ---------------
# Lamar Owen
# Tom Lane
# Peter Eisentraut
# Alvaro Herrera
# David Fetter
# Greg Smith
# and others in the Changelog....
# This spec file and ancilliary files are licensed in accordance with
# The PostgreSQL license.
# In this file you can find the default build package list macros. These can be overridden by defining
# on the rpm command line:
# rpm --define 'packagename 1' .... to force the package to build.
# rpm --define 'packagename 0' .... to force the package NOT to build.
# The base package, the lib package, the devel package, and the server package always get built.
%define _unpackaged_files_terminate_build 0
%define beta 0
%{?beta:%define __os_install_post /usr/lib/rpm/brp-compress}
%{!?kerbdir:%define kerbdir "/usr"}
# This is a macro to be used with find_lang and other stuff
%define majorversion 9.2
%define packageversion 92
%define oname postgresql
%define pgbaseinstdir /usr/pgsql-%{majorversion}
%{!?test:%define test 1}
%{!?plpython:%define plpython 1}
%{!?pltcl:%define pltcl 0}
%{!?plperl:%define plperl 1}
%{!?ssl:%define ssl 1}
%{!?intdatetimes:%define intdatetimes 0}
%{!?kerberos:%define kerberos 1}
%{!?nls:%define nls 1}
%{!?xml:%define xml 1}
%{!?pam:%define pam 1}
%{!?disablepgfts:%define disablepgfts 0}
%{!?runselftest:%define runselftest 0}
%{!?uuid:%define uuid 0}
%{!?ldap:%define ldap 1}
%{!?icu:%define icu 1}
#%ifarch x86_64
# %define local_libdir /usr/local/lib64
#%else
%define local_libdir /usr/local/lib
#%endif
Summary: PostgreSQL client programs and libraries
Name: %{oname}%{packageversion}
Version: 9.2.1
Release: 1.1C
License: PostgreSQL
Group: Applications/Databases
Url: http://www.postgresql.org/
Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
Source3: postgresql.init
Source4: Makefile.regress
Source5: pg_config.h
Source6: README.rpm-dist
Source7: ecpg_config.h
Source9: postgresql-9.2-libs.conf
Source12: http://www.postgresql.org/files/documentation/pdf/%{majorversion}/%{oname}-%{majorversion}-A4.pdf
Source14: postgresql.pam
Source16: filter-requires-perl-Pg.sh
Patch1: rpm-pgsql.patch
Patch3: postgresql-logging.patch
Patch6: postgresql-perl-rpath.patch
Patch8: postgresql-prefer-ncurses.patch
Patch9: 1c_FULL_92-0.22
Patch10: postgresql-1c-9.2.patch
Patch11: applock-1c-9.2.patch
Patch12: online_analyze.patch
Patch13: plantuner.patch
Buildrequires: perl glibc-devel bison flex perl-ExtUtils-Embed
Requires: /sbin/ldconfig initscripts
%if %plpython
BuildRequires: python-devel
%endif
%if %pltcl
BuildRequires: tcl-devel
%endif
BuildRequires: readline-devel
BuildRequires: zlib-devel >= 1.0.4
%if %ssl
BuildRequires: openssl-devel
%endif
%if %kerberos
BuildRequires: krb5-devel
BuildRequires: e2fsprogs-devel
%endif
%if %nls
BuildRequires: gettext >= 0.10.35
%endif
%if %xml
BuildRequires: libxml2-devel libxslt-devel
%endif
%if %pam
BuildRequires: pam-devel
%endif
%if %uuid
BuildRequires: uuid-devel
%endif
%if %ldap
BuildRequires: openldap-devel
%endif
%if %icu
BuildRequires: libicu-devel
%endif
Requires: %{name}-libs = %{version}-%{release}
Requires(post): %{_sbindir}/update-alternatives
Requires(postun): %{_sbindir}/update-alternatives
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Provides: postgresql
%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
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
structure of PostgreSQL databases on a PostgreSQL server. These client
programs can be located on the same machine with the PostgreSQL
server, or may be on a remote machine which accesses a PostgreSQL
server over a network connection. This package contains the command-line
utilities for managing PostgreSQL databases on a PostgreSQL server.
If you want to manipulate a PostgreSQL database on a local or remote PostgreSQL
server, you need this package. You also need to install this package
if you're installing the postgresql92-server package.
%package libs
Summary: The shared libraries required for any PostgreSQL clients
Group: Applications/Databases
Provides: libpq.so
Provides: postgresql-libs
%description libs
The postgresql92-libs package provides the essential shared libraries for any
PostgreSQL client program or interface. You will need to install this package
to use any other PostgreSQL package or any clients that need to connect to a
PostgreSQL server.
%package server
Summary: The programs needed to create and run a PostgreSQL server
Group: Applications/Databases
Requires: /usr/sbin/useradd /sbin/chkconfig
Requires: %{name} = %{version}-%{release}
Provides: postgresql-server
%description server
The postgresql92-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
user-defined types and functions). You should install
postgresql92-server if you want to create and maintain your own
PostgreSQL databases and/or your own PostgreSQL server. You also need
to install the postgresql package.
%package docs
Summary: Extra documentation for PostgreSQL
Group: Applications/Databases
Provides: postgresql-docs
%description docs
The postgresql92-docs package includes the SGML source for the documentation
as well as the documentation in PDF format and some extra documentation.
Install this package if you want to help with the PostgreSQL documentation
project, or if you want to generate printed documentation. This package also
includes HTML version of the documentation.
%package contrib
Summary: Contributed source and binaries distributed with PostgreSQL
Group: Applications/Databases
Requires: %{name} = %{version}
Provides: postgresql-contrib
%description contrib
The postgresql92-contrib package contains contributed packages that are
included in the PostgreSQL distribution.
%package devel
Summary: PostgreSQL development header files and libraries
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Provides: postgresql-devel
%description devel
The postgresql92-devel package contains the header files and libraries
needed to compile C or C++ applications which will directly interact
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 %plperl
%package plperl
Summary: The Perl procedural language for PostgreSQL
Group: Applications/Databases
Requires: %{name}-server = %{version}-%{release}
%ifarch ppc ppc64
BuildRequires: perl-devel
%endif
Obsoletes: postgresql-pl
Provides: postgresql-plperl
%description plperl
PostgreSQL is an advanced Object-Relational database management
system. The postgresql92-plperl package contains the PL/Perl language
for the backend.
%endif
%if %plpython
%package plpython
Summary: The Python procedural language for PostgreSQL
Group: Applications/Databases
Requires: %{name} = %{version}
Requires: %{name}-server = %{version}
Obsoletes: postgresql-pl
Provides: postgresql-plpython
%description plpython
PostgreSQL is an advanced Object-Relational database management
system. The postgresql92-plpython package contains the PL/Python language
for the backend.
%endif
%if %pltcl
%package pltcl
Summary: The Tcl procedural language for PostgreSQL
Group: Applications/Databases
Requires: %{name} = %{version}
Requires: %{name}-server = %{version}
Obsoletes: postgresql-pl
Provides: postgresql-pltcl
%description pltcl
PostgreSQL is an advanced Object-Relational database management
system. The postgresql92-pltcl package contains the PL/Tcl language
for the backend.
%endif
%if %test
%package test
Summary: The test suite distributed with PostgreSQL
Group: Applications/Databases
Requires: %{name}-server = %{version}-%{release}
Provides: postgresql-test
%description test
PostgreSQL is an advanced Object-Relational database management
system. The postgresql-test package includes the sources and pre-built
binaries of various tests for the PostgreSQL database management
system, including regression tests and benchmarks.
%endif
%define __perl_requires %{SOURCE16}
%prep
%setup -q -n %{oname}-%{version}
%patch1 -p1
%patch3 -p1
# patch5 is applied later
%patch6 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p0
#%patch11 -p0
%patch12 -p0
%patch13 -p0
cp -p %{SOURCE12} .
%build
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS
%if %kerberos
CPPFLAGS="${CPPFLAGS} -I%{_includedir}/et" ; export CPPFLAGS
CFLAGS="${CFLAGS} -I%{_includedir}/et" ; export CFLAGS
%endif
# Strip out -ffast-math from CFLAGS....
CFLAGS=`echo $CFLAGS|xargs -n 1|grep -v ffast-math|xargs -n 100`
export LIBNAME=%{_lib}
./configure --disable-rpath \
--prefix=%{pgbaseinstdir} \
--includedir=%{pgbaseinstdir}/include \
--mandir=%{pgbaseinstdir}/share/man \
--datadir=%{pgbaseinstdir}/share \
%if %beta
--enable-debug \
--enable-cassert \
%endif
%if %plperl
--with-perl \
%endif
%if %plpython
--with-python \
%endif
%if %pltcl
--with-tcl \
--with-tclconfig=%{_libdir} \
%endif
%if %ssl
--with-openssl \
%endif
%if %pam
--with-pam \
%endif
%if %kerberos
--with-krb5 \
--with-gssapi \
--with-includes=%{kerbdir}/include \
--with-libraries=%{kerbdir}/%{_lib} \
%endif
%if %nls
--enable-nls \
%endif
%if !%intdatetimes
--disable-integer-datetimes \
%endif
%if %disablepgfts
--disable-thread-safety \
%endif
%if %uuid
--with-ossp-uuid \
%endif
%if %xml
--with-libxml \
--with-libxslt \
%endif
%if %ldap
--with-ldap \
%endif
--with-system-tzdata=%{_datadir}/zoneinfo \
--sysconfdir=/etc/sysconfig/pgsql \
--docdir=%{_docdir}
make %{?_smp_mflags} all
make %{?_smp_mflags} -C contrib all
%if %uuid
make %{?_smp_mflags} -C contrib/uuid-ossp all
%endif
# Have to hack makefile to put correct path into tutorial scripts
sed "s|C=\`pwd\`;|C=%{pgbaseinstdir}/lib/tutorial;|" < src/tutorial/Makefile > src/tutorial/GNUmakefile
make %{?_smp_mflags} -C src/tutorial NO_PGXS=1 all
rm -f src/tutorial/GNUmakefile
%if %runselftest
pushd src/test/regress
make all
cp ../../../contrib/spi/refint.so .
cp ../../../contrib/spi/autoinc.so .
make MAX_CONNECTIONS=5 check
make clean
popd
pushd src/pl
make MAX_CONNECTIONS=5 check
popd
pushd contrib
make MAX_CONNECTIONS=5 check
popd
%endif
%if %test
pushd src/test/regress
make all
popd
%endif
%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install
mkdir -p %{buildroot}%{pgbaseinstdir}/share/extensions/
make -C contrib DESTDIR=%{buildroot} install
%if %uuid
make -C contrib/uuid-ossp DESTDIR=%{buildroot} install
%endif
# 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)
mv %{buildroot}%{pgbaseinstdir}/include/pg_config.h %{buildroot}%{pgbaseinstdir}/include/pg_config_`uname -i`.h
install -m 644 %{SOURCE5} %{buildroot}%{pgbaseinstdir}/include/
mv %{buildroot}%{pgbaseinstdir}/include/server/pg_config.h %{buildroot}%{pgbaseinstdir}/include/server/pg_config_`uname -i`.h
install -m 644 %{SOURCE5} %{buildroot}%{pgbaseinstdir}/include/server/
mv %{buildroot}%{pgbaseinstdir}/include/ecpg_config.h %{buildroot}%{pgbaseinstdir}/include/ecpg_config_`uname -i`.h
install -m 644 %{SOURCE7} %{buildroot}%{pgbaseinstdir}/include/
;;
*)
;;
esac
install -d %{buildroot}/etc/rc.d/init.d
sed 's/^PGVERSION=.*$/PGVERSION=%{version}/' <%{SOURCE3} > postgresql.init
install -m 755 postgresql.init %{buildroot}/etc/rc.d/init.d/postgresql-%{majorversion}
%if %pam
install -d %{buildroot}/etc/pam.d
install -m 644 %{SOURCE14} %{buildroot}/etc/pam.d/postgresql%{packageversion}
%endif
# PGDATA needs removal of group and world permissions due to pg_pwd hole.
install -d -m 700 %{buildroot}/var/lib/pgsql/%{majorversion}/data
# backups of data go here...
install -d -m 700 %{buildroot}/var/lib/pgsql/%{majorversion}/backups
# Create the multiple postmaster startup directory
install -d -m 700 %{buildroot}/etc/sysconfig/pgsql/%{majorversion}
# Install linker conf file under postgresql installation directory.
# We will install the latest version via alternatives.
install -d -m 755 %{buildroot}%{pgbaseinstdir}/share/
install -m 700 %{SOURCE9} %{buildroot}%{pgbaseinstdir}/share/
%if %test
# tests. There are many files included here that are unnecessary,
# but include them anyway for completeness. We replace the original
# Makefiles, however.
mkdir -p %{buildroot}%{pgbaseinstdir}/lib/test
cp -a src/test/regress %{buildroot}%{pgbaseinstdir}/lib/test
install -m 0755 contrib/spi/refint.so %{buildroot}%{pgbaseinstdir}/lib/test/regress
install -m 0755 contrib/spi/autoinc.so %{buildroot}%{pgbaseinstdir}/lib/test/regress
pushd %{buildroot}%{pgbaseinstdir}/lib/test/regress
strip *.so
rm -f GNUmakefile Makefile *.o
chmod 0755 pg_regress regress.so
popd
cp %{SOURCE4} %{buildroot}%{pgbaseinstdir}/lib/test/regress/Makefile
chmod 0644 %{buildroot}%{pgbaseinstdir}/lib/test/regress/Makefile
%endif
# Fix some more documentation
# gzip doc/internals.ps
cp %{SOURCE6} README.rpm-dist
mkdir -p %{buildroot}%{pgbaseinstdir}/share/doc/html
mv doc/src/sgml/html doc
mkdir -p %{buildroot}%{pgbaseinstdir}/share/man/
mv doc/src/sgml/man1 doc/src/sgml/man3 doc/src/sgml/man7 %{buildroot}%{pgbaseinstdir}/share/man/
rm -rf %{buildroot}%{_docdir}/pgsql
%if %icu
# install -m 0755 %{local_libdir}/libicuuc.so.46 %{buildroot}%{pgbaseinstdir}/lib/
# install -m 0755 %{local_libdir}/libicui18n.so.46 %{buildroot}%{pgbaseinstdir}/lib/
# install -m 0755 %{local_libdir}/libicudata.so.46 %{buildroot}%{pgbaseinstdir}/lib/
install -m 0755 %{_libdir}/libicuuc.so %{buildroot}%{pgbaseinstdir}/lib/
install -m 0755 %{_libdir}/libicui18n.so %{buildroot}%{pgbaseinstdir}/lib/
install -m 0755 %{_libdir}/libicudata.so %{buildroot}%{pgbaseinstdir}/lib/
%endif
# initialize file lists
cp /dev/null main.lst
cp /dev/null libs.lst
cp /dev/null server.lst
cp /dev/null devel.lst
cp /dev/null plperl.lst
cp /dev/null pltcl.lst
cp /dev/null plpython.lst
%if %nls
%find_lang ecpg-%{majorversion}
%find_lang ecpglib6-%{majorversion}
%find_lang initdb-%{majorversion}
%find_lang libpq5-%{majorversion}
%find_lang pg_basebackup-%{majorversion}
%find_lang pg_config-%{majorversion}
%find_lang pg_controldata-%{majorversion}
%find_lang pg_ctl-%{majorversion}
%find_lang pg_dump-%{majorversion}
%find_lang pg_resetxlog-%{majorversion}
%find_lang pgscripts-%{majorversion}
%if %plperl
%find_lang plperl-%{majorversion}
cat plperl-%{majorversion}.lang > pg_plperl.lst
%endif
%find_lang plpgsql-%{majorversion}
%if %plpython
%find_lang plpython-%{majorversion}
cat plpython-%{majorversion}.lang > pg_plpython.lst
%endif
%if %pltcl
%find_lang pltcl-%{majorversion}
cat pltcl-%{majorversion}.lang > pg_pltcl.lst
%endif
%find_lang postgres-%{majorversion}
%find_lang psql-%{majorversion}
%endif
cat libpq5-%{majorversion}.lang > pg_libpq5.lst
cat pg_config-%{majorversion}.lang ecpg-%{majorversion}.lang ecpglib6-%{majorversion}.lang > pg_devel.lst
cat initdb-%{majorversion}.lang pg_ctl-%{majorversion}.lang psql-%{majorversion}.lang pg_dump-%{majorversion}.lang pg_basebackup-%{majorversion}.lang pgscripts-%{majorversion}.lang > pg_main.lst
cat postgres-%{majorversion}.lang pg_resetxlog-%{majorversion}.lang pg_controldata-%{majorversion}.lang plpgsql-%{majorversion}.lang > pg_server.lst
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%pre server
groupadd -g 26 -o -r postgres >/dev/null 2>&1 || :
useradd -M -n -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
-c "PostgreSQL Server" -u 26 postgres >/dev/null 2>&1 || :
touch /var/log/pgsql
chown postgres:postgres /var/log/pgsql
chmod 0700 /var/log/pgsql
%post server
chkconfig --add postgresql-9.2
/sbin/ldconfig
# postgres' .bash_profile.
# We now don't install .bash_profile as we used to in pre 9.0. Instead, use cat,
# so that package manager will be happy during upgrade to new major version.
echo "[ -f /etc/profile ] && source /etc/profile
PGDATA=/var/lib/pgsql/9.2/data
export PGDATA" > /var/lib/pgsql/.bash_profile
chown postgres: /var/lib/pgsql/.bash_profile
%preun server
if [ $1 = 0 ] ; then
/sbin/service postgresql-9.2 condstop >/dev/null 2>&1
chkconfig --del postgresql-9.2
fi
%postun server
/sbin/ldconfig
if [ $1 -ge 1 ]; then
/sbin/service postgresql-9.2 condrestart >/dev/null 2>&1
fi
%if %plperl
%post -p /sbin/ldconfig plperl
%postun -p /sbin/ldconfig plperl
%endif
%if %plpython
%post -p /sbin/ldconfig plpython
%postun -p /sbin/ldconfig plpython
%endif
%if %pltcl
%post -p /sbin/ldconfig pltcl
%postun -p /sbin/ldconfig pltcl
%endif
%if %test
%post test
chown -R postgres:postgres /usr/share/pgsql/test >/dev/null 2>&1 || :
%endif
# Create alternatives entries for common binaries and man files
%post
%{_sbindir}/update-alternatives --install /usr/bin/psql pgsql-psql %{pgbaseinstdir}/bin/psql 920
%{_sbindir}/update-alternatives --install /usr/bin/clusterdb pgsql-clusterdb %{pgbaseinstdir}/bin/clusterdb 920
%{_sbindir}/update-alternatives --install /usr/bin/createdb pgsql-createdb %{pgbaseinstdir}/bin/createdb 920
%{_sbindir}/update-alternatives --install /usr/bin/createlang pgsql-createlang %{pgbaseinstdir}/bin/createlang 920
%{_sbindir}/update-alternatives --install /usr/bin/createuser pgsql-createuser %{pgbaseinstdir}/bin/createuser 920
%{_sbindir}/update-alternatives --install /usr/bin/dropdb pgsql-dropdb %{pgbaseinstdir}/bin/dropdb 920
%{_sbindir}/update-alternatives --install /usr/bin/droplang pgsql-droplang %{pgbaseinstdir}/bin/droplang 920
%{_sbindir}/update-alternatives --install /usr/bin/dropuser pgsql-dropuser %{pgbaseinstdir}/bin/dropuser 920
%{_sbindir}/update-alternatives --install /usr/bin/pg_dump pgsql-pg_dump %{pgbaseinstdir}/bin/pg_dump 920
%{_sbindir}/update-alternatives --install /usr/bin/pg_dumpall pgsql-pg_dumpall %{pgbaseinstdir}/bin/pg_dumpall 920
%{_sbindir}/update-alternatives --install /usr/bin/pg_restore pgsql-pg_restore %{pgbaseinstdir}/bin/pg_restore 920
%{_sbindir}/update-alternatives --install /usr/bin/reindexdb pgsql-reindexdb %{pgbaseinstdir}/bin/reindexdb 920
%{_sbindir}/update-alternatives --install /usr/bin/vacuumdb pgsql-vacuumdb %{pgbaseinstdir}/bin/vacuumdb 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/clusterdb.1 pgsql-clusterdbman %{pgbaseinstdir}/share/man/man1/clusterdb.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/createdb.1 pgsql-createdbman %{pgbaseinstdir}/share/man/man1/createdb.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/createlang.1 pgsql-createlangman %{pgbaseinstdir}/share/man/man1/createlang.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/createuser.1 pgsql-createuserman %{pgbaseinstdir}/share/man/man1/createuser.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/dropdb.1 pgsql-dropdbman %{pgbaseinstdir}/share/man/man1/dropdb.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/droplang.1 pgsql-droplangman %{pgbaseinstdir}/share/man/man1/droplang.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/dropuser.1 pgsql-dropuserman %{pgbaseinstdir}/share/man/man1/dropuser.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/pg_dump.1 pgsql-pg_dumpman %{pgbaseinstdir}/share/man/man1/pg_dump.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/pg_dumpall.1 pgsql-pg_dumpallman %{pgbaseinstdir}/share/man/man1/pg_dumpall.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/pg_restore.1 pgsql-pg_restoreman %{pgbaseinstdir}/share/man/man1/pg_restore.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/psql.1 pgsql-psqlman %{pgbaseinstdir}/share/man/man1/psql.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/reindexdb.1 pgsql-reindexdbman %{pgbaseinstdir}/share/man/man1/reindexdb.1 920
%{_sbindir}/update-alternatives --install /usr/share/man/man1/vacuumdb.1 pgsql-vacuumdbman %{pgbaseinstdir}/share/man/man1/vacuumdb.1 920
%{_sbindir}/update-alternatives --install /etc/ld.so.conf.d/postgresql-pgdg-libs.conf pgsql-ld-conf %{pgbaseinstdir}/share/postgresql-9.2-libs.conf 920
# Drop alternatives entries for common binaries and man files
%postun
if [ "$1" -eq 0 ]
then
# Only remove these links if the package is completely removed from the system (vs.just being upgraded)
%{_sbindir}/update-alternatives --remove pgsql-psql %{pgbaseinstdir}/bin/psql
%{_sbindir}/update-alternatives --remove pgsql-clusterdb %{pgbaseinstdir}/bin/clusterdb
%{_sbindir}/update-alternatives --remove pgsql-clusterdbman %{pgbaseinstdir}/share/man/man1/clusterdb.1
%{_sbindir}/update-alternatives --remove pgsql-createdb %{pgbaseinstdir}/bin/createdb
%{_sbindir}/update-alternatives --remove pgsql-createdbman %{pgbaseinstdir}/share/man/man1/createdb.1
%{_sbindir}/update-alternatives --remove pgsql-createlang %{pgbaseinstdir}/bin/createlang
%{_sbindir}/update-alternatives --remove pgsql-createlangman %{pgbaseinstdir}/share/man/man1/createlang.1
%{_sbindir}/update-alternatives --remove pgsql-createuser %{pgbaseinstdir}/bin/createuser
%{_sbindir}/update-alternatives --remove pgsql-createuserman %{pgbaseinstdir}/share/man/man1/createuser.1
%{_sbindir}/update-alternatives --remove pgsql-dropdb %{pgbaseinstdir}/bin/dropdb
%{_sbindir}/update-alternatives --remove pgsql-dropdbman %{pgbaseinstdir}/share/man/man1/dropdb.1
%{_sbindir}/update-alternatives --remove pgsql-droplang %{pgbaseinstdir}/bin/droplang
%{_sbindir}/update-alternatives --remove pgsql-droplangman %{pgbaseinstdir}/share/man/man1/droplang.1
%{_sbindir}/update-alternatives --remove pgsql-dropuser %{pgbaseinstdir}/bin/dropuser
%{_sbindir}/update-alternatives --remove pgsql-dropuserman %{pgbaseinstdir}/share/man/man1/dropuser.1
%{_sbindir}/update-alternatives --remove pgsql-pg_dump %{pgbaseinstdir}/bin/pg_dump
%{_sbindir}/update-alternatives --remove pgsql-pg_dumpall %{pgbaseinstdir}/bin/pg_dumpall
%{_sbindir}/update-alternatives --remove pgsql-pg_dumpallman %{pgbaseinstdir}/share/man/man1/pg_dumpall.1
%{_sbindir}/update-alternatives --remove pgsql-pg_dumpman %{pgbaseinstdir}/share/man/man1/pg_dump.1
%{_sbindir}/update-alternatives --remove pgsql-pg_restore %{pgbaseinstdir}/bin/pg_restore
%{_sbindir}/update-alternatives --remove pgsql-pg_restoreman %{pgbaseinstdir}/share/man/man1/pg_restore.1
%{_sbindir}/update-alternatives --remove pgsql-psqlman %{pgbaseinstdir}/share/man/man1/psql.1
%{_sbindir}/update-alternatives --remove pgsql-reindexdb %{pgbaseinstdir}/bin/reindexdb
%{_sbindir}/update-alternatives --remove pgsql-reindexdbman %{pgbaseinstdir}/share/man/man1/reindexdb.1
%{_sbindir}/update-alternatives --remove pgsql-vacuumdb %{pgbaseinstdir}/bin/vacuumdb
%{_sbindir}/update-alternatives --remove pgsql-vacuumdbman %{pgbaseinstdir}/share/man/man1/vacuumdb.1
%{_sbindir}/update-alternatives --remove pgsql-ld-conf %{pgbaseinstdir}/share/postgresql-9.2-libs.conf
fi
%clean
rm -rf %{buildroot}
# FILES section.
%files -f pg_main.lst
%defattr(-,root,root)
%doc doc/KNOWN_BUGS doc/MISSING_FEATURES
%doc COPYRIGHT doc/bug.template
%doc README.rpm-dist
%{pgbaseinstdir}/bin/clusterdb
%{pgbaseinstdir}/bin/createdb
%{pgbaseinstdir}/bin/createlang
%{pgbaseinstdir}/bin/createuser
%{pgbaseinstdir}/bin/dropdb
%{pgbaseinstdir}/bin/droplang
%{pgbaseinstdir}/bin/dropuser
%{pgbaseinstdir}/bin/pg_basebackup
%{pgbaseinstdir}/bin/pg_config
%{pgbaseinstdir}/bin/pg_dump
%{pgbaseinstdir}/bin/pg_dumpall
%{pgbaseinstdir}/bin/pg_restore
%{pgbaseinstdir}/bin/pg_test_fsync
%{pgbaseinstdir}/bin/pg_receivexlog
%{pgbaseinstdir}/bin/psql
%{pgbaseinstdir}/bin/reindexdb
%{pgbaseinstdir}/bin/vacuumdb
%{pgbaseinstdir}/share/man/man1/clusterdb.*
%{pgbaseinstdir}/share/man/man1/createdb.*
%{pgbaseinstdir}/share/man/man1/createlang.*
%{pgbaseinstdir}/share/man/man1/createuser.*
%{pgbaseinstdir}/share/man/man1/dropdb.*
%{pgbaseinstdir}/share/man/man1/droplang.*
%{pgbaseinstdir}/share/man/man1/dropuser.*
%{pgbaseinstdir}/share/man/man1/pg_basebackup.*
%{pgbaseinstdir}/share/man/man1/pg_config.*
%{pgbaseinstdir}/share/man/man1/pg_dump.*
%{pgbaseinstdir}/share/man/man1/pg_dumpall.*
%{pgbaseinstdir}/share/man/man1/pg_receivexlog.*
%{pgbaseinstdir}/share/man/man1/pg_restore.*
%{pgbaseinstdir}/share/man/man1/psql.*
%{pgbaseinstdir}/share/man/man1/reindexdb.*
%{pgbaseinstdir}/share/man/man1/vacuumdb.*
%{pgbaseinstdir}/share/man/man3/*
%{pgbaseinstdir}/share/man/man7/*
%files docs
%defattr(-,root,root)
%doc doc/src/*
%doc *-A4.pdf
%doc src/tutorial
%doc doc/html
%files contrib
%defattr(-,root,root)
%{pgbaseinstdir}/lib/_int.so
%{pgbaseinstdir}/lib/adminpack.so
%{pgbaseinstdir}/lib/auth_delay.so
%{pgbaseinstdir}/lib/autoinc.so
%{pgbaseinstdir}/lib/auto_explain.so
%{pgbaseinstdir}/lib/btree_gin.so
%{pgbaseinstdir}/lib/btree_gist.so
%{pgbaseinstdir}/lib/chkpass.so
%{pgbaseinstdir}/lib/citext.so
%{pgbaseinstdir}/lib/cube.so
%{pgbaseinstdir}/lib/dblink.so
%{pgbaseinstdir}/lib/dummy_seclabel.so
%{pgbaseinstdir}/lib/earthdistance.so
%{pgbaseinstdir}/lib/fasttrun.so
%{pgbaseinstdir}/lib/fulleq.so
%{pgbaseinstdir}/lib/online_analyze.so
%{pgbaseinstdir}/lib/plantuner.so
%{pgbaseinstdir}/lib/file_fdw.so*
%{pgbaseinstdir}/lib/fuzzystrmatch.so
%{pgbaseinstdir}/lib/insert_username.so
%{pgbaseinstdir}/lib/isn.so
%{pgbaseinstdir}/lib/hstore.so
%{pgbaseinstdir}/lib/mchar.so
%{pgbaseinstdir}/lib/passwordcheck.so
%{pgbaseinstdir}/lib/pg_freespacemap.so
%{pgbaseinstdir}/lib/pg_stat_statements.so
%{pgbaseinstdir}/lib/pgrowlocks.so
%{pgbaseinstdir}/lib/sslinfo.so
%{pgbaseinstdir}/lib/lo.so
%{pgbaseinstdir}/lib/ltree.so
%{pgbaseinstdir}/lib/moddatetime.so
%{pgbaseinstdir}/lib/pageinspect.so
%{pgbaseinstdir}/lib/pgcrypto.so
%{pgbaseinstdir}/lib/pgstattuple.so
%{pgbaseinstdir}/lib/pg_buffercache.so
%{pgbaseinstdir}/lib/pg_trgm.so
%{pgbaseinstdir}/lib/pg_upgrade_support.so
%{pgbaseinstdir}/lib/refint.so
%{pgbaseinstdir}/lib/seg.so
%{pgbaseinstdir}/lib/tablefunc.so
%{pgbaseinstdir}/lib/tcn.so
%{pgbaseinstdir}/lib/timetravel.so
%{pgbaseinstdir}/lib/unaccent.so
%if %xml
%{pgbaseinstdir}/lib/pgxml.so
%endif
%if %uuid
%{pgbaseinstdir}/lib/uuid-ossp.so
%endif
%{pgbaseinstdir}/share/extension/adminpack*
%{pgbaseinstdir}/share/extension/autoinc*
%{pgbaseinstdir}/share/extension/btree_gin*
%{pgbaseinstdir}/share/extension/btree_gist*
%{pgbaseinstdir}/share/extension/chkpass*
%{pgbaseinstdir}/share/extension/citext*
%{pgbaseinstdir}/share/extension/cube*
%{pgbaseinstdir}/share/extension/dblink*
%{pgbaseinstdir}/share/extension/dict_int*
%{pgbaseinstdir}/share/extension/dict_xsyn*
%{pgbaseinstdir}/share/extension/earthdistance*
%{pgbaseinstdir}/share/extension/file_fdw*
%{pgbaseinstdir}/share/extension/fuzzystrmatch*
%{pgbaseinstdir}/share/extension/hstore*
%{pgbaseinstdir}/share/extension/insert_username*
%{pgbaseinstdir}/share/extension/intagg*
%{pgbaseinstdir}/share/extension/intarray*
%{pgbaseinstdir}/share/extension/isn*
%{pgbaseinstdir}/share/extension/lo*
%{pgbaseinstdir}/share/extension/ltree*
%{pgbaseinstdir}/share/extension/moddatetime*
%{pgbaseinstdir}/share/extension/pageinspect*
%{pgbaseinstdir}/share/extension/pg_buffercache*
%{pgbaseinstdir}/share/extension/pg_freespacemap*
%{pgbaseinstdir}/share/extension/pg_stat_statements*
%{pgbaseinstdir}/share/extension/pg_trgm*
%{pgbaseinstdir}/share/extension/pgcrypto*
%{pgbaseinstdir}/share/extension/pgrowlocks*
%{pgbaseinstdir}/share/extension/pgstattuple*
%{pgbaseinstdir}/share/extension/refint*
%{pgbaseinstdir}/share/extension/seg*
%{pgbaseinstdir}/share/extension/sslinfo*
%{pgbaseinstdir}/share/extension/tablefunc*
%{pgbaseinstdir}/share/extension/tcn*
%{pgbaseinstdir}/share/extension/test_parser*
%{pgbaseinstdir}/share/extension/timetravel*
%{pgbaseinstdir}/share/extension/tsearch2*
%{pgbaseinstdir}/share/extension/unaccent*
%if %uuid
%{pgbaseinstdir}/share/extension/uuid-ossp*
%endif
%{pgbaseinstdir}/share/extension/xml2*
%{pgbaseinstdir}/bin/oid2name
%{pgbaseinstdir}/bin/pgbench
%{pgbaseinstdir}/bin/vacuumlo
%{pgbaseinstdir}/bin/pg_archivecleanup
%{pgbaseinstdir}/bin/pg_standby
%{pgbaseinstdir}/bin/pg_test_timing
%{pgbaseinstdir}/bin/pg_upgrade
%{pgbaseinstdir}/share/man/man1/oid2name.1
%{pgbaseinstdir}/share/man/man1/pg_archivecleanup.1
%{pgbaseinstdir}/share/man/man1/pg_standby.1
%{pgbaseinstdir}/share/man/man1/pg_test_fsync.1
%{pgbaseinstdir}/share/man/man1/pg_test_timing.1
%{pgbaseinstdir}/share/man/man1/pg_upgrade.1
%{pgbaseinstdir}/share/man/man1/pgbench.1
%{pgbaseinstdir}/share/man/man1/vacuumlo.1
%if %icu
%attr(755,root,root) %{pgbaseinstdir}/lib/libicuuc.so
%attr(755,root,root) %{pgbaseinstdir}/lib/libicui18n.so
%attr(755,root,root) %{pgbaseinstdir}/lib/libicudata.so
%endif
/usr/pgsql-9.2/share/contrib/fasttrun.sql
/usr/pgsql-9.2/share/contrib/fulleq.sql
/usr/pgsql-9.2/share/contrib/mchar.sql
/usr/pgsql-9.2/share/contrib/uninstall_mchar.sql
%files libs -f pg_libpq5.lst
%defattr(-,root,root)
%{pgbaseinstdir}/lib/libpq.so.*
%{pgbaseinstdir}/lib/libecpg.so*
%{pgbaseinstdir}/lib/libpgtypes.so.*
%{pgbaseinstdir}/lib/libecpg_compat.so.*
%{pgbaseinstdir}/lib/libpqwalreceiver.so
%config(noreplace) %{pgbaseinstdir}/share/postgresql-9.2-libs.conf
%files server -f pg_server.lst
%defattr(-,root,root)
%config(noreplace) /etc/rc.d/init.d/postgresql-%{majorversion}
%if %pam
%config(noreplace) /etc/pam.d/postgresql%{packageversion}
%endif
%attr (755,root,root) %dir /etc/sysconfig/pgsql
%{pgbaseinstdir}/bin/initdb
%{pgbaseinstdir}/bin/pg_controldata
%{pgbaseinstdir}/bin/pg_ctl
%{pgbaseinstdir}/bin/pg_resetxlog
%{pgbaseinstdir}/bin/postgres
%{pgbaseinstdir}/bin/postmaster
%{pgbaseinstdir}/share/man/man1/initdb.*
%{pgbaseinstdir}/share/man/man1/pg_controldata.*
%{pgbaseinstdir}/share/man/man1/pg_ctl.*
%{pgbaseinstdir}/share/man/man1/pg_resetxlog.*
%{pgbaseinstdir}/share/man/man1/postgres.*
%{pgbaseinstdir}/share/man/man1/postmaster.*
%{pgbaseinstdir}/share/postgres.bki
%{pgbaseinstdir}/share/postgres.description
%{pgbaseinstdir}/share/postgres.shdescription
%{pgbaseinstdir}/share/system_views.sql
%{pgbaseinstdir}/share/*.sample
%{pgbaseinstdir}/share/timezonesets/*
%{pgbaseinstdir}/share/tsearch_data/*.affix
%{pgbaseinstdir}/share/tsearch_data/*.dict
%{pgbaseinstdir}/share/tsearch_data/*.ths
%{pgbaseinstdir}/share/tsearch_data/*.rules
%{pgbaseinstdir}/share/tsearch_data/*.stop
%{pgbaseinstdir}/share/tsearch_data/*.syn
%{pgbaseinstdir}/lib/dict_int.so
%{pgbaseinstdir}/lib/dict_snowball.so
%{pgbaseinstdir}/lib/dict_xsyn.so
%{pgbaseinstdir}/lib/euc2004_sjis2004.so
%{pgbaseinstdir}/lib/plpgsql.so
%dir %{pgbaseinstdir}/share/extension
%{pgbaseinstdir}/share/extension/plpgsql*
%{pgbaseinstdir}/lib/test_parser.so
%{pgbaseinstdir}/lib/tsearch2.so
%dir %{pgbaseinstdir}/lib
%dir %{pgbaseinstdir}/share
%attr(700,postgres,postgres) %dir /var/lib/pgsql
%attr(700,postgres,postgres) %dir /var/lib/pgsql/%{majorversion}
%attr(700,postgres,postgres) %dir /var/lib/pgsql/%{majorversion}/data
%attr(700,postgres,postgres) %dir /var/lib/pgsql/%{majorversion}/backups
%{pgbaseinstdir}/lib/*_and_*.so
%{pgbaseinstdir}/share/conversion_create.sql
%{pgbaseinstdir}/share/information_schema.sql
%{pgbaseinstdir}/share/snowball_create.sql
%{pgbaseinstdir}/share/sql_features.txt
%files devel -f pg_devel.lst
%defattr(-,root,root)
%{pgbaseinstdir}/include/*
%{pgbaseinstdir}/bin/ecpg
%{pgbaseinstdir}/lib/libpq.so
%{pgbaseinstdir}/lib/libecpg.so
%{pgbaseinstdir}/lib/libpq.a
%{pgbaseinstdir}/lib/libecpg.a
%{pgbaseinstdir}/lib/libecpg_compat.so
%{pgbaseinstdir}/lib/libecpg_compat.a
%{pgbaseinstdir}/lib/libpgport.a
%{pgbaseinstdir}/lib/libpgtypes.so
%{pgbaseinstdir}/lib/libpgtypes.a
%{pgbaseinstdir}/lib/pgxs/*
%{pgbaseinstdir}/share/man/man1/ecpg.*
%if %plperl
%files plperl -f pg_plperl.lst
%defattr(-,root,root)
%{pgbaseinstdir}/lib/plperl.so
%{pgbaseinstdir}/share/extension/plperl*
%endif
%if %pltcl
%files pltcl -f pg_pltcl.lst
%defattr(-,root,root)
%{pgbaseinstdir}/lib/pltcl.so
%{pgbaseinstdir}/bin/pltcl_delmod
%{pgbaseinstdir}/bin/pltcl_listmod
%{pgbaseinstdir}/bin/pltcl_loadmod
%{pgbaseinstdir}/share/unknown.pltcl
%{pgbaseinstdir}/share/extension/pltcl*
%endif
%if %plpython
%files plpython -f pg_plpython.lst
%defattr(-,root,root)
%{pgbaseinstdir}/lib/plpython*.so
%{pgbaseinstdir}/share/extension/plpython2u*
%{pgbaseinstdir}/share/extension/plpythonu*
%endif
%if %test
%files test
%defattr(-,postgres,postgres)
%attr(-,postgres,postgres) %{pgbaseinstdir}/lib/test/*
%attr(-,postgres,postgres) %dir %{pgbaseinstdir}/lib/test
%endif
%changelog
* Thu Sep 20 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2.1-1PGDG
- Update to 9.2.1, per changes described at:
http://www.postgresql.org/docs/9.2/static/release-9-2-1.html
- Add new functionality: Upgrade from previous version.
Usage: service postgresql-9.2 upgrade
- Fix version number in initdb warning message, per Jose Pedro Oliveira.
* Thu Sep 6 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2.0-1PGDG
- Update to 9.2.0
- Split .control files in appropriate packages. This is a late port
from 9.1 branch. With this patch, pls can be created w/o installing
-contrib subpackage.
- Re-enable -test subpackage, removed accidentally.
* Tue Aug 28 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2rc1-2PGDG
- Install linker conf file with alternatives, so that the latest
version will always be used. Fixes #77.
* Fri Aug 24 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2rc1-1PGDG
- Update to 9.2 RC1
* Thu Aug 16 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2beta4-1PGDG
- Update to 9.2 beta4, which also includes fixes for CVE-2012-3489
and CVE-2012-3488.
* Mon Aug 6 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2beta3-1PGDG
- Update to 9.2 beta3
* Wed Jun 6 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2beta2-1PGDG
- Update to 9.2 beta2, which also includes fixes for CVE-2012-2143,
CVE-2012-2655.
* Fri May 18 2012 Devrim GÜNDÜZ <devrim@gunduz.org> - 9.2beta1-1PGDG
- Initial cut for 9.2 Beta 1

45
postgresql-logging.patch Normal file
View file

@ -0,0 +1,45 @@
--- postgresql-9.1alpha3/src/backend/utils/misc/postgresql.conf.sample.old 2011-01-03 10:07:15.446773001 +0200
+++ postgresql-9.1alpha3/src/backend/utils/misc/postgresql.conf.sample 2011-01-03 10:08:14.416773000 +0200
@@ -256,25 +256,25 @@
# - Where to Log -
-#log_destination = 'stderr' # Valid values are combinations of
+log_destination = 'stderr' # Valid values are combinations of
# stderr, csvlog, syslog, and eventlog,
# depending on platform. csvlog
# requires logging_collector to be on.
# This is used when logging to stderr:
-#logging_collector = off # Enable capturing of stderr and csvlog
+logging_collector = on # Enable capturing of stderr and csvlog
# into log files. Required to be on for
# csvlogs.
# (change requires restart)
# These are only used if logging_collector is on:
-#log_directory = 'pg_log' # directory where log files are written,
+log_directory = 'pg_log' # directory where log files are written,
# can be absolute or relative to PGDATA
-#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
+log_filename = 'postgresql-%a.log' # log file name pattern,
# can include strftime() escapes
#log_file_mode = 0600 # creation mode for log files,
# begin with 0 to use octal notation
-#log_truncate_on_rotation = off # If on, an existing log file with the
+log_truncate_on_rotation = on # If on, an existing log file with the
# same name as the new log file will be
# truncated rather than appended to.
# But such truncation only occurs on
@@ -282,9 +282,9 @@
# or size-driven rotation. Default is
# off, meaning append to existing files
# in all cases.
-#log_rotation_age = 1d # Automatic rotation of logfiles will
+log_rotation_age = 1d # Automatic rotation of logfiles will
# happen after that time. 0 disables.
-#log_rotation_size = 10MB # Automatic rotation of logfiles will
+log_rotation_size = 0 # Automatic rotation of logfiles will
# happen after that much log output.
# 0 disables.

View file

@ -0,0 +1,20 @@
We configure Postgres with --disable-rpath because for the most part we
want to leave it to ldconfig to determine where libraries are. However,
for some reason the Perl package puts libperl.so in a nonstandard place
and doesn't add that place to the ldconfig search path. I think this
is a Perl packaging bug, myself, but apparently it's not going to change.
So work around it by adding an rpath spec to plperl.so (only).
Per bug #162198.
--- postgresql-9.2beta3/src/pl/plperl/GNUmakefile.old 2012-08-06 15:20:12.568068055 +0300
+++ postgresql-9.2beta3/src/pl/plperl/GNUmakefile 2012-08-06 15:20:37.256068618 +0300
@@ -43,6 +43,9 @@
SHLIB_LINK = $(perl_embed_ldflags)
+# Force rpath to be used even though we disable it everywhere else
+SHLIB_LINK += $(rpath)
+
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=plperl --load-extension=plperlu
REGRESS = plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array
# if Perl can support two interpreters in one backend,

View file

@ -0,0 +1,18 @@
This patch hacks the Postgres configure script to prefer libncurses over
libtermcap. This is needed in the current Fedora environment because while
both are available, libtermcap is deprecated and will be removed in the
fairly near future. Because the need for this is short-term, I'm not
going to try to push it upstream; this patch can go away once libtermcap
is no longer present in the standard build environment.
--- postgresql-9.1alpha3/config/programs.m4.old 2011-01-07 09:44:56.000000000 +0200
+++ postgresql-9.1alpha3/config/programs.m4 2011-01-07 09:45:14.000000000 +0200
@@ -125,7 +125,7 @@
else READLINE_ORDER="-ledit -lreadline"
fi
for pgac_rllib in $READLINE_ORDER ; do
- for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
+ for pgac_lib in "" " -lncurses" " -ltermcap" " -lcurses" ; do
LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
AC_TRY_LINK_FUNC([readline], [[
# Older NetBSD, OpenBSD, and Irix have a broken linker that does not

365
postgresql.init Normal file
View file

@ -0,0 +1,365 @@
#!/bin/sh
#
# postgresql This is the init script for starting up the PostgreSQL
# server.
#
# chkconfig: - 64 36
# description: PostgreSQL database server.
# processname: postmaster
# pidfile: /var/run/postmaster-9.2.pid
# This script is slightly unusual in that the name of the daemon (postmaster)
# is not the same as the name of the subsystem (postgresql)
# Version 9.0 Devrim Gunduz <devrim@gunduz.org>
# Get rid of duplicate PGDATA assignment.
# Ensure pgstartup.log gets the right ownership/permissions during initdb
# Version 9.1 Devrim Gunduz <devrim@gunduz.org>
# Update for 9.1
# Add an option to initdb to specify locale (default is $LANG):
# service postgresql initdb tr_TR.UTF-8
# Version 9.2 Devrim Gunduz <devrim@gunduz.org>
# Update for 9.2
# Version 9.2.1 Devrim Gunduz <devrim@gunduz.org>
# Fix version number in initdb warning message, per Jose Pedro Oliveira.
# Add new functionality: Upgrade from previous version.
# Usage: service postgresql-9.2 upgrade
# PGVERSION is the full package version, e.g., 9.2.0
# Note: the specfile inserts the correct value during package build
PGVERSION=xxxx
# PGMAJORVERSION is major version, e.g., 9.2 (this should match PG_VERSION)
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
PGPREVMAJORVERSION=9.1
# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions
# Get function listing for cross-distribution logic.
TYPESET=`typeset -f|grep "declare"`
# Get network config.
. /etc/sysconfig/network
# Find the name of the script
NAME=`basename $0`
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi
# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi
# Define variable for locale parameter:
LOCALEPARAMETER=$2
# Set defaults for configuration variables
PGENGINE=/usr/pgsql-9.2/bin
PGPORT=5432
PGDATA=/var/lib/pgsql/9.2/data
PGLOG=/var/lib/pgsql/9.2/pgstartup.log
# Log file for pg_upgrade
PGUPLOG=/var/lib/pgsql/$PGMAJORVERSION/pgupgrade.log
# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}
export PGDATA
export PGPORT
lockfile="/var/lock/subsys/${NAME}"
pidfile="/var/run/postmaster-9.2.pid"
[ -f "$PGENGINE/postmaster" ] || exit 1
script_result=0
start(){
[ -x "$PGENGINE/postmaster" ] || exit 5
PSQL_START=$"Starting ${NAME} service: "
# Make sure startup-time log file is valid
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
then
touch "$PGLOG" || exit 1
chown postgres:postgres "$PGLOG"
chmod go-rwx "$PGLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
fi
# Check for the PGDATA structure
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
then
# Check version of existing PGDATA
if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
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."
exit 1
fi
else
# No existing PGDATA! Warn the user to initdb it.
echo
echo "$PGDATA is missing. Use \"service postgresql-$PGMAJORVERSION initdb\" to initialize the cluster first."
echo_failure
echo
exit 1
fi
echo -n "$PSQL_START"
$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
sleep 2
pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null`
if [ "x$pid" != x ]
then
success "$PSQL_START"
touch "$lockfile"
echo $pid > "$pidfile"
echo
else
failure "$PSQL_START"
echo
script_result=1
fi
}
stop(){
echo -n $"Stopping ${NAME} service: "
if [ -e "$lockfile" ]
then
$SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo_success
rm -f "$pidfile"
rm -f "$lockfile"
else
echo_failure
script_result=1
fi
else
# not running; per LSB standards this is "ok"
echo_success
fi
echo
}
restart(){
stop
start
}
initdb(){
# If the locale name is specified just after the initdb parameter, use it:
if [ -z $LOCALEPARAMETER ]
then
LOCALE=`echo $LANG`
else
LOCALE=`echo $LOCALEPARAMETER`
fi
LOCALESTRING="--locale=$LOCALE"
if [ -f "$PGDATA/PG_VERSION" ]
then
echo "Data directory is not empty!"
echo_failure
else
echo -n $"Initializing database: "
if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
then
mkdir -p "$PGDATA" || exit 1
chown postgres:postgres "$PGDATA"
chmod go-rwx "$PGDATA"
fi
# Clean up SELinux tagging for PGDATA
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
# Make sure the startup-time log file is OK, too
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
then
touch "$PGLOG" || exit 1
chown postgres:postgres "$PGLOG"
chmod go-rwx "$PGLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
fi
# Initialize the database
$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident' $LOCALESTRING" >> "$PGLOG" 2>&1 < /dev/null
# Create directory for postmaster log
mkdir "$PGDATA/pg_log"
chown postgres:postgres "$PGDATA/pg_log"
chmod go-rwx "$PGDATA/pg_log"
[ -f "$PGDATA/PG_VERSION" ] && echo_success
[ ! -f "$PGDATA/PG_VERSION" ] && echo_failure
echo
fi
}
upgrade(){
## Absorb configuration settings from the specified systemd service files.
# The second parameter is the new database version, i.e. $PGMAJORVERSION in this case.
# Use "postgresql-$PGMAJORVERSION" service, if not specified.
INIT_SCRIPT="$2"
if [ x"$INIT_SCRIPT" = x ]
then
INIT_SCRIPT=postgresql-$PGMAJORVERSION
fi
# The third parameter is the old database version, i.e. $PGPREVMAJORVERSION in this case.
# Use "postgresql-$PGPREVMAJORVERSION" service, if not specified.
OLD_INIT_SCRIPT="$3"
if [ x"$OLD_INIT_SCRIPT" = x ]
then
OLD_INIT_SCRIPT=postgresql-$PGPREVMAJORVERSION
fi
# Find the init script of the new version:
if [ ! -f "/etc/init.d/${INIT_SCRIPT}" ]
then
echo "Could not find init script /etc/init.d/${INIT_SCRIPT}"
fi
# Find the init script of the old version
if [ ! -f "/etc/init.d/${OLD_INIT_SCRIPT}" ]
then
echo "Could not find init script /etc/init.d/${OLD_INIT_SCRIPT}"
echo "Please install postgresql91-server RPM first."
exit
fi
# Get port number and data directory of the old instance from the init script
OLDPGDATA=` sed -n 's/^PGDATA=//p' /etc/init.d/postgresql-$PGPREVMAJORVERSION`
OLDPGPORT=`sed -n 's/^PGPORT=//p' /etc/init.d/postgresql-$PGPREVMAJORVERSION`
# Get port number and data directory of the new instance from the init script
NEWPGDATA=` sed -n 's/^PGDATA=//p' /etc/init.d/postgresql-$PGMAJORVERSION`
NEWPGPORT=`sed -n 's/^PGPORT=//p' /etc/init.d/postgresql-$PGMAJORVERSION`
if [ ! -x "$PGENGINE/pg_upgrade" ]
then
echo
echo $"Please install the postgresql92-contrib RPM for pg_upgrade command."
echo
exit 5
fi
# Perform initdb on the new server
/sbin/service postgresql-$PGMAJORVERSION initdb
RETVAL=$?
if [ $RETVAL -ne 0 ]
then
echo "initdb failed!"
exit 1
fi
# Check the clusters first, without changing any data:
su -l postgres -c "$PGENGINE/pg_upgrade -b /usr/pgsql-$PGPREVMAJORVERSION/bin/ -B $PGENGINE/ -d $OLDPGDATA -D $NEWPGDATA -p $OLDPGPORT -P $NEWPGPORT -c"
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo "Clusters checked successfully, proceeding with upgrade from $PGPREVMAJORVERSION to $PGMAJORVERSION"
echo "Stopping old cluster"
/sbin/service $OLD_INIT_SCRIPT stop
# Set up log file for pg_upgrade
rm -f "$PGUPLOG"
touch "$PGUPLOG" || exit 1
chown postgres:postgres "$PGUPLOG"
chmod go-rwx "$PGUPLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGUPLOG"
echo "Performing upgrade"
su -l postgres -c "$PGENGINE/pg_upgrade \
-b /usr/pgsql-$PGPREVMAJORVERSION/bin/ -B $PGENGINE/ \
-d $OLDPGDATA -D $NEWPGDATA \
-p $OLDPGPORT -P $NEWPGPORT" >> "$PGUPLOG" 2>&1 < /dev/null
else
echo "Cluster check failed. Please see the output above."
exit 1
fi
echo
exit 0
}
condrestart(){
[ -e "$lockfile" ] && restart || :
}
reload(){
$SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p /var/run/postmaster-9.2.pid
script_result=$?
;;
restart)
restart
;;
initdb)
initdb
;;
upgrade)
upgrade
;;
condrestart|try-restart)
condrestart
;;
reload)
reload
;;
force-reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|upgrade|condrestart|try-restart|reload|force-reload|initdb}"
exit 2
esac
exit $script_result

3
postgresql.pam Normal file
View file

@ -0,0 +1,3 @@
#%PAM-1.0
auth include password-auth
account include password-auth

54
rpm-pgsql.patch Normal file
View file

@ -0,0 +1,54 @@
--- postgresql-8.3devel/src/Makefile.global.in.old 2005-10-13 20:35:18.000000000 +0300
+++ postgresql-8.3devel/src/Makefile.global.in 2005-10-13 20:37:01.000000000 +0300
@@ -53,7 +53,7 @@
# Installation directories
#
# These are set by the equivalent --xxxdir configure options. We
-# append "postgresql" to some of them, if the string does not already
+# append "pgsql" to some of them, if the string does not already
# contain "pgsql" or "postgres", in order to avoid directory clutter.
#
# In a PGXS build, we cannot use the values inserted into Makefile.global
@@ -73,14 +73,14 @@
datadir := @datadir@
ifeq "$(findstring pgsql, $(datadir))" ""
ifeq "$(findstring postgres, $(datadir))" ""
-override datadir := $(datadir)/postgresql
+override datadir := $(datadir)/pgsql
endif
endif
sysconfdir := @sysconfdir@
ifeq "$(findstring pgsql, $(sysconfdir))" ""
ifeq "$(findstring postgres, $(sysconfdir))" ""
-override sysconfdir := $(sysconfdir)/postgresql
+override sysconfdir := $(sysconfdir)/pgsql
endif
endif
@@ -89,7 +89,7 @@
pkglibdir = $(libdir)
ifeq "$(findstring pgsql, $(pkglibdir))" ""
ifeq "$(findstring postgres, $(pkglibdir))" ""
-override pkglibdir := $(pkglibdir)/postgresql
+override pkglibdir := $(pkglibdir)/pgsql
endif
endif
@@ -98,7 +98,7 @@
pkgincludedir = $(includedir)
ifeq "$(findstring pgsql, $(pkgincludedir))" ""
ifeq "$(findstring postgres, $(pkgincludedir))" ""
-override pkgincludedir := $(pkgincludedir)/postgresql
+override pkgincludedir := $(pkgincludedir)/pgsql
endif
endif
@@ -114,7 +114,7 @@
docdir := @docdir@
ifeq "$(findstring pgsql, $(docdir))" ""
ifeq "$(findstring postgres, $(docdir))" ""
-override docdir := $(docdir)/postgresql
+override docdir := $(docdir)/pgsql
endif
endif