diff --git a/.postgresql.metadata b/.postgresql.metadata
index 4c39b1f..a57509e 100644
--- a/.postgresql.metadata
+++ b/.postgresql.metadata
@@ -1,3 +1,3 @@
-e3ae82eb864af03ebf213c430c65e69fef472fbd SOURCES/postgresql-8.4.18.tar.bz2
-176ac1de372c06192ec1012b17001414cfa40929 SOURCES/postgresql-9.2.5.tar.bz2
-86391a61c4dfb73900b6725d7a1ecf7fef6d6857 SOURCES/postgresql-9.2.5-US.pdf
+20b6a83e7ba4bbaa1544bfdf4622ccd205bfc509 SOURCES/postgresql-9.2.7.tar.bz2
+d420a9eb3871aa71ac2d9e0abeccb0b9de1300b1 SOURCES/postgresql-9.2.7-US.pdf
+bad68fc70f90a28212459e5347c32ebbdfcf2c8e SOURCES/postgresql-8.4.20.tar.bz2
diff --git a/SOURCES/postgresql-setup b/SOURCES/postgresql-setup
old mode 100644
new mode 100755
index a755e11..acf07f7
--- a/SOURCES/postgresql-setup
+++ b/SOURCES/postgresql-setup
@@ -1,46 +1,91 @@
-#!/bin/sh
+#!/bin/bash
 #
-# postgresql-setup	Initialization and upgrade operations for PostgreSQL
+# postgresql-setup - Initialization and upgrade operations for PostgreSQL
+
+test x"$PGSETUP_DEBUG" != x && set -x
 
 # PGVERSION is the full package version, e.g., 9.0.2
 # Note: the specfile inserts the correct value during package build
 PGVERSION=xxxx
+
+# PGMAJORVERSION is the major version, e.g. 9.0
+PGMAJORVERSION=xxxx
+
 # PGENGINE is the directory containing the postmaster executable
-# Note: the specfile inserts the correct value during package build
 PGENGINE=xxxx
+
 # PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades
-# Note: the specfile inserts the correct value during package build
 PREVMAJORVERSION=xxxx
+
 # PREVPGENGINE is the directory containing the previous postmaster executable
-# Note: the specfile inserts the correct value during package build
 PREVPGENGINE=xxxx
 
 # Absorb configuration settings from the specified systemd service file,
 # or the default "postgresql" service if not specified
 SERVICE_NAME="$2"
-if [ x"$SERVICE_NAME" = x ]
-then
+if [ x"$SERVICE_NAME" = x ]; then
     SERVICE_NAME=postgresql
 fi
 
+# Pathname of the RPM distribution README
+README_RPM_DIST=xxxx
+
+USAGE_STRING=$"
+Usage: $0 {initdb|upgrade} [SERVICE_NAME]
+
+Script is aimed to help sysadmin with basic database cluster administration.
+
+The SERVICE_NAME is used for selection of proper unit configuration file; For
+more info and howto/when use this script please look at the docu file
+$README_RPM_DIST.  The 'postgresql'
+string is used when no SERVICE_NAME is explicitly passed.
+
+Available operation mode:
+  initdb        Create a new PostgreSQL database cluster.  This is usually the
+                first action you perform after PostgreSQL server installation.
+  upgrade       Upgrade PostgreSQL database cluster to be usable with new
+                server.  Use this if you upgraded your PostgreSQL server to
+                newer major version (currently from $PREVMAJORVERSION \
+to $PGMAJORVERSION).
+
+Environment:
+  PGSETUP_INITDB_OPTIONS     Options carried by this variable are passed to
+                             subsequent call of \`initdb\` binary (see man
+                             initdb(1)).  This variable is used also during
+                             'upgrade' mode because the new cluster is actually
+                             re-initialized from the old one.
+  PGSETUP_PGUPGRADE_OPTIONS  Options in this variable are passed next to the
+                             subsequent call of \`pg_upgrade\`.  For more info
+                             about possible options please look at man
+                             pg_upgrade(1).
+  PGSETUP_DEBUG              Set to '1' if you want to see debugging output."
+
+# note that these options are useful at least for help2man processing
+case "$1" in
+    --version)
+        echo "postgresql-setup $PGVERSION"
+        exit 0
+        ;;
+    --help|--usage)
+        echo "$USAGE_STRING"
+        exit 0
+        ;;
+esac
+
 # this parsing technique fails for PGDATA pathnames containing spaces,
 # but there's not much I can do about it given systemctl's output format...
 PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" |
-  sed 's/^Environment=//' | tr ' ' '\n' |
-  sed -n 's/^PGDATA=//p' | tail -n 1`
-
-if [ x"$PGDATA" = x ]
-then
+                sed 's/^Environment=//' | tr ' ' '\n' |
+                sed -n 's/^PGDATA=//p' | tail -n 1`
+if [ x"$PGDATA" = x ]; then
     echo "failed to find PGDATA setting in ${SERVICE_NAME}.service"
     exit 1
 fi
 
 PGPORT=`systemctl show -p Environment "${SERVICE_NAME}.service" |
-  sed 's/^Environment=//' | tr ' ' '\n' |
-  sed -n 's/^PGPORT=//p' | tail -n 1`
-
-if [ x"$PGPORT" = x ]
-then
+                sed 's/^Environment=//' | tr ' ' '\n' |
+                sed -n 's/^PGPORT=//p' | tail -n 1`
+if [ x"$PGPORT" = x ]; then
     echo "failed to find PGPORT setting in ${SERVICE_NAME}.service"
     exit 1
 fi
@@ -55,8 +100,7 @@ export PGDATA
 export PGPORT
 
 # For SELinux we need to use 'runuser' not 'su'
-if [ -x /sbin/runuser ]
-then
+if [ -x /sbin/runuser ]; then
     SU=runuser
 else
     SU=su
@@ -66,81 +110,75 @@ script_result=0
 
 # code shared between initdb and upgrade actions
 perform_initdb(){
-	if [ ! -e "$PGDATA" ]
-	then
-		mkdir "$PGDATA" || return 1
-		chown postgres:postgres "$PGDATA"
-		chmod go-rwx "$PGDATA"
-	fi
-	# Clean up SELinux tagging for PGDATA
-	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
-
-	# Create the initdb log file if needed
-	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
-	then
-		touch "$PGLOG" || return 1
-		chown postgres:postgres "$PGLOG"
-		chmod go-rwx "$PGLOG"
-		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
-	fi
-
-	# Initialize the database
-	$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null
-
-	# Create directory for postmaster log files
-	mkdir "$PGDATA/pg_log"
-	chown postgres:postgres "$PGDATA/pg_log"
-	chmod go-rwx "$PGDATA/pg_log"
-	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA/pg_log"
-
-	if [ -f "$PGDATA/PG_VERSION" ]
-	then
-	    return 0
-	fi
-	return 1
+    if [ ! -e "$PGDATA" ]; then
+        mkdir "$PGDATA" || return 1
+        chown postgres:postgres "$PGDATA"
+        chmod go-rwx "$PGDATA"
+    fi
+    # Clean up SELinux tagging for PGDATA
+    [ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
+
+    # Create the initdb log file if needed
+    if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]; then
+        touch "$PGLOG" || return 1
+        chown postgres:postgres "$PGLOG"
+        chmod go-rwx "$PGLOG"
+        [ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
+    fi
+
+    # Initialize the database
+    initdbcmd="$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'"
+    initdbcmd+=" $PGSETUP_INITDB_OPTIONS"
+
+    $SU -l postgres -c "$initdbcmd" >> "$PGLOG" 2>&1 < /dev/null
+
+    # Create directory for postmaster log files
+    mkdir "$PGDATA/pg_log"
+    chown postgres:postgres "$PGDATA/pg_log"
+    chmod go-rwx "$PGDATA/pg_log"
+    [ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA/pg_log"
+
+    if [ -f "$PGDATA/PG_VERSION" ]; then
+        return 0
+    fi
+    return 1
 }
 
 initdb(){
-    if [ -f "$PGDATA/PG_VERSION" ]
-    then
-	echo $"Data directory is not empty!"
-	echo
-	script_result=1
+    if [ -f "$PGDATA/PG_VERSION" ]; then
+        echo $"Data directory is not empty!"
+        echo
+        script_result=1
     else
-	echo -n $"Initializing database ... "
-	if perform_initdb
-	then
-	    echo $"OK"
-	else
-	    echo $"failed, see $PGLOG"
-	    script_result=1
-	fi
-	echo
+        echo -n $"Initializing database ... "
+        if perform_initdb; then
+            echo $"OK"
+        else
+            echo $"failed, see $PGLOG"
+            script_result=1
+        fi
+        echo
     fi
 }
 
 upgrade(){
     # must see previous version in PG_VERSION
     if [ ! -f "$PGDATA/PG_VERSION" -o \
-	 x`cat "$PGDATA/PG_VERSION"` != x"$PREVMAJORVERSION" ]
+         x`cat "$PGDATA/PG_VERSION"` != x"$PREVMAJORVERSION" ]
     then
-	echo
-	echo $"Cannot upgrade because database is not of version $PREVMAJORVERSION."
-	echo
-	exit 1
+        echo
+        echo $"Cannot upgrade because the database in $PGDATA is not of"
+        echo $"compatible previous version $PREVMAJORVERSION."
+        echo
+        exit 1
     fi
-    if [ ! -x "$PGENGINE/pg_upgrade" ]
-    then
-	echo
-	echo $"Please install the postgresql-upgrade RPM."
-	echo
-	exit 5
+    if [ ! -x "$PGENGINE/pg_upgrade" ]; then
+        echo
+        echo $"Please install the postgresql-upgrade RPM."
+        echo
+        exit 5
     fi
 
-    # Make sure service is stopped
-    # Using service here makes it work both with systemd and other init systems
-    service "$SERVICE_NAME" stop
-
     # Set up log file for pg_upgrade
     rm -f "$PGUPLOG"
     touch "$PGUPLOG" || exit 1
@@ -153,39 +191,60 @@ upgrade(){
     rm -rf "$PGDATAOLD"
     mv "$PGDATA" "$PGDATAOLD" || exit 1
 
+    # Create configuration file for upgrade process
+    HBA_CONF_BACKUP="$PGDATAOLD/pg_hba.conf.postgresql-setup.`date +%s`"
+    HBA_CONF_BACKUP_EXISTS=0
+
+    if [ ! -f $HBA_CONF_BACKUP ]; then
+        mv "$PGDATAOLD/pg_hba.conf" "$HBA_CONF_BACKUP"
+        HBA_CONF_BACKUP_EXISTS=1
+
+        # For fluent upgrade 'postgres' user should be able to connect
+        # to any database without password.  Temporarily, no other type
+        # of connection is needed.
+        echo "local all postgres ident" > "$PGDATAOLD/pg_hba.conf"
+    fi
+
     echo -n $"Upgrading database: "
 
     # Create empty new-format database
-    if perform_initdb
-    then
-	# Do the upgrade
-	$SU -l postgres -c "$PGENGINE/pg_upgrade \
-		'--old-bindir=$PREVPGENGINE' \
-		'--new-bindir=$PGENGINE' \
-		'--old-datadir=$PGDATAOLD' \
-		'--new-datadir=$PGDATA' \
-		--link \
-		'--old-port=$PGPORT' '--new-port=$PGPORT' \
-		--user=postgres" >> "$PGUPLOG" 2>&1 < /dev/null
-	if [ $? -ne 0 ]
-	then
-	    # pg_upgrade failed
-	    script_result=1
-	fi
+    if perform_initdb; then
+        # Do the upgrade
+        $SU -l postgres -c "$PGENGINE/pg_upgrade \
+                        '--old-bindir=$PREVPGENGINE' \
+                        '--new-bindir=$PGENGINE' \
+                        '--old-datadir=$PGDATAOLD' \
+                        '--new-datadir=$PGDATA' \
+                        --link \
+                        '--old-port=$PGPORT' '--new-port=$PGPORT' \
+                        --user=postgres \
+                        $PGSETUP_PGUPGRADE_OPTIONS" \
+                                >> "$PGUPLOG" 2>&1 < /dev/null
+        if [ $? -ne 0 ]; then
+            # pg_upgrade failed
+            script_result=1
+        fi
     else
-	# initdb failed
-	script_result=1
+        # initdb failed
+        script_result=1
     fi
 
-    if [ $script_result -eq 0 ]
-    then
-	    echo $"OK"
-    else
-	    # Clean up after failure
-	    rm -rf "$PGDATA"
-	    mv "$PGDATAOLD" "$PGDATA"
+    # Move back the backed-up pg_hba.conf regardless of the script_result.
+    if [ x$HBA_CONF_BACKUP_EXISTS = x1 ]; then
+        mv -f "$HBA_CONF_BACKUP" "$PGDATAOLD/pg_hba.conf"
+    fi
 
-	    echo $"failed"
+    if [ $script_result -eq 0 ]; then
+        echo $"OK"
+        echo
+        echo $"The configuration files were replaced by default configuration."
+        echo $"The previous configuration and data are stored in folder"
+        echo $PGDATAOLD.
+    else
+        # Clean up after failure
+        rm -rf "$PGDATA"
+        mv "$PGDATAOLD" "$PGDATA"
+        echo $"failed"
     fi
     echo
     echo $"See $PGUPLOG for details."
@@ -193,15 +252,15 @@ upgrade(){
 
 # See how we were called.
 case "$1" in
-  initdb)
-	initdb
-	;;
-  upgrade)
-	upgrade
-	;;
-  *)
-	echo $"Usage: $0 {initdb|upgrade} [ service_name ]"
-	exit 2
+    initdb)
+        initdb
+        ;;
+    upgrade)
+        upgrade
+        ;;
+    *)
+        echo >&2 "$USAGE_STRING"
+        exit 2
 esac
 
 exit $script_result
diff --git a/SPECS/postgresql.spec b/SPECS/postgresql.spec
index c7d0f6a..37fadd9 100644
--- a/SPECS/postgresql.spec
+++ b/SPECS/postgresql.spec
@@ -53,12 +53,17 @@
 %{!?selinux:%global selinux 1}
 %{!?runselftest:%global runselftest 1}
 
+# By default, patch(1) creates backup files when chunks apply with offsets.
+# Turn that off to ensure such files don't get included in RPMs.
+%global _default_patch_flags --no-backup-if-mismatch
+
+%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}
 
 Summary: PostgreSQL client programs
 Name: postgresql
 %global majorversion 9.2
-Version: 9.2.5
-Release: 3%{?dist}
+Version: 9.2.7
+Release: 1%{?dist}
 
 # The PostgreSQL license is very similar to other MIT licenses, but the OSI
 # recognizes it as an independent license, so we do as well.
@@ -73,7 +78,7 @@ Url: http://www.postgresql.org/
 # in-place upgrade of an old database.  In most cases it will not be critical
 # that this be kept up with the latest minor release of the previous series;
 # but update when bugs affecting pg_dump output are fixed.
-%global prevversion 8.4.18
+%global prevversion 8.4.20
 %global prevmajorversion 8.4
 
 Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
@@ -123,7 +128,7 @@ Patch12: postgresql-9.2.4-upgrade-from-8.4.13.patch
 # ~> #896161
 Patch13: postgresql-9.2.4-upgrade-and-perm-problems.patch
 
-BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
+BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk help2man
 BuildRequires: perl(ExtUtils::Embed), perl-devel
 BuildRequires: readline-devel zlib-devel
 BuildRequires: systemd-units
@@ -378,6 +383,25 @@ popd
 # remove .gitignore files to ensure none get into the RPMs (bug #642210)
 find . -type f -name .gitignore | xargs rm
 
+# prep the setup script, including insertion of some values it needs
+sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
+        -e 's|^PGMAJORVERSION=.*$|PGMAJORVERSION=%{majorversion}|' \
+        -e 's|^PGENGINE=.*$|PGENGINE=%{_bindir}|' \
+        -e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
+        -e 's|^PREVPGENGINE=.*$|PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin|' \
+        -e 's|^README_RPM_DIST=.*$|README_RPM_DIST=%{_pkgdocdir}/%(basename %{SOURCE8})|' \
+        <%{SOURCE9} >postgresql-setup
+touch -r %{SOURCE9} postgresql-setup
+chmod +x postgresql-setup
+help2man -N -m "Postgresql RPM-dist manual" ./postgresql-setup -o postgresql-setup.1
+
+# prep the startup check script, including insertion of some values it needs
+sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
+        -e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
+        -e 's|^PGDOCDIR=.*$|PGDOCDIR=%{_pkgdocdir}|' \
+        <%{SOURCE4} >postgresql-check-db-dir
+touch -r %{SOURCE4} postgresql-check-db-dir
+
 %build
 
 # fail quickly and obviously if user tries to build as root
@@ -390,17 +414,18 @@ find . -type f -name .gitignore | xargs rm
 	fi
 %endif
 
-CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS
+# Fiddling with CFLAGS.
 
