Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitddc54d4

Browse files
kovdb75Mikhail Rutman
authored and
Mikhail Rutman
committed
Fixed processing of error for DDL-queries in PgPlSQL block
Tags: atx, multimaster
1 parentb6fcf8c commitddc54d4

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

‎src/commit.c‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,39 @@ mtm_commit_cleanup(int status, Datum arg)
135135
/* there was no precommit, we can abort */
136136
PG_TRY();
137137
{
138-
AbortOutOfAnyTransaction();
139-
StartTransactionCommand();
138+
#ifdefPGPRO_EE
139+
intatxLevel=DatumGetInt32(arg);
140+
141+
/*
142+
* If we are inside ATX transaction, we can not call
143+
* AbortOutOfAnyTransaction() because this call will abort
144+
* ALL transactions and we will have problems if the
145+
* calling code is not designed for this case.
146+
*/
147+
if (atxLevel)
148+
{
149+
/* Abort (current ATX transaction only): */
150+
AbortCurrentTransaction();
151+
/* Restart ATX transaction if it was resumed: */
152+
if (atxLevel>getNestLevelATX())
153+
SuspendTransaction();
154+
}
155+
else
156+
#endif
157+
{
158+
AbortOutOfAnyTransaction();
159+
StartTransactionCommand();
160+
}
140161
FinishPreparedTransaction(mtm_commit_state.gid, false, false);
141162
mtm_commit_state.gtx->state.status=GTXAborted;
142163
mtm_log(MtmTxFinish,"%s aborted as own orphaned not precomitted",
143164
mtm_commit_state.gid);
144165
CommitTransactionCommand();
145-
166+
#ifdefPGPRO_EE
167+
/* Restart ATX transaction if it was resumed: */
168+
if (atxLevel>getNestLevelATX())
169+
SuspendTransaction();
170+
#endif
146171
}
147172
/*
148173
* this should be extremely unlikely, but if we fail, don't
@@ -218,7 +243,7 @@ MtmBeginTransaction()
218243
* register gtx hook first (it will be called last)
219244
*/
220245
GlobalTxEnsureBeforeShmemExitHook();
221-
before_shmem_exit(mtm_commit_cleanup,Int32GetDatum(1));
246+
before_shmem_exit(mtm_commit_cleanup,Int32GetDatum(0));
222247
mtm_commit_state.mctx=AllocSetContextCreate(TopMemoryContext,
223248
"MtmCommitContext",
224249
ALLOCSET_DEFAULT_SIZES);
@@ -373,6 +398,9 @@ MtmTwoPhaseCommit(void)
373398
MtmGenerationxact_gen;
374399
chardmq_stream_name[DMQ_STREAM_NAME_MAXLEN];
375400
GTxStategtx_state;
401+
#ifdefPGPRO_EE
402+
intatxLevel=getNestLevelATX();
403+
#endif
376404

377405
if (MtmNo3PC)
378406
{
@@ -714,7 +742,7 @@ MtmTwoPhaseCommit(void)
714742
}
715743
PG_CATCH();
716744
{
717-
mtm_commit_cleanup(0,Int32GetDatum(0));
745+
mtm_commit_cleanup(0,Int32GetDatum(atxLevel));
718746

719747
PG_RE_THROW();
720748
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp