aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/postinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-04-26 22:47:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-04-26 22:47:40 +0000
commitea0382e3706ab25935c733fd452d828832e4675f (patch)
tree1bf47e84c58c9e337934b1d3bddcb707dfb7cb06 /src/backend/utils/init/postinit.c
parentb6e2fab9788ab7cd7ca18903787dff2398441167 (diff)
downloadpostgresql-ea0382e3706ab25935c733fd452d828832e4675f.tar.gz
postgresql-ea0382e3706ab25935c733fd452d828832e4675f.zip
Code review for recent patch to terminate online backup during shutdown:
do CancelBackup at a sane place, fix some oversights in the state transitions, allow only superusers to connect while we are waiting for backup mode to end.
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r--src/backend/utils/init/postinit.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 6c29ea19174..695db95c726 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.182 2008/03/26 21:10:39 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.183 2008/04/26 22:47:40 tgl Exp $
*
*
*-------------------------------------------------------------------------
@@ -26,6 +26,7 @@
#include "catalog/pg_database.h"
#include "catalog/pg_tablespace.h"
#include "libpq/hba.h"
+#include "libpq/libpq-be.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
@@ -578,6 +579,16 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
CheckMyDatabase(dbname, am_superuser);
/*
+ * If we're trying to shut down, only superusers can connect.
+ */
+ if (!am_superuser &&
+ MyProcPort != NULL &&
+ MyProcPort->canAcceptConnections == CAC_WAITBACKUP)
+ ereport(FATAL,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be superuser to connect during database shutdown")));
+
+ /*
* Check a normal user hasn't connected to a superuser reserved slot.
*/
if (!am_superuser &&