+CFLAGS="${CFLAGS:-%optflags}"
+%ifarch %{power64}
+# See the bug #1051075, ppc64 should benefit from -O3
+CFLAGS=`echo $CFLAGS | xargs -n 1 | sed 's|-O2|-O3|g' | xargs -n 100`
+%endif
 # Strip out -ffast-math from CFLAGS....
 CFLAGS=`echo $CFLAGS|xargs -n 1|grep -v ffast-math|xargs -n 100`
 # Add LINUX_OOM_SCORE_ADJ=0 to ensure child processes reset postmaster's oom_score_adj
 CFLAGS="$CFLAGS -DLINUX_OOM_SCORE_ADJ=0"
-# let's try removing this kluge, it may just be a workaround for bz#520916
-# # use -O1 on sparc64 and alpha
-# %%ifarch sparc64 alpha
-# CFLAGS=`echo $CFLAGS| sed -e "s|-O2|-O1|g" `
-# %%endif
+export CFLAGS
 
 # plpython requires separate configure/build runs to build against python 2
 # versus python 3.  Our strategy is to do the python 3 run first, then make
@@ -635,21 +660,9 @@ esac
 install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
 cp -p src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
 
-# prep the setup script, including insertion of some values it needs
-sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
-	-e 's|^PGENGINE=.*$|PGENGINE=%{_bindir}|' \
-	-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
-	-e 's|^PREVPGENGINE=.*$|PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin|' \
-	<%{SOURCE9} >postgresql-setup
-touch -r %{SOURCE9} postgresql-setup
 install -m 755 postgresql-setup $RPM_BUILD_ROOT%{_bindir}/postgresql-setup
+install -p -m 644 postgresql-setup.1 $RPM_BUILD_ROOT%{_mandir}/man1
 
-# prep the startup check script, including insertion of some values it needs
-sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
-	-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
-	-e 's|^PGDOCDIR=.*$|PGDOCDIR=%{_docdir}/%{name}-%{version}|' \
-	<%{SOURCE4} >postgresql-check-db-dir
-touch -r %{SOURCE4} postgresql-check-db-dir
 install -m 755 postgresql-check-db-dir $RPM_BUILD_ROOT%{_bindir}/postgresql-check-db-dir
 
 install -d $RPM_BUILD_ROOT%{_unitdir}
@@ -1048,6 +1061,7 @@ fi
 %{_mandir}/man1/pg_receivexlog.*
 %{_mandir}/man1/pg_resetxlog.*
 %{_mandir}/man1/postgres.*
+%{_mandir}/man1/postgresql-setup.*
 %{_mandir}/man1/postmaster.*
 %{_datadir}/pgsql/postgres.bki
 %{_datadir}/pgsql/postgres.description
@@ -1132,6 +1146,33 @@ fi
 %endif
 
 %changelog
+* Tue Feb 18 2014 Pavel Raiskup <praiskup@redhat.com> - 9.2.7-1
+- update to 9.2.7 per release notes (#1065845)
+  http://www.postgresql.org/docs/9.2/static/release-9-2-7.html
+
+* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 9.2.6-7
+- Mass rebuild 2014-01-24
+
+* Thu Jan 23 2014 Pavel Raiskup <praiskup@redhat.com> - 9.2.6-6
+- fix typos related to postgresql-setup (#1055965)
+
+* Wed Jan 22 2014 Jozef Mlich <jmlich@redhat.com> - 9.2.6-5
+- revamp postgresql-setup a little (#1055965)
+
+* Fri Jan 10 2014 Pavel Raiskup <praiskup@redhat.com> - 9.2.6-4
+- build with -O3 on ppc64 (#1051075)
+
+* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 9.2.6-3
+- Mass rebuild 2013-12-27
+
+* Tue Dec 17 2013 Pavel Raiskup <praiskup@redhat.com> - 9.2.6-2
+- don't fail if user has badly configured 'postgres' user access (#1043477)
+
+* Thu Dec 12 2013 Jozef Mlich <jmlich@redhat.com> - 9.2.6-1
+- Resolves #1038688
+- rebase to 9.2.6 see changes at
+  http://www.postgresql.org/docs/9.2/static/release-9-2-6.html
+
 * Wed Oct 23 2013 Jozef Mlich <jmlich@redhat.com> - 9.2.5-3
 - Resolves: #1019762
 - Diff hunk order is important in this patch