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

Commit 0055b46

Browse files
committed
distinguish notices and warnigs on remote connections; handle DISCARD stmt
1 parent 2ccf1fc commit 0055b46

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

multimaster.c

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,10 +2244,24 @@ MtmNoticeReceiver(void *i, const PGresult *res)
22442244

22452245
stripped_notice = palloc0(len);
22462246

2247-
/* Strip "NOTICE: " from beginning and "\n" from end of error string */
2248-
strncpy(stripped_notice, notice + 9, len - 1 - 9);
2247+
if (*notice == 'N')
2248+
{
2249+
/* Strip "NOTICE: " from beginning and "\n" from end of error string */
2250+
strncpy(stripped_notice, notice + 9, len - 1 - 9);
2251+
elog(NOTICE, "%s", stripped_notice);
2252+
}
2253+
else if (*notice == 'W')
2254+
{
2255+
/* Strip "WARNING: " from beginning and "\n" from end of error string */
2256+
strncpy(stripped_notice, notice + 10, len - 1 - 10);
2257+
elog(WARNING, "%s", stripped_notice);
2258+
}
2259+
else
2260+
{
2261+
stripped_notice = notice;
2262+
elog(WARNING, "%s", stripped_notice);
2263+
}
22492264

2250-
MTM_LOG1("%s", stripped_notice);
22512265
pfree(stripped_notice);
22522266
}
22532267

@@ -2473,41 +2487,45 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24732487
case T_PrepareStmt:
24742488
case T_ExecuteStmt:
24752489
case T_DeallocateStmt:
2476-
//case T_GrantStmt: /* XXX: we could replicate some of these these */;
2477-
//case T_GrantRoleStmt:
2478-
//case T_AlterDatabaseStmt:
2479-
//case T_AlterDatabaseSetStmt:
24802490
case T_NotifyStmt:
24812491
case T_ListenStmt:
24822492
case T_UnlistenStmt:
24832493
case T_LoadStmt:
24842494
case T_ClusterStmt: /* XXX: we could replicate these */;
24852495
case T_VacuumStmt:
24862496
case T_ExplainStmt:
2487-
//case T_AlterSystemStmt:
24882497
case T_VariableShowStmt:
2489-
case T_DiscardStmt:
2490-
//case T_CreateEventTrigStmt:
2491-
//case T_AlterEventTrigStmt:
2492-
//case T_CreateRoleStmt:
2493-
//case T_AlterRoleStmt:
2494-
//case T_AlterRoleSetStmt:
2495-
//case T_DropRoleStmt:
24962498
case T_ReassignOwnedStmt:
24972499
case T_LockStmt:
2498-
//case T_ConstraintsSetStmt:
24992500
case T_CheckPointStmt:
25002501
case T_ReindexStmt:
25012502
skipCommand = true;
25022503
break;
2504+
case T_DiscardStmt:
2505+
{
2506+
//DiscardStmt *stmt = (DiscardStmt *) parsetree;
2507+
//skipCommand = stmt->target == DISCARD_TEMP;
2508+
2509+
skipCommand = true;
2510+
2511+
if (MtmGUCBufferAllocated)
2512+
{
2513+
// XXX: move allocation somewhere to backend startup and check
2514+
// where buffer is empty in send routines.
2515+
MtmGUCBufferAllocated = false;
2516+
pfree(MtmGUCBuffer);
2517+
}
2518+
2519+
}
2520+
break;
25032521
case T_VariableSetStmt:
25042522
{
25052523
VariableSetStmt *stmt = (VariableSetStmt *) parsetree;
25062524

25072525
skipCommand = true;
25082526

25092527
/* Prevent SET TRANSACTION from replication */
2510-
if (MtmTx.isTransactionBlock || stmt->kind == VAR_SET_MULTI)
2528+
if (stmt->kind == VAR_SET_MULTI)
25112529
break;
25122530

25132531
if (!MtmGUCBufferAllocated)
@@ -2520,13 +2538,10 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
25202538
MtmGUCBufferAllocated = true;
25212539
}
25222540

2523-
//appendStringInfoString(MtmGUCBuffer, "SET ");
2524-
//appendStringInfoString(MtmGUCBuffer, stmt->name);
2525-
//appendStringInfoString(MtmGUCBuffer, " TO ");
2526-
//appendStringInfoString(MtmGUCBuffer, ExtractSetVariableArgs(stmt));
2527-
//appendStringInfoString(MtmGUCBuffer, "; ");
2528-
25292541
appendStringInfoString(MtmGUCBuffer, queryString);
2542+
2543+
// sometimes there is no ';' char at the end.
2544+
appendStringInfoString(MtmGUCBuffer, ";");
25302545
}
25312546
break;
25322547
case T_CreateStmt:

0 commit comments

Comments
 (0)