diff --git a/config/docbook.m4 b/config/docbook.m4
index 491d329d53733339c664c963f8bc63df5b6433e8..0d8c1fad7e1ee44b865f12b4d4c6793f918b5875 100644
--- a/config/docbook.m4
+++ b/config/docbook.m4
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/config/docbook.m4,v 1.10 2008/11/26 11:26:54 petere Exp $
+# $PostgreSQL: pgsql/config/docbook.m4,v 1.11 2009/08/04 22:04:37 petere Exp $
 
 # PGAC_PROG_JADE
 # --------------
@@ -97,32 +97,3 @@ if test -n "$DOCBOOKSTYLE"; then
 else
   AC_PATH_PROGS(COLLATEINDEX, collateindex.pl)
 fi])# PGAC_PATH_COLLATEINDEX
-
-
-# PGAC_PATH_DOCBOOK2MAN
-# ---------------------
-# Find docbook2man program from the docbook2X package.  Upstream calls
-# this program docbook2man, but there is also a different docbook2man
-# out there from the docbook-utils package.  Thus, the program we want
-# is called docbook2x-man on Debian and db2x_docbook2man on Fedora.
-#
-# (Consider rewriting this macro using AC_PATH_PROGS_FEATURE_CHECK
-# when switching to Autoconf 2.62+.)
-AC_DEFUN([PGAC_PATH_DOCBOOK2MAN],
-[AC_CACHE_CHECK([for docbook2man], [ac_cv_path_DOCBOOK2MAN],
-[if test -z "$DOCBOOK2MAN"; then
-  _AS_PATH_WALK([],
-  [for ac_prog in docbook2x-man db2x_docbook2man docbook2man; do
-    ac_path="$as_dir/$ac_prog"
-    AS_EXECUTABLE_P(["$ac_path"]) || continue
-    if "$ac_path" --version 2>/dev/null | $GREP docbook2x >/dev/null 2>&1; then
-      ac_cv_path_DOCBOOK2MAN=$ac_path
-      break
-    fi
-  done])
-else
-  ac_cv_path_DOCBOOK2MAN=$DOCBOOK2MAN
-fi])
-DOCBOOK2MAN=$ac_cv_path_DOCBOOK2MAN
-AC_SUBST(DOCBOOK2MAN)
-])# PGAC_PATH_DOCBOOK2MAN
diff --git a/configure b/configure
index fb41c024e21a04ecacc8332ef28f455a6a763eda..61b3c72e525d350c7a55d4fb03c8203c5254f1cd 100755
--- a/configure
+++ b/configure
@@ -642,8 +642,8 @@ ac_includes_default="\
 
 ac_subst_vars='LTLIBOBJS
 vpath_build
-DOCBOOK2MAN
-SGMLSPL
+OSX
+XSLTPROC
 COLLATEINDEX
 DOCBOOKSTYLE
 have_docbook
@@ -28028,17 +28028,17 @@ fi
 done
 
 fi
-for ac_prog in sgmlspl
+for ac_prog in xsltproc
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_SGMLSPL+set}" = set; then
+if test "${ac_cv_prog_XSLTPROC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$SGMLSPL"; then
-  ac_cv_prog_SGMLSPL="$SGMLSPL" # Let the user override the test.
+  if test -n "$XSLTPROC"; then
+  ac_cv_prog_XSLTPROC="$XSLTPROC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -28047,7 +28047,7 @@ do
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_SGMLSPL="$ac_prog"
+    ac_cv_prog_XSLTPROC="$ac_prog"
     $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -28057,49 +28057,60 @@ IFS=$as_save_IFS
 
 fi
 fi
