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

Commit d2c6b06

Browse files
knizhnikkelvich
authored andcommitted
Change handling of utility statements
1 parent 9e943d0 commit d2c6b06

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

multimaster.c

+9-16
Original file line numberDiff line numberDiff line change
@@ -4893,7 +4893,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
48934893
bool skipCommand = false;
48944894
bool executed = false;
48954895

4896-
MTM_LOG1("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query=%s",
4896+
MTM_LOG2("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query=%s",
48974897
MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), creating_extension, queryString);
48984898
switch (nodeTag(parsetree))
48994899
{
@@ -5147,24 +5147,14 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
51475147
break;
51485148
}
51495149

5150-
/* XXX: dirty. Clear on new tx */
5151-
/* Some "black magic here":( We want to avoid redundant execution of utility statement by ProcessUtilitySlow (which is done with PROCESS_UTILITY_SUBCOMMAND).
5152-
* But if we allow only PROCESS_UTILITY_TOPLEVEL context, then we will not replicated DDL inside dynamic queries in plpgsql functions (see https://jira.postgrespro.ru/browse/CORE-526).
5153-
* If we disable only PROCESS_UTILITY_SUBCOMMAND, then we will get problems with "create extension" which is executed also in PROCESS_UTILITY_QUERY context.
5154-
* So workaround at this moment is to treat extension as special case.
5155-
* TODO: try to find right solution and rewrite this dummy check.
5156-
*/
5157-
if (!skipCommand && (context == PROCESS_UTILITY_TOPLEVEL || (context == PROCESS_UTILITY_QUERY && !creating_extension) || MtmUtilityProcessedInXid != GetCurrentTransactionId()))
5158-
MtmUtilityProcessedInXid = InvalidTransactionId;
5159-
5160-
if (!skipCommand && !MtmTx.isReplicated && (MtmUtilityProcessedInXid == InvalidTransactionId)) {
5150+
if (!skipCommand && !MtmTx.isReplicated && (context == PROCESS_UTILITY_TOPLEVEL || MtmUtilityProcessedInXid != GetCurrentTransactionId()))
5151+
{
51615152
MtmUtilityProcessedInXid = GetCurrentTransactionId();
5162-
5163-
if (context == PROCESS_UTILITY_TOPLEVEL)
5153+
if (context == PROCESS_UTILITY_TOPLEVEL) {
51645154
MtmProcessDDLCommand(queryString, true);
5165-
else
5155+
} else {
51665156
MtmProcessDDLCommand(ActivePortal->sourceText, true);
5167-
5157+
}
51685158
executed = true;
51695159
}
51705160

@@ -5211,6 +5201,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
52115201
}
52125202
}
52135203
}
5204+
if (context == PROCESS_UTILITY_TOPLEVEL) {
5205+
MtmUtilityProcessedInXid = InvalidTransactionId;
5206+
}
52145207
}
52155208

52165209
static void

0 commit comments

Comments
 (0)