Skip to content

Commit 1d6e3c3

Browse files
committed
Change handling of utility statements
1 parent 91dbb86 commit 1d6e3c3

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

contrib/mmts/multimaster.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4879,7 +4879,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
48794879
bool skipCommand = false;
48804880
bool executed = false;
48814881

4882-
MTM_LOG1("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query=%s",
4882+
MTM_LOG2("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query=%s",
48834883
MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), creating_extension, queryString);
48844884
switch (nodeTag(parsetree))
48854885
{
@@ -5133,24 +5133,14 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
51335133
break;
51345134
}
51355135

5136-
/* XXX: dirty. Clear on new tx */
5137-
/* Some "black magic here":( We want to avoid redundant execution of utility statement by ProcessUtilitySlow (which is done with PROCESS_UTILITY_SUBCOMMAND).
5138-
* 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).
5139-
* If we disable only PROCESS_UTILITY_SUBCOMMAND, then we will get problems with "create extension" which is executed also in PROCESS_UTILITY_QUERY context.
5140-
* So workaround at this moment is to treat extension as special case.
5141-
* TODO: try to find right solution and rewrite this dummy check.
5142-
*/
5143-
if (!skipCommand && (context == PROCESS_UTILITY_TOPLEVEL || (context == PROCESS_UTILITY_QUERY && !creating_extension) || MtmUtilityProcessedInXid != GetCurrentTransactionId()))
5144-
MtmUtilityProcessedInXid = InvalidTransactionId;
5145-
5146-
if (!skipCommand && !MtmTx.isReplicated && (MtmUtilityProcessedInXid == InvalidTransactionId)) {
5136+
if (!skipCommand && !MtmTx.isReplicated && (context == PROCESS_UTILITY_TOPLEVEL || MtmUtilityProcessedInXid != GetCurrentTransactionId()))
5137+
{
51475138
MtmUtilityProcessedInXid = GetCurrentTransactionId();
5148-
5149-
if (context == PROCESS_UTILITY_TOPLEVEL)
5139+
if (context == PROCESS_UTILITY_TOPLEVEL) {
51505140
MtmProcessDDLCommand(queryString, true);
5151-
else
5141+
} else {
51525142
MtmProcessDDLCommand(ActivePortal->sourceText, true);
5153-
5143+
}
51545144
executed = true;
51555145
}
51565146

@@ -5197,6 +5187,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
51975187
}
51985188
}
51995189
}
5190+
if (context == PROCESS_UTILITY_TOPLEVEL) {
5191+
MtmUtilityProcessedInXid = InvalidTransactionId;
5192+
}
52005193
}
52015194

52025195
static void

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy