@@ -155,7 +155,7 @@ static void MtmShmemStartup(void);
155
155
static BgwPool * MtmPoolConstructor (void );
156
156
static bool MtmRunUtilityStmt (PGconn * conn , char const * sql , char * * errmsg );
157
157
static void MtmBroadcastUtilityStmt (char const * sql , bool ignoreError );
158
- static bool MtmProcessDDLCommand (char const * queryString , bool transactional );
158
+ static bool MtmProcessDDLCommand (char const * queryString , bool transactional , bool contextFree );
159
159
160
160
MtmState * Mtm ;
161
161
@@ -3824,33 +3824,31 @@ static char * MtmGucSerialize(void)
3824
3824
* -------------------------------------------
3825
3825
*/
3826
3826
3827
- static bool MtmProcessDDLCommand (char const * queryString , bool transactional )
3827
+ static bool MtmProcessDDLCommand (char const * queryString , bool transactional , bool contextFree )
3828
3828
{
3829
- char * queryWithContext ;
3829
+ char * queryWithContext = ( char * ) queryString ;
3830
3830
char * gucContext ;
3831
3831
3832
- /* Append global GUC to utility stmt. */
3833
- gucContext = MtmGucSerialize ();
3834
- if (gucContext )
3835
- {
3836
- queryWithContext = palloc (strlen (gucContext ) + strlen (queryString ) + 1 );
3837
- strcpy (queryWithContext , gucContext );
3838
- strcat (queryWithContext , queryString );
3839
- }
3840
- else
3841
- {
3842
- queryWithContext = (char * ) queryString ;
3832
+ if (!contextFree ) {
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
+ }
3843
3841
}
3844
3842
3845
3843
MTM_LOG3 ("Sending utility: %s" , queryWithContext );
3846
- if (transactional )
3844
+ if (transactional ) {
3847
3845
/* DDL */
3848
3846
LogLogicalMessage ("D" , queryWithContext , strlen (queryWithContext ) + 1 , true);
3849
- else
3847
+ MtmTx .containsDML = true;
3848
+ } else {
3850
3849
/* CONCURRENT DDL */
3851
- LogLogicalMessage ("C" , queryWithContext , strlen (queryWithContext ) + 1 , false);
3852
-
3853
- MtmTx .containsDML = true;
3850
+ XLogFlush (LogLogicalMessage ("C" , queryWithContext , strlen (queryWithContext ) + 1 , false));
3851
+ }
3854
3852
return false;
3855
3853
}
3856
3854
@@ -3929,7 +3927,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3929
3927
case T_UnlistenStmt :
3930
3928
case T_LoadStmt :
3931
3929
case T_ClusterStmt :
3932
- case T_VacuumStmt :
3933
3930
case T_VariableShowStmt :
3934
3931
case T_ReassignOwnedStmt :
3935
3932
case T_LockStmt :
@@ -3938,6 +3935,13 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3938
3935
skipCommand = true;
3939
3936
break ;
3940
3937
3938
+ case T_VacuumStmt :
3939
+ context = PROCESS_UTILITY_TOPLEVEL ;
3940
+ MtmProcessDDLCommand (queryString , false, true);
3941
+ MtmTx .isDistributed = false;
3942
+ skipCommand = true;
3943
+ break ;
3944
+
3941
3945
case T_CreateDomainStmt :
3942
3946
/* Detect temp tables access */
3943
3947
{
@@ -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
}
@@ -4144,7 +4148,7 @@ MtmExecutorStart(QueryDesc *queryDesc, int eflags)
4144
4148
}
4145
4149
4146
4150
if (ddl_generating_call && !MtmTx .isReplicated )
4147
- MtmProcessDDLCommand (ActivePortal -> sourceText , true);
4151
+ MtmProcessDDLCommand (ActivePortal -> sourceText , true, false );
4148
4152
4149
4153
if (PreviousExecutorStartHook != NULL )
4150
4154
PreviousExecutorStartHook (queryDesc , eflags );
0 commit comments