--- postgresql-8.4-8.4.1.orig/debian/rules
+++ postgresql-8.4-8.4.1/debian/rules
@@ -0,0 +1,160 @@
+#!/usr/bin/make	-f 
+TCL_VER := 8.5
+MAJOR_VER := 8.4
+
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+
+LDFLAGS+= -Wl,--as-needed
+CFLAGS+= -fPIC
+
+ifneq ($(findstring $(DEB_BUILD_ARCH), sparc alpha),)
+# sparc and alpha's gcc currently miscompiles; see
+# http://lists.debian.org/debian-alpha/2007/11/msg00025.html
+    CFLAGS+=-O1
+endif
+
+export DEB_BUILD_HARDENING=1
+
+# build should fail on test suite failures on all arches
+TESTSUITE_FAIL_CMD=exit 1
+
+DEB_DH_INSTALL_SOURCEDIR=debian/tmp
+DEB_CONFIGURE_EXTRA_FLAGS := --mandir=\$${prefix}/share/postgresql/$(MAJOR_VER)/man \
+  --with-docdir=\$${prefix}/share/doc/postgresql-doc-$(MAJOR_VER) \
+  --sysconfdir=/etc/postgresql-common \
+  --datadir=\$${prefix}/share/postgresql/$(MAJOR_VER) \
+  --bindir=\$${prefix}/lib/postgresql/$(MAJOR_VER)/bin \
+  --includedir=\$${prefix}/include/postgresql/ \
+  --enable-nls \
+  --enable-integer-datetimes \
+  --enable-thread-safety \
+  --enable-debug \
+  --disable-rpath \
+  --with-tcl \
+  --with-perl \
+  --with-python \
+  --with-pam \
+  --with-krb5 \
+  --with-gssapi \
+  --with-openssl \
+  --with-libxml \
+  --with-libxslt \
+  --with-ldap \
+  --with-ossp-uuid \
+  --with-gnu-ld \
+  --with-tclconfig=/usr/lib/tcl$(TCL_VER) \
+  --with-tkconfig=/usr/lib/tk$(TCL_VER) \
+  --with-includes=/usr/include/tcl$(TCL_VER) \
+  --with-system-tzdata=/usr/share/zoneinfo \
+  --with-pgport=5432 \
+  $(ARCH_OPTS) \
+  CFLAGS='$(CFLAGS)' \
+  LDFLAGS='$(LDFLAGS)'
+
+DEB_DH_MAKESHLIBS_ARGS := -Xusr/lib/postgresql/$(MAJOR_VER)
+# disabled for CVS builds
+#DEB_DH_INSTALLCHANGELOGS_ARGS := HISTORY
+DEB_COMPRESS_EXCLUDE := .source .c
+DEB_DH_INSTALLINIT_ARGS := -u'defaults 19 21'
+
+# build documentation tarball if not present
+common-configure-indep:: doc/postgres.tar.gz doc/man.tar.gz
+common-configure-arch:: doc/postgres.tar.gz doc/man.tar.gz
+
+doc/postgres.tar.gz:
+	make -C doc/src postgres.tar
+	mv doc/src/postgres.tar doc/
+	gzip -9 doc/postgres.tar
+
+doc/man.tar.gz:
+	chmod 755 debian/docbook2man-sgmlspl/*
+	make -C doc/src man.tar D2MDIR=`pwd`/debian/docbook2man-sgmlspl
+	mv doc/src/man.tar doc/
+	gzip -9 doc/man.tar
+
+clean::
+	rm -f doc/postgres.tar.gz doc/man.tar.gz
+
+common-binary-predeb-arch::
+	# verify that all files are installed; ignore manpages, since
+	# they are handled by dh_installman
+	missing=`dh_install --sourcedir=debian/tmp --list-missing --no-act 2>&1 | grep -v man/man`; \
+	if [ -n "$$missing" ]; then \
+	    echo "Not all files are installed:"; \
+	    echo "$$missing"; \
+	    exit 1; \
+	fi
+
+common-post-build-arch::
+	# generate POT files for translators
+	find -name nls.mk -exec sh -c "make -C \$$(dirname {}) init-po" \;
+	
+common-post-build-indep::
+	# build tutorial stuff
+	make -C src/tutorial NO_PGXS=1
+
+install/postgresql-doc-$(MAJOR_VER)::
+	install src/tutorial/*.c src/tutorial/*.source src/tutorial/Makefile src/tutorial/README debian/$(cdbs_curpkg)/usr/share/doc/$(cdbs_curpkg)/tutorial
+
+binary-predeb/postgresql-$(MAJOR_VER)::
+ifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS)))
+	# patch away the "don't execute as root" check for the test
+	# suite; doing it here will ensure that the actual debs have
+	# the check.
+	set -e; \
+	patch --no-backup-if-mismatch -p1 < debian/disable-root-check.patch; \
+	make -C src/test/regress bigcheck || fail=1; \
+	patch --no-backup-if-mismatch -Rp1 < debian/disable-root-check.patch; \
+	if [ -n "$$fail" ]; then \
+	    for l in regression.diffs log/initdb.log log/postmaster.log; do \
+	    	if [ -e src/test/regress/$$l ]; then \
+		    echo "********* $$l *******"; \
+		    cat src/test/regress/$$l; \
+		fi; \
+	    done; \
+	    $(TESTSUITE_FAIL_CMD); \
+	fi
+endif
+
+	# compress manpages
+	find debian/postgresql-$(MAJOR_VER)/usr/share/postgresql/$(MAJOR_VER)/man -type f -exec gzip -9 '{}' \;
+
+binary-predeb/postgresql-client-$(MAJOR_VER)::
+	find debian/postgresql-client-$(MAJOR_VER)/usr/share/postgresql/$(MAJOR_VER)/man -type f -exec gzip -9 '{}' \;
+
+binary-install/postgresql-plpython-$(MAJOR_VER)::
+	dh_pycentral -p$(cdbs_curpkg)
+	dh_python -p$(cdbs_curpkg) usr/lib/postgresql/$(MAJOR_VER)/lib
+
+# run tests in contrib in temporary test installations, using programs
+# from local tree
+contrib-check:
+	set -e; cd contrib; \
+	for d in *; do \
+	    [ -d $$d/sql ] || continue; \
+	    echo "==============  Running tests in $$d"; \
+	    (cd $$d; \
+	    if ! ../../src/test/regress/pg_regress --top-builddir=../.. --temp-install=tmp_check --dbname=contrib_regression `cd sql; ls *.sql | sed 's/.sql$$//'`; then \
+		 cat regression.diffs; \
+	    fi); \
+	done
+
+# run tests in contrib in temporary test installation, using programs
+# from system installation
+contrib-installcheck:
+	# set up temporary db
+	rm -rf tmp_data
+	mkdir tmp_data
+	/usr/lib/postgresql/$(MAJOR_VER)/bin/initdb -D tmp_data
+	/usr/lib/postgresql/$(MAJOR_VER)/bin/pg_ctl -D tmp_data -l tmp_data/postgres.log -o '-k /tmp' start
+	# wait until it started up
+	while !/usr/lib/postgresql/$(MAJOR_VER)/bin/psql -h /tmp -l >/dev/null 2>&1; do sleep 1; done
+	sleep 1
+	while !/usr/lib/postgresql/$(MAJOR_VER)/bin/psql -h /tmp -l >/dev/null 2>&1; do sleep 1; done
+	# run the tests
+	-cd contrib; make installcheck
+	/usr/lib/postgresql/$(MAJOR_VER)/bin/pg_ctl -D tmp_data stop
+	# find and print the regression diffs
+	find contrib/ -name regression.diffs -exec cat '{}' \;
--- postgresql-8.4-8.4.1.orig/debian/postgresql-doc-8.4.doc-base
+++ postgresql-8.4-8.4.1/debian/postgresql-doc-8.4.doc-base
@@ -0,0 +1,13 @@
+Document: postgresql-8.4
+Title: PostgreSQL 8.4 Documentation
+Author: The PostgreSQL Global Development Group
+Abstract: The documentation for the PostgreSQL database management system,
+ version 8.4. PostgreSQL is a sophisticated Object-Relational DBMS, supporting
+ almost all SQL constructs, including subselects, transactions, and
+ user-defined types and functions.
+Section: Data Management
+
+Format: HTML
+Index: /usr/share/doc/postgresql-doc-8.4/html/index.html
+Files: /usr/share/doc/postgresql-doc-8.4/html/*
+
--- postgresql-8.4-8.4.1.orig/debian/control
+++ postgresql-8.4-8.4.1/debian/control
@@ -0,0 +1,292 @@
+Source: postgresql-8.4
+Section: database
+Priority: optional
+Maintainer: Martin Pitt <mpitt@debian.org>
+Uploaders: Gerfried Fuchs <rhonda@debian.at>
+Standards-Version: 3.8.3
+XS-Python-Version: current
+Build-Depends: debhelper (>= 5.0.37.2), cdbs (>= 0.4.43), perl (>= 5.8),
+ libperl-dev, tcl8.5-dev, libreadline5-dev (>= 4.2), libssl-dev, 
+ zlib1g-dev | libz-dev, libpam0g-dev | libpam-dev, libxml2-dev, libkrb5-dev,
+ libldap2-dev, libxslt1-dev, libossp-uuid-dev, python-dev,
+ python-central (>= 0.5), gettext, bzip2, hardening-wrapper,
+ bison, flex, docbook-utils, openjade, docbook
+
+Package: libpq-dev
+Architecture: any
+Section: libdevel
+Depends: ${shlibs:Depends}, libpq5 (= ${binary:Version}), libssl-dev, libkrb5-dev, comerr-dev
+Conflicts: postgresql-dev (<< 7.5)
+Replaces: postgresql-dev
+Suggests: postgresql-doc-8.4
+Description: header files for libpq5 (PostgreSQL library)
+ Header files and static library for compiling C programs to link
+ with the libpq library in order to communicate with a PostgreSQL
+ database backend.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: libpq5
+Architecture: any
+Section: libs
+Depends: ${shlibs:Depends}
+Description: PostgreSQL C client library
+ libpq is a C library that enables user programs to communicate with
+ the PostgreSQL database server.  The server can be on another machine
+ and accessed through TCP/IP.  This version of libpq is compatible
+ with servers from PostgreSQL 8.2 or later.
+ .
+ This package contains the run-time library, needed by packages using
+ libpq.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: libecpg6
+Architecture: any
+Section: libs
+Depends:  ${shlibs:Depends}
+Description: run-time library for ECPG programs
+ The libecpg shared library is used by programs built with ECPG
+ (Embedded PostgreSQL for C).
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: libecpg-dev
+Architecture: any
+Section: libdevel
+Depends: ${shlibs:Depends}, libpq-dev, libecpg-compat3, libpgtypes3
+Conflicts: postgresql-dev, libecpg3-dev
+Description: development files for ECPG (Embedded PostgreSQL for C)
+ This package contains the necessary files to build ECPG (Embedded
+ PostgreSQL for C) programs.  It includes the development libraries
+ and the preprocessor program ecpg.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+ .
+ Install this package if you want to write C programs with SQL statements
+ embedded in them (rather than run by an external process).
+
+Package: libecpg-compat3
+Architecture: any
+Section: libs
+Depends:  ${shlibs:Depends}
+Description: older version of run-time library for ECPG programs
+ The libecpg_compat shared library is used by programs built with ecpg.
+ (Embedded PostgreSQL for C).
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: libpgtypes3
+Architecture: any
+Section: libs
+Depends:  ${shlibs:Depends}
+Description: shared library libpgtypes for PostgreSQL 8.4
+ The libpgtypes shared library is used by programs built with ecpg.
+ (Embedded PostgreSQL for C).
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-8.4
+Architecture: any
+Depends: ${shlibs:Depends}, postgresql-client-8.4, postgresql-common (>= 98~), tzdata, ssl-cert, locales
+Suggests: oidentd | ident-server
+Conflicts: postgresql (<< 7.5)
+Description: object-relational SQL database, version 8.4 server
+ PostgreSQL is a fully featured object-relational database management
+ system.  It supports a large part of the SQL standard and is designed
+ to be extensible by users in many aspects.  Some of the features are:
+ ACID transactions, foreign keys, views, sequences, subqueries,
+ triggers, user-defined types and functions, outer joins, multiversion
+ concurrency control.  Graphical user interfaces and bindings for many
+ programming languages are available as well.
+ .
+ This package provides the database server for PostgreSQL 8.4. Servers
+ for other major release versions can be installed simultaneously and
+ are coordinated by the postgresql-common package. A package providing
+ ident-server is needed if you want to authenticate remote connections
+ with identd.
+
+Package: postgresql-client-8.4
+Architecture: any
+Depends: ${shlibs:Depends}, postgresql-client-common (>= 98~)
+Conflicts: postgresql (<< 7.5)
+Suggests: postgresql-8.4, postgresql-doc-8.4
+Provides: postgresql-client
+Description: front-end programs for PostgreSQL 8.4
+ This package contains client and administrative programs for
+ PostgreSQL: these are the interactive terminal client psql and
+ programs for creating and removing users and databases.
+ .
+ This is the client package for PostgreSQL 8.4. If you install
+ PostgreSQL 8.4 on a standalone machine, you need the server package
+ postgresql-8.4, too. On a network, you can install this package on
+ many client machines, while the server package may be installed on
+ only one machine.
+ .  
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-server-dev-8.4
+Architecture: any
+Section: libdevel
+Depends: ${shlibs:Depends}, libpq-dev (>= 8.4~)
+Description: development files for PostgreSQL 8.4 server-side programming
+ Header files for compiling SSI code to link into PostgreSQL's backend; for
+ example, for C functions to be called from SQL.
+ .
+ This package also contains the Makefiles necessary for building add-on 
+ modules of PostgreSQL, which would otherwise have to be built in the
+ PostgreSQL source-code tree.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-doc-8.4
+Architecture: all
+Section: doc
+Conflicts: postgresql-doc (<< 7.5)
+Description: documentation for the PostgreSQL database management system
+ This package contains all README files, user manual, and examples for
+ PostgreSQL 8.4. The manual is in HTML format.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-contrib-8.4
+Architecture: any
+Depends: postgresql-8.4, ${shlibs:Depends}, postgresql-common (>= 98~)
+Suggests: libdbd-pg-perl
+Conflicts: postgresql-contrib (<< 7.5)
+Description: additional facilities for PostgreSQL
+ The PostgreSQL contrib package provides several additional features
+ for the PostgreSQL database. This version is built to work with the
+ server package postgresql-8.4.  contrib often serves as a testbed for
+ features before they are adopted into PostgreSQL proper:
+ .
+  adminpack      - File and log manipulation routines, used by pgAdmin
+  btree_gist     - B-Tree indexing using GiST (Generalised Search Tree)
+  chkpass        - An auto-encrypted password datatype
+  cube           - Multidimensional-cube datatype (GiST indexing example)
+  dblink         - Functions to return results from a remote database
+  earthdistance  - Operator for computing the distance (in miles) between
+                   two points on the earth's surface
+  fuzzystrmatch  - Levenshtein, metaphone, and soundex fuzzy string matching
+  hstore         - Store (key, value) pairs
+  intagg         - Integer aggregator/enumerator
+  _int           - Index support for arrays of int4, using GiST (benchmark
+                   needs the libdbd-pg-perl package)
+  isn            - type extensions for ISBN, ISSN, ISMN, EAN13 product numbers
+  lo             - Large Object maintenance
+  ltree          - Tree-like data structures
+  oid2name       - Maps OIDs to table names
+  pageinspect    - Inspection of database pages
+  pg_buffercache - Real time queries on the shared buffer cache
+  pg_freespacemap- Displays the contents of the free space map (FSM)
+  pg_trgm        - Determine the similarity of text based on trigram matching
+  pg_standby     - Create a warm stand-by server
+  pgbench        - TPC-B like benchmark
+  pgcrypto       - Cryptographic functions
+  pgrowlocks     - A function to return row locking information
+  pgstattuple    - Returns the percentage of dead tuples in a table; this
+                   indicates whether a vacuum is required.
+  seg            - Confidence-interval datatype (GiST indexing example)
+  spi            - PostgreSQL Server Programming Interface; 4 examples of
+                   its use:
+                   autoinc    - A function for implementing AUTOINCREMENT/
+                                IDENTITY
+                   insert_username - function for inserting user names
+                   moddatetime - Update modification timestamps
+                   refint     - Functions for implementing referential
+                                integrity (foreign keys).  Note that this is
+                                now superseded by built-in referential
+                                integrity.
+                   timetravel - Re-implements in user code the time travel
+                                feature that was removed in 6.3.
+  tablefunc      - examples of functions returning tables
+  uuid-ossp      - UUID generation functions
+  vacuumlo       - Remove orphaned large objects
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-plperl-8.4
+Architecture: any
+Depends: ${shlibs:Depends}, postgresql-8.4, perl
+Description: PL/Perl procedural language for PostgreSQL 8.4
+ PL/Perl enables an SQL developer to write procedural language functions
+ for PostgreSQL 8.4 in Perl.  You need this package if you have any
+ PostgreSQL 8.4 functions that use the languages plperl or plperlu.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-plpython-8.4
+Architecture: any
+Depends: ${shlibs:Depends}, postgresql-8.4
+XB-Python-Version: ${python:Versions}
+Description: PL/Python procedural language for PostgreSQL 8.4
+ PL/Python enables an SQL developer to write procedural language functions
+ for PostgreSQL 8.4 in Python.  You need this package if you have any
+ PostgreSQL 8.4 functions that use the languages plpython or plpythonu.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-pltcl-8.4
+Architecture: any
+Depends: ${shlibs:Depends}, postgresql-8.4
+Description: PL/Tcl procedural language for PostgreSQL 8.4
+ PL/Tcl enables an SQL developer to write procedural language functions
+ for PostgreSQL 8.4 in Tcl.  You need this package if you have any
+ PostgreSQL 8.4 functions that use the languages pltcl or pltclu.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql
+Architecture: all
+Depends: postgresql-8.4
+Description: object-relational SQL database (supported version)
+ PostgreSQL is a fully featured object-relational database management
+ system.  It supports a large part of the SQL standard and is designed
+ to be extensible by users in many aspects.  Some of the features are:
+ ACID transactions, foreign keys, views, sequences, subqueries,
+ triggers, user-defined types and functions, outer joins, multiversion
+ concurrency control.  Graphical user interfaces and bindings for many
+ programming languages are available as well.
+ .
+ This package always depends on the currently supported PostgreSQL
+ database server version.
+
+Package: postgresql-client
+Architecture: all
+Depends: postgresql-client-8.4
+Description: front-end programs for PostgreSQL (supported version)
+ This package contains client and administrative programs for
+ PostgreSQL: these are the interactive terminal client psql and
+ programs for creating and removing users and databases.
+ .
+ This package always depends on the currently supported database
+ client package for PostgreSQL. If you install PostgreSQL on a
+ standalone machine, you need the server package postgresql, too. On a
+ network, you can install this package on many client machines, while
+ the server package may be installed on only one machine.
+ .  
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-doc
+Architecture: all
+Section: doc
+Depends: postgresql-doc-8.4
+Description: documentation for the PostgreSQL database management system
+ This package contains all README files, user manual, and examples for
+ the currently supported PostgreSQL version. The manual is in HTML
+ format.
+ .
+ PostgreSQL is an object-relational SQL database management system.
+
+Package: postgresql-contrib
+Architecture: all
+Depends: postgresql-contrib-8.4
+Description: additional facilities for PostgreSQL (supported version)
+ The PostgreSQL contrib package provides several additional features
+ for the PostgreSQL database. contrib often serves as a testbed for
+ features before they are adopted into PostgreSQL proper.
+ .
+ This package always depends on the currently supported contrib
+ package for PostgreSQL.
+ .
+ PostgreSQL is an object-relational SQL database management system.
--- postgresql-8.4-8.4.1.orig/debian/libecpg6.install
+++ postgresql-8.4-8.4.1/debian/libecpg6.install
@@ -0,0 +1,2 @@
+usr/lib/libecpg.so.6*
+/usr/share/locale/*/*/ecpg*.mo
--- postgresql-8.4-8.4.1.orig/debian/changelog
+++ postgresql-8.4-8.4.1/debian/changelog
@@ -0,0 +1,160 @@
+postgresql-8.4 (8.4.1-1~bpo50+1) lenny-backports; urgency=low
+
+  * Security rebuild for lenny-backports to fix CVE-2007-6600 (privilege
+    escalation).
+
+ -- Gerfried Fuchs <rhonda@debian.at>  Wed, 09 Sep 2009 19:21:27 +0200
+
+postgresql-8.4 (8.4.1-1) unstable; urgency=medium
+
+  * Urgency medium due to security fix.
+  * New upstream security/bug fix release:
+    - Disallow "RESET ROLE" and "RESET SESSION AUTHORIZATION" inside
+      security-definer functions. This covers a case that was missed in the
+      previous patch that disallowed "SET ROLE" and "SET SESSION
+      AUTHORIZATION" inside security-definer functions. [CVE-2007-6600]
+    - Fix WAL page header initialization at the end of archive recovery.
+      This could lead to failure to process the WAL in a subsequent archive
+      recovery.
+    - Fix "cannot make new WAL entries during recovery" error.
+    - Fix problem that could make expired rows visible after a crash.
+      This bug involved a page status bit potentially not being set
+      correctly after a server crash.
+    - Make "LOAD" of an already-loaded loadable module into a no-op.
+      Formerly, "LOAD" would attempt to unload and re-load the module,
+      but this is unsafe and not all that useful.
+    - Make window function PARTITION BY and ORDER BY items always be
+      interpreted as simple expressions.
+      In 8.4.0 these lists were parsed following the rules used for
+      top-level GROUP BY and ORDER BY lists. But this was not correct per
+      the SQL standard, and it led to possible circularity.
+    - Fix several errors in planning of semi-joins. These led to wrong query
+      results in some cases where IN or EXISTS was used together with another
+      join.
+    - Fix handling of whole-row references to subqueries that are within
+      an outer join. An example is SELECT COUNT(ss.-) FROM ... LEFT JOIN
+      (SELECT ...) ss ON .... Here, ss.- would be treated as
+      ROW(NULL,NULL,...) for null-extended join rows, which is not the same as
+      a simple NULL.  Now it is treated as a simple NULL.
+    - Fix locale handling with plperl. This bug could cause the server's
+      locale setting to change when a plperl function is called, leading to
+      data corruption.
+    - Fix handling of reloptions to ensure setting one option doesn't
+      force default values for others.
+    - Ensure that a "fast shutdown" request will forcibly terminate open
+      sessions, even if a "smart shutdown" was already in progress.
+    - Avoid memory leak for array_agg() in GROUP BY queries.
+    - Treat to_char(..., 'TH') as an uppercase ordinal suffix with
+      'HH'/'HH12'.  It was previously handled as 'th'.
+    - Include the fractional part in the result of EXTRACT(second) and
+      EXTRACT(milliseconds) for time and time with time zone inputs.
+      This has always worked for floating-point datetime configurations,
+      but was broken in the integer datetime code.
+    - Fix overflow for INTERVAL 'x ms' when "x" is more than 2 million
+      and integer datetimes are in use.
+    - Improve performance when processing toasted values in index scans.
+      This is particularly useful for PostGIS.
+    - Fix a typo that disabled commit_delay.
+    - Output early-startup messages to "postmaster.log" if the server is
+      started in silent mode. Previously such error messages were discarded,
+      leading to difficulty in debugging.
+    - Remove translated FAQs. They are now on the wiki. The main FAQ was moved
+      to the wiki some time ago.
+    - Fix pg_ctl to not go into an infinite loop if "postgresql.conf" is
+      empty.
+    - Fix several errors in pg_dump's --binary-upgrade mode. pg_dump
+      --binary-upgrade is used by pg_migrator.
+    - Fix "contrib/xml2"'s xslt_process() to properly handle the maximum
+      number of parameters (twenty).
+    - Improve robustness of libpq's code to recover from errors during
+      "COPY FROM STDIN".
+    - Avoid including conflicting readline and editline header files when
+      both libraries are installed.
+    - Work around gcc bug that causes "floating-point exception" instead
+      of "division by zero" on some platforms.
+  * debian/control: Bump Standards-Version to 3.8.3 (no changes necessary).
+
+ -- Martin Pitt <mpitt@debian.org>  Sun, 06 Sep 2009 14:11:13 +0200
+
+postgresql-8.4 (8.4.0-2) unstable; urgency=low
+
+  * debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
+  * debian/rules: Drop --enable-cassert for final release.
+
+ -- Martin Pitt <mpitt@debian.org>  Sat, 11 Jul 2009 16:59:35 +0200
+
+postgresql-8.4 (8.4.0-1) unstable; urgency=low
+
+  * Final 8.4.0 release. Major enhancements:
+    - Windowing Functions
+    - Common Table Expressions and Recursive Queries
+    - Default and variadic parameters for functions
+    - Parallel Restore
+    - Column Permissions
+    - Per-database locale settings
+    - Improved hash indexes
+    - Improved join performance for EXISTS and NOT EXISTS queries
+    - Easier-to-use Warm Standby
+    - Automatic sizing of the Free Space Map
+    - Visibility Map (greatly reduces vacuum overhead for slowly-changing
+      tables)
+    - Version-aware psql (backslash commands work against older servers)
+    - Support SSL certificates for user authentication
+    - Per-function runtime statistics
+    - Easy editing of functions in psql
+    - New contrib modules: pg_stat_statements, auto_explain, citext,
+      btree_gin 
+    Upload to unstable, 8.4 is the new default. 
+  * debian/control: Build the versionless metapackages and have them point to
+    8.4.
+
+ -- Martin Pitt <mpitt@debian.org>  Wed, 01 Jul 2009 17:41:41 +0200
+
+postgresql-8.4 (8.4~rc1-1) experimental; urgency=low
+
+  * First release candidate of 8.4.
+
+ -- Martin Pitt <mpitt@debian.org>  Mon, 22 Jun 2009 09:17:52 +0200
+
+postgresql-8.4 (8.4~beta2-2) experimental; urgency=low
+
+  * Second public beta of 8.4.
+  * debian/control: Slightly lower the dependencies for postgresql-common to
+    >= 98~, so that backports also match.
+
+ -- Martin Pitt <mpitt@debian.org>  Tue, 19 May 2009 14:03:37 +0200
+
+postgresql-8.4 (8.4~beta1+cvs20090503-1) experimental; urgency=low
+
+  * New upstream snapshot.
+
+ -- Martin Pitt <mpitt@debian.org>  Tue, 05 May 2009 00:58:06 +0200
+
+postgresql-8.4 (8.4~beta1-1) experimental; urgency=low
+
+  * First public beta of 8.4.
+  * debian/*.install: Add new gettext translations.
+  * debian/control: Bump p-common dependency to >= 98 to ensure support for
+    8.4.
+  * debian/rules: Build with --enable-cassert while in beta.
+
+ -- Martin Pitt <mpitt@debian.org>  Mon, 27 Apr 2009 08:35:30 +0200
+
+postgresql-8.4 (8.4~0cvs20090328-1) experimental; urgency=low
+
+  * Package current trunk, which will become 8.4 in time. Packaging branched
+    from 8.3 packaging trunk. Move from cdbs' tarball.mk to bzr-builddeb.
+  * Drop obsolete patches:
+    - 03-gettext-domains.patch: Adopted upstream.
+    - 04-psql-passwordprompt.patch: Obsoleted by new psql -w option.
+    - 05-check-rlimits-nofile.patch: Adopted upstream.
+  * Update remaining patches for new upstream version.
+  * Add debian/docbook2man-sgmlspl/docbook2man-spec{.pl,_makelinks}: Current
+    Debian version in docbook-utils is way too old and broken (see #275715,
+    #271611), locally ship the current ones from upstream, in order to build
+    manpages.
+  * debian/rules: Build documentation and manpage tarballs if not present (as
+    with building from CVS). Add necessary build dependencies docbook-utils,
+    openjade, and docbook.
+
+ -- Martin Pitt <mpitt@debian.org>  Fri, 20 Mar 2009 12:00:13 +0100
--- postgresql-8.4-8.4.1.orig/debian/postgresql-client-8.4.prerm
+++ postgresql-8.4-8.4.1/debian/postgresql-client-8.4.prerm
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+#DEBHELPER#
+
+VERSION=8.4
+
+if [ "$1" = remove ]; then
+    . /usr/share/postgresql-common/maintscripts-functions
+    remove_client_version $VERSION
+fi
--- postgresql-8.4-8.4.1.orig/debian/libecpg-dev.manpages
+++ postgresql-8.4-8.4.1/debian/libecpg-dev.manpages
@@ -0,0 +1 @@
+debian/tmp/usr/share/postgresql/8.4/man/man1/ecpg.1
--- postgresql-8.4-8.4.1.orig/debian/postgresql-contrib-8.4.postinst
+++ postgresql-8.4-8.4.1/debian/postgresql-contrib-8.4.postinst
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+VERSION=8.4
+
+. /usr/share/postgresql-common/maintscripts-functions
+
+if [ "$1" = configure ]; then
+    configure_contrib_version $VERSION "$2"
+fi
+
+#DEBHELPER#
--- postgresql-8.4-8.4.1.orig/debian/postgresql-plpython-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-plpython-8.4.install
@@ -0,0 +1,2 @@
+usr/lib/postgresql/8.4/lib/plpython.so
+/usr/share/locale/*/*/plpython-*.mo
--- postgresql-8.4-8.4.1.orig/debian/watch
+++ postgresql-8.4-8.4.1/debian/watch
@@ -0,0 +1,2 @@
+version=3
+http://www.postgresql.org/ftp/source/ /ftp/source/v(8\.4.*)/
--- postgresql-8.4-8.4.1.orig/debian/postgresql-contrib-8.4.prerm
+++ postgresql-8.4-8.4.1/debian/postgresql-contrib-8.4.prerm
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+#DEBHELPER#
+
+VERSION=8.4
+
+if [ "$1" = remove ]; then
+    . /usr/share/postgresql-common/maintscripts-functions
+    remove_contrib_version $VERSION
+fi
--- postgresql-8.4-8.4.1.orig/debian/postgresql-client-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-client-8.4.install
@@ -0,0 +1,31 @@
+usr/lib/postgresql/8.4/bin/clusterdb
+usr/lib/postgresql/8.4/bin/pg_dumpall
+usr/lib/postgresql/8.4/bin/pg_dump
+usr/lib/postgresql/8.4/bin/createdb
+usr/lib/postgresql/8.4/bin/createlang
+usr/lib/postgresql/8.4/bin/createuser
+usr/lib/postgresql/8.4/bin/dropdb
+usr/lib/postgresql/8.4/bin/droplang
+usr/lib/postgresql/8.4/bin/dropuser
+usr/lib/postgresql/8.4/bin/reindexdb
+usr/lib/postgresql/8.4/bin/pg_restore
+usr/lib/postgresql/8.4/bin/psql
+usr/lib/postgresql/8.4/bin/vacuumdb
+usr/share/postgresql/8.4/man/man1/pg_restore.1
+usr/share/postgresql/8.4/man/man1/psql.1
+usr/share/postgresql/8.4/man/man1/vacuumdb.1
+usr/share/postgresql/8.4/man/man1/clusterdb.1
+usr/share/postgresql/8.4/man/man1/pg_dump.1
+usr/share/postgresql/8.4/man/man1/pg_dumpall.1
+usr/share/postgresql/8.4/man/man1/createdb.1
+usr/share/postgresql/8.4/man/man1/createlang.1
+usr/share/postgresql/8.4/man/man1/createuser.1
+usr/share/postgresql/8.4/man/man1/dropdb.1
+usr/share/postgresql/8.4/man/man1/droplang.1
+usr/share/postgresql/8.4/man/man1/dropuser.1
+usr/share/postgresql/8.4/man/man1/reindexdb.1
+usr/share/postgresql/8.4/man/man7/*7
+usr/share/postgresql/8.4/psqlrc.sample
+usr/share/locale/*/LC_MESSAGES/pg_dump-8.4.mo
+usr/share/locale/*/LC_MESSAGES/psql-8.4.mo
+usr/share/locale/*/LC_MESSAGES/pgscripts-8.4.mo
--- postgresql-8.4-8.4.1.orig/debian/disable-root-check.patch
+++ postgresql-8.4-8.4.1/debian/disable-root-check.patch
@@ -0,0 +1,36 @@
+diff -Nur postgresql-8.4/build-tree/postgresql-8.4beta1/src/backend/main/main.c postgresql-8.4.new/build-tree/postgresql-8.4beta1/src/backend/main/main.c
+--- postgresql-8.4beta1/src/backend/main/main.c	2006-09-26 00:50:41.000000000 +0200
++++ postgresql-8.4beta1/src/backend/main/main.c	2006-09-26 00:51:43.000000000 +0200
+@@ -326,7 +326,7 @@
+ check_root(const char *progname)
+ {
+ #ifndef WIN32
+-	if (geteuid() == 0)
++	if (0 && geteuid() == 0)
+ 	{
+ 		write_stderr("\"root\" execution of the PostgreSQL server is not permitted.\n"
+ 					 "The server must be started under an unprivileged user ID to prevent\n"
+diff -Nur postgresql-8.4/build-tree/postgresql-8.4beta1/src/bin/initdb/initdb.c postgresql-8.4.new/build-tree/postgresql-8.4beta1/src/bin/initdb/initdb.c
+--- postgresql-8.4beta1/src/bin/initdb/initdb.c	2006-09-26 00:50:41.000000000 +0200
++++ postgresql-8.4beta1/src/bin/initdb/initdb.c	2006-09-26 00:52:09.000000000 +0200
+@@ -636,7 +636,7 @@
+ 
+ 	pw = getpwuid(geteuid());
+ 
+-	if (geteuid() == 0)			/* 0 is root's uid */
++	if (0 && geteuid() == 0)		/* 0 is root's uid */
+ 	{
+ 		fprintf(stderr,
+ 				_("%s: cannot be run as root\n"
+diff -Nur postgresql-8.4/build-tree/postgresql-8.4beta1/src/bin/pg_ctl/pg_ctl.c postgresql-8.4.new/build-tree/postgresql-8.4beta1/src/bin/pg_ctl/pg_ctl.c
+--- postgresql-8.4beta1/src/bin/pg_ctl/pg_ctl.c	2006-09-26 00:50:41.000000000 +0200
++++ postgresql-8.4beta1/src/bin/pg_ctl/pg_ctl.c	2006-09-26 00:52:23.000000000 +0200
+@@ -1517,7 +1517,7 @@
+ 	 * Disallow running as root, to forestall any possible security holes.
+ 	 */
+ #ifndef WIN32
+-	if (geteuid() == 0)
++	if (0 && geteuid() == 0)
+ 	{
+ 		write_stderr(_("%s: cannot be run as root\n"
+ 					   "Please log in (using, e.g., \"su\") as the "
--- postgresql-8.4-8.4.1.orig/debian/libpq5.install
+++ postgresql-8.4-8.4.1/debian/libpq5.install
@@ -0,0 +1,2 @@
+usr/lib/libpq.so.5*
+usr/share/locale/*/LC_MESSAGES/libpq*.mo
--- postgresql-8.4-8.4.1.orig/debian/postgresql-doc-8.4.dirs
+++ postgresql-8.4-8.4.1/debian/postgresql-doc-8.4.dirs
@@ -0,0 +1 @@
+/usr/share/doc/postgresql-doc-8.4/tutorial
--- postgresql-8.4-8.4.1.orig/debian/postgresql-contrib-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-contrib-8.4.install
@@ -0,0 +1,42 @@
+usr/share/doc/postgresql/contrib/* usr/share/doc/postgresql-contrib-8.4
+usr/share/postgresql/8.4/contrib/*
+usr/lib/postgresql/8.4/bin/oid2name
+usr/lib/postgresql/8.4/bin/pgbench
+usr/lib/postgresql/8.4/bin/vacuumlo
+usr/lib/postgresql/8.4/bin/pg_standby
+usr/lib/postgresql/8.4/lib/_int.so
+usr/lib/postgresql/8.4/lib/autoinc.so
+usr/lib/postgresql/8.4/lib/btree_gist.so
+usr/lib/postgresql/8.4/lib/chkpass.so
+usr/lib/postgresql/8.4/lib/cube.so
+usr/lib/postgresql/8.4/lib/dblink.so
+usr/lib/postgresql/8.4/lib/earthdistance.so
+usr/lib/postgresql/8.4/lib/fuzzystrmatch.so
+usr/lib/postgresql/8.4/lib/insert_username.so
+usr/lib/postgresql/8.4/lib/lo.so
+usr/lib/postgresql/8.4/lib/ltree.so
+usr/lib/postgresql/8.4/lib/moddatetime.so
+usr/lib/postgresql/8.4/lib/pageinspect.so
+usr/lib/postgresql/8.4/lib/pg_trgm.so
+usr/lib/postgresql/8.4/lib/pgcrypto.so
+usr/lib/postgresql/8.4/lib/pgstattuple.so
+usr/lib/postgresql/8.4/lib/refint.so
+usr/lib/postgresql/8.4/lib/seg.so
+usr/lib/postgresql/8.4/lib/tablefunc.so
+usr/lib/postgresql/8.4/lib/timetravel.so
+usr/lib/postgresql/8.4/lib/pgxml.so
+usr/lib/postgresql/8.4/lib/pg_buffercache.so
+usr/lib/postgresql/8.4/lib/adminpack.so
+usr/lib/postgresql/8.4/lib/sslinfo.so
+usr/lib/postgresql/8.4/lib/isn.so
+usr/lib/postgresql/8.4/lib/hstore.so
+usr/lib/postgresql/8.4/lib/pgrowlocks.so
+usr/lib/postgresql/8.4/lib/pg_freespacemap.so
+usr/lib/postgresql/8.4/lib/uuid-ossp.so
+usr/lib/postgresql/8.4/lib/test_parser.so
+usr/lib/postgresql/8.4/lib/dict_int.so
+usr/lib/postgresql/8.4/lib/dict_xsyn.so
+usr/lib/postgresql/8.4/lib/auto_explain.so
+usr/lib/postgresql/8.4/lib/pg_stat_statements.so
+usr/lib/postgresql/8.4/lib/citext.so
+usr/lib/postgresql/8.4/lib/btree_gin.so
--- postgresql-8.4-8.4.1.orig/debian/postgresql-8.4.links
+++ postgresql-8.4-8.4.1/debian/postgresql-8.4.links
@@ -0,0 +1 @@
+/usr/share/doc/postgresql-common/README.Debian.gz /usr/share/doc/postgresql-8.4/README.Debian.gz
--- postgresql-8.4-8.4.1.orig/debian/libpq-dev.install
+++ postgresql-8.4-8.4.1/debian/libpq-dev.install
@@ -0,0 +1,19 @@
+usr/include/postgresql/internal/*
+usr/include/postgresql/libpq-fe.h
+usr/include/postgresql/libpq-events.h
+usr/include/postgresql/libpq/libpq-fs.h
+usr/include/postgresql/pg_config*.h
+usr/include/postgresql/postgres_ext.h
+usr/include/postgresql/8.4/server/catalog/pg_type.h /usr/include/postgresql/catalog
+usr/include/postgresql/8.4/server/catalog/genbki.h /usr/include/postgresql/catalog
+usr/include/postgresql/8.4/server/nodes/nodes.h /usr/include/postgresql/nodes
+usr/include/postgresql/8.4/server/utils/{elog,errcodes,palloc}.h /usr/include/postgresql/utils
+usr/include/postgresql/8.4/server/{c,pg_config,pg_config_manual,pg_config_os,port,pg_trace}.h /usr/include/postgresql/
+usr/include/postgresql/8.4/server/postgres{,_fe,_ext}.h /usr/include/postgresql/
+usr/include/postgresql/8.4/server/mb/pg_wchar.h /usr/include/postgresql/mb
+usr/lib/libpgport.a
+usr/lib/libpq.a
+usr/lib/libpq.so
+usr/lib/postgresql/8.4/bin/pg_config usr/bin
+usr/share/postgresql/8.4/man/man1/pg_config.1
+usr/share/locale/*/LC_MESSAGES/pg_config-8.4.mo
--- postgresql-8.4-8.4.1.orig/debian/copyright
+++ postgresql-8.4-8.4.1/debian/copyright
@@ -0,0 +1,110 @@
+This package was debianized by Martin Pitt <mpitt@debian.org>. 
+
+PostgreSQL was downloaded from ftp://ftp.postgresql.org/mirror/postgresql/src/
+
+Please note that there are many other mirrors, listed on
+http://www.postgresql.org/mirrors-ftp.html.
+
+Copyright.  The following copyright applies to the entire distribution:
+
+  PostgreSQL Data Base Management System
+  (formerly known as Postgres, then as Postgres95).
+  
+  Portions Copyright (c) 1996-2003, The PostgreSQL Global Development Group
+
+  Portions Copyright (c) 1994, The Regents of the University of California
+  
+  Permission to use, copy, modify, and distribute this software and its
+  documentation for any purpose, without fee, and without a written agreement
+  is hereby granted, provided that the above copyright notice and this
+  paragraph and the following two paragraphs appear in all copies.
+  
+  IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+  LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
+  DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+  
+  THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+  AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+  ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
+  PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+
+The following copyright applies to the regex code in the backend
+(src/backend/regex):
+
+  Copyright (c) 1998, 1999 Henry Spencer.  All rights reserved.
+  
+  Development of this software was funded, in part, by Cray Research Inc.,
+  UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
+  Corporation, none of whom are responsible for the results.  The author
+  thanks all of them. 
+  
+  Redistribution and use in source and binary forms -- with or without
+  modification -- are permitted for any purpose, provided that
+  redistributions in source form retain this entire copyright notice and
+  indicate the origin and nature of any modifications.
+  
+  I'd appreciate being given credit for this package in the documentation
+  of software which uses it, but that is not a requirement.
+  
+  THIS SOFTWARE IS PROVIDED ``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
+  HENRY SPENCER 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.
+
+PostgreSQL adopted the code out of Tcl 8.4.1.  Portions of regc_locale.c
+and re_syntax.n were developed by Tcl developers other than Henry; these
+files bear the Tcl copyright and license notice:
+
+  This software is copyrighted by the Regents of the University of
+  California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState
+  Corporation and other parties.  The following terms apply to all files
+  associated with the software unless explicitly disclaimed in
+  individual files.
+  
+  The authors hereby grant permission to use, copy, modify, distribute,
+  and license this software and its documentation for any purpose, provided
+  that existing copyright notices are retained in all copies and that this
+  notice is included verbatim in any distributions. No written agreement,
+  license, or royalty fee is required for any of the authorized uses.
+  Modifications to this software may be copyrighted by their authors
+  and need not follow the licensing terms described here, provided that
+  the new terms are clearly indicated on the first page of each file where
+  they apply.
+  
+  IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+  FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+  ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+  DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+  
+  THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+  IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+  NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+  MODIFICATIONS.
+  
+  GOVERNMENT USE: If you are acquiring this software on behalf of the
+  U.S. government, the Government shall have only "Restricted Rights"
+  in the software and related documentation as defined in the Federal 
+  Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
+  are acquiring the software on behalf of the Department of Defense, the
+  software shall be classified as "Commercial Computer Software" and the
+  Government shall have only "Restricted Rights" as defined in Clause
+  252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
+  authors grant the U.S. Government and others acting in its behalf
+  permission to use and distribute the software in accordance with the
+  terms specified in this license. 
+
+Subsequent modifications to the code by the PostgreSQL project follow
+the same license terms as the rest of PostgreSQL.
--- postgresql-8.4-8.4.1.orig/debian/postgresql-8.4.postinst
+++ postgresql-8.4-8.4.1/debian/postgresql-8.4.postinst
@@ -0,0 +1,24 @@
+#!/bin/sh -e
+
+VERSION=8.4
+
+
+if [ "$1" = configure ]; then
+    # fix init script stop priority on upgrades
+    if dpkg --compare-versions "$2" le-nl "8.4~rc2-1"; then
+        echo "Fixing init script priorities..."
+        for l in 0 1 6; do
+            old=/etc/rc$l.d/K19postgresql-8.4
+            new=/etc/rc$l.d/K21postgresql-8.4
+            if [ -e $old ] && ! [ -e $new ]; then
+                mv $old $new
+            fi
+        done
+    fi
+
+    . /usr/share/postgresql-common/maintscripts-functions
+
+    configure_version $VERSION "$2"
+fi
+
+#DEBHELPER#
--- postgresql-8.4-8.4.1.orig/debian/postgresql-doc-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-doc-8.4.install
@@ -0,0 +1 @@
+usr/share/doc/postgresql/html usr/share/doc/postgresql-doc-8.4/
--- postgresql-8.4-8.4.1.orig/debian/libecpg-dev.install
+++ postgresql-8.4-8.4.1/debian/libecpg-dev.install
@@ -0,0 +1,12 @@
+usr/include/postgresql/ecpg*.h
+usr/include/postgresql/informix/*
+usr/include/postgresql/pgtypes_*.h
+usr/include/postgresql/sql3types.h
+usr/include/postgresql/sqlca.h
+usr/lib/postgresql/8.4/bin/ecpg usr/bin
+usr/lib/libecpg.so
+usr/lib/libecpg_compat.so
+usr/lib/libpgtypes.so
+usr/lib/libecpg.a
+usr/lib/libecpg_compat.a
+usr/lib/libpgtypes.a
--- postgresql-8.4-8.4.1.orig/debian/pycompat
+++ postgresql-8.4-8.4.1/debian/pycompat
@@ -0,0 +1 @@
+2
--- postgresql-8.4-8.4.1.orig/debian/compat
+++ postgresql-8.4-8.4.1/debian/compat
@@ -0,0 +1 @@
+5
--- postgresql-8.4-8.4.1.orig/debian/postgresql-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-8.4.install
@@ -0,0 +1,30 @@
+usr/lib/postgresql/8.4/bin/initdb
+usr/lib/postgresql/8.4/bin/pg_controldata
+usr/lib/postgresql/8.4/bin/pg_ctl
+usr/lib/postgresql/8.4/bin/pg_resetxlog
+usr/lib/postgresql/8.4/bin/postgres
+usr/lib/postgresql/8.4/bin/postmaster
+usr/lib/postgresql/8.4/lib/*_and_*.so
+usr/lib/postgresql/8.4/lib/plpgsql.so
+usr/lib/postgresql/8.4/lib/dict_snowball.so
+usr/lib/postgresql/8.4/lib/tsearch2.so
+usr/share/locale/*/LC_MESSAGES/initdb-8.4.mo
+usr/share/locale/*/LC_MESSAGES/pg_controldata-8.4.mo
+usr/share/locale/*/LC_MESSAGES/pg_ctl-8.4.mo
+usr/share/locale/*/LC_MESSAGES/pg_resetxlog-8.4.mo
+usr/share/locale/*/LC_MESSAGES/postgres-8.4.mo
+usr/share/locale/*/LC_MESSAGES/plpgsql-8.4.mo
+usr/share/postgresql/8.4/man/man1/initdb.1
+usr/share/postgresql/8.4/man/man1/pg_controldata.1
+usr/share/postgresql/8.4/man/man1/pg_ctl.1
+usr/share/postgresql/8.4/man/man1/pg_resetxlog.1
+usr/share/postgresql/8.4/man/man1/postgres.1
+usr/share/postgresql/8.4/man/man1/postmaster.1
+usr/share/postgresql/8.4/timezonesets/*
+usr/share/postgresql/8.4/tsearch_data
+usr/share/postgresql/8.4/*.sql
+usr/share/postgresql/8.4/*.conf.sample
+usr/share/postgresql/8.4/postgres.bki
+usr/share/postgresql/8.4/postgres.description
+usr/share/postgresql/8.4/postgres.shdescription
+usr/share/postgresql/8.4/sql_features.txt
--- postgresql-8.4-8.4.1.orig/debian/postgresql-client-8.4.postinst
+++ postgresql-8.4-8.4.1/debian/postgresql-client-8.4.postinst
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+VERSION=8.4
+
+. /usr/share/postgresql-common/maintscripts-functions
+
+if [ "$1" = configure ]; then
+    configure_client_version $VERSION "$2"
+fi
+
+#DEBHELPER#
--- postgresql-8.4-8.4.1.orig/debian/postgresql-pltcl-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-pltcl-8.4.install
@@ -0,0 +1,4 @@
+usr/lib/postgresql/8.4/lib/pltcl.so
+usr/lib/postgresql/8.4/bin/pltcl_*
+usr/share/postgresql/8.4/unknown.pltcl
+/usr/share/locale/*/*/pltcl-*.mo
--- postgresql-8.4-8.4.1.orig/debian/libpgtypes3.install
+++ postgresql-8.4-8.4.1/debian/libpgtypes3.install
@@ -0,0 +1 @@
+usr/lib/libpgtypes.so.3*
--- postgresql-8.4-8.4.1.orig/debian/postgresql-plperl-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-plperl-8.4.install
@@ -0,0 +1,2 @@
+usr/lib/postgresql/8.4/lib/plperl.so
+/usr/share/locale/*/*/plperl-*.mo
--- postgresql-8.4-8.4.1.orig/debian/postgresql-8.4.prerm
+++ postgresql-8.4-8.4.1/debian/postgresql-8.4.prerm
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+VERSION=8.4
+
+#DEBHELPER#
+
+if [ "$1" = remove ]; then
+    . /usr/share/postgresql-common/maintscripts-functions
+    remove_version $VERSION
+fi
+
--- postgresql-8.4-8.4.1.orig/debian/postgresql-8.4.postrm
+++ postgresql-8.4-8.4.1/debian/postgresql-8.4.postrm
@@ -0,0 +1,60 @@
+#!/bin/sh -e
+
+#DEBHELPER#
+
+VERSION=8.4
+
+clean_dir() {
+    if [ -d "$1" ] && [ ! -L "$1" ]; then
+        rmdir "$1" >/dev/null 2>/dev/null || true
+    fi
+}
+
+drop_cluster() {
+    # if we still have the postgresql-common package, use it to also shutdown
+    # server, etc.; otherwise just remove the directories
+    if [ -x /usr/bin/pg_dropcluster ]; then
+        pg_dropcluster --stop-server $VERSION "$1"
+    else
+        # remove data directory
+        PGDATALINK="/etc/postgresql/$VERSION/$1/pgdata"
+        if [ -e "$PGDATALINK" ]; then
+            rm -rf $(readlink -f "$PGDATALINK") "$PGDATALINK"
+        else
+            rm -rf "/var/lib/postgresql/$VERSION/$1/"
+        fi
+
+        # remove log file, including rotated ones
+        LOGLINK="/etc/postgresql/$VERSION/$1/log"
+        if [ -e "$LOGLINK" ]; then
+            LOG=$(readlink -f "$LOGLINK")
+            rm -f $LOG* "$LOGLINK"
+        else
+            rm -f /var/log/postgresql/postgresql-$VERSION-"$1".log*
+        fi
+
+        # remove conffiles
+        for f in pg_hba.conf pg_ident.conf postgresql.conf start.conf environment; do
+            rm -f /etc/postgresql/$VERSION/"$1"/$f
+        done
+
+        clean_dir /etc/postgresql/$VERSION/"$1"
+    fi
+}
+
+if [ "$1" = purge ]; then
+    [ -d "/etc/postgresql/$VERSION" ] || exit 0
+    if [ "$(ls /etc/postgresql/$VERSION)" ]; then
+        for c in /etc/postgresql/$VERSION/*; do
+            [ -e "$c/postgresql.conf" ] || continue
+            cluster=$(basename "$c")
+            echo "Dropping cluster $cluster..."
+            drop_cluster "$cluster"
+        done
+    fi
+
+    clean_dir /etc/postgresql/$VERSION
+    clean_dir /etc/postgresql
+    clean_dir /var/lib/postgresql/$VERSION
+    clean_dir /var/lib/postgresql
+fi
--- postgresql-8.4-8.4.1.orig/debian/libecpg-compat3.install
+++ postgresql-8.4-8.4.1/debian/libecpg-compat3.install
@@ -0,0 +1 @@
+usr/lib/libecpg_compat.so.3*
--- postgresql-8.4-8.4.1.orig/debian/postgresql-server-dev-8.4.install
+++ postgresql-8.4-8.4.1/debian/postgresql-server-dev-8.4.install
@@ -0,0 +1,3 @@
+usr/include/postgresql/8.4/*
+usr/lib/postgresql/8.4/lib/pgxs/*
+usr/lib/postgresql/8.4/bin/pg_config
--- postgresql-8.4-8.4.1.orig/debian/libpq-dev.manpages
+++ postgresql-8.4-8.4.1/debian/libpq-dev.manpages
@@ -0,0 +1 @@
+debian/tmp/usr/share/postgresql/8.4/man/man1/pg_config.1
--- postgresql-8.4-8.4.1.orig/debian/postgresql-8.4.init
+++ postgresql-8.4-8.4.1/debian/postgresql-8.4.init
@@ -0,0 +1,46 @@
+#!/bin/sh -e
+
+### BEGIN INIT INFO
+# Provides:		postgresql postgresql-8.4
+# Required-Start:	$local_fs $remote_fs $network $time
+# Required-Stop:	$local_fs $remote_fs $network $time
+# Should-Start:		$syslog
+# Should-Stop:		$syslog
+# Default-Start:	2 3 4 5
+# Default-Stop:		0 1 6
+# Short-Description:	PostgreSQL 8.4 RDBMS server
+### END INIT INFO
+
+# Setting environment variables for the postmaster here does not work; please
+# set them in /etc/postgresql/8.4/<cluster>/environment instead.
+
+[ -r /usr/share/postgresql-common/init.d-functions ] || exit 0
+
+. /usr/share/postgresql-common/init.d-functions
+
+VERSION=8.4
+
+case "$1" in
+    start)
+        start $VERSION
+        ;;
+    stop)
+        stop "$VERSION"
+        ;;
+    restart)
+	restart "$VERSION"
+        ;;
+    force-reload | reload)
+        reload $VERSION
+        ;;
+    status)
+        status $VERSION
+	;;
+    *)
+        echo "Usage: $0 {start|stop|restart|reload|force-reload|status|autovac-start|autovac-stop|autovac-restart}"
+        exit 1
+        ;;
+esac
+
+exit 0
+
--- postgresql-8.4-8.4.1.orig/debian/libpq5.shlibs
+++ postgresql-8.4-8.4.1/debian/libpq5.shlibs
@@ -0,0 +1 @@
+libpq 5 libpq5 (>= 8.4~0cvs20090328)
--- postgresql-8.4-8.4.1.orig/debian/patches/11-pg_regress-socketpath.patch
+++ postgresql-8.4-8.4.1/debian/patches/11-pg_regress-socketpath.patch
@@ -0,0 +1,42 @@
+diff -Nur -x '*.orig' -x '*~' postgresql-8.4-8.4~0cvs20090328/src/test/regress/pg_regress.c postgresql-8.4-8.4~0cvs20090328.new/src/test/regress/pg_regress.c
+--- postgresql-8.4-8.4~0cvs20090328/src/test/regress/pg_regress.c	2009-03-28 23:04:14.000000000 +0100
++++ postgresql-8.4-8.4~0cvs20090328.new/src/test/regress/pg_regress.c	2009-03-28 23:32:54.660811088 +0100
+@@ -888,7 +888,7 @@
+ 
+ 	/* And now we can build and execute the shell command */
+ 	snprintf(psql_cmd, sizeof(psql_cmd),
+-			 SYSTEMQUOTE "\"%s%spsql\" -X -c \"%s\" \"%s\"" SYSTEMQUOTE,
++			 SYSTEMQUOTE "\"%s%spsql\" -h /tmp -X -c \"%s\" \"%s\"" SYSTEMQUOTE,
+ 			 psqldir ? psqldir : "",
+ 			 psqldir ? "/" : "",
+ 			 query_escaped,
+@@ -2122,7 +2122,7 @@
+ 		 * Check if there is a postmaster running already.
+ 		 */
+ 		snprintf(buf2, sizeof(buf2),
+-				 SYSTEMQUOTE "\"%s/psql\" -X postgres <%s 2>%s" SYSTEMQUOTE,
++				 SYSTEMQUOTE "\"%s/psql\" -h /tmp -X postgres <%s 2>%s" SYSTEMQUOTE,
+ 				 bindir, DEVNULL, DEVNULL);
+ 
+ 		for (i = 0; i < 16; i++)
+@@ -2154,7 +2154,7 @@
+ 		 */
+ 		header(_("starting postmaster"));
+ 		snprintf(buf, sizeof(buf),
+-				 SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
++				 SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -k /tmp -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
+ 				 bindir, temp_install,
+ 				 debug ? " -d 5" : "",
+ 				 hostname ? hostname : "",
+diff -Nur -x '*.orig' -x '*~' postgresql-8.4-8.4~0cvs20090328/src/test/regress/pg_regress_main.c postgresql-8.4-8.4~0cvs20090328.new/src/test/regress/pg_regress_main.c
+--- postgresql-8.4-8.4~0cvs20090328/src/test/regress/pg_regress_main.c	2009-03-28 23:04:14.000000000 +0100
++++ postgresql-8.4-8.4~0cvs20090328.new/src/test/regress/pg_regress_main.c	2009-03-28 23:31:22.307182553 +0100
+@@ -59,7 +59,7 @@
+ 	add_stringlist_item(expectfiles, expectfile);
+ 
+ 	snprintf(psql_cmd, sizeof(psql_cmd),
+-			 SYSTEMQUOTE "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
++			 SYSTEMQUOTE "\"%s%spsql\" -h /tmp -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
+ 			 psqldir ? psqldir : "",
+ 			 psqldir ? "/" : "",
+ 			 dblist->str,
--- postgresql-8.4-8.4.1.orig/debian/patches/12-psql-sensible-editor.patch
+++ postgresql-8.4-8.4.1/debian/patches/12-psql-sensible-editor.patch
@@ -0,0 +1,11 @@
+--- postgresql-8.3beta3/src/bin/psql/settings.h	2007-01-05 23:19:49.000000000 +0100
++++ postgresql-8.3beta3/src/bin/psql/settings.h	2007-11-21 17:10:38.000000000 +0100
+@@ -19,7 +19,7 @@
+ #if defined(WIN32) || defined(__CYGWIN__)
+ #define DEFAULT_EDITOR	"notepad.exe"
+ #else
+-#define DEFAULT_EDITOR	"vi"
++#define DEFAULT_EDITOR	"sensible-editor"
+ #endif
+ 
+ #define DEFAULT_PROMPT1 "%/%R%# "
--- postgresql-8.4-8.4.1.orig/debian/patches/01-build-contrib.patch
+++ postgresql-8.4-8.4.1/debian/patches/01-build-contrib.patch
@@ -0,0 +1,25 @@
+diff -Nur postgresql-8.2/build-tree/postgresql-8.2beta1/GNUmakefile.in postgresql-8.2.new/build-tree/postgresql-8.2beta1/GNUmakefile.in
+--- postgresql-8.2beta1/GNUmakefile.in	2006-08-18 21:58:05.000000000 +0200
++++ postgresql-8.2beta1/GNUmakefile.in	2006-09-25 19:15:34.000000000 +0200
+@@ -12,18 +14,21 @@
+ 	$(MAKE) -C doc all
+ 	$(MAKE) -C src all
+ 	$(MAKE) -C config all
++	$(MAKE) -C contrib all
+ 	@echo "All of PostgreSQL successfully made. Ready to install."
+ 
+ install:
+ 	$(MAKE) -C doc $@
+ 	$(MAKE) -C src $@
+ 	$(MAKE) -C config $@
++	$(MAKE) -C contrib $@
+ 	@echo "PostgreSQL installation complete."
+ 
+ installdirs uninstall:
+ 	$(MAKE) -C doc $@
+ 	$(MAKE) -C src $@
+ 	$(MAKE) -C config $@
++	$(MAKE) -C contrib $@
+ 
+ distprep:
+ 	$(MAKE) -C doc $@
--- postgresql-8.4-8.4.1.orig/debian/patches/07-relax-sslkey-permscheck.patch
+++ postgresql-8.4-8.4.1/debian/patches/07-relax-sslkey-permscheck.patch
@@ -0,0 +1,21 @@
+diff -Nur -x '*.orig' -x '*~' postgresql-8.4-8.4~rc1/src/backend/libpq/be-secure.c postgresql-8.4-8.4~rc1.new/src/backend/libpq/be-secure.c
+--- postgresql-8.4-8.4~rc1/src/backend/libpq/be-secure.c	2009-06-11 16:48:58.000000000 +0200
++++ postgresql-8.4-8.4~rc1.new/src/backend/libpq/be-secure.c	2009-06-22 07:49:45.873269466 +0200
+@@ -751,12 +751,15 @@
+ 		 * directory permission check in postmaster.c)
+ 		 */
+ #if !defined(WIN32) && !defined(__CYGWIN__)
+-		if (!S_ISREG(buf.st_mode) || buf.st_mode & (S_IRWXG | S_IRWXO))
++		if (!S_ISREG(buf.st_mode) || (buf.st_mode & (S_IWGRP | S_IRWXO)) ||
++			(buf.st_uid != geteuid()) && buf.st_uid != 0)
+ 			ereport(FATAL,
+ 					(errcode(ERRCODE_CONFIG_FILE_ERROR),
+ 				  errmsg("private key file \"%s\" has group or world access",
+ 						 SERVER_PRIVATE_KEY_FILE),
+-				   errdetail("Permissions should be u=rw (0600) or less.")));
++					 errdetail("File must be owned by the \
++database user or root, must have no write permission for \"group\", and must \
++have no permissions for \"other\".")));
+ #endif
+ 
+ 		if (SSL_CTX_use_PrivateKey_file(SSL_context,
--- postgresql-8.4-8.4.1.orig/debian/patches/09-server-includedir.patch
+++ postgresql-8.4-8.4.1/debian/patches/09-server-includedir.patch
@@ -0,0 +1,12 @@
+diff -ruN postgresql-8.2.0-old/src/Makefile.global.in postgresql-8.2.0/src/Makefile.global.in
+--- postgresql-8.2.0-old/src/Makefile.global.in	2005-11-05 18:54:55.000000000 -0500
++++ postgresql-8.2.0/src/Makefile.global.in	2005-11-05 18:55:59.000000000 -0500
+@@ -133,7 +133,7 @@
+ 
+ # These derived path variables aren't separately configurable.
+ 
+-includedir_server = $(pkgincludedir)/server
++includedir_server = $(pkgincludedir)/8.4/server
+ includedir_internal = $(pkgincludedir)/internal
+ pgxsdir = $(pkglibdir)/pgxs
+ 
--- postgresql-8.4-8.4.1.orig/debian/patches/02-pager.patch
+++ postgresql-8.4-8.4.1/debian/patches/02-pager.patch
@@ -0,0 +1,12 @@
+diff -Nur postgresql-8.2/build-tree/postgresql-8.2beta1/src/bin/psql/print.h postgresql-8.2.new/build-tree/postgresql-8.2beta1/src/bin/psql/print.h
+--- postgresql-8.2beta1/src/bin/psql/print.h	2006-08-30 00:25:07.000000000 +0200
++++ postgresql-8.2beta1/src/bin/psql/print.h	2006-09-25 19:18:54.000000000 +0200
+@@ -89,7 +89,7 @@
+ void		setDecimalLocale(void);
+ 
+ #ifndef __CYGWIN__
+-#define DEFAULT_PAGER "more"
++#define DEFAULT_PAGER "/usr/bin/pager"
+ #else
+ #define DEFAULT_PAGER "less"
+ #endif
--- postgresql-8.4-8.4.1.orig/debian/patches/10-tutorial-README.patch
+++ postgresql-8.4-8.4.1/debian/patches/10-tutorial-README.patch
@@ -0,0 +1,13 @@
+diff -ruN postgresql-8.2.3-old/src/tutorial/README postgresql-8.2.3/src/tutorial/README
+--- postgresql-8.2.3-old/src/tutorial/README	2001-10-26 22:45:33.000000000 +0200
++++ postgresql-8.2.3/src/tutorial/README	2006-04-10 22:17:29.000000000 +0200
+@@ -1,8 +1,7 @@
+ This directory contains SQL tutorial scripts.  To look at them, first do a
+ 	% make
+ to compile all the scripts and C files for the user-defined functions
+-and types.  (make needs to be GNU make --- it may be named something
+-different on your system, often gmake)
++and types. This requires postgresql-server-dev-8.4 to be installed.
+ 
+ Then, run psql with the -s (single-step) flag:
+ 	% psql -s
--- postgresql-8.4-8.4.1.orig/debian/patches/14-pg_config-paths.patch
+++ postgresql-8.4-8.4.1/debian/patches/14-pg_config-paths.patch
@@ -0,0 +1,26 @@
+--- postgresql-8.3.0/src/bin/pg_config/pg_config.c	2008-02-03 12:12:01.000000000 +0100
++++ postgresql-8.3.0/src/bin/pg_config/pg_config.c	2008-02-03 12:13:09.000000000 +0100
+@@ -26,6 +26,8 @@
+ 
+ #include "port.h"
+ 
++#include "../port/pg_config_paths.h"
++
+ static const char *progname;
+ static char mypath[MAXPGPATH];
+ 
+@@ -465,13 +467,7 @@
+ 		}
+ 	}
+ 
+-	ret = find_my_exec(argv[0], mypath);
+-
+-	if (ret)
+-	{
+-		fprintf(stderr, _("%s: could not find own program executable\n"), progname);
+-		exit(1);
+-	}
++	snprintf(mypath, sizeof(mypath), "%s/%s", PGBINDIR, progname);
+ 
+ 	/* no arguments -> print everything */
+ 	if (argc < 2)
--- postgresql-8.4-8.4.1.orig/debian/patches/08-pkglibdir.patch
+++ postgresql-8.4-8.4.1/debian/patches/08-pkglibdir.patch
@@ -0,0 +1,12 @@
+diff -ruN postgresql-8.2beta4-old/src/Makefile.global.in postgresql-8.2beta4/src/Makefile.global.in
+--- postgresql-8.2beta4-old/src/Makefile.global.in	2005-09-27 18:39:32.000000000 +0100
++++ postgresql-8.2beta4/src/Makefile.global.in	2005-10-26 20:40:52.000000000 +0100
+@@ -89,7 +89,7 @@
+ pkglibdir = $(libdir)
+ ifeq "$(findstring pgsql, $(pkglibdir))" ""
+ ifeq "$(findstring postgres, $(pkglibdir))" ""
+-override pkglibdir := $(pkglibdir)/postgresql
++override pkglibdir := $(pkglibdir)/postgresql/8.4/lib
+ endif
+ endif
+ 
--- postgresql-8.4-8.4.1.orig/debian/patches/15-dict-fallback-dir.patch
+++ postgresql-8.4-8.4.1/debian/patches/15-dict-fallback-dir.patch
@@ -0,0 +1,43 @@
+# Description: If a tsearch/stem dictionary is not found in sharedir/tsearch_data/ll_cc.{dict,affix}, fall back to sharedir/tsearch_data/system_ll_cc.{dict,affix}, where postgresql-common creates them from system directories.
+# Ubuntu: https://launchpad.net/bugs/301770
+--- postgresql-8.3.5/src/backend/tsearch/ts_utils.c	2008-06-19 09:52:31.000000000 -0700
++++ postgresql-8.3.5/src/backend/tsearch/ts_utils.c	2008-12-05 12:48:02.000000000 -0800
+@@ -15,6 +15,7 @@
+ #include "postgres.h"
+ 
+ #include <ctype.h>
++#include <unistd.h>
+ 
+ #include "miscadmin.h"
+ #include "tsearch/ts_locale.h"
+@@ -36,7 +37,7 @@
+ 							const char *extension)
+ {
+ 	char		sharepath[MAXPGPATH];
+-	char	   *result;
++	char	   *result, *system_result;
+ 
+ 	/*
+ 	 * We limit the basename to contain a-z, 0-9, and underscores.	This may
+@@ -58,6 +59,21 @@
+ 	snprintf(result, MAXPGPATH, "%s/tsearch_data/%s.%s",
+ 			 sharepath, basename, extension);
+ 
++	/* fall back to a system-supplied one */
++	if (access(result, R_OK) != 0)
++	{
++		system_result = palloc(MAXPGPATH);
++		snprintf(system_result, MAXPGPATH, "%s/tsearch_data/system_%s.%s",
++			 sharepath, basename, extension);
++		if (access(system_result, R_OK) == 0)
++		{
++			pfree(result);
++			result = system_result;
++		} 
++		else
++			pfree(system_result);
++	}
++
+ 	return result;
+ }
+ 
--- postgresql-8.4-8.4.1.orig/debian/patches/13-pg_service.conf_directory_doc.patch
+++ postgresql-8.4-8.4.1/debian/patches/13-pg_service.conf_directory_doc.patch
@@ -0,0 +1,13 @@
+--- postgresql-8.3RC2/src/interfaces/libpq/pg_service.conf.sample	2007-09-14 16:31:22.000000000 +0200
++++ postgresql-8.3RC2/src/interfaces/libpq/pg_service.conf.sample	2008-01-19 17:24:45.000000000 +0100
+@@ -8,8 +8,8 @@
+ # to look up such parameters.  A sample configuration for postgres is 
+ # included in this file.  Lines beginning with '#' are comments.
+ #
+-# Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
+-# rename it pg_service.conf.
++# Copy this to /etc/postgresql-common/ (or select its location with the
++# PGSYSCONFDIR environment variable) and rename it pg_service.conf.
+ #
+ #
+ #[postgres]
--- postgresql-8.4-8.4.1.orig/debian/patches/06-libpq-defaultsocketdir.patch
+++ postgresql-8.4-8.4.1/debian/patches/06-libpq-defaultsocketdir.patch
@@ -0,0 +1,12 @@
+diff -ruN postgresql-8.2.3-old/src/include/pg_config_manual.h postgresql-8.2.3/src/include/pg_config_manual.h
+--- postgresql-8.2.3-old/src/include/pg_config_manual.h	2004-09-10 16:27:37.000000000 +0200
++++ postgresql-8.2.3/src/include/pg_config_manual.h	2005-06-14 19:21:28.200000000 +0200
+@@ -160,7 +160,7 @@
+  * here's where to twiddle it.  You can also override this at runtime
+  * with the postmaster's -k switch.
+  */
+-#define DEFAULT_PGSOCKET_DIR  "/tmp"
++#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
+ 
+ /*
+  * The random() function is expected to yield values between 0 and
--- postgresql-8.4-8.4.1.orig/debian/docbook2man-sgmlspl/docbook2man-spec.pl
+++ postgresql-8.4-8.4.1/debian/docbook2man-sgmlspl/docbook2man-spec.pl
@@ -0,0 +1,1546 @@
+=head1 NAME
+
+docbook2man-spec.pl - convert DocBook RefEntries to Unix manpages
+
+=head1 SYNOPSIS
+
+The sgmlspl script from the SGMLSpm Perl module must be used to run
+this script.  Use it like this:
+
+nsgmls some-docbook-document.sgml | sgmlspl docbook2man-spec.pl
+
+See man page or included DocBook documentation for details.
+
+=head1 DESCRIPTION
+
+This is a sgmlspl spec file that produces Unix-style
+man pages from DocBook RefEntry markup.
+
+=head1 COPYRIGHT
+
+Copyright (C) 1998-2001 Steve Cheng <stevecheng@users.sourceforge.net>
+
+Copyright (C) 1999 Thomas Lockhart <lockhart@alumni.caltech.edu>
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+You should have received a copy of the GNU General Public License along with
+this program; see the file COPYING.  If not, please write to the Free
+Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+=cut
+
+# $Id: docbook2man-spec.pl,v 1.1.1.1 2001/09/06 18:37:06 stevecheng Exp $
+
+use SGMLS;			# Use the SGMLS package.
+use SGMLS::Output;		# Use stack-based output.
+use SGMLS::Refs;
+
+
+########################################################################
+# SGMLSPL script produced automatically by the script sgmlspl.pl
+#
+# Document Type: any, but processes only RefEntries
+# Edited by: me :)
+########################################################################
+
+
+$write_manpages = 0;
+$blank_xrefs = 0;
+
+$default_sect = "1";
+$default_date = `date "+%d %B %Y"`;
+$cite_numeral_only = 1;
+
+while (@ARGV) {
+	my $arg = shift @ARGV;
+	if ($arg eq "--section") {
+		$default_sect = shift @ARGV || die "$arg requires an argument\n";
+	} elsif ($arg eq "--date") {
+		$default_date = shift @ARGV || die "$arg requires an argument\n";
+	} elsif ($arg eq "--lowercase") {
+		$lowercase_names = 1;
+	} elsif ($arg eq "--preserve-case") {
+		$lowercase_names = 0;
+	} elsif ($arg eq "--cite-numeral-only") {
+		$cite_numeral_only = 1;
+	} elsif ($arg eq "--nocite-numeral-only") {
+		$cite_numeral_only = 0;
+	} elsif ($arg eq "--help") {
+		print "Usage: $0",
+			" [ --section <label> ]",
+			" [ --date <string> ]",
+			" [ --lowercase | --preserve-case ]",
+			" [ --cite-numeral-only | --nocite-numeral-only ]",
+			"\n";
+		exit;
+	} else {
+		die "unrecognized switch $arg; try $0 --help\n";
+	}
+}
+
+sgml('start', sub { 
+	push_output('nul');
+	$raw_cdata = 1;			# Makes it a bit faster.
+	
+	# Links file
+	open(LINKSFILE, ">manpage.links");
+
+	$Refs = new SGMLS::Refs("manpage.refs", "manpage.log");
+});
+sgml('end', sub {
+	close(LINKSFILE);
+
+	# Explicitly invoke destructor,
+	# otherwise cache file may not get written!
+	# Thomas Lockhart, 1999-08-03, perl-5.004, RedHat5.2
+	undef $Refs;
+
+	if($blank_xrefs) {
+		warn "Warning: output contains unresolved XRefs\n";
+	}
+});
+
+
+########################################################################
+#
+# Output helpers 
+#
+########################################################################
+
+# Remove leading and trailing blanks.
+
+sub StripString
+{
+	my $str = shift;
+
+	$str = $1 if ($str =~ m#^\s*(\S.*)#);
+	$str = $1 if ($str =~ m#^(.*\S)\s*$#);
+
+	return $str;
+}
+
+# Generate a good file name, for given manpage title and manvolnum
+# (cdata content).
+# Cleanup whitespace and convert to lower case if required.
+
+sub FileInfo
+{
+	my $title = StripString(shift);
+	my $volnum = StripString(shift);
+
+	$title = lc $title if $lowercase_names;
+
+	$title =~ tr/ /_/;
+	$volnum =~ tr/ /_/;
+
+	my $sectcite = $volnum;
+	# The 'package name' part of the section should
+	# not be used when citing it.
+	if ($cite_numeral_only) {
+		$sectcite = $1 if ($volnum =~ /^([0-9]+)/);
+	}
+	
+	return ("$title.$volnum", "$title($sectcite)");
+}
+
+# Our own version of sgml() and output() to allow simple string output
+# to play well with roff's stupid whitespace rules. 
+
+sub man_sgml
+{
+	if(ref($_[1]) eq 'CODE') {
+		return &sgml;
+	}
+	
+	my $s = $_[1];
+	$s =~ s/\\/\\\\/g;
+	$s =~ s/'/\\'/g;
+
+	sgml($_[0], eval("sub { man_output '$s' }"));
+}
+
+sub man_output
+{
+	if($separator eq 'full') {
+		output "\n" unless $newline_last++;
+		output ".PP\n";
+		$separator = '';
+	}
+	
+	$_ = shift;
+	if(s/^\n//) {
+		output "\n" unless $newline_last++;
+	}
+	return if $_ eq '';
+	
+	output $_;
+
+	if(@_) {
+		output @_;
+		$newline_last = (pop(@_) =~ /\n$/);
+	} else {
+		$newline_last = ($_ =~ /\n$/)
+	}
+}
+
+# Fold lines into one, quote some characters
+sub fold_string
+{
+	$_ = shift;
+	
+	s/\\/\\\\/g;
+	s/"/\\\&"/g;
+
+	# Change tabs and newlines to spaces
+	# The newlines will be swallowed later while trimming
+	tr/[\t\n]/  /;
+
+	# Trim whitespace from beginning and end.
+	s/^ +//;
+	s/ +$//;
+
+	return $_;
+}
+	
+sub save_cdata()
+{
+	$raw_cdata++;
+	push_output('string');
+}
+
+sub bold_on()
+{
+	# If the last font is also bold, don't change anything.
+	# Basically this is to just get more readable man output.
+	if($fontstack[$#fontstack] ne 'bold') {
+		if(!$raw_cdata) {
+			output '\fB';
+			#$newline_last = 0;
+		}
+	}
+	push(@fontstack, 'bold');
+}
+
+sub italic_on()
+{
+	# If the last font is also italic, don't change anything.
+	if($fontstack[$#fontstack] ne 'italic') {
+		if(!$raw_cdata) {
+			output '\fI';
+			#$newline_last = 0;
+		}
+	}
+	push(@fontstack, 'italic');
+}
+
+sub font_off()
+{
+	my $thisfont = pop(@fontstack);
+	my $lastfont = $fontstack[$#fontstack];
+	
+	# Only output font change if it is different
+	if($thisfont ne $lastfont) {
+		if($raw_cdata)			{ return; }
+		elsif($lastfont eq 'bold') 	{ output '\fB'; }
+		elsif($lastfont eq 'italic')	{ output '\fI'; }
+		else				{ output '\fR'; }
+	
+		#$newline_last = 0;
+	}
+}
+
+
+########################################################################
+#
+# Manpage management
+#
+########################################################################
+
+sgml('<REFENTRY>', sub { 
+	# This will be overwritten at end of REFMETA, when we know the name of the page.
+	pop_output();
+	
+	$write_manpages = 1;		# Currently writing manpage.
+	
+	$nocollapse_whitespace = 0;	# Current whitespace collapse counter.
+	$newline_last = 1;		# At beginning of line?
+		# Just a bit of warning, you will see this variable manipulated
+		# manually a lot.  It makes the code harder to follow but it
+		# saves you from having to worry about collapsing at the end of
+		# parse, stopping at verbatims, etc.
+	$raw_cdata = 0;                 # Instructs certain output functions to
+					# leave CDATA alone, so we can assign
+					# it to a string and process it, etc.
+	@fontstack = ();		# Fonts being activated.
+	
+	$list_nestlevel = 0;		# Indent certain nested content.
+
+	# Separator to use between 'elements' in the content of a
+	# paragraph (usually).  This makes sure that PCDATA after a list
+	# in a PARA gets a break in between and not become part of the
+	# last listitem.  Note that we can't do it after the list ends,
+	# because often the list ends the paragraph and we'll get an
+	# extra break.  Anything that changes the separator status from
+	# the default should also save its last state in the parent
+	# element's ext, but I'm not going to explain further.  It's a
+	# gross hack and almost guaranteed to fail in unforseen cases.
+	# The only way to avoid all this is to use a tree/grove model, which
+	# we're _not_ doing.
+	$separator = '';
+	
+	$manpage_title = '';		# Needed for indexing.
+	$manpage_sect = '';
+	@manpage_names = ();
+	
+	$manpage_misc = '';
+
+	# check refentry's language
+	if(defined($_[0]->attribute('LANG')->value)) {
+	  $manpage_lang = $_[0]->attribute('LANG')->value;
+	}
+	else {
+	  $manpage_lang = '';
+	}
+});
+sgml('</REFENTRY>', sub {
+	if(!$newline_last) {
+		output "\n";
+	}
+	
+	$raw_cdata = 1;
+	push_output('nul');
+
+	$write_manpages = 0;
+});
+
+sgml('</REFMETA>', sub {
+	my ($filename, $citation) = 
+		FileInfo($manpage_title, $manpage_sect || $default_sect);
+
+	push_output('file', $filename);
+
+	output <<'_END_BANNER';
+.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $
+_END_BANNER
+
+	my $manpage_date = $_[0]->parent->ext->{'date'} || $default_date;
+
+	output '.TH "';
+
+	# If the title is not mixed-case, convention says to
+	# uppercase the whole title.  (The canonical title is
+	# lowercase.)
+	if($manpage_title =~ /[A-Z]/) {
+		output fold_string($manpage_title);
+	} else {
+		output uc(fold_string($manpage_title));
+	}
+	
+	output  '" "', fold_string($manpage_sect), 
+		'" "', fold_string($manpage_date),
+		'" "', $manpage_misc, 
+		'" "', $manpage_manual, 
+		"\"\n";
+
+	$newline_last = 1;
+
+	# References to this RefEntry.
+	if(defined($_[0]->parent->attribute('ID')->value)) {
+		my $id = $_[0]->parent->attribute('ID')->value;
+
+		# Append XREFLABEL content to citations.
+		if(defined($_[0]->parent->attribute('XREFLABEL')->value)) {
+			$citation = $_[0]->parent->attribute('XREFLABEL')->value .
+					' [' . $citation . ']';
+		}
+
+		$Refs->put("refentry:$id", $citation);
+	}
+});
+
+sgml('<REFENTRYTITLE>', sub { 
+	if($_[0]->in('REFMETA')) { 
+		save_cdata();
+	} else { 
+		# Manpage citations are in bold.
+		bold_on();
+	}
+});
+sgml('</REFENTRYTITLE>', sub { 
+	if($_[0]->in('REFMETA')) {
+		$raw_cdata--;
+		$manpage_title = pop_output();
+	}
+	else { font_off(); }
+
+	if (defined($_[0]->attribute('ID')->value)) {
+		my $id = $_[0]->attribute('ID')->value;
+		$Refs->put("refentrytitle:$id", $manpage_title);
+	}
+});
+
+sgml('<MANVOLNUM>', sub { 
+	if($_[0]->in('REFMETA')) { 
+		save_cdata();	
+	} else {
+		# Manpage citations use ().
+		output '(';
+	}
+});
+sgml('</MANVOLNUM>', sub { 
+	if($_[0]->in('REFMETA')) {
+		$raw_cdata--;
+		$manpage_sect = pop_output();
+	}
+	else { output ')' }
+});
+
+sgml('<REFMISCINFO>', \&save_cdata);
+sgml('</REFMISCINFO>', sub { 
+	$raw_cdata--;
+	$manpage_misc = fold_string(pop_output());
+});
+
+
+# NAME section
+#man_sgml('<REFNAMEDIV>', "\n.SH NAME\n");
+man_sgml('<REFNAMEDIV>', sub {
+	my %text = { fr=>'NOM', es=>'NOMBRE', pl=>'NAZWA' };
+	
+	if(defined $text{lc($manpage_lang)})
+	{
+		man_output "\n.SH " . $text{lc($manpage_lang)} . "\n";
+	} elsif(defined $_[0]->attribute('LANG') and
+		defined $text{lc($_[0]->attribute('LANG')->value)})
+	{
+		man_output "\n.SH " . $text{lc($_[0]->attribute('LANG'))} . "\n";
+	} else {
+		man_output "\n.SH NAME\n";
+	}
+});
+
+sgml('<REFNAME>', \&save_cdata);
+sgml('</REFNAME>', sub { 
+	$raw_cdata--;
+	push(@manpage_names, pop_output());
+});
+
+sgml('<REFPURPOSE>', \&save_cdata);
+sgml('</REFPURPOSE>', sub { 
+	$raw_cdata--;
+	my $manpage_purpose = fold_string(pop_output());
+	
+	for(my $i = 0; $i < $#manpage_names; $i++) {
+		output fold_string($manpage_names[$i]), ', ';
+	}
+
+	output fold_string($manpage_names[$#manpage_names]);
+	output " \\- $manpage_purpose\n";
+
+	$newline_last = 1;
+
+	foreach(@manpage_names) {
+		# Don't link to itself
+		if($_ ne $manpage_title) {
+			print LINKSFILE "$manpage_title.$manpage_sect	$_.$manpage_sect\n";
+		}
+	}
+});
+	
+man_sgml('<REFCLASS>', "\n.sp\n");
+
+#RefDescriptor
+
+
+########################################################################
+#
+# SYNOPSIS section and synopses
+#
+########################################################################
+
+#man_sgml('<REFSYNOPSISDIV>', "\n.SH SYNOPSIS\n");
+man_sgml('<REFSYNOPSISDIV>', sub {
+	   if ($manpage_lang eq "pl") { man_output "\n.SH SKŁADNIA\n"; }
+	   # waits for another languages
+	   #elsif ($manpage_lang eq "xx") { man_output "\n.SH xxxxxxx\n"; } 
+	   else { man_output "\n.SH SYNOPSIS\n"; }
+});   
+
+man_sgml('</REFSYNOPSISDIV>', "\n");
+
+## FIXME! Must be made into block elements!!
+#sgml('<FUNCSYNOPSIS>', \&bold_on);
+#sgml('</FUNCSYNOPSIS>', \&font_off);
+#sgml('<CMDSYNOPSIS>', \&bold_on);
+#sgml('</CMDSYNOPSIS>', \&font_off);
+
+man_sgml('<FUNCSYNOPSIS>', sub {
+	#man_output("\n.sp\n");
+	bold_on();
+});
+man_sgml('</FUNCSYNOPSIS>', sub {
+	font_off();
+	man_output "\n";
+});
+
+man_sgml('<CMDSYNOPSIS>', "\n.sp\n");
+man_sgml('</CMDSYNOPSIS>', "\n");
+
+man_sgml('<FUNCPROTOTYPE>', "\n.sp\n");
+
+# Arguments to functions.  This is C convention.
+man_sgml('<PARAMDEF>', '(');
+man_sgml('</PARAMDEF>', ");\n");
+man_sgml('<VOID>', "(void);\n");
+
+
+sub arg_start
+{
+	# my $choice = $_[0]->attribute('CHOICE')->value;
+
+	# The content model for CmdSynopsis doesn't include #PCDATA,
+	# so we won't see any of the whitespace in the source file,
+	# so we have to add it after each component.
+	man_output ' ';
+
+	if($_[0]->attribute('CHOICE')->value =~ /opt/i) {
+		man_output '[ ';
+	}
+	bold_on();
+}
+sub arg_end
+{
+	font_off();
+	if($_[0]->attribute('REP')->value =~ /^Repeat/i) {
+		italic_on();
+		man_output '...';
+		font_off();
+	}
+	if($_[0]->attribute('CHOICE')->value =~ /opt/i) {
+		man_output ' ] ';
+	}
+}
+
+sgml('<ARG>', \&arg_start);
+sgml('</ARG>', \&arg_end);
+sgml('<GROUP>', \&arg_start);
+sgml('</GROUP>', \&arg_end);
+
+sgml('<OPTION>', \&bold_on);
+sgml('</OPTION>', \&font_off);
+
+# FIXME: This is one _blank_ line.
+man_sgml('<SBR>', "\n\n");
+
+
+########################################################################
+#
+# General sections
+#
+########################################################################
+
+# The name of the section is handled by TITLE.  This just sets
+# up the roff markup.
+man_sgml('<REFSECT1>', sub { $separator = ''; man_output "\n.SH "});
+man_sgml('<REFSECT2>', sub { $separator = ''; man_output "\n.SS "});
+man_sgml('<REFSECT3>', sub { $separator = ''; man_output "\n.SS "});
+
+
+########################################################################
+#
+# Titles, metadata.
+#
+########################################################################
+
+sgml('<TITLE>', sub {
+	if($_[0]->in('REFERENCE') or $_[0]->in('BOOK')) {
+		$write_manpages = 1;
+	}
+	save_cdata();
+});
+sgml('</TITLE>', sub {
+	my ($element, $event) = @_;
+	my $title = fold_string(pop_output());
+	$raw_cdata--;
+	
+	if($element->in('REFERENCE') or $element->in('BOOK')) {
+		# We use TITLE of enclosing Reference or Book as manual name
+		$manpage_manual = $title;
+		$write_manpages = 0;
+	}
+	elsif(exists $element->parent->ext->{'title'}) {
+		# By far the easiest case.  Just fold the string as
+		# above, and then set the parent element's variable.
+		$_[0]->parent->ext->{'title'} = $title;
+	}
+	else {
+		# If the parent element's handlers are lazy, 
+		# output the folded string for them :)
+		# We assume they want uppercase and a newline.
+		man_output '"', uc($title), "\"\n";
+	}
+
+	if (defined($element->attribute('ID')->value)) {
+		my $id = $_[0]->attribute('ID')->value;
+		$Refs->put("title:$id", $title);
+	}
+
+	my ($filename, $citation) =
+		FileInfo($manpage_title, $manpage_sect || $default_sect);
+	my $parentid = $element->parent->attribute('ID')->value;
+	if ($parentid and ($element->in('REFSECT1') or $element->in('REFSECT2') or $element->in('REFSECT3'))) {
+		$Refs->put("refsect:$parentid", "$citation");
+	}
+});
+
+sgml('<ATTRIBUTION>', sub { 
+	if($_[0]->in('BLOCKQUOTE')) {
+		push_output('string');
+	}
+});
+sgml('</ATTRIBUTION>', sub { 
+	if($_[0]->in('BLOCKQUOTE')) {
+		$_[0]->parent->ext->{'attribution'} = pop_output(); 
+	} else {
+		# For an Epigraph.
+		man_output "\n\n";
+	}
+});
+
+sgml('<DATE>', sub {
+      save_cdata();
+});
+sgml('</DATE>', sub {
+      $_[0]->parent->parent->ext->{'date'} = fold_string(pop_output());
+      $raw_cdata--;
+});
+
+sub ignore_content { push_output 'nul'; }
+sub restore_content { pop_output(); }
+
+sgml('<DOCINFO>', \&ignore_content);
+sgml('</DOCINFO>', \&restore_content);
+sgml('<REFSYNOPSISDIVINFO>', \&ignore_content);
+sgml('</REFSYNOPSISDIVINFO>', \&restore_content);
+sgml('<REFSECT1INFO>', \&ignore_content);
+sgml('</REFSECT1INFO>', \&restore_content);
+sgml('<REFSECT2INFO>', \&ignore_content);
+sgml('</REFSECT2INFO>', \&restore_content);
+sgml('<REFSECT3INFO>', \&ignore_content);
+sgml('</REFSECT3INFO>', \&restore_content);
+
+sgml('<INDEXTERM>', \&ignore_content);
+sgml('</INDEXTERM>', \&restore_content);
+
+sgml('<AUTHORBLURB>', \&ignore_content);
+sgml('</AUTHORBLURB>', \&restore_content);
+
+
+########################################################################
+#
+# Set bold on enclosed content 
+#
+########################################################################
+
+sgml('<APPLICATION>', \&bold_on);
+sgml('</APPLICATION>', \&font_off);
+
+sgml('<CLASSNAME>', \&bold_on);		sgml('</CLASSNAME>', \&font_off);
+sgml('<STRUCTNAME>', \&bold_on);	sgml('</STRUCTNAME>', \&font_off);
+sgml('<STRUCTFIELD>', \&bold_on);	sgml('</STRUCTFIELD>', \&font_off);
+sgml('<SYMBOL>', \&bold_on);		sgml('</SYMBOL>', \&font_off);
+sgml('<TYPE>', \&bold_on);		sgml('</TYPE>', \&font_off);
+
+sgml('<ENVAR>', \&bold_on);	sgml('</ENVAR>', \&font_off);
+
+sgml('<FUNCTION>', \&bold_on);	sgml('</FUNCTION>', \&font_off);
+
+sgml('<EMPHASIS>', \&bold_on);	sgml('</EMPHASIS>', \&font_off);
+
+sgml('<ERRORNAME>', \&bold_on);	sgml('</ERRORNAME>', \&font_off);
+# ERRORTYPE
+
+sgml('<COMMAND>', \&bold_on);	sgml('</COMMAND>', \&font_off);
+
+sgml('<GUIBUTTON>', \&bold_on);	sgml('</GUIBUTTON>', \&font_off);
+sgml('<GUIICON>', \&bold_on);	sgml('</GUIICON>', \&font_off);
+# GUILABEL
+# GUIMENU
+# GUIMENUITEM
+# GUISUBMENU
+# MENUCHOICE
+
+sgml('<ACCEL>', \&bold_on);	sgml('</ACCEL>', \&font_off);
+# KEYCODE
+# SHORTCUT
+
+
+sgml('<KEYCOMBO>', sub {
+	$separator = 'none';
+	$_[0]->ext->{'separator'} = 'none';
+});
+sgml('</KEYCOMBO>', sub { $separator = $_[0]->parent->ext->{'separator'}; });
+
+sub _keycombo {
+	if($_[0]->in('KEYCOMBO')) {
+		if($separator eq 'none') { $separator = '' }
+		else { man_output "+"; }
+	}
+	bold_on();
+}
+sgml('<KEYCAP>', \&_keycombo);	sgml('</KEYCAP>', \&font_off);
+sgml('<KEYSYM>', \&_keycombo);	sgml('</KEYSYM>', \&font_off);
+sgml('<MOUSEBUTTON>', \&_keycombo);	sgml('</MOUSEBUTTON>', \&font_off);
+
+
+sgml('<USERINPUT>', \&bold_on);	sgml('</USERINPUT>', \&font_off);
+
+sgml('<INTERFACEDEFINITION>', \&bold_on);
+sgml('</INTERFACEDEFINITION>', \&font_off);
+
+# May need to look at the CLASS
+sgml('<SYSTEMITEM>', \&bold_on);
+sgml('</SYSTEMITEM>', \&font_off);
+
+
+########################################################################
+#
+# Set italic on enclosed content 
+#
+########################################################################
+
+sgml('<FIRSTTERM>', \&italic_on);	sgml('</FIRSTTERM>', \&font_off);
+
+sgml('<FILENAME>', \&italic_on);	sgml('</FILENAME>', \&font_off);
+sgml('<PARAMETER>', \&italic_on);	sgml('</PARAMETER>', \&font_off);
+sgml('<PROPERTY>', \&italic_on);	sgml('</PROPERTY>', \&font_off);
+
+sgml('<REPLACEABLE>', sub {
+	italic_on();
+	if($_[0]->in('TOKEN')) {
+		# When tokenizing, follow more 'intuitive' convention
+		output "<";
+	}
+});
+sgml('</REPLACEABLE>', sub {
+	if($_[0]->in('TOKEN')) {
+		output ">";
+	}
+	font_off();
+});
+
+sgml('<CITETITLE>', \&italic_on);	sgml('</CITETITLE>', \&font_off);
+sgml('<FOREIGNPHRASE>', \&italic_on);	sgml('</FOREIGNPHRASE>', \&font_off);
+
+sgml('<LINEANNOTATION>', \&italic_on);	sgml('</LINEANNOTATION>', \&font_off);
+
+
+########################################################################
+#
+# Other 'inline' elements 
+#
+########################################################################
+
+man_sgml('<EMAIL>', '<');
+man_sgml('</EMAIL>', '>');
+man_sgml('<OPTIONAL>', '[');
+man_sgml('</OPTIONAL>', ']');
+
+man_sgml('</TRADEMARK>', "\\u\\s-2TM\\s+2\\d");
+
+man_sgml('<COMMENT>', "[Comment: ");
+man_sgml('</COMMENT>', "]");
+
+man_sgml('<QUOTE>', "``");
+man_sgml('</QUOTE>', "''");
+
+#man_sgml('<LITERAL>', '"');
+#man_sgml('</LITERAL>', '"');
+# There doesn't seem to be a good way to represent LITERAL in -man
+# ComputerOutput, SGMLTag, Markup are the same thing.
+
+# These create spaces between content in special elements
+# without PCDATA content.
+man_sgml('</HONORIFIC>', " ");
+man_sgml('</FIRSTNAME>', " ");
+man_sgml('</SURNAME>', " ");
+man_sgml('</LINEAGE>', " ");
+man_sgml('</OTHERNAME>', " ");
+
+man_sgml('<AFFILIATION>', "(");
+man_sgml('</AFFILIATION>', ") ");
+man_sgml('<CONTRIB>', "(");
+man_sgml('</CONTRIB>', ") ");
+
+man_sgml('</STREET>', " ");
+man_sgml('</POB>', " ");
+man_sgml('</POSTCODE>', " ");
+man_sgml('</CITY>', " ");
+man_sgml('</STATE>', " ");
+man_sgml('</COUNTRY>', " ");
+man_sgml('</PHONE>', " ");
+man_sgml('</FAX>', " ");
+man_sgml('</OTHERADDRESS>', " ");
+
+man_sgml('</ALT>', ": ");
+man_sgml('<GRAPHIC>', " [GRAPHIC] ");
+
+# No special presentation:
+
+# AUTHORINITIALS
+
+# ABBREV
+# ACTION
+# ACRONYM
+# CITATION
+# PHRASE
+# QUOTE
+# WORDASWORD
+
+# PROMPT
+# RETURNVALUE
+# TOKEN
+
+# DATABASE
+# HARDWARE
+# INTERFACE
+# MEDIALABEL
+
+
+########################################################################
+#
+# Paragraph and paragraph-like elements 
+#
+########################################################################
+
+sub para_start {
+	if($separator eq '' or $separator eq 'full') {
+		$separator = '';
+		man_output "\n.PP\n";
+	} elsif($separator eq 'blank') { 
+		man_output "\n\n";
+	} elsif($separator eq 'none' ) {
+		$_[0]->parent->ext->{'separator'} = 'blank';
+		$separator = 'blank';
+	}
+}
+# Actually applies to a few other block elements as well
+sub para_end {
+	$separator = $_[0]->parent->ext->{'separator'};
+	man_output "\n";
+}
+
+sgml('<PARA>', \&para_start);
+sgml('</PARA>', \&para_end);
+sgml('<SIMPARA>', \&para_start);
+sgml('</SIMPARA>', \&para_end);
+
+# Nothing special, except maybe FIXME set nobreak.
+sgml('<INFORMALEXAMPLE>', \&para_start);
+sgml('</INFORMALEXAMPLE>', \&para_end);
+
+
+########################################################################
+#
+# Blocks using SS sections
+#
+########################################################################
+
+# FIXME: We need to consider the effects of SS
+# in a hanging tag :(
+
+# Complete with the optional-title dilemma (again).
+sgml('<ABSTRACT>', sub {
+	$_[0]->ext->{'title'} = 'ABSTRACT';
+	output "\n" unless $newline_last++;
+	push_output('string');
+});
+sgml('</ABSTRACT>', sub {
+	my $content = pop_output();
+	
+	# As ABSTRACT is never on the same level as RefSect1,
+	# this leaves us with only .SS in terms of -man macros.
+	output ".SS \"", uc($_[0]->ext->{'title'}), "\"\n";
+
+	output $content;
+	output "\n" unless $newline_last++;
+});
+
+
+
+# Ah, I needed a break.  Example always has a title.
+sgml('<EXAMPLE>', sub { $separator = ''; man_output "\n.SS "});
+sgml('</EXAMPLE>', \&para_end);
+
+# Same with sidebar.
+sgml('<SIDEBAR>', sub { $separator = ''; man_output "\n.SS "});
+sgml('</SIDEBAR>', \&para_end);
+
+sgml('<FORMALPARA>', sub { $separator = ''; man_output "\n.SS "});
+sgml('</FORMALPARA>', \&para_end);
+
+sgml('<FIGURE>', sub { $separator = ''; man_output "\n.SS "});
+sgml('</FIGURE>', \&para_end);
+
+
+
+# NO title.
+sgml('<HIGHLIGHTS>', sub { $separator = ''; man_output "\n.SS HIGHLIGHTS\n"});
+sgml('</HIGHLIGHTS>', \&para_end);
+
+
+########################################################################
+#
+# Indented 'Block' elements 
+#
+########################################################################
+
+sub indent_block_start
+{
+	$separator = '';
+	man_output "\n.sp\n.RS\n";
+}
+sub indent_block_end
+{
+	$separator = $_[0]->parent->ext->{'separator'};
+	man_output "\n.RE\n.sp\n";
+}
+
+sgml('<ADDRESS>', sub {
+	&indent_block_start;
+	if($_[0]->attribute('FORMAT')->type eq 'NOTATION'
+	   and $_[0]->attribute('FORMAT')->value->name eq 'LINESPECIFIC') {
+		&verbatim_start;
+	}
+});
+sgml('</ADDRESS>', sub {
+	if($_[0]->attribute('FORMAT')->type eq 'NOTATION'
+	   and $_[0]->attribute('FORMAT')->value->name eq 'LINESPECIFIC') {
+		&verbatim_end;
+	}
+	&indent_block_end;
+});
+	
+# This element is almost like an admonition (below),
+# only the default title is blank :)
+
+sgml('<BLOCKQUOTE>', sub { 
+	$_[0]->ext->{'title'} = ''; 
+	&indent_block_start;
+	push_output('string');
+});
+sgml('</BLOCKQUOTE>', sub {
+	my $content = pop_output();
+
+	if($_[0]->ext->{'title'}) {
+		output ".B \"", $_[0]->ext->{'title'}, ":\"\n";
+	}
+	
+	output $content;
+
+	if($_[0]->ext->{'attribution'}) {
+		man_output "\n\n                -- ",
+				$_[0]->ext->{'attribution'}, "\n";
+	}
+	
+	&indent_block_end;
+});
+
+# Set off admonitions from the rest of the text by indenting.
+# FIXME: Need to check if this works inside paragraphs, not enclosing them.
+sub admonition_end {
+	my $content = pop_output();
+
+	# When the admonition is only one paragraph,
+	# it looks nicer if the title was inline.
+	my $num_para;
+	while ($content =~ /^\.PP/gm) { $num_para++ }
+	if($num_para==1) {
+		$content =~ s/^\.PP\n//;
+	}
+	
+	output ".B \"" . $_[0]->ext->{'title'} . ":\"\n";
+	output $content;
+	
+	&indent_block_end;
+}
+
+sgml('<NOTE>', sub {
+	# We can't see right now whether or not there is a TITLE
+	# element, so we have to save the output now and add it back
+	# at the end of this admonition.
+	$_[0]->ext->{'title'} = 'Note';
+	
+	&indent_block_start;
+	
+	push_output('string');
+});
+sgml('</NOTE>', \&admonition_end);
+
+# Same as above.
+sgml('<WARNING>', sub { 
+	$_[0]->ext->{'title'} = 'Warning'; 
+	&indent_block_start;
+	push_output('string');
+});
+sgml('</WARNING>', \&admonition_end);
+
+sgml('<TIP>', sub {
+	$_[0]->ext->{'title'} = 'Tip';
+	&indent_block_start;
+	push_output('string');
+});
+sgml('</TIP>', \&admonition_end);
+sgml('<CAUTION>', sub {
+	$_[0]->ext->{'title'} = 'Caution';
+	&indent_block_start;
+	push_output('string');
+});
+sgml('</CAUTION>', \&admonition_end);
+
+sgml('<IMPORTANT>', sub {
+	$_[0]->ext->{'title'} = 'Important';
+	&indent_block_start;
+	push_output('string');
+});
+sgml('</IMPORTANT>', \&admonition_end);
+
+
+########################################################################
+#
+# Verbatim displays. 
+#
+########################################################################
+
+sub verbatim_start {
+	$separator = '';
+	man_output "\n.sp\n";
+	man_output "\n.nf\n" unless $nocollapse_whitespace++;
+}
+
+sub verbatim_end {
+	man_output "\n.sp\n";
+	man_output "\n.fi\n" unless --$nocollapse_whitespace;
+	$separator = $_[0]->parent->ext->{'separator'};
+}
+
+sgml('<PROGRAMLISTING>', \&verbatim_start); 
+sgml('</PROGRAMLISTING>', \&verbatim_end);
+
+sgml('<SCREEN>', \&verbatim_start); 
+sgml('</SCREEN>', \&verbatim_end);
+
+sgml('<LITERALLAYOUT>', \&verbatim_start); 
+sgml('</LITERALLAYOUT>', \&verbatim_end);
+
+sgml('<SYNOPSIS>', sub {
+	my $format = $_[0]->attribute('FORMAT');
+
+	if($format->type eq 'NOTATION'
+	   and $format->value->name eq 'LINESPECIFIC')
+	{
+		&verbatim_start;
+	} else {
+		$separator = '';
+		man_output "\n.sp\n";
+	}
+});
+
+sgml('</SYNOPSIS>', sub {
+	my $format = $_[0]->attribute('FORMAT');
+	
+	if($format->type eq 'NOTATION'
+	   and $format->value->name eq 'LINESPECIFIC')
+	{
+		&verbatim_end;
+	} else {
+		man_output "\n";
+		$_[0]->parent->ext->{'separator'} = 'full';
+		$separator = 'full';
+	}
+});
+
+
+########################################################################
+#
+# Lists
+#
+########################################################################
+
+# Indent nested lists.
+sub list_start {
+	man_output "\n.RS\n" if $list_nestlevel++;
+}
+sub list_end {
+	man_output "\n.RE\n" if --$list_nestlevel;
+	$_[0]->parent->ext->{'separator'} = 'full';
+	$separator = 'full';
+}
+
+sgml('<VARIABLELIST>', \&list_start);
+sgml('</VARIABLELIST>', \&list_end);
+sgml('<ITEMIZEDLIST>', \&list_start);
+sgml('</ITEMIZEDLIST>', \&list_end);
+sgml('<ORDEREDLIST>', sub { 
+	&list_start;
+	$_[0]->ext->{'count'} = 1;
+});
+sgml('</ORDEREDLIST>', \&list_end);
+		
+# Output content on one line, bolded.
+sgml('<TERM>', sub { 
+	man_output "\n.TP\n";
+	bold_on();
+	push_output('string');
+});
+sgml('</TERM>', sub { 
+	my $term = StripString(pop_output());
+	$term =~ tr/\n/ /;
+	output $term;
+	font_off();
+	output "\n";
+	$newline_last = 1;
+});
+	
+sgml('<LISTITEM>', sub {
+	# A bulleted list.
+	if($_[0]->in('ITEMIZEDLIST')) {
+		man_output "\n.TP 0.2i\n\\(bu\n";
+	}
+
+	# Need numbers.
+	# Assume Arabic numeration for now.
+	elsif($_[0]->in('ORDEREDLIST')) {
+		man_output "\n.IP ", $_[0]->parent->ext->{'count'}++, ". \n";
+	}
+	
+	$_[0]->ext->{'separator'} = 'none';
+	$separator = 'none';
+});
+
+sgml('<SIMPLELIST>', sub {
+	$_[0]->ext->{'first_member'} = 1;
+});
+sgml('<MEMBER>', sub {
+	my $parent = $_[0]->parent;
+	
+	if($parent->attribute('TYPE')->value =~ /Inline/i) {
+		if($parent->ext->{'first_member'}) {
+			# If this is the first member don't put any commas
+			$parent->ext->{'first_member'} = 0;
+		} else {
+			man_output ", ";
+		}
+
+	# We don't really have Horiz rendering, so it's the same
+	# as Vert.
+	} else {
+		man_output "\n\n";
+	}
+});
+
+# We implement Procedures as indent and lists
+
+sgml('<PROCEDURE>', sub {
+	$_[0]->ext->{'count'} = 1;
+	&indent_block_start;
+});
+sgml('</PROCEDURE>', sub {
+	&indent_block_end;
+	$_[0]->parent->ext->{'separator'} = 'full';
+	$separator = 'full';
+});
+
+sgml('<STEP>', sub {
+	man_output "\n.IP ", $_[0]->parent->ext->{'count'}++, ". \n";
+	$_[0]->ext->{'separator'} = 'none';
+	$separator = 'none';
+});
+
+
+########################################################################
+#
+# Linkage, cross references
+#
+########################################################################
+
+# Print the URL
+sgml('</ULINK>', sub {
+	man_output ' <URL:', $_[0]->attribute('URL')->value, '>';
+});
+
+# If cross reference target is a RefEntry, 
+# output CiteRefEntry-style references.
+sgml('<XREF>', sub {
+	my $id = $_[0]->attribute('LINKEND')->value;
+
+	my $manref = $Refs->get("refentry:$id") || $Refs->get("refsect:$id");
+	if(!defined $manref) {
+		$blank_xrefs++ if $write_manpages;
+		man_output "[XRef to $id]";
+		return;
+	}
+
+	# Limited ENDTERM support.
+	if(defined $_[0]->attribute('ENDTERM')->value) {
+		my $endterm = $_[0]->attribute('ENDTERM')->value;
+		my $content = $Refs->get("title:$endterm") ||
+				$Refs->get("refentrytitle:$endterm");
+		man_output $content, ' [';
+	}
+
+	# This also displays the XREFLABEL (as bold)...
+	# It's not worth the bother to fix it though, there
+	# are better tools for this.
+	my ($title, $sect) = ($manref =~ /(.*)(\(.*\))/);
+	bold_on();
+	man_output $title;
+	font_off();
+	man_output $sect;
+
+	if(defined $_[0]->attribute('ENDTERM')->value) {
+		man_output ']';
+	}
+});
+
+# Anchor
+
+########################################################################
+#
+# SDATA 
+#
+########################################################################
+
+man_sgml('|[lt    ]|', '<');
+man_sgml('|[equals]|', '=');
+man_sgml('|[gt    ]|', '>');
+man_sgml('|[plus  ]|', '\(pl');
+man_sgml('|[dollar]|', '$');
+man_sgml('|[num   ]|', '#');
+man_sgml('|[percnt]|', '%');
+man_sgml('|[amp   ]|', '&');
+man_sgml('|[commat]|', '@');
+man_sgml('|[lsqb  ]|', '[');
+man_sgml('|[bsol  ]|', '\e');
+man_sgml('|[rsqb  ]|', ']');
+man_sgml('|[lcub  ]|', '{');
+man_sgml('|[verbar]|', '\(or');
+man_sgml('|[rcub  ]|', '}');
+man_sgml('|[excl  ]|', '!');
+man_sgml('|[quot  ]|', '"');
+man_sgml('|[apos  ]|', '\\&\'');
+man_sgml('|[lpar  ]|', '(');
+man_sgml('|[rpar  ]|', ')');
+man_sgml('|[comma ]|', ',');
+man_sgml('|[lowbar]|', '_');
+man_sgml('|[period]|', '.');
+man_sgml('|[sol   ]|', '/');
+man_sgml('|[colon ]|', ':');
+man_sgml('|[semi  ]|', ';');
+man_sgml('|[quest ]|', '?');
+man_sgml('|[grave ]|', '`');
+man_sgml('|[tilde ]|', '~');
+man_sgml('|[half  ]|', '\(12');
+man_sgml('|[frac12]|', '\(12');
+man_sgml('|[frac14]|', '\(14');
+man_sgml('|[frac34]|', '\(34');
+man_sgml('|[frac18]|', '1/8');
+man_sgml('|[frac38]|', '3/8');
+man_sgml('|[frac58]|', '5/8');
+man_sgml('|[frac78]|', '7/8');
+man_sgml('|[sup1  ]|', '\u1\l');
+man_sgml('|[sup2  ]|', '\u2\l');
+man_sgml('|[sup3  ]|', '\u3\l');
+man_sgml('|[plusmn]|', '\(+-');
+man_sgml('|[divide]|', '\(di');
+man_sgml('|[times ]|', '\(ti');
+man_sgml('|[pound ]|', '#');
+man_sgml('|[cent  ]|', '\(ct');
+man_sgml('|[yen   ]|', 'yen');
+man_sgml('|[ast   ]|', '*');
+man_sgml('|[horbar]|', '_');
+man_sgml('|[micro ]|', '\(*m');
+man_sgml('|[ohm   ]|', '\(*W');
+man_sgml('|[deg   ]|', '\(de');
+man_sgml('|[sect  ]|', '\(sc');
+man_sgml('|[larr  ]|', '\(<-');
+man_sgml('|[rarr  ]|', '\(->');
+man_sgml('|[uarr  ]|', '\(ua');
+man_sgml('|[darr  ]|', '\(da');
+man_sgml('|[copy  ]|', '\(co');
+man_sgml('|[reg   ]|', '\(rg');
+man_sgml('|[trade ]|', '\(tm');
+man_sgml('|[brvbar]|', '|');
+man_sgml('|[not   ]|', '\(no');
+man_sgml('|[hyphen]|', '\-');
+man_sgml('|[laquo ]|', '<<');
+man_sgml('|[raquo ]|', '>>');
+man_sgml('|[lsquo ]|', '`');
+man_sgml('|[rsquo ]|', '\&\'');
+man_sgml('|[ldquo ]|', '"');
+man_sgml('|[rdquo ]|', '"');
+man_sgml('|[nbsp  ]|', '\ ');
+man_sgml('|[shy   ]|', '\%');
+man_sgml('|[emsp  ]|', '\ \ ');
+man_sgml('|[ensp  ]|', '\ ');
+man_sgml('|[emsp3 ]|', '\ ');
+man_sgml('|[emsp4 ]|', '\ ');
+man_sgml('|[numsp ]|', '\0');
+man_sgml('|[puncsp]|', '\|');
+man_sgml('|[thinsp]|', '\!');
+man_sgml('|[hairsp]|', '\\^');
+man_sgml('|[mdash ]|', '\(em');
+man_sgml('|[ndash ]|', '-');
+man_sgml('|[dash  ]|', '-');
+man_sgml('|[blank ]|', '\ ');
+man_sgml('|[hellip]|', '\&...');
+man_sgml('|[nldr  ]|', '\&..');
+man_sgml('|[frac13]|', '1/3');
+man_sgml('|[frac23]|', '2/3');
+man_sgml('|[frac15]|', '1/5');
+man_sgml('|[frac25]|', '2/5');
+man_sgml('|[frac35]|', '3/5');
+man_sgml('|[frac45]|', '4/5');
+man_sgml('|[frac16]|', '1/6');
+man_sgml('|[frac56]|', '5/6');
+man_sgml('|[cir   ]|', '\(ci');
+man_sgml('|[squ   ]|', '\(sq');
+man_sgml('|[star  ]|', '\(**');
+man_sgml('|[bull  ]|', '\(bu');
+man_sgml('|[dagger]|', '\(dg');
+man_sgml('|[Dagger]|', '\(dd');
+man_sgml('|[caret ]|', '\^');
+man_sgml('|[lsquor]|', '`');
+man_sgml('|[ldquor]|', '``');
+man_sgml('|[fflig ]|', '\(ff');
+man_sgml('|[filig ]|', '\(fi');
+man_sgml('|[ffilig]|', '\(Fi');
+man_sgml('|[ffllig]|', '\(Fl');
+man_sgml('|[fllig ]|', '\(fl');
+man_sgml('|[rdquor]|', '\&\'\'');
+man_sgml('|[rsquor]|', '\&\'');
+man_sgml('|[vellip]|', '\&...');
+man_sgml('|[aacute]|', '\(a\'');
+man_sgml('|[Aacute]|', '\(A\'');
+man_sgml('|[acirc ]|', '\(a^');
+man_sgml('|[Acirc ]|', '\(A^');
+man_sgml('|[agrave]|', '\(a`');
+man_sgml('|[Agrave]|', '\(A`');
+man_sgml('|[auml  ]|', '\(a:');
+man_sgml('|[aelig ]|', '\(ae');
+man_sgml('|[AElig ]|', '\(AE');
+man_sgml('|[eacute]|', '\(e\'');
+man_sgml('|[Eacute]|', '\(E\'');
+man_sgml('|[egrave]|', '\(e`');
+man_sgml('|[Egrave]|', '\(E`');
+man_sgml('|[iacute]|', '\(i\'');
+man_sgml('|[Iacute]|', '\(I\'');
+man_sgml('|[igrave]|', '\(i`');
+man_sgml('|[Igrave]|', '\(I`');
+man_sgml('|[ntilde]|', '\(n~');
+man_sgml('|[Ntilde]|', '\(N~');
+man_sgml('|[oacute]|', '\(o\'');
+man_sgml('|[Oacute]|', '\(O\'');
+man_sgml('|[ograve]|', '\(o`');
+man_sgml('|[Ograve]|', '\(O`');
+man_sgml('|[oslash]|', '\(o/');
+man_sgml('|[Oslash]|', '\(O/');
+man_sgml('|[szlig ]|', '\(ss');
+man_sgml('|[thorn ]|', '\(th');
+man_sgml('|[uacute]|', '\(u\'');
+man_sgml('|[Uacute]|', '\(U\'');
+man_sgml('|[ugrave]|', '\(u`');
+man_sgml('|[Ugrave]|', '\(U`');
+man_sgml('|[aogon ]|', '\(ao');
+man_sgml('|[agr   ]|', '\(*a');
+man_sgml('|[Agr   ]|', '\(*A');
+man_sgml('|[bgr   ]|', '\(*b');
+man_sgml('|[Bgr   ]|', '\(*B');
+man_sgml('|[ggr   ]|', '\(*g');
+man_sgml('|[Ggr   ]|', '\(*G');
+man_sgml('|[dgr   ]|', '\(*d');
+man_sgml('|[Dgr   ]|', '\(*D');
+man_sgml('|[egr   ]|', '\(*e');
+man_sgml('|[Egr   ]|', '\(*E');
+man_sgml('|[zgr   ]|', '\(*z');
+man_sgml('|[Zgr   ]|', '\(*Z');
+man_sgml('|[eegr  ]|', '\(*y');
+man_sgml('|[EEgr  ]|', '\(*Y');
+man_sgml('|[thgr  ]|', '\(*h');
+man_sgml('|[THgr  ]|', '\(*H');
+man_sgml('|[igr   ]|', '\(*i');
+man_sgml('|[Igr   ]|', '\(*I');
+man_sgml('|[kgr   ]|', '\(*k');
+man_sgml('|[Kgr   ]|', '\(*K');
+man_sgml('|[lgr   ]|', '\(*l');
+man_sgml('|[Lgr   ]|', '\(*L');
+man_sgml('|[mgr   ]|', '\(*m');
+man_sgml('|[Mgr   ]|', '\(*M');
+man_sgml('|[ngr   ]|', '\(*n');
+man_sgml('|[Ngr   ]|', '\(*N');
+man_sgml('|[xgr   ]|', '\(*c');
+man_sgml('|[Xgr   ]|', '\(*C');
+man_sgml('|[ogr   ]|', '\(*o');
+man_sgml('|[Ogr   ]|', '\(*O');
+man_sgml('|[pgr   ]|', '\(*p');
+man_sgml('|[Pgr   ]|', '\(*P');
+man_sgml('|[rgr   ]|', '\(*r');
+man_sgml('|[Rgr   ]|', '\(*R');
+man_sgml('|[sgr   ]|', '\(*s');
+man_sgml('|[Sgr   ]|', '\(*S');
+man_sgml('|[sfgr  ]|', '\(ts');
+man_sgml('|[tgr   ]|', '\(*t');
+man_sgml('|[Tgr   ]|', '\(*T');
+man_sgml('|[ugr   ]|', '\(*u');
+man_sgml('|[Ugr   ]|', '\(*U');
+man_sgml('|[phgr  ]|', '\(*f');
+man_sgml('|[PHgr  ]|', '\(*F');
+man_sgml('|[khgr  ]|', '\(*x');
+man_sgml('|[KHgr  ]|', '\(*X');
+man_sgml('|[psgr  ]|', '\(*q');
+man_sgml('|[PSgr  ]|', '\(*Q');
+man_sgml('|[ohgr  ]|', '\(*w');
+man_sgml('|[OHgr  ]|', '\(*W');
+man_sgml('|[alpha ]|', '\(*a');
+man_sgml('|[beta  ]|', '\(*b');
+man_sgml('|[gamma ]|', '\(*g');
+man_sgml('|[Gamma ]|', '\(*G');
+man_sgml('|[delta ]|', '\(*d');
+man_sgml('|[Delta ]|', '\(*D');
+man_sgml('|[epsi  ]|', '\(*e');
+man_sgml('|[epsis ]|', '\(*e');
+man_sgml('|[zeta  ]|', '\(*z');
+man_sgml('|[eta   ]|', '\(*y');
+man_sgml('|[thetas]|', '\(*h');
+man_sgml('|[Theta ]|', '\(*H');
+man_sgml('|[iota  ]|', '\(*i');
+man_sgml('|[kappa ]|', '\(*k');
+man_sgml('|[lambda]|', '\(*l');
+man_sgml('|[Lambda]|', '\(*L');
+man_sgml('|[mu    ]|', '\(*m');
+man_sgml('|[nu    ]|', '\(*n');
+man_sgml('|[xi    ]|', '\(*c');
+man_sgml('|[Xi    ]|', '\(*C');
+man_sgml('|[pi    ]|', '\(*p');
+man_sgml('|[Pi    ]|', '\(*P');
+man_sgml('|[rho   ]|', '\(*r');
+man_sgml('|[sigma ]|', '\(*s');
+man_sgml('|[Sigma ]|', '\(*S');
+man_sgml('|[tau   ]|', '\(*t');
+man_sgml('|[upsi  ]|', '\(*u');
+man_sgml('|[Upsi  ]|', '\(*U');
+man_sgml('|[phis  ]|', '\(*f');
+man_sgml('|[Phi   ]|', '\(*F');
+man_sgml('|[chi   ]|', '\(*x');
+man_sgml('|[psi   ]|', '\(*q');
+man_sgml('|[Psi   ]|', '\(*X');
+man_sgml('|[omega ]|', '\(*w');
+man_sgml('|[Omega ]|', '\(*W');
+man_sgml('|[ap    ]|', '\(ap');
+man_sgml('|[equiv ]|', '\(==');
+man_sgml('|[ge    ]|', '\(>=');
+man_sgml('|[infin ]|', '\(if');
+man_sgml('|[isin  ]|', '\(sb');
+man_sgml('|[le    ]|', '\(<=');
+man_sgml('|[minus ]|', '\(mi');
+man_sgml('|[ne    ]|', '\(!=');
+man_sgml('|[prop  ]|', '\(pt');
+man_sgml('|[square]|', '\(sq');
+man_sgml('|[sub   ]|', '\(sb');
+man_sgml('|[sube  ]|', '\(ib');
+man_sgml('|[sup   ]|', '\(sp');
+man_sgml('|[supe  ]|', '\(ip');
+man_sgml('|[acute ]|', '\&\'');
+man_sgml('|[breve ]|', '\(be');
+man_sgml('|[caron ]|', '\(hc');
+man_sgml('|[cedil ]|', '\(cd');
+man_sgml('|[dot   ]|', '\(dt');
+man_sgml('|[macr  ]|', '\(ma');
+man_sgml('|[ogon  ]|', '\(og');
+man_sgml('|[ring  ]|', '\(ri');
+man_sgml('|[uml   ]|', '\(..');
+
+sgml('sdata',sub {
+	my ($element, $event) = @_;
+	my ($file, $line) = ($event->file, $event->line);
+	man_output "|[", $_[0], "]|";
+	warn "Warning: unrecognized SDATA '$_[0]'"
+	     . ($file && $line ? " in $file on line $line" : "")
+	     . ": please add definition to docbook2man-spec.pl\n";
+});
+
+#
+# Default handlers (uncomment these if needed).  Right now, these are set
+# up to gag on any unrecognised elements, sdata, processing-instructions,
+# or entities.
+#
+# sgml('start_element',sub { die "Unknown element: " . $_[0]->name; });
+# sgml('end_element','');
+
+# This is for weeding out and escaping certain characters.
+# This looks like it's inefficient since it's done on every line, but
+# in reality, SGMLSpm and sgmlspl parsing ESIS takes _much_ longer.
+
+sgml('cdata', sub
+{ 
+	if(!$write_manpages) { return; }
+	elsif($raw_cdata) { output $_[0]; return; }
+
+	if($separator eq 'full') {
+		output "\n" unless $newline_last++;
+		output ".PP\n";
+		$separator = '';
+	}
+	
+	# Escape backslashes
+	$_[0] =~ s/\\/\\\\/g;
+
+	# In non-'pre'-type elements:
+	if(!$nocollapse_whitespace) {
+		# Change tabs to spaces
+		$_[0] =~ tr/\t / /s;
+
+		# Do not allow indents at beginning of line
+		# groff chokes on that.
+		if($newline_last) { 
+			$_[0] =~ s/^ //;
+
+			# If the line is all blank, don't do anything.
+			if($_[0] eq '') { return; }
+			
+			$_[0] =~ s/^\./\\\&\./;
+	
+			# Argh... roff doesn't like ' for some unknown reason 
+			$_[0] =~ s/^\'/\\\&\'/;
+		}
+	}
+
+	$newline_last = 0;
+
+	output $_[0];
+});
+
+
+# When in whitespace-collapsing mode, we disallow consecutive newlines.
+
+sgml('re', sub
+{
+	if($nocollapse_whitespace || !$newline_last) {
+		output "\n";
+	}
+
+	$newline_last = 1;
+});
+
+sgml('pi', sub {});
+sgml('entity',sub { die "Unknown external entity: " . $_[0]->name; });
+sgml('start_subdoc',sub { die "Unknown subdoc entity: " . $_[0]->name; });
+sgml('end_subdoc',sub{});
+sgml('conforming',sub{});
+
+1;
+
--- postgresql-8.4-8.4.1.orig/debian/docbook2man-sgmlspl/docbook2man-spec_makelinks
+++ postgresql-8.4-8.4.1/debian/docbook2man-sgmlspl/docbook2man-spec_makelinks
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+
+while(<STDIN>)
+{
+	chomp;
+	($main, $link) = split(/\t/);
+	
+	$n = $main;
+	$n =~ s/^.*\.(\d).*$/$1/;
+	
+	open(LINK, ">$link");
+	print LINK ".so man$n/$main\n";
+	close(LINK);
+}
+
