diff options
| author | Peter Eisentraut | 2002-03-01 22:45:19 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2002-03-01 22:45:19 +0000 |
| commit | 1aac2c852a2ccd817daf2dac99cf450e7822eb20 (patch) | |
| tree | 905d452d101bd6ef6024d178261556ef7cd73470 /src/backend/utils/init | |
| parent | 851f7661154f6de6dd0cfef5fec5aa7cce0a7ae8 (diff) | |
User and database-specific session defaults for run-time configuration
variables. New commands ALTER DATABASE ... SET and ALTER USER ... SET.
Diffstat (limited to 'src/backend/utils/init')
| -rw-r--r-- | src/backend/utils/init/miscinit.c | 20 | ||||
| -rw-r--r-- | src/backend/utils/init/postinit.c | 26 |
2 files changed, 44 insertions, 2 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 9705dda664c..0ccbe753d06 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.82 2002/01/09 19:13:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.83 2002/03/01 22:45:15 petere Exp $ * *------------------------------------------------------------------------- */ @@ -31,6 +31,7 @@ #include "libpq/libpq-be.h" #include "miscadmin.h" #include "utils/builtins.h" +#include "utils/guc.h" #include "utils/lsyscache.h" #include "utils/syscache.h" @@ -437,6 +438,8 @@ void InitializeSessionUserId(const char *username) { HeapTuple userTup; + Datum datum; + bool isnull; /* * Don't do scans if we're bootstrapping, none of the system catalogs @@ -457,6 +460,21 @@ InitializeSessionUserId(const char *username) AuthenticatedUserIsSuperuser = ((Form_pg_shadow) GETSTRUCT(userTup))->usesuper; + /* + * Set up user-specific configuration variables. This is a good + * place to do it so we don't have to read pg_shadow twice during + * session startup. + */ + datum = SysCacheGetAttr(SHADOWNAME, userTup, + Anum_pg_shadow_useconfig, &isnull); + if (!isnull) + { + ArrayType *a; + + a = (ArrayType *) pg_detoast_datum((struct varlena *)datum); + ProcessGUCArray(a, PGC_S_USER); + } + ReleaseSysCache(userTup); } diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 222ab6d54ab..858b6e649c7 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.98 2002/02/19 20:11:18 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.99 2002/03/01 22:45:15 petere Exp $ * * *------------------------------------------------------------------------- @@ -35,6 +35,7 @@ #include "storage/sinval.h" #include "storage/smgr.h" #include "utils/fmgroids.h" +#include "utils/guc.h" #include "utils/portal.h" #include "utils/relcache.h" #include "utils/syscache.h" @@ -70,6 +71,10 @@ static bool ThereIsAtLeastOneUser(void); * * This is also a handy place to fetch the database encoding info out * of pg_database, if we are in MULTIBYTE mode. + * + * To avoid having to read pg_database more times than necessary + * during session startup, this place is also fitting to set up any + * database-specific configuration variables. * -------------------------------- */ static void @@ -132,6 +137,25 @@ ReverifyMyDatabase(const char *name) dbform->encoding); #endif + /* + * Set up datbase-specific configuration variables. + */ + if (IsUnderPostmaster) + { + Datum datum; + bool isnull; + + datum = heap_getattr(tup, Anum_pg_database_datconfig, + RelationGetDescr(pgdbrel), &isnull); + if (!isnull) + { + ArrayType *a; + + a = (ArrayType *) pg_detoast_datum((struct varlena *)datum); + ProcessGUCArray(a, PGC_S_DATABASE); + } + } + heap_endscan(pgdbscan); heap_close(pgdbrel, AccessShareLock); } |
