8000 send GUC variables to nodes · postgrespro/postgres_cluster@1cb8c17 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cb8c17

Browse files
committed
send GUC variables to nodes
1 parent 629f40d commit 1cb8c17

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

contrib/mmts/multimaster.c

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ HTAB* MtmXid2State;
140140
static HTAB* MtmGid2State;
141141
static HTAB* MtmLocalTables;
142142

143-
static bool MtmIsRecoverySession;
143+
static bool MtmIsRecoverySession;
144144

145145
static MtmCurrentTrans MtmTx;
146146

@@ -199,6 +199,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
199199
ProcessUtilityContext context, ParamListInfo params,
200200
DestReceiver *dest, char *completionTag);
201201

202+
static StringInfo MtmGUCBuffer;
203+
static bool MtmGUCBufferAllocated = false;
204+
202205
/*
203206
* -------------------------------------------
204207
* Synchronize access to MTM structures.
@@ -2239,6 +2242,12 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
22392242
{
22402243
if (conns[i])
22412244
{
2245+
if (MtmGUCBufferAllocated && !MtmRunUtilityStmt(conns[i], MtmGUCBuffer->data, &utility_errmsg) && !ignoreError)
2246+
{
2247+
errorMsg = "Failed to set GUC variables at node %d";
2248+
failedNode = i;
2249+
break;
2250+
}
22422251
if (!MtmRunUtilityStmt(conns[i], "BEGIN TRANSACTION", &utility_errmsg) && !ignoreError)
22432252
{
22442253
errorMsg = "Failed to start transaction at node %d";
@@ -2250,7 +2259,10 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
22502259
if (i + 1 == MtmNodeId)
22512260
errorMsg = utility_errmsg;
22522261
else
2262+
{
2263+
elog(ERROR, utility_errmsg);
22532264
errorMsg = "Failed to run command at node %d";
2265+
}
22542266

22552267
failedNode = i;
22562268
break;
@@ -2412,7 +2424,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24122424
case T_FetchStmt:
24132425
case T_DoStmt:
24142426
case T_CreateTableSpaceStmt:
2415-
case T_DropTableSpaceStmt:
24162427
case T_AlterTableSpaceOptionsStmt:
24172428
case T_TruncateStmt:
24182429
case T_CommentStmt: /* XXX: we could replicate these */;
@@ -2421,9 +2432,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24212432
case T_ExecuteStmt:
24222433
case T_DeallocateStmt:
24232434
case T_GrantStmt: /* XXX: we could replicate some of these these */;
2424-
case T_GrantRoleStmt:
2425-
case T_AlterDatabaseStmt:
2426-
case T_AlterDatabaseSetStmt:
2435+
//case T_GrantRoleStmt:
2436+
//case T_AlterDatabaseStmt:
2437+
//case T_AlterDatabaseSetStmt:
24272438
case T_NotifyStmt:
24282439
case T_ListenStmt:
24292440
case T_UnlistenStmt:
@@ -2432,22 +2443,46 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24322443
case T_VacuumStmt:
24332444
case T_ExplainStmt:
24342445
case T_AlterSystemStmt:
2435-
case T_VariableSetStmt:
24362446
case T_VariableShowStmt:
24372447
case T_DiscardStmt:
2438-
case T_CreateEventTrigStmt:
2439-
case T_AlterEventTrigStmt:
2440-
case T_CreateRoleStmt:
2441-
case T_AlterRoleStmt:
2442-
case T_AlterRoleSetStmt:
2443-
case T_DropRoleStmt:
2448+
//case T_CreateEventTrigStmt:
2449+
//case T_AlterEventTrigStmt:
2450+
//case T_CreateRoleStmt:
2451+
//case T_AlterRoleStmt:
2452+
//case T_AlterRoleSetStmt:
2453+
//case T_DropRoleStmt:
24442454
case T_ReassignOwnedStmt:
24452455
case T_LockStmt:
2446-
case T_ConstraintsSetStmt:
2456+
//case T_ConstraintsSetStmt:
24472457
case T_CheckPointStmt:
24482458
case T_ReindexStmt:
24492459
skipCommand = true;
24502460
break;
2461+
case T_VariableSetStmt:
2462+
{
2463+
//VariableSetStmt *stmt = (VariableSetStmt *) parsetree;
2464+
2465+
if (!MtmGUCBufferAllocated)
2466+
{
2467+
MemoryContext oldcontext;
2468+
2469+
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
2470+
MtmGUCBuffer = makeStringInfo();
2471+
MemoryContextSwitchTo(oldcontext);
2472+
MtmGUCBufferAllocated = true;
2473+
}
2474+
2475+
//appendStringInfoString(MtmGUCBuffer, "SET ");
2476+
//appendStringInfoString(MtmGUCBuffer, stmt->name);
2477+
//appendStringInfoString(MtmGUCBuffer, " TO ");
2478+
//appendStringInfoString(MtmGUCBuffer, ExtractSetVariableArgs(stmt));
2479+
//appendStringInfoString(MtmGUCBuffer, "; ");
2480+
2481+
appendStringInfoString(MtmGUCBuffer, queryString);
2482+
2483+
skipCommand = true;
2484+
}
2485+
break;
24512486
case T_CreateStmt:
24522487
{
24532488
/* Do not replicate temp tables */
@@ -2495,7 +2530,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24952530
}
24962531
}
24972532
break;
2498-
case T_CreateSchemaStmt:
24992533
default:
25002534
skipCommand = false;
25012535
break;

0 commit comments

Comments
 (0)
0