Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 68abec2

Browse files
committed
catch current user on backend startup
1 parent 7032011 commit 68abec2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

multimaster.c

+13
Original file line numberDiff line numberDiff line change
@@ -4487,10 +4487,12 @@ typedef struct MtmGucEntry
44874487

44884488
static HTAB *MtmGucHash = NULL;
44894489
static dlist_head MtmGucList = DLIST_STATIC_INIT(MtmGucList);
4490+
static inline void MtmGucUpdate(const char *key, char *value);
44904491

44914492
static void MtmGucInit(void)
44924493
{
44934494
HASHCTL hash_ctl;
4495+
char *current_role;
44944496

44954497
MemSet(&hash_ctl, 0, sizeof(hash_ctl));
44964498
hash_ctl.keysize = GUC_KEY_MAXLEN;
@@ -4500,6 +4502,14 @@ static void MtmGucInit(void)
45004502
MTM_GUC_HASHSIZE,
45014503
&hash_ctl,
45024504
HASH_ELEM | HASH_CONTEXT);
4505+
4506+
/*
4507+
* If current role is not equal to MtmDatabaseUser, than set it bofore
4508+
* any other GUC vars.
4509+
*/
4510+
current_role = GetConfigOptionByName("session_authorization", NULL, false);
4511+
if (strcmp(MtmDatabaseUser, current_role) != 0)
4512+
MtmGucUpdate("session_authorization", current_role);
45034513
}
45044514

45054515
static void MtmGucDiscard()
@@ -4593,6 +4603,9 @@ char* MtmGucSerialize(void)
45934603
dlist_iter iter;
45944604
int nvars = 0;
45954605

4606+
if (!MtmGucHash)
4607+
MtmGucInit();
4608+
45964609
serialized_gucs = makeStringInfo();
45974610

45984611
dlist_foreach(iter, &MtmGucList)

sql/multimaster.sql

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
create user user1;
2+
create schema user1;
3+
alter schema user1 owner to user1;
4+
5+
\c "user=user1 dbname=regression"
6+
create table user1.test(i int primary key);
7+
8+
\c "user=user1 dbname=regression port=5433"
9+
select * from test;
10+

0 commit comments

Comments
 (0)