From 577577e9730135c1e8565de3e2b284c85ae60c17 Mon Sep 17 00:00:00 2001
From: Christoph Berg <myon@debian.org>
Date: Sun, 3 Nov 2013 23:50:11 +0100
Subject: [PATCH] pg_wrapper: Always use the latest available version of
 "pg_isready" instead of the target cluster's. pg_isready appeared only in
 9.3, but is usable with older versions as well. Suggested by Peter
 Eisentraut. (Closes: #728599)

---
 debian/changelog | 9 +++++++++
 pg_wrapper       | 7 +++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 0630b501..a060b223 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+postgresql-common (151) UNRELEASED; urgency=low
+
+  * pg_wrapper: Always use the latest available version of "pg_isready"
+    instead of the target cluster's. pg_isready appeared only in 9.3, but is
+    usable with older versions as well. Suggested by Peter Eisentraut.
+    (Closes: #728599)
+
+ -- Christoph Berg <myon@debian.org>  Sun, 03 Nov 2013 23:47:53 +0100
+
 postgresql-common (150) unstable; urgency=low
 
   [ Christoph Berg ]
diff --git a/pg_wrapper b/pg_wrapper
index a0f33e49..28adbe36 100755
--- a/pg_wrapper
+++ b/pg_wrapper
@@ -103,8 +103,8 @@ my $cmd;
 
 # for psql we always want the latest version, as this is backwards compatible
 # to every major version that that we support
-if ($cmdname eq 'psql') {
-    $cmd = get_program_path ('psql', get_newest_version);
+if ($cmdname =~ /^(psql|pg_isready)$/) {
+    $cmd = get_program_path ($cmdname, get_newest_version);
 } else {
     $cmd = get_program_path ($cmdname, $version);
 }
@@ -210,6 +210,9 @@ will be selected.
 
 If none of these rules match, B<pg_wrapper> aborts with an error.
 
+For B<psql> and B<pg_isready>, B<pg_wrapper> will always use the binary from
+the newest PostgreSQL version installed, as these are downwards compatible.
+
 =head1 OPTIONS
 
 =over
-- 
GitLab