@@ -616,10 +616,10 @@ process_remote_commit(StringInfo in)
616
616
{
617
617
uint8 event ;
618
618
csn_t csn ;
619
- const char * gid = NULL ;
620
619
lsn_t end_lsn ;
621
620
lsn_t origin_lsn ;
622
621
int origin_node ;
622
+ char gid [MULTIMASTER_MAX_GID_SIZE ];
623
623
/* read event */
624
624
event = pq_getmsgbyte (in );
625
625
MtmReplicationNodeId = pq_getmsgbyte (in );
@@ -640,7 +640,7 @@ process_remote_commit(StringInfo in)
640
640
case PGLOGICAL_PRECOMMIT_PREPARED :
641
641
{
642
642
Assert (!TransactionIdIsValid (MtmGetCurrentTransactionId ()));
643
- gid = pq_getmsgstring (in );
643
+ strcpy ( gid , pq_getmsgstring (in ) );
644
644
MTM_LOG2 ("%d: PGLOGICAL_PRECOMMIT_PREPARED %s" , MyProcPid , gid );
645
645
MtmBeginSession (origin_node );
646
646
MtmPrecommitTransaction (gid );
@@ -661,7 +661,7 @@ process_remote_commit(StringInfo in)
661
661
case PGLOGICAL_PREPARE :
662
662
{
663
663
Assert (IsTransactionState () && TransactionIdIsValid (MtmGetCurrentTransactionId ()));
664
- gid = pq_getmsgstring (in );
664
+ strcpy ( gid , pq_getmsgstring (in ) );
665
665
if (MtmExchangeGlobalTransactionStatus (gid , TRANSACTION_STATUS_IN_PROGRESS ) == TRANSACTION_STATUS_ABORTED ) {
666
666
MTM_LOG1 ("Avoid prepare of previously aborted global transaction %s" , gid );
667
667
AbortCurrentTransaction ();
@@ -694,7 +694,7 @@ process_remote_commit(StringInfo in)
694
694
{
695
695
Assert (!TransactionIdIsValid (MtmGetCurrentTransactionId ()));
696
696
csn = pq_getmsgint64 (in );
697
- gid = pq_getmsgstring (in );
697
+ strcpy ( gid , pq_getmsgstring (in ) );
698
698
MTM_LOG2 ("PGLOGICAL_COMMIT_PREPARED commit: csn=%lld, gid=%s, lsn=%llx" , csn , gid , end_lsn );
699
699
MtmResetTransaction ();
700
700
StartTransactionCommand ();
@@ -711,7 +711,7 @@ process_remote_commit(StringInfo in)
711
711
case PGLOGICAL_ABORT_PREPARED :
712
712
{
713
713
Assert (!TransactionIdIsValid (MtmGetCurrentTransactionId ()));
714
- gid = pq_getmsgstring (in );
714
+ strcpy ( gid , pq_getmsgstring (in ) );
715
715
/* MtmRollbackPreparedTransaction will set origin session itself */
716
716
MTM_LOG1 ("Receive ABORT_PREPARED logical message for transaction %s from node %d" , gid , origin_node );
717
717
MtmRollbackPreparedTransaction (origin_node , gid );
@@ -1034,19 +1034,21 @@ void MtmExecutor(void* work, size_t size)
1034
1034
int spill_file = -1 ;
1035
1035
int save_cursor = 0 ;
1036
1036
int save_len = 0 ;
1037
+
1037
1038
s .data = work ;
1038
1039
s .len = size ;
1039
1040
s .maxlen = -1 ;
1040
1041
s .cursor = 0 ;
1041
-
1042
+
1042
1043
if (MtmApplyContext == NULL ) {
1043
1044
MtmApplyContext = AllocSetContextCreate (TopMemoryContext ,
1044
1045
"ApplyContext" ,
1045
1046
ALLOCSET_DEFAULT_MINSIZE ,
1046
1047
ALLOCSET_DEFAULT_INITSIZE ,
1047
1048
ALLOCSET_DEFAULT_MAXSIZE );
1048
1049
}
1049
- TopMemoryContext = MemoryContextSwitchTo (MtmApplyContext );
1050
+ MemoryContextSwitchTo (MtmApplyContext );
1051
+
1050
1052
replorigin_session_origin = InvalidRepOriginId ;
1051
1053
PG_TRY ();
1052
1054
{
0 commit comments