diff options
author | Thomas Munro <tmunro@postgresql.org> | 2018-07-13 16:12:03 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2018-07-13 16:19:15 +1200 |
commit | e8d9caa436db2931613d7cb4a4a8b3933d5f6ded (patch) | |
tree | 6278939b42427e18a2f0af34c140ff8ff2f8adb7 /src | |
parent | 387a5cfb94f041ffe18d03ccc4063c626bb4b73e (diff) | |
download | postgresql-e8d9caa436db2931613d7cb4a4a8b3933d5f6ded.tar.gz postgresql-e8d9caa436db2931613d7cb4a4a8b3933d5f6ded.zip |
Accept invalidation messages in InitializeSessionUserId().
If the authentication method modified the system catalogs through a
separate database connection (say, to create a new role on the fly),
make sure syscache sees the changes before we try to find the user.
Author: Thomas Munro
Reviewed-by: Tom Lane, Andres Freund
Discussion: https://postgr.es/m/CAEepm%3D3_h0_cgmz5PMyab4xk_OFrg6G5VCN%3DnF4chFXM9iFOqA%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/init/miscinit.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 4bb28938c27..865119d2729 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -48,6 +48,7 @@ #include "storage/procarray.h" #include "utils/builtins.h" #include "utils/guc.h" +#include "utils/inval.h" #include "utils/memutils.h" #include "utils/pidfile.h" #include "utils/syscache.h" @@ -594,6 +595,13 @@ InitializeSessionUserId(const char *rolename, Oid roleid) /* call only once */ AssertState(!OidIsValid(AuthenticatedUserId)); + /* + * Make sure syscache entries are flushed for recent catalog changes. + * This allows us to find roles that were created on-the-fly during + * authentication. + */ + AcceptInvalidationMessages(); + if (rolename != NULL) { roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(rolename)); |