diff options
| author | Tom Lane | 2002-05-17 01:19:19 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-05-17 01:19:19 +0000 |
| commit | f0811a74b37427d7ee5eee56b00f7f2ea323d7d6 (patch) | |
| tree | 51a596c44fd21144383062aa7d2ce852ae270268 /src/backend/utils/init | |
| parent | fa613fa1eafd8fd80272a31e8477ad9368c95dbb (diff) | |
Merge the last few variable.c configuration variables into the generic
GUC support. It's now possible to set datestyle, timezone, and
client_encoding from postgresql.conf and per-database or per-user
settings. Also, implement rollback of SET commands that occur in a
transaction that later fails. Create a SET LOCAL var = value syntax
that sets the variable only for the duration of the current transaction.
All per previous discussions in pghackers.
Diffstat (limited to 'src/backend/utils/init')
| -rw-r--r-- | src/backend/utils/init/miscinit.c | 24 | ||||
| -rw-r--r-- | src/backend/utils/init/postinit.c | 11 |
2 files changed, 14 insertions, 21 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 4cc9d396c70..fd3f191d5cd 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.90 2002/05/06 19:47:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.91 2002/05/17 01:19:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -614,6 +614,9 @@ InitializeSessionUserId(const char *username) SetSessionUserId(usesysid); /* sets CurrentUserId too */ + /* Record username as a config option too */ + SetConfigOption("session_authorization", username, + PGC_BACKEND, PGC_S_OVERRIDE); /* * Set up user-specific configuration variables. This is a good @@ -653,23 +656,16 @@ InitializeSessionUserIdStandalone(void) * Change session auth ID while running * * Only a superuser may set auth ID to something other than himself. - * - * username == NULL implies reset to default (AuthenticatedUserId). */ void -SetSessionAuthorization(const char *username) +SetSessionAuthorization(Oid userid) { - Oid userid; + /* Must have authenticated already, else can't make permission check */ + AssertState(OidIsValid(AuthenticatedUserId)); - if (username == NULL) - userid = AuthenticatedUserId; - else - { - userid = get_usesysid(username); - if (userid != AuthenticatedUserId && - !AuthenticatedUserIsSuperuser) - elog(ERROR, "permission denied"); - } + if (userid != AuthenticatedUserId && + !AuthenticatedUserIsSuperuser) + elog(ERROR, "permission denied"); SetSessionUserId(userid); SetUserId(userid); diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 95974c6d6a6..817c87c80a0 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.104 2002/05/05 00:03:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.105 2002/05/17 01:19:18 tgl Exp $ * * *------------------------------------------------------------------------- @@ -28,7 +28,6 @@ #include "catalog/pg_database.h" #include "catalog/pg_shadow.h" #include "commands/trigger.h" -#include "commands/variable.h" #include "mb/pg_wchar.h" #include "miscadmin.h" #include "storage/backendid.h" @@ -132,6 +131,9 @@ ReverifyMyDatabase(const char *name) */ #ifdef MULTIBYTE SetDatabaseEncoding(dbform->encoding); + /* If we have no other source of client_encoding, use server encoding */ + SetConfigOption("client_encoding", GetDatabaseEncodingName(), + PGC_BACKEND, PGC_S_DEFAULT); #else if (dbform->encoding != PG_SQL_ASCII) elog(FATAL, "database was initialized with MULTIBYTE encoding %d,\n\tbut the backend was compiled without multibyte support.\n\tlooks like you need to initdb or recompile.", @@ -388,11 +390,6 @@ InitPostgres(const char *dbname, const char *username) /* set default namespace search path */ InitializeSearchPath(); -#ifdef MULTIBYTE - /* set default client encoding --- uses info from ReverifyMyDatabase */ - set_default_client_encoding(); -#endif - /* * 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 |
