diff --git a/PgCommon.pm b/PgCommon.pm
index 2de467b9c7520bbf149fc87dcbcc289faf7ca0c9..aee70cbdd4ecdbafde152bed16d72c98a833e8f1 100644
--- a/PgCommon.pm
+++ b/PgCommon.pm
@@ -562,7 +562,8 @@ sub check_pidfile_running {
 # Return a hash with information about a specific cluster.
 # Arguments: <version> <cluster name>
 # Returns: information hash (keys: pgdata, port, running, logfile [unless it
-#          has a custom one], configdir, owneruid, ownergid, socketdir)
+#          has a custom one], configdir, owneruid, ownergid, socketdir,
+#          statstempdir)
 sub cluster_info {
     error 'cluster_info must be called with <version> <cluster> arguments' unless $_[0] && $_[1];
 
@@ -572,6 +573,7 @@ sub cluster_info {
     $result{'pgdata'} = cluster_data_directory $_[0], $_[1], \%postgresql_conf;
     $result{'port'} = $postgresql_conf{'port'} || $defaultport;
     $result{'socketdir'} = get_cluster_socketdir  $_[0], $_[1];
+    $result{'statstempdir'} = $postgresql_conf{'stats_temp_directory'};
 
     # if we can determine the running status with the pid file, prefer that
     if ($postgresql_conf{'external_pid_file'} &&
diff --git a/debian/changelog b/debian/changelog
index 0382097e1e10ba26ffd75ab6b8ca0024ddccea3f..adc1d94e367a4203c9f2bb71d4efb21c0c705018 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,8 +6,9 @@ postgresql-common (146) UNRELEASED; urgency=low
     + On error, show tail of server log file.
     + When no command is given, open a shell.
   * pg_createcluster: Add --createclusterconf and --environment options.
+  * pg_ctlcluster: Create stats_temp_directory when missing.
 
- -- Christoph Berg <myon@debian.org>  Thu, 27 Jun 2013 15:19:02 +0200
+ -- Christoph Berg <myon@debian.org>  Mon, 01 Jul 2013 11:47:25 +0200
 
 postgresql-common (145) unstable; urgency=low
 
diff --git a/pg_ctlcluster b/pg_ctlcluster
index 0a285883db66b31ec47752805351a23ec7de9d6b..9503b4b04690522a5decc83e6a2d3f01619f4e5f 100755
--- a/pg_ctlcluster
+++ b/pg_ctlcluster
@@ -390,6 +390,12 @@ if ($action ne 'stop' && ! -d $info{'socketdir'}) {
 	'-o', $info{'owneruid'}, '-g', $info{'ownergid'}, $info{'socketdir'};
 }
 
+# recreate stats_temp_directory
+if ($action ne 'stop' && $info{'statstempdir'} && ! -d $info{'statstempdir'}) {
+    system 'install', '-d', '-m', 750,
+	'-o', $info{'owneruid'}, '-g', $info{'ownergid'}, $info{'statstempdir'};
+}
+
 if ($> == 0) {
     # have the postmaster start with increased OOM killer protection; 9.1 and
     # later has builtin support for resetting the adjustment of child processes