@@ -156,7 +156,7 @@ static void MtmShmemStartup(void);
156
156
static BgwPool * MtmPoolConstructor (void );
157
157
static bool MtmRunUtilityStmt (PGconn * conn , char const * sql , char * * errmsg );
158
158
static void MtmBroadcastUtilityStmt (char const * sql , bool ignoreError );
159
- static bool MtmProcessDDLCommand (char const * queryString , bool transactional );
159
+ static bool MtmProcessDDLCommand (char const * queryString , bool transactional , bool contextFree );
160
160
161
161
MtmState * Mtm ;
162
162
@@ -3825,33 +3825,31 @@ static char * MtmGucSerialize(void)
3825
3825
* -------------------------------------------
3826
3826
*/
3827
3827
3828
- static bool MtmProcessDDLCommand (char const * queryString , bool transactional )
3828
+ static bool MtmProcessDDLCommand (char const * queryString , bool transactional , bool contextFree )
3829
3829
{
3830
- char * queryWithContext ;
3830
+ char * queryWithContext = ( char * ) queryString ;
3831
3831
char * gucContext ;
3832
3832
3833
- /* Append global GUC to utility stmt. */
3834
- gucContext = MtmGucSerialize ();
3835
- if (gucContext )
3836
- {
3837
- queryWithContext = palloc (strlen (gucContext ) + strlen (queryString ) + 1 );
3838
- strcpy (queryWithContext , gucContext );
3839
- strcat (queryWithContext , queryString );
3840
- }
3841
- else
3842
- {
3843
- queryWithContext = (char * ) queryString ;
3833
+ if (!contextFree ) {
3834
+ /* Append global GUC to utility stmt. */
3835
+ gucContext = MtmGucSerialize ();
3836
+ if (gucContext )
3837
+ {
3838
+ queryWithContext = palloc (strlen (gucContext ) + strlen (queryString ) + 1 );
3839
+ strcpy (queryWithContext , gucContext );
3840
+ strcat (queryWithContext , queryString );
3841
+ }
3844
3842
}
3845
3843
3846
3844
MTM_LOG3 ("Sending utility: %s" , queryWithContext );
3847
- if (transactional )
3845
+ if (transactional ) {
3848
3846
/* DDL */
3849
3847
LogLogicalMessage ("D" , queryWithContext , strlen (queryWithContext ) + 1 , true);
3850
- else
3848
+ MtmTx .containsDML = true;
3849
+ } else {
3851
3850
/* CONCURRENT DDL */
3852
- LogLogicalMessage ("C" , queryWithContext , strlen (queryWithContext ) + 1 , false);
3853
-
3854
- MtmTx .containsDML = true;
3851
+ XLogFlush (LogLogicalMessage ("C" , queryWithContext , strlen (queryWithContext ) + 1 , false));
3852
+ }
3855
3853
return false;
3856
3854
}
3857
3855
@@ -3930,7 +3928,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3930
3928
case T_UnlistenStmt :
3931
3929
case T_LoadStmt :
3932
3930
case T_ClusterStmt :
3933
- case T_VacuumStmt :
3934
3931
case T_VariableShowStmt :
3935
3932
case T_ReassignOwnedStmt :
3936
3933
case T_LockStmt :
@@ -3939,6 +3936,13 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3939
3936
skipCommand = true;
3940
3937
break ;
3941
3938
3939
+ case T_VacuumStmt :
3940
+ context = PROCESS_UTILITY_TOPLEVEL ;
3941
+ MtmProcessDDLCommand (queryString , false, true);
3942
+ MtmTx .isDistributed = false;
3943
+ skipCommand = true;
3944
+ break ;
3945
+
3942
3946
case T_CreateDomainStmt :
3943
3947
{
3944
3948
CreateDomainStmt * stmt = (CreateDomainStmt * ) parsetree ;
@@ -4030,7 +4034,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
4030
4034
if (indexStmt -> concurrent && !IsTransactionBlock () && !MtmTx .isReplicated )
4031
4035
{
4032
4036
skipCommand = true;
4033
- MtmProcessDDLCommand (queryString , false);
4037
+ MtmProcessDDLCommand (queryString , false, false );
4034
4038
MtmTx .isDistributed = false;
4035
4039
}
4036
4040
}
@@ -4042,7 +4046,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
4042
4046
if (stmt -> removeType == OBJECT_INDEX && stmt -> concurrent && !IsTransactionBlock () && !MtmTx .isReplicated )
4043
4047
{
4044
4048
skipCommand = true;
4045
- MtmProcessDDLCommand (queryString , false);
4049
+ MtmProcessDDLCommand (queryString , false, false );
4046
4050
MtmTx .isDistributed = false;
4047
4051
}
4048
4052
}
@@ -4085,9 +4089,9 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
4085
4089
MtmUtilityProcessedInXid = GetCurrentTransactionId ();
4086
4090
4087
4091
if (context == PROCESS_UTILITY_TOPLEVEL )
4088
- MtmProcessDDLCommand (queryString , true);
4092
+ MtmProcessDDLCommand (queryString , true, false );
4089
4093
else
4090
- MtmProcessDDLCommand (ActivePortal -> sourceText , true);
4094
+ MtmProcessDDLCommand (ActivePortal -> sourceText , true, false );
4091
4095
4092
4096
executed = true;
4093
4097
}
@@ -4143,7 +4147,7 @@ MtmExecutorStart(QueryDesc *queryDesc, int eflags)
4143
4147
}
4144
4148
4145
4149
if (ddl_generating_call && !MtmTx .isReplicated )
4146
- MtmProcessDDLCommand (ActivePortal -> sourceText , true);
4150
+ MtmProcessDDLCommand (ActivePortal -> sourceText , true, false );
4147
4151
4148
4152
if (PreviousExecutorStartHook != NULL )
4149
4153
PreviousExecutorStartHook (queryDesc , eflags );
0 commit comments