@@ -616,10 +616,10 @@ process_remote_commit(StringInfo in)
616616{
617617uint8 event ;
618618csn_t csn ;
619- const char * gid = NULL ;
620619lsn_t end_lsn ;
621620lsn_t origin_lsn ;
622621int origin_node ;
622+ char gid [MULTIMASTER_MAX_GID_SIZE ];
623623/* read event */
624624event = pq_getmsgbyte (in );
625625MtmReplicationNodeId = pq_getmsgbyte (in );
@@ -640,7 +640,7 @@ process_remote_commit(StringInfo in)
640640case PGLOGICAL_PRECOMMIT_PREPARED :
641641{
642642Assert (!TransactionIdIsValid (MtmGetCurrentTransactionId ()));
643- gid = pq_getmsgstring (in );
643+ strcpy ( gid , pq_getmsgstring (in ) );
644644MTM_LOG2 ("%d: PGLOGICAL_PRECOMMIT_PREPARED %s" ,MyProcPid ,gid );
645645MtmBeginSession (origin_node );
646646MtmPrecommitTransaction (gid );
@@ -661,7 +661,7 @@ process_remote_commit(StringInfo in)
661661case PGLOGICAL_PREPARE :
662662{
663663Assert (IsTransactionState ()&& TransactionIdIsValid (MtmGetCurrentTransactionId ()));
664- gid = pq_getmsgstring (in );
664+ strcpy ( gid , pq_getmsgstring (in ) );
665665if (MtmExchangeGlobalTransactionStatus (gid ,TRANSACTION_STATUS_IN_PROGRESS )== TRANSACTION_STATUS_ABORTED ) {
666666MTM_LOG1 ("Avoid prepare of previously aborted global transaction %s" ,gid );
667667AbortCurrentTransaction ();
@@ -694,7 +694,7 @@ process_remote_commit(StringInfo in)
694694{
695695Assert (!TransactionIdIsValid (MtmGetCurrentTransactionId ()));
696696csn = pq_getmsgint64 (in );
697- gid = pq_getmsgstring (in );
697+ strcpy ( gid , pq_getmsgstring (in ) );
698698MTM_LOG2 ("PGLOGICAL_COMMIT_PREPARED commit: csn=%lld, gid=%s, lsn=%llx" ,csn ,gid ,end_lsn );
699699MtmResetTransaction ();
700700StartTransactionCommand ();
@@ -711,7 +711,7 @@ process_remote_commit(StringInfo in)
711711case PGLOGICAL_ABORT_PREPARED :
712712{
713713Assert (!TransactionIdIsValid (MtmGetCurrentTransactionId ()));
714- gid = pq_getmsgstring (in );
714+ strcpy ( gid , pq_getmsgstring (in ) );
715715/* MtmRollbackPreparedTransaction will set origin session itself */
716716MTM_LOG1 ("Receive ABORT_PREPARED logical message for transaction %s from node %d" ,gid ,origin_node );
717717MtmRollbackPreparedTransaction (origin_node ,gid );
@@ -1034,19 +1034,21 @@ void MtmExecutor(void* work, size_t size)
10341034int spill_file = -1 ;
10351035int save_cursor = 0 ;
10361036int save_len = 0 ;
1037+
10371038s .data = work ;
10381039s .len = size ;
10391040s .maxlen = -1 ;
10401041s .cursor = 0 ;
1041-
1042+
10421043if (MtmApplyContext == NULL ) {
10431044MtmApplyContext = AllocSetContextCreate (TopMemoryContext ,
10441045"ApplyContext" ,
10451046ALLOCSET_DEFAULT_MINSIZE ,
10461047ALLOCSET_DEFAULT_INITSIZE ,
10471048ALLOCSET_DEFAULT_MAXSIZE );
10481049 }
1049- TopMemoryContext = MemoryContextSwitchTo (MtmApplyContext );
1050+ MemoryContextSwitchTo (MtmApplyContext );
1051+
10501052replorigin_session_origin = InvalidRepOriginId ;
10511053PG_TRY ();
10521054 {