Skip to content

Commit 979a388

Browse files
knizhnikkelvich
authored andcommitted
Store GID on stack
1 parent 1ecd0d6 commit 979a388

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pglogical_apply.c

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy