Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68abec2

Browse files
committed
catch current user on backend startup
1 parent7032011 commit68abec2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

‎multimaster.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4487,10 +4487,12 @@ typedef struct MtmGucEntry
44874487

44884488
staticHTAB*MtmGucHash=NULL;
44894489
staticdlist_headMtmGucList=DLIST_STATIC_INIT(MtmGucList);
4490+
staticinlinevoidMtmGucUpdate(constchar*key,char*value);
44904491

44914492
staticvoidMtmGucInit(void)
44924493
{
44934494
HASHCTLhash_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
staticvoidMtmGucDiscard()
@@ -4593,6 +4603,9 @@ char* MtmGucSerialize(void)
45934603
dlist_iteriter;
45944604
intnvars=0;
45954605

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

45984611
dlist_foreach(iter,&MtmGucList)

‎sql/multimaster.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
createuseruser1;
2+
createschemauser1;
3+
alterschema user1 owner to user1;
4+
5+
\c"user=user1 dbname=regression"
6+
createtableuser1.test(iintprimary key);
7+
8+
\c"user=user1 dbname=regression port=5433"
9+
select*from test;
10+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp