diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-11-21 06:36:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-11-21 06:36:08 +0000 |
commit | 8362be35e82574801113a7fe4dfdc3037010fc04 (patch) | |
tree | b5603e45b2956d5dc8b52f9adf2c02f9d42494ed /src/backend/utils/init/postinit.c | |
parent | 02d83d7565bfa306f876c3fecc89a159e28e0e3b (diff) | |
download | postgresql-8362be35e82574801113a7fe4dfdc3037010fc04.tar.gz postgresql-8362be35e82574801113a7fe4dfdc3037010fc04.zip |
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.c | 25 |
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..3ad2c50a843 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.118 2002/11/21 06:36:08 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"); } /* |