diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-11-14 19:35:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-11-14 19:35:35 +0000 |
commit | ea23ec82c2ec2ac14007f002692743b67b18f80f (patch) | |
tree | f2cc94b72ce963bfc815834154d542723c2f0623 /src/backend/utils/init/postinit.c | |
parent | 1c7a47cea42fadf91d343e7f037225d5834f3df0 (diff) | |
download | postgresql-ea23ec82c2ec2ac14007f002692743b67b18f80f.tar.gz postgresql-ea23ec82c2ec2ac14007f002692743b67b18f80f.zip |
Remove GUC USERLIMIT variable category, making the affected variables
plain SUSET instead. Also delay processing of options received in
client connection request until after we know if the user is a superuser,
so that SUSET values can be set that way by legitimate superusers.
Per recent discussion.
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index a8af269591e..ddbe08d5daa 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.137 2004/08/29 05:06:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.138 2004/11/14 19:35:32 tgl Exp $ * * *------------------------------------------------------------------------- @@ -221,14 +221,21 @@ BaseInit(void) * InitPostgres * Initialize POSTGRES. * + * In bootstrap mode neither of the parameters are used. + * + * The return value indicates whether the userID is a superuser. (That + * can only be tested inside a transaction, so we want to do it during + * the startup transaction rather than doing a separate one in postgres.c.) + * * Note: * Be very careful with the order of calls in the InitPostgres function. * -------------------------------- */ -void +bool InitPostgres(const char *dbname, const char *username) { bool bootstrap = IsBootstrapProcessingMode(); + bool am_superuser; /* * Set up the global variables holding database id and path. @@ -398,15 +405,19 @@ InitPostgres(const char *dbname, const char *username) RelationCacheInitializePhase3(); /* + * Check if user is a superuser. + */ + if (bootstrap) + am_superuser = true; + else + am_superuser = superuser(); + + /* * 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()) + if (!am_superuser && + ReservedBackends > 0 && + CountEmptyBackendSlots() < ReservedBackends) ereport(FATAL, (errcode(ERRCODE_TOO_MANY_CONNECTIONS), errmsg("connection limit exceeded for non-superusers"))); @@ -423,12 +434,6 @@ InitPostgres(const char *dbname, const char *username) InitializeClientEncoding(); /* - * Now all default states are fully set up. Report them to client if - * appropriate. - */ - BeginReportingGUCOptions(); - - /* * Set up process-exit callback to do pre-shutdown cleanup. This * should be last because we want shmem_exit to call this routine * before the exit callbacks that are registered by buffer manager, @@ -440,6 +445,8 @@ InitPostgres(const char *dbname, const char *username) /* close the transaction we started above */ if (!bootstrap) CommitTransactionCommand(); + + return am_superuser; } /* |