summaryrefslogtreecommitdiff
path: root/src/backend/utils/init/postinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-11-21 06:36:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-11-21 06:36:27 +0000
commiteda8dd8b2d7d7969bad7d65f3dceb0ad8b617f54 (patch)
treeddcbd26bc76652413b1ffd057a7b34f6c90dce6e /src/backend/utils/init/postinit.c
parent6d227ae782466763869c7cc8ca7aebcaf631a96f (diff)
Code review for superuser_reserved_connections patch. Don't try to do
database access outside a transaction; revert bogus performance improvement in SIBackendInit(); improve comments; add documentation (this part courtesy Neil Conway).
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r--src/backend/utils/init/postinit.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 9ac71c6a812..94532e782f4 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.117 2002/10/03 19:19:09 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.117.2.1 2002/11/21 06:36:27 tgl Exp $
*
*
*-------------------------------------------------------------------------
@@ -378,6 +378,18 @@ InitPostgres(const char *dbname, const char *username)
RelationCacheInitializePhase3();
/*
+ * Check a normal user hasn't connected to a superuser reserved slot.
+ * We can't do this till after we've read the user information, and
+ * we must do it inside a transaction since checking superuserness
+ * may require database access. The superuser check is probably the
+ * most expensive part; don't do it until necessary.
+ */
+ if (ReservedBackends > 0 &&
+ CountEmptyBackendSlots() < ReservedBackends &&
+ !superuser())
+ elog(FATAL, "Non-superuser connection limit exceeded");
+
+ /*
* Initialize various default states that can't be set up until we've
* selected the active user and done ReverifyMyDatabase.
*/
@@ -397,17 +409,6 @@ InitPostgres(const char *dbname, const char *username)
/* close the transaction we started above */
if (!bootstrap)
CommitTransactionCommand(true);
-
- /*
- * Check a normal user hasn't connected to a superuser reserved slot.
- * Do this here since we need the user information and that only
- * happens after we've started bringing the shared memory online. So
- * we wait until we've registered exit handlers and potentially shut
- * an open transaction down for an as safety conscious rejection as
- * possible.
- */
- if (CountEmptyBackendSlots() < ReservedBackends && !superuser())
- elog(ERROR, "Non-superuser connection limit exceeded");
}
/*