diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2014-12-23 10:22:09 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2014-12-23 10:22:09 -0300 |
commit | 1826987a46d079458007b7b6bbcbbd852353adbb (patch) | |
tree | c3598d1d9c006551d2adff2b888112a24f2d03ed /src/backend/utils/init/miscinit.c | |
parent | 7eca575d1c28f6eee2bf4564f3d458d10c4a8f47 (diff) | |
download | postgresql-1826987a46d079458007b7b6bbcbbd852353adbb.tar.gz postgresql-1826987a46d079458007b7b6bbcbbd852353adbb.zip |
Use a bitmask to represent role attributes
The previous representation using a boolean column for each attribute
would not scale as well as we want to add further attributes.
Extra auxilliary functions are added to go along with this change, to
make up for the lost convenience of access of the old representation.
Catalog version bumped due to change in catalogs and the new functions.
Author: Adam Brightwell, minor tweaks by Álvaro
Reviewed by: Stephen Frost, Andres Freund, Álvaro Herrera
Diffstat (limited to 'src/backend/utils/init/miscinit.c')
-rw-r--r-- | src/backend/utils/init/miscinit.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 8fccb4c8262..db2a0fb48ef 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -40,6 +40,7 @@ #include "storage/pg_shmem.h" #include "storage/proc.h" #include "storage/procarray.h" +#include "utils/acl.h" #include "utils/builtins.h" #include "utils/guc.h" #include "utils/memutils.h" @@ -329,24 +330,6 @@ SetUserIdAndContext(Oid userid, bool sec_def_context) /* - * Check whether specified role has explicit REPLICATION privilege - */ -bool -has_rolreplication(Oid roleid) -{ - bool result = false; - HeapTuple utup; - - utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); - if (HeapTupleIsValid(utup)) - { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication; - ReleaseSysCache(utup); - } - return result; -} - -/* * Initialize user identity during normal backend startup */ void @@ -375,7 +358,7 @@ InitializeSessionUserId(const char *rolename) roleid = HeapTupleGetOid(roleTup); AuthenticatedUserId = roleid; - AuthenticatedUserIsSuperuser = rform->rolsuper; + AuthenticatedUserIsSuperuser = (rform->rolattr & ROLE_ATTR_SUPERUSER); /* This sets OuterUserId/CurrentUserId too */ SetSessionUserId(roleid, AuthenticatedUserIsSuperuser); @@ -394,7 +377,7 @@ InitializeSessionUserId(const char *rolename) /* * Is role allowed to login at all? */ - if (!rform->rolcanlogin) + if (!(rform->rolattr & ROLE_ATTR_CANLOGIN)) ereport(FATAL, (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), errmsg("role \"%s\" is not permitted to log in", |