@@ -5138,18 +5138,24 @@ AdjustCreateSequence(List *options)
5138
5138
}
5139
5139
5140
5140
static void MtmProcessUtility (PlannedStmt * pstmt ,
5141
- const char * queryString , ProcessUtilityContext context ,
5142
- ParamListInfo params ,
5143
- QueryEnvironment * queryEnv ,
5144
- DestReceiver * dest , char * completionTag )
5141
+ const char * queryString , ProcessUtilityContext context ,
5142
+ ParamListInfo params ,
5143
+ QueryEnvironment * queryEnv ,
5144
+ DestReceiver * dest , char * completionTag )
5145
5145
{
5146
5146
bool skipCommand = false;
5147
5147
bool executed = false;
5148
5148
bool prevMyXactAccessedTempRel ;
5149
5149
Node * parsetree = pstmt -> utilityStmt ;
5150
+ int stmt_start = pstmt -> stmt_location > 0 ? pstmt -> stmt_location : 0 ;
5151
+ int stmt_len = pstmt -> stmt_len > 0 ? pstmt -> stmt_len : strlen (queryString + stmt_start );
5152
+ char * stmt_string = palloc (stmt_len + 1 );
5153
+
5154
+ strncpy (stmt_string , queryString + stmt_start , stmt_len );
5155
+ stmt_string [stmt_len ] = 0 ;
5150
5156
5151
- MTM_LOG2 ("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query =%s" ,
5152
- MyProcPid , nodeTag (parsetree ), context , IsSubTransaction (), creating_extension , queryString );
5157
+ MTM_LOG2 ("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, statement =%s" ,
5158
+ MyProcPid , nodeTag (parsetree ), context , IsSubTransaction (), creating_extension , stmt_string );
5153
5159
switch (nodeTag (parsetree ))
5154
5160
{
5155
5161
case T_TransactionStmt :
@@ -5230,7 +5236,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5230
5236
else
5231
5237
{
5232
5238
skipCommand = true;
5233
- MtmProcessDDLCommand (queryString , false);
5239
+ MtmProcessDDLCommand (stmt_string , false);
5234
5240
}
5235
5241
}
5236
5242
break ;
@@ -5242,7 +5248,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5242
5248
if (!MtmVolksWagenMode )
5243
5249
{
5244
5250
if (context == PROCESS_UTILITY_TOPLEVEL ) {
5245
- MtmProcessDDLCommand (queryString , false);
5251
+ MtmProcessDDLCommand (stmt_string , false);
5246
5252
MtmTx .isDistributed = false;
5247
5253
} else if (MtmApplyContext != NULL ) {
5248
5254
MemoryContext oldContext = MemoryContextSwitchTo (MtmApplyContext );
@@ -5335,7 +5341,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5335
5341
if (!IsTransactionBlock ())
5336
5342
{
5337
5343
skipCommand = true;
5338
- MtmGucSet (stmt , queryString );
5344
+ MtmGucSet (stmt , stmt_string );
5339
5345
}
5340
5346
}
5341
5347
break ;
@@ -5346,7 +5352,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5346
5352
if (indexStmt -> concurrent )
5347
5353
{
5348
5354
if (context == PROCESS_UTILITY_TOPLEVEL ) {
5349
- MtmProcessDDLCommand (queryString , false);
5355
+ MtmProcessDDLCommand (stmt_string , false);
5350
5356
MtmTx .isDistributed = false;
5351
5357
skipCommand = true;
5352
5358
/*
@@ -5378,7 +5384,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5378
5384
if (stmt -> removeType == OBJECT_INDEX && stmt -> concurrent )
5379
5385
{
5380
5386
if (context == PROCESS_UTILITY_TOPLEVEL ) {
5381
- MtmProcessDDLCommand (queryString , false);
5387
+ MtmProcessDDLCommand (stmt_string , false);
5382
5388
MtmTx .isDistributed = false;
5383
5389
skipCommand = true;
5384
5390
} else if (MtmApplyContext != NULL ) {
@@ -5448,12 +5454,14 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5448
5454
5449
5455
if (!skipCommand && !MtmTx .isReplicated && !MtmDDLStatement )
5450
5456
{
5451
- MTM_LOG3 ("Process DDL statement '%s', MtmTx.isReplicated=%d, MtmIsLogicalReceiver=%d" , queryString , MtmTx .isReplicated , MtmIsLogicalReceiver );
5452
- MtmProcessDDLCommand (queryString , true);
5457
+ MTM_LOG3 ("Process DDL statement '%s', MtmTx.isReplicated=%d, "
5458
+ "MtmIsLogicalReceiver=%d" , stmt_string , MtmTx .isReplicated ,
5459
+ MtmIsLogicalReceiver );
5460
+ MtmProcessDDLCommand (stmt_string , true);
5453
5461
executed = true;
5454
- MtmDDLStatement = queryString ;
5462
+ MtmDDLStatement = stmt_string ;
5455
5463
}
5456
- else MTM_LOG3 ("Skip utility statement '%s': skip=%d, insideDDL=%d" , queryString , skipCommand , MtmDDLStatement != NULL );
5464
+ else MTM_LOG3 ("Skip utility statement '%s': skip=%d, insideDDL=%d" , stmt_string , skipCommand , MtmDDLStatement != NULL );
5457
5465
5458
5466
prevMyXactAccessedTempRel = MyXactFlags & XACT_FLAGS_ACCESSEDTEMPREL ;
5459
5467
@@ -5491,7 +5499,7 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
5491
5499
}
5492
5500
if (MyXactFlags & XACT_FLAGS_ACCESSEDTEMPREL )
5493
5501
{
5494
- MTM_LOG1 ("Xact accessed temp table, stopping replication of statement '%s'" , queryString );
5502
+ MTM_LOG1 ("Xact accessed temp table, stopping replication of statement '%s'" , stmt_string );
5495
5503
MtmTx .isDistributed = false; /* Skip */
5496
5504
MtmTx .snapshot = INVALID_CSN ;
5497
5505
}
0 commit comments