-SGMLSPL=$ac_cv_prog_SGMLSPL
-if test -n "$SGMLSPL"; then
-  { $as_echo "$as_me:$LINENO: result: $SGMLSPL" >&5
-$as_echo "$SGMLSPL" >&6; }
+XSLTPROC=$ac_cv_prog_XSLTPROC
+if test -n "$XSLTPROC"; then
+  { $as_echo "$as_me:$LINENO: result: $XSLTPROC" >&5
+$as_echo "$XSLTPROC" >&6; }
 else
   { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-  test -n "$SGMLSPL" && break
+  test -n "$XSLTPROC" && break
 done
 
-{ $as_echo "$as_me:$LINENO: checking for docbook2man" >&5
-$as_echo_n "checking for docbook2man... " >&6; }
-if test "${ac_cv_path_DOCBOOK2MAN+set}" = set; then
+for ac_prog in osx sgml2xml sx
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OSX+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  if test -z "$DOCBOOK2MAN"; then
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+  if test -n "$OSX"; then
+  ac_cv_prog_OSX="$OSX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for ac_prog in docbook2x-man db2x_docbook2man docbook2man; do
-    ac_path="$as_dir/$ac_prog"
-    { test -f "$ac_path" && $as_test_x "$ac_path"; } || continue
-    if "$ac_path" --version 2>/dev/null | $GREP docbook2x >/dev/null 2>&1; then
-      ac_cv_path_DOCBOOK2MAN=$ac_path
-      break
-    fi
-  done
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OSX="$ac_prog"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 IFS=$as_save_IFS
 
-else
-  ac_cv_path_DOCBOOK2MAN=$DOCBOOK2MAN
 fi
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_DOCBOOK2MAN" >&5
-$as_echo "$ac_cv_path_DOCBOOK2MAN" >&6; }
-DOCBOOK2MAN=$ac_cv_path_DOCBOOK2MAN
+OSX=$ac_cv_prog_OSX
+if test -n "$OSX"; then
+  { $as_echo "$as_me:$LINENO: result: $OSX" >&5
+$as_echo "$OSX" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
 
+  test -n "$OSX" && break
+done
 
 
 # Thread testing
diff --git a/configure.in b/configure.in
index 79e1541e25b1fb0f433adc5fea843329dd565017..ba0dc1cb7d59707b9711df5f7b87ba0669ffc7ad 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.607 2009/07/24 15:03:07 tgl Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.608 2009/08/04 22:04:36 petere Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -1731,8 +1731,8 @@ PGAC_PROG_JADE
 PGAC_CHECK_DOCBOOK(4.2)
 PGAC_PATH_DOCBOOK_STYLESHEETS
 PGAC_PATH_COLLATEINDEX
-AC_CHECK_PROGS(SGMLSPL, sgmlspl)
-PGAC_PATH_DOCBOOK2MAN
+AC_CHECK_PROGS(XSLTPROC, xsltproc)
+AC_CHECK_PROGS(OSX, [osx sgml2xml sx])
 
 # Thread testing
 
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 7e1e113f149c8cb71d4660a06d7fc4e7b861271d..33bd247629e722b6652cdf999badb94337c25e01 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -2,7 +2,7 @@
 #
 # PostgreSQL documentation makefile
 #
-# $PostgreSQL: pgsql/doc/src/sgml/Makefile,v 1.119 2009/07/20 18:34:58 petere Exp $
+# $PostgreSQL: pgsql/doc/src/sgml/Makefile,v 1.120 2009/08/04 22:04:37 petere Exp $
 #
 #----------------------------------------------------------------------------
 
@@ -33,17 +33,15 @@ ifndef NSGMLS
 NSGMLS = nsgmls
 endif
 
-ifndef SGMLSPL
-SGMLSPL = sgmlspl
+ifndef OSX
+OSX = osx
 endif
 
-ifndef DOCBOOK2MAN
-DOCBOOK2MAN = docbook2man_is_missing
+ifndef XSLTPROC
+XSLTPROC = xsltproc
 endif
 
-# docbook2man generates man pages from docbook refentry source code.
-D2MSCRIPT= $(D2MDIR)/docbook2man-spec.pl
-D2MLINKS = $(D2MDIR)/docbook2man-spec_makelinks
+override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
 
 
 GENERATED_SGML = bookindex.sgml version.sgml \
@@ -70,25 +68,14 @@ override SPFLAGS += -wall -wno-unused-param -wno-empty -wfully-tagged
 ## Man pages
 ##
 
-.PHONY: html man draft clean
+.PHONY: man
 
-DEFAULTSECTION = l
+man: man-stamp
 
-fix_man_xrefs = $(PERL) -npi -e 's{\[XRef to GUC-([A-Z0-9-]*)\]}{($$l = $$1) =~ tr/A-Z-/a-z_/, $$l}ge || s{\[XRef to [A-Z0-9-]*\]}{in the documentation}g'
-lowercase = tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
-
-man: postgres.sgml $(ALLSGML)
-	$(NSGMLS) $(NSGMLS_FLAGS) $(SGMLINCLUDE) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
-# One more time, to resolve cross-references
-	$(NSGMLS) $(NSGMLS_FLAGS) $(SGMLINCLUDE) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
-	$(fix_man_xrefs) *.1 *.7
-	$(mkinstalldirs) man1 man7
-	$(D2MLINKS) < manpage.links
-	mv *.1 man1/
-	mv *.7 man7/
-	rm *.$(DEFAULTSECTION)
-# manpage.links doesn't handle lowercase, needs fixups
-	cd man7 && for file in `awk '{ print $$2 }' ../manpage.links`; do $(lowercase) <$$file >`echo $$file | $(lowercase)` && rm $$file || exit; done
+man-stamp: stylesheet-man.xsl postgres.xml
+	$(XSLTPROC) $(XSLTPROCFLAGS) $^
+	rm man1/SPI* man1/dblink*
+	touch $@
 
 
 ##
@@ -97,6 +84,8 @@ man: postgres.sgml $(ALLSGML)
 
 all: html
 
+.PHONY: html draft
+
 JADE.html.call = $(JADE) $(JADEFLAGS) $(SPFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t sgml -i output-html
 
 # The draft target creates HTML output in draft mode, without index (for faster build).
@@ -222,9 +211,6 @@ regress_README.html: regress.sgml
 ## XSLT processing
 ##
 
-OSX = osx # (may be called sx or sgml2xml on some systems)
-XSLTPROC = xsltproc
-
 postgres.xml: postgres.sgml $(ALMOSTALLSGML)
 	$(OSX) -D. -x lower $< | \
 	  $(PERL) -p -e 's/\[(amp|copy|egrave|gt|lt|mdash|nbsp|ouml|pi|quot|uuml) *\]/\&\1;/g;' \
@@ -232,8 +218,6 @@ postgres.xml: postgres.sgml $(ALMOSTALLSGML)
 	  >$@
 # ' hello Emacs
 
-override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
-
 xslthtml: stylesheet.xsl postgres.xml
 	$(XSLTPROC) $(XSLTPROCFLAGS) $^
 
@@ -268,18 +252,6 @@ MAKEINFO = makeinfo
 .SUFFIXES:
 
 
-##
-## Experimental man page building through docbook2x
-##
-
-manx: postgres.xml stylesheet-man.xsl
-	$(DOCBOOK2MAN) --solinks -s $(srcdir)/stylesheet-man.xsl --string-param default-manpage-section=$(DEFAULTSECTION)  $<
-	$(mkinstalldirs) man1 man7
-	mv *.1 man1/
-	mv *.7 man7/
-	rm *.$(DEFAULTSECTION)
-
-
 ##
 ## Check
 ##
@@ -297,7 +269,7 @@ clean distclean maintainer-clean:
 # HTML
 	rm -f *.html html-stamp
 # man
-	rm -rf *.1 *.7 *.$(DEFAULTSECTION) man1 man7 manpage.refs manpage.links manpage.log
+	rm -rf man1 man7 man-stamp
 # print
 	rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.fot
 # index
diff --git a/doc/src/sgml/docguide.sgml b/doc/src/sgml/docguide.sgml
index 4aafc4e2a0212ba501814695425f24af911d01b6..9e07f5a31a6be920f7bfbeb9dfec5c0e35622aba 100644
--- a/doc/src/sgml/docguide.sgml
+++ b/doc/src/sgml/docguide.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/docguide.sgml,v 1.76 2009/06/17 21:58:49 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/docguide.sgml,v 1.77 2009/08/04 22:04:37 petere Exp $ -->
 
 <appendix id="docguide">
  <title>Documentation</title>
@@ -83,13 +83,14 @@
 
    <variablelist>
     <varlistentry>
-     <term><ulink url="http://www.oasis-open.org/docbook/sgml/">DocBook DTD</ulink></term>
+     <term><ulink url="http://www.oasis-open.org/docbook/">DocBook DTD</ulink></term>
      <listitem>
       <para>
        This is the definition of DocBook itself.  We currently use
-       version 4.2; you cannot use later or earlier versions.  Note
-       that there is also an <acronym>XML</acronym> version of DocBook
-       &mdash; do not use that.
+       version 4.2; you cannot use later or earlier versions.  You
+       need the <acronym>SGML</acronym> variant of the DocBook DTD,
+       but to build man pages you also need the <acronym>XML</acronym>
+       variant of the same version.
       </para>
      </listitem>
     </varlistentry>
@@ -105,47 +106,51 @@
     </varlistentry>
 
     <varlistentry>
-     <term><ulink url="http://openjade.sourceforge.net">OpenJade</ulink></term>
+     <term><ulink url="http://wiki.docbook.org/topic/DocBookDssslStylesheets">DocBook DSSSL Stylesheets</ulink></term>
      <listitem>
       <para>
-       This is the base package of <acronym>SGML</acronym> processing.
-       It contains an <acronym>SGML</acronym> parser, a
-       <acronym>DSSSL</acronym> processor (that is, a program to
-       convert <acronym>SGML</acronym> to other formats using
-       <acronym>DSSSL</acronym> stylesheets), as well as a number of
-       related tools.  <productname>Jade</productname> is now being
-       maintained by the OpenJade group, no longer by James Clark.
+       These contain the processing instructions for converting the
+       DocBook sources to other formats, such as
+       <acronym>HTML</acronym>.
       </para>
      </listitem>
     </varlistentry>
 
     <varlistentry>
-     <term><ulink url="http://wiki.docbook.org/topic/DocBookDssslStylesheets">DocBook DSSSL Stylesheets</ulink></term>
+     <term><ulink url="http://wiki.docbook.org/topic/DocBookXslStylesheets">DocBook XSL Stylesheets</ulink></term>
      <listitem>
       <para>
-       These contain the processing instructions for converting the
-       DocBook sources to other formats, such as
-       <acronym>HTML</acronym>.
+       This is another stylesheet for converting DocBook to other
+       formats.  We currently use this to produce man pages and
+       optionally HTMLHelp.  You can also use this toolchain to
+       produce HTML or PDF output, but official PostgreSQL releases
+       use the DSSSL stylesheets for that.
       </para>
      </listitem>
     </varlistentry>
 
     <varlistentry>
-     <term><ulink url="http://search.cpan.org/dist/SGMLSpm/">SGMLSpm</ulink></term>
+     <term><ulink url="http://openjade.sourceforge.net">OpenJade</ulink></term>
      <listitem>
       <para>
-       This optional package is used to create man pages.
+       This is the base package of <acronym>SGML</acronym> processing.
+       It contains an <acronym>SGML</acronym> parser, a
+       <acronym>DSSSL</acronym> processor (that is, a program to
+       convert <acronym>SGML</acronym> to other formats using
+       <acronym>DSSSL</acronym> stylesheets), as well as a number of
+       related tools.  <productname>Jade</productname> is now being
+       maintained by the OpenJade group, no longer by James Clark.
       </para>
      </listitem>
     </varlistentry>
 
     <varlistentry>
-     <term><ulink url="http://docbook2x.sourceforge.net">DocBook2X</ulink></term>
+     <term><ulink url="http://xmlsoft.org/XSLT/">Libxslt</ulink> for <command>xsltproc</command></term>
      <listitem>
       <para>
-       This optional package is also used to create man pages.  You
-       want the <literal>docbook2man-sgmlspl</literal> package, not
-       the main <literal>docbook2x</literal> package.
+       This is the processing tool to use with the XSLT stylesheets
+       (like <command>jade</command> is the processing tool for DSSSL
+       stylesheets).
       </para>
      </listitem>
     </varlistentry>
@@ -263,13 +268,8 @@ CATALOG "docbook/4.2/catalog"
     available for <productname>Debian GNU/Linux</productname>.
     To install, simply use:
 <programlisting>
-apt-get install openjade1.3
-apt-get install docbook
-apt-get install docbook-dsssl
-apt-get install sgmlspl   # for the man pages
+apt-get install docbook docbook-dsssl docbook-xsl openjade xsltproc
 </programlisting>
-    (The plain <literal>openjade</literal> package installs
-    OpenJade 1.4, which seems not to work.)
    </para>
   </sect2>
 
@@ -511,13 +511,15 @@ CATALOG "docbook-dsssl-1.<replaceable>xx</>/catalog"
 checking for onsgmls... onsgmls
 checking for openjade... openjade
 checking for DocBook V4.2... yes
-checking for DocBook stylesheets... /usr/lib/sgml/stylesheets/nwalsh-modular
-checking for sgmlspl... sgmlspl
+checking for DocBook stylesheets... /usr/share/sgml/docbook/stylesheet/dsssl/modular
+checking for collateindex.pl... /usr/bin/collateindex.pl
+checking for xsltproc... xsltproc
+checking for osx... osx
 </computeroutput>
 </screen>
    If neither <filename>onsgmls</filename> nor
-   <filename>nsgmls</filename> were found then you will not see the
-   remaining 4 lines.  <filename>nsgmls</filename> is part of the Jade
+   <filename>nsgmls</filename> were found then some of the following tests
+   will be skipped.  <filename>nsgmls</filename> is part of the Jade
    package.  You can pass the environment variables
    <envar>JADE</envar> and <envar>NSGMLS</envar> to configure to point
    to the programs if they are not found automatically.  If
@@ -583,8 +585,7 @@ gmake postgres.tar.gz
   <title>Manpages</title>
 
   <para>
-   We use the <application>docbook2man-sgmlspl</application> utility
-   from the <productname>DocBook2X</productname> project to
+   We use the DocBook XSL stylesheets to
    convert <productname>DocBook</productname>
    <sgmltag>refentry</sgmltag> pages to *roff output suitable for man
    pages.  The man pages are also distributed as a tar archive,
@@ -592,32 +593,15 @@ gmake postgres.tar.gz
    pages, use the commands:
 <programlisting>
 cd doc/src/sgml
-gmake man D2MDIR=<replaceable>directory</replaceable>
+gmake man
 </programlisting>
-   Use the <varname>D2MDIR</varname> variable to specify the name of
-   the directory where the
-   file <filename>docbook2man-spec.pl</filename> from
-   the <application>docbook2man-sgmlspl</application> package resides.
-   There is no default for that.  Since that package is not available
-   or outdated in many packaging systems, you might want to just
-   download the source code tarball and unpack it.  No building is
-   required.  Then the path is something
-   like <literal>D2MDIR=/home/you/somewhere/docbook2man-sgmlspl-1.0/perl</literal>.
-   You may get warnings like this:
-<screen>
-Warning: unrecognized SDATA '[scaron]': please add definition to docbook2man-spec.pl
-Warning: unrecognized SDATA '[ouml  ]': please add definition to docbook2man-spec.pl
-</screen>
-   which can ignore if (and only if) you are using the latest version
-   of <filename>docbook2man-spec.pl</filename>
-   and you are not seeing any other SDATA warnings besides those.
   </para>
 
   <para>
    To create the man page package for a release, use the following commands:
 <programlisting>
 cd doc/src
-gmake man.tar.gz D2MDIR=<replaceable>directory</replaceable>
+gmake man.tar.gz
 </programlisting>
    which will result in a tar file being generated in the
    <filename>doc/src</filename> directory.
diff --git a/doc/src/sgml/postgres.sgml b/doc/src/sgml/postgres.sgml
index d4c4d40bbe28c99382d5d64325166cce9cfecf8d..caebed54447f7cb6b4af06aedf2645e707d0e4a8 100644
--- a/doc/src/sgml/postgres.sgml
+++ b/doc/src/sgml/postgres.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/postgres.sgml,v 1.89 2009/07/14 22:16:38 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/postgres.sgml,v 1.90 2009/08/04 22:04:37 petere Exp $ -->
 
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [
 
@@ -16,6 +16,8 @@
 
  <bookinfo>
   <corpauthor>The PostgreSQL Global Development Group</corpauthor>
+  <productname>PostgreSQL</productname>
+  <productnumber>&version;</productnumber>
   &legal;
  </bookinfo>
 
diff --git a/doc/src/sgml/ref/analyze.sgml b/doc/src/sgml/ref/analyze.sgml
index c0d2673dc50f01d0d6ece91ee1689d3329842233..cb9f20f3f56909dc70106af44369e4acb6d540e5 100644
--- a/doc/src/sgml/ref/analyze.sgml
+++ b/doc/src/sgml/ref/analyze.sgml
@@ -1,5 +1,5 @@
 <!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/analyze.sgml,v 1.26 2009/08/02 22:14:51 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/analyze.sgml,v 1.27 2009/08/04 22:04:37 petere Exp $
 PostgreSQL documentation
 -->
 
@@ -94,7 +94,7 @@ ANALYZE [ VERBOSE ] [ <replaceable class="PARAMETER">table</replaceable> [ ( <re
 
   <para>
    In the default <productname>PostgreSQL</productname> configuration,
-   <xref linkend="autovacuum" endterm="autovacuum-title">
+   the autovacuum daemon (see <xref linkend="autovacuum">)
    takes care of automatic analyzing of tables when they are first loaded
    with data, and as they change throughout regular operation.
    When autovacuum is disabled,
diff --git a/doc/src/sgml/stylesheet-man.xsl b/doc/src/sgml/stylesheet-man.xsl
index 2d37a42f1a5c17a6da5aad8fd7bdb6bd015d483d..842a9bd50399ec297d3aedd226a1b47a72d098d1 100644
--- a/doc/src/sgml/stylesheet-man.xsl
+++ b/doc/src/sgml/stylesheet-man.xsl
@@ -1,16 +1,158 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0">
+		xmlns:exsl="http://exslt.org/common"
+                version='1.0'
+                exclude-result-prefixes="exsl">
 
-<xsl:import href="http://docbook2x.sourceforge.net/latest/xslt/man/docbook.xsl"/>
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
+<xsl:import href="stylesheet-common.xsl" />
 
-<!--
-  Man pages don't really support a third section level, but this
-  makes our man pages work OK and matches the behavior of the sgmlspl
-  style.
+
+<!-- The following is a workaround for what may actually be a mistake
+     in our markup.  The problem is in a situation like
+
+<para>
+ <command>FOO</command> is ...
+
+     there is strictly speaking a line break before "FOO".  In the
+     HTML output, this does not appear to be a problem, but in the man
+     page output, this shows up.  Using this setting, pure whitespace
+     text nodes are removed, so the problem is solved. -->
+<xsl:strip-space elements="para"/>
+
+
+<!-- Parameters -->
+
+<xsl:param name="man.authors.section.enabled">0</xsl:param>
+<xsl:param name="man.copyright.section.enabled">0</xsl:param>
+<xsl:param name="man.output.base.dir"></xsl:param>
+<xsl:param name="man.output.in.separate.dir" select="1"></xsl:param>
+<xsl:param name="refentry.meta.get.quietly" select="0"></xsl:param>
+<xsl:param name="man.th.extra3.max.length">40</xsl:param> <!-- enough room for "PostgreSQL 8.5devel Documentation" -->
+<xsl:param name="refentry.xref.manvolnum" select="1"/> <!-- overridden from stylesheet-common.xsl -->
+
+<!-- Fixup for apostrophe groff output.  See the following references:
+     <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=457839>
+     <https://sourceforge.net/tracker/?func=detail&aid=2412738&group_id=21935&atid=373747>
  -->
-<xsl:template match="refsect3">
-  <xsl:call-template name="SS-section" />
+<xsl:param name="man.string.subst.map.local.post">
+  <substitution oldstring="\'" newstring="\(aq"></substitution>
+</xsl:param>
+
+
+<!-- Custom templates -->
+
+<xsl:template match="refentry" mode="xref-to">
+  <xsl:param name="referrer"/>
+  <xsl:param name="xrefstyle"/>
+
+  <xsl:choose>
+    <!-- If the refname contains a space, we construct a reference
+         like CREATE DATABASE (CREATE_DATABASE(7)), so the reader
+         knows both the command name being referred to and the name of
+         the man page to read about it. -->
+    <xsl:when test="contains(refnamediv/refname[1],' ')">
+      <xsl:variable name="mangled.title">
+       <xsl:value-of select="translate(refnamediv/refname[1],' ','_')"/>
+      </xsl:variable>
+      <xsl:apply-templates select="refnamediv/refname[1]"/>
+      <xsl:text> (</xsl:text>
+      <xsl:call-template name="bold">
+       <xsl:with-param name="node" select="exsl:node-set($mangled.title)"/>
+       <xsl:with-param name="context" select="."/>
+      </xsl:call-template>
+      <xsl:apply-templates select="refmeta/manvolnum"/>
+      <xsl:text>)</xsl:text>
+    </xsl:when>
+
+    <!-- This is the original case, except that boldness has been
+         added, per the convention mentioned in man-pages(7). -->
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="refmeta/refentrytitle">
+	 <xsl:call-template name="bold">
+	  <xsl:with-param name="node" select="refmeta/refentrytitle"/>
+	  <xsl:with-param name="context" select="."/>
+	 </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+	 <xsl:call-template name="bold">
+	  <xsl:with-param name="node" select="refnamediv/refname[1]"/>
+	  <xsl:with-param name="context" select="."/>
+	 </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:apply-templates select="refmeta/manvolnum"/>
+    </xsl:otherwise>
+  </xsl:choose>
+
 </xsl:template>
 
+
+<!-- Overridden template as workaround for this problem:
+     <https://sourceforge.net/tracker/?func=detail&aid=2831602&group_id=21935&atid=373747>
+-->
+  <xsl:template name="write.stubs">
+    <xsl:param name="first.refname"/>
+    <xsl:param name="section"/>
+    <xsl:param name="lang"/>
+    <xsl:for-each select="refnamediv/refname">
+      <xsl:if test=". != $first.refname">
+        <xsl:call-template name="write.text.chunk">
+          <xsl:with-param name="filename">
+            <xsl:call-template name="make.adjusted.man.filename">
+              <xsl:with-param name="name" select="."/>
+              <xsl:with-param name="section" select="$section"/>
+              <xsl:with-param name="lang" select="$lang"/>
+            </xsl:call-template>
+          </xsl:with-param>
+          <xsl:with-param name="quiet" select="$man.output.quietly"/>
+          <xsl:with-param name="suppress-context-node-name" select="1"/>
+          <xsl:with-param name="message-prolog">Note: </xsl:with-param>
+          <xsl:with-param name="message-epilog"> (soelim stub)</xsl:with-param>
+          <xsl:with-param name="content">
+	    <xsl:choose>
+	      <xsl:when test="$man.output.in.separate.dir = 0">
+		<xsl:value-of select="concat('.so man', $section, '/')"/>
+	      </xsl:when>
+	      <xsl:otherwise>
+		<xsl:value-of select="'.so '"/> <!-- added case -->
+	      </xsl:otherwise>
+	    </xsl:choose>
+            <xsl:call-template name="make.adjusted.man.filename">
+              <xsl:with-param name="name" select="$first.refname"/>
+              <xsl:with-param name="section" select="$section"/>
+            </xsl:call-template>
+            <xsl:text>&#10;</xsl:text>
+          </xsl:with-param>
+        </xsl:call-template>
+      </xsl:if>
+    </xsl:for-each>
+  </xsl:template>
+
+
+<!-- Gentext customization -->
+
+<!-- see http://www.sagehill.net/docbookxsl/CustomGentext.html -->
+<xsl:param name="local.l10n.xml" select="document('')"/>
+<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
+  <l:l10n language="en">
+    <!-- Use ISO 8601 date format. -->
+    <l:context name="datetime">
+      <l:template name="format" text="Y-m-d"/>
+    </l:context>
+
+    <!-- Slight rephrasing to indicate that missing sections are found
+         in the documentation. -->
+    <l:context name="xref-number-and-title">
+      <l:template name="chapter" text="Chapter %n, %t, in the documentation"/>
+      <l:template name="sect1" text="Section %n, “%t”, in the documentation"/>
+      <l:template name="sect2" text="Section %n, “%t”, in the documentation"/>
+      <l:template name="sect3" text="Section %n, “%t”, in the documentation"/>
+      <l:template name="sect4" text="Section %n, “%t”, in the documentation"/>
+      <l:template name="sect5" text="Section %n, “%t”, in the documentation"/>
+    </l:context>
+  </l:l10n>
+</l:i18n>
+
 </xsl:stylesheet>
diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml
index 348434f9174dfc42be44a4cb5e99c3984e7768df..50e5943401b0debc8bcc7e85dfbc08801814ba1b 100644
--- a/doc/src/sgml/trigger.sgml
+++ b/doc/src/sgml/trigger.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.57 2009/07/28 02:56:29 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.58 2009/08/04 22:04:37 petere Exp $ -->
 
  <chapter id="triggers">
   <title>Triggers</title>
@@ -541,7 +541,7 @@ typedef struct Trigger
   </sect1>
 
   <sect1 id="trigger-example">
-   <title>A Complete Example</title>
+   <title>A Complete Trigger Example</title>
 
    <para>
     Here is a very simple example of a trigger function written in C.
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 763bdc004a04a2da4e19598c4f81230bbb88f3c5..04f3b1a7dd8872350ac689c2135feb99d2d5ba4f 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
 # -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.254 2009/06/23 03:46:00 tgl Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.255 2009/08/04 22:04:37 petere Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
@@ -187,11 +187,6 @@ TCL_SHLIB_LD_LIBS	= @TCL_SHLIB_LD_LIBS@
 PTHREAD_CFLAGS		= @PTHREAD_CFLAGS@
 PTHREAD_LIBS		= @PTHREAD_LIBS@
 
-have_docbook	= @have_docbook@
-DOCBOOKSTYLE	= @DOCBOOKSTYLE@
-COLLATEINDEX	= @COLLATEINDEX@
-DOCBOOK2MAN	= @DOCBOOK2MAN@
-
 
 ##########################################################################
 #
@@ -298,9 +293,13 @@ STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
 
 # Documentation
 
-JADE	= @JADE@
-NSGMLS	= @NSGMLS@
-SGMLSPL	= @SGMLSPL@
+have_docbook	= @have_docbook@
+COLLATEINDEX	= @COLLATEINDEX@
+DOCBOOKSTYLE	= @DOCBOOKSTYLE@
+JADE			= @JADE@
+NSGMLS			= @NSGMLS@
+OSX				= @OSX@
+XSLTPROC		= @XSLTPROC@
 
 # Code coverage