|
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"
|
@@ -4865,7 +4866,8 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
|
4865 | 4866 | boolskipCommand= false;
|
4866 | 4867 | boolexecuted= false;
|
4867 | 4868 |
|
4868 |
| -MTM_LOG3("%d: Process utility statement %s",MyProcPid,queryString); |
| 4869 | +MTM_LOG3("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, query=%s", |
| 4870 | +MyProcPid,nodeTag(parsetree),context,IsSubTransaction(),queryString); |
4869 | 4871 | switch (nodeTag(parsetree))
|
4870 | 4872 | {
|
4871 | 4873 | caseT_TransactionStmt:
|
@@ -5119,7 +5121,13 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
|
5119 | 5121 | }
|
5120 | 5122 |
|
5121 | 5123 | /* XXX: dirty. Clear on new tx */
|
5122 |
| -if (!skipCommand&& (context!=PROCESS_UTILITY_SUBCOMMAND||MtmUtilityProcessedInXid!=GetCurrentTransactionId())) |
| 5124 | +/* Some "black magic here":( We want to avoid redundant execution of utility statement by ProcessUtilitySlow (which is done with PROCESS_UTILITY_SUBCOMMAND). |
| 5125 | + * 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). |
| 5126 | + * If we disable only PROCESS_UTILITY_SUBCOMMAND, then we will get problems with "create extension" which is executed also in PROCESS_UTILITY_QUERY context. |
| 5127 | + * So workaround at this moment is to treat extension as special case. |
| 5128 | + * TODO: try to find right solution and rewrite this dummy check. |
| 5129 | + */ |
| 5130 | +if (!skipCommand&& (context==PROCESS_UTILITY_TOPLEVEL|| (context==PROCESS_UTILITY_QUERY&& !creating_extension)||MtmUtilityProcessedInXid!=GetCurrentTransactionId())) |
5123 | 5131 | MtmUtilityProcessedInXid=InvalidTransactionId;
|
5124 | 5132 |
|
5125 | 5133 | if (!skipCommand&& !MtmTx.isReplicated&& (MtmUtilityProcessedInXid==InvalidTransactionId)) {
|
|