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

Commit 26b59ca

Browse files
committed
send GUC variables to nodes
1 parent 98aa93a commit 26b59ca

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

multimaster.c

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

142-
static bool MtmIsRecoverySession;
142+
static bool MtmIsRecoverySession;
143143

144144
static MtmCurrentTrans MtmTx;
145145

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

201+
static StringInfo MtmGUCBuffer;
202+
static bool MtmGUCBufferAllocated = false;
203+
201204
/*
202205
* -------------------------------------------
203206
* Synchronize access to MTM structures.
@@ -2238,6 +2241,12 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
22382241
{
22392242
if (conns[i])
22402243
{
2244+
if (MtmGUCBufferAllocated && !MtmRunUtilityStmt(conns[i], MtmGUCBuffer->data, &utility_errmsg) && !ignoreError)
2245+
{
2246+
errorMsg = "Failed to set GUC variables at node %d";
2247+
failedNode = i;
2248+
break;
2249+
}
22412250
if (!MtmRunUtilityStmt(conns[i], "BEGIN TRANSACTION", &utility_errmsg) && !ignoreError)
22422251
{
22432252
errorMsg = "Failed to start transaction at node %d";
@@ -2249,7 +2258,10 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
22492258
if (i + 1 == MtmNodeId)
22502259
errorMsg = utility_errmsg;
22512260
else
2261+
{
2262+
elog(ERROR, utility_errmsg);
22522263
errorMsg = "Failed to run command at node %d";
2264+
}
22532265

22542266
failedNode = i;
22552267
break;
@@ -2407,7 +2419,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24072419
case T_FetchStmt:
24082420
case T_DoStmt:
24092421
case T_CreateTableSpaceStmt:
2410-
case T_DropTableSpaceStmt:
24112422
case T_AlterTableSpaceOptionsStmt:
24122423
case T_TruncateStmt:
24132424
case T_CommentStmt: /* XXX: we could replicate these */;
@@ -2416,9 +2427,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24162427
case T_ExecuteStmt:
24172428
case T_DeallocateStmt:
24182429
case T_GrantStmt: /* XXX: we could replicate some of these these */;
2419-
case T_GrantRoleStmt:
2420-
case T_AlterDatabaseStmt:
2421-
case T_AlterDatabaseSetStmt:
2430+
//case T_GrantRoleStmt:
2431+
//case T_AlterDatabaseStmt:
2432+
//case T_AlterDatabaseSetStmt:
24222433
case T_NotifyStmt:
24232434
case T_ListenStmt:
24242435
case T_UnlistenStmt:
@@ -2427,22 +2438,46 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24272438
case T_VacuumStmt:
24282439
case T_ExplainStmt:
24292440
case T_AlterSystemStmt:
2430-
case T_VariableSetStmt:
24312441
case T_VariableShowStmt:
24322442
case T_DiscardStmt:
2433-
case T_CreateEventTrigStmt:
2434-
case T_AlterEventTrigStmt:
2435-
case T_CreateRoleStmt:
2436-
case T_AlterRoleStmt:
2437-
case T_AlterRoleSetStmt:
2438-
case T_DropRoleStmt:
2443+
//case T_CreateEventTrigStmt:
2444+
//case T_AlterEventTrigStmt:
2445+
//case T_CreateRoleStmt:
2446+
//case T_AlterRoleStmt:
2447+
//case T_AlterRoleSetStmt:
2448+
//case T_DropRoleStmt:
24392449
case T_ReassignOwnedStmt:
24402450
case T_LockStmt:
2441-
case T_ConstraintsSetStmt:
2451+
//case T_ConstraintsSetStmt:
24422452
case T_CheckPointStmt:
24432453
case T_ReindexStmt:
24442454
skipCommand = true;
24452455
break;
2456+
case T_VariableSetStmt:
2457+
{
2458+
//VariableSetStmt *stmt = (VariableSetStmt *) parsetree;
2459+
2460+
if (!MtmGUCBufferAllocated)
2461+
{
2462+
MemoryContext oldcontext;
2463+
2464+
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
2465+
MtmGUCBuffer = makeStringInfo();
2466+
MemoryContextSwitchTo(oldcontext);
2467+
MtmGUCBufferAllocated = true;
2468+
}
2469+
2470+
//appendStringInfoString(MtmGUCBuffer, "SET ");
2471+
//appendStringInfoString(MtmGUCBuffer, stmt->name);
2472+
//appendStringInfoString(MtmGUCBuffer, " TO ");
2473+
//appendStringInfoString(MtmGUCBuffer, ExtractSetVariableArgs(stmt));
2474+
//appendStringInfoString(MtmGUCBuffer, "; ");
2475+
2476+
appendStringInfoString(MtmGUCBuffer, queryString);
2477+
2478+
skipCommand = true;
2479+
}
2480+
break;
24462481
case T_CreateStmt:
24472482
{
24482483
/* Do not replicate temp tables */
@@ -2490,7 +2525,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24902525
}
24912526
}
24922527
break;
2493-
case T_CreateSchemaStmt:
24942528
default:
24952529
skipCommand = false;
24962530
break;

0 commit comments

Comments
 (0)