diff --git a/debian/changelog b/debian/changelog
index 320b566b6c84b666d7e239f80547e15ee98145c7..49dc20bc02c73d07461d34ef7962d85ef07d64b4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ postgresql-common (122) UNRELEASED; urgency=low
   * debian/control: Fix duplicate package description. (Closes: #639562)
   * debian/control: Add lsb-release dependency to -server-dev-all, as the
     pg_buildext tool needs it.
+  * pg_wrapper: Find libreadline in multiarch directory, too.
+    (Closes: #640520)
 
  -- Martin Pitt <mpitt@debian.org>  Sun, 28 Aug 2011 17:19:28 +0200
 
diff --git a/pg_wrapper b/pg_wrapper
index 45644953b60a0458fe9a3b460e1c98d7836eaa72..00a6451bd8bc82b27dc0fe4162d476000576ae33 100755
--- a/pg_wrapper
+++ b/pg_wrapper
@@ -99,7 +99,13 @@ my $cmd = get_program_path ($cmdname, $version);
 
 # libreadline is a lot better than libedit, so prefer that
 if ($cmdname eq 'psql') {
-    my @readlines = sort(</lib/libreadline.so.*>);
+    my @readlines;
+    my $multiarch = `dpkg-architecture -qDEB_HOST_MULTIARCH`;
+    chomp $multiarch;
+    if ($multiarch) {
+	push @readlines, sort(</lib/$multiarch/libreadline.so.*>);
+    }
+    push @readlines, sort(</lib/libreadline.so.*>);
     if (@readlines) {
 	$ENV{'LD_PRELOAD'} = ($ENV{'LD_PRELOAD'} or '') . ':' . $readlines[-1];
     }