|
46 | 46 | #include "utils/builtins.h"
|
47 | 47 | #include "utils/memutils.h"
|
48 | 48 | #include "commands/dbcommands.h"
|
| 49 | +#include "commands/extension.h" |
49 | 50 | #include "postmaster/autovacuum.h"
|
50 | 51 | #include "storage/pmsignal.h"
|
51 | 52 | #include "storage/proc.h"
|
@@ -4879,7 +4880,8 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
|
4879 | 4880 | bool skipCommand = false;
|
4880 | 4881 | bool executed = false;
|
4881 | 4882 |
|
4882 |
| - MTM_LOG3("%d: Process utility statement %s", MyProcPid, queryString); |
| 4883 | + MTM_LOG3("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, query=%s", |
| 4884 | + MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), queryString); |
4883 | 4885 | switch (nodeTag(parsetree))
|
4884 | 4886 | {
|
4885 | 4887 | case T_TransactionStmt:
|
@@ -5133,7 +5135,13 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
|
5133 | 5135 | }
|
5134 | 5136 |
|
5135 | 5137 | /* XXX: dirty. Clear on new tx */
|
5136 |
| - if (!skipCommand && (context != PROCESS_UTILITY_SUBCOMMAND || MtmUtilityProcessedInXid != GetCurrentTransactionId())) |
| 5138 | + /* Some "black magic here":( We want to avoid redundant execution of utility statement by ProcessUtilitySlow (which is done with PROCESS_UTILITY_SUBCOMMAND). |
| 5139 | + * 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). |
| 5140 | + * If we disable only PROCESS_UTILITY_SUBCOMMAND, then we will get problems with "create extension" which is executed also in PROCESS_UTILITY_QUERY context. |
| 5141 | + * So workaround at this moment is to treat extension as special case. |
| 5142 | + * TODO: try to find right solution and rewrite this dummy check. |
| 5143 | + */ |
| 5144 | + if (!skipCommand && (context == PROCESS_UTILITY_TOPLEVEL || (context == PROCESS_UTILITY_QUERY && !creating_extension) || MtmUtilityProcessedInXid != GetCurrentTransactionId())) |
5137 | 5145 | MtmUtilityProcessedInXid = InvalidTransactionId;
|
5138 | 5146 |
|
5139 | 5147 | if (!skipCommand && !MtmTx.isReplicated && (MtmUtilityProcessedInXid == InvalidTransactionId)) {
|
|
0 commit comments