Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 47c5b39

Browse files
committed
Merge branch 'PGPROEE9_6_atx' into PGPROEE9_6_ALPHA
2 parents 915b023 + d618b75 commit 47c5b39

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

src/backend/access/transam/xact.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,8 @@ typedef struct {
18541854
void *SPIState;
18551855
void *SnapshotState;
18561856
struct TransInvalidationInfo* InvalidationInfo;
1857+
1858+
List *on_commit_actions;
18571859
} SuspendedTransactionState;
18581860

18591861
static int suspendedXactNum = 0;
@@ -2209,8 +2211,10 @@ CommitTransaction(void)
22092211
AtEOXact_Namespace(true, is_parallel_worker);
22102212
AtEOXact_SMgr();
22112213
if (getNestLevelATX() == 0)
2214+
{
22122215
AtEOXact_Files();
2213-
AtEOXact_ComboCid();
2216+
AtEOXact_ComboCid();
2217+
}
22142218
AtEOXact_HashTables(true);
22152219
AtEOXact_PgStat(true);
22162220
AtEOXact_Snapshot(true);
@@ -3581,9 +3585,11 @@ void SuspendTransaction(void)
35813585
MOVELEFT(sus->vxid.backendId, MyProc->backendId, MyBackendId);
35823586
MOVELEFT(sus->vxid.localTransactionId, MyProc->lxid, GetNextLocalTransactionId());
35833587

3588+
MOVELEFT(sus->on_commit_actions, pg_on_commit_actions, NULL);
3589+
35843590
sus->PgStatState = PgStatSuspend();
35853591
sus->TriggerState = TriggerSuspend();
3586-
sus->SPIState = SuspendSPI();
3592+
sus->SPIState = SuspendSPI();
35873593
}
35883594

35893595
AtStart_Memory();
@@ -3653,6 +3659,8 @@ bool ResumeTransaction(void)
36533659

36543660
MyProc->backendId = sus->vxid.backendId;
36553661
MyProc->lxid = sus->vxid.localTransactionId;
3662+
3663+
pg_on_commit_actions = sus->on_commit_actions;
36563664
}
36573665

36583666
ResumePgXact(MyPgXact);

src/backend/commands/tablecmds.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ typedef struct OnCommitItem
118118
SubTransactionId deleting_subid;
119119
} OnCommitItem;
120120

121-
static List *on_commits = NIL;
121+
List* pg_on_commit_actions = NIL;
122122

123123

124124
/*
@@ -11985,7 +11985,7 @@ register_on_commit_action(Oid relid, OnCommitAction action)
1198511985
oc->creating_subid = GetCurrentSubTransactionId();
1198611986
oc->deleting_subid = InvalidSubTransactionId;
1198711987

11988-
on_commits = lcons(oc, on_commits);
11988+
pg_on_commit_actions = lcons(oc, pg_on_commit_actions);
1198911989

1199011990
MemoryContextSwitchTo(oldcxt);
1199111991
}
@@ -12000,7 +12000,7 @@ remove_on_commit_action(Oid relid)
1200012000
{
1200112001
ListCell *l;
1200212002

12003-
foreach(l, on_commits)
12003+
foreach(l, pg_on_commit_actions)
1200412004
{
1200512005
OnCommitItem *oc = (OnCommitItem *) lfirst(l);
1200612006

@@ -12024,7 +12024,7 @@ PreCommit_on_commit_actions(void)
1202412024
ListCell *l;
1202512025
List *oids_to_truncate = NIL;
1202612026

12027-
foreach(l, on_commits)
12027+
foreach(l, pg_on_commit_actions)
1202812028
{
1202912029
OnCommitItem *oc = (OnCommitItem *) lfirst(l);
1203012030

@@ -12096,7 +12096,7 @@ AtEOXact_on_commit_actions(bool isCommit)
1209612096
ListCell *prev_item;
1209712097

1209812098
prev_item = NULL;
12099-
cur_item = list_head(on_commits);
12099+
cur_item = list_head(pg_on_commit_actions);
1210012100

1210112101
while (cur_item != NULL)
1210212102
{
@@ -12106,12 +12106,12 @@ AtEOXact_on_commit_actions(bool isCommit)
1210612106
oc->creating_subid != InvalidSubTransactionId)
1210712107
{
1210812108
/* cur_item must be removed */
12109-
on_commits = list_delete_cell(on_commits, cur_item, prev_item);
12109+
pg_on_commit_actions = list_delete_cell(pg_on_commit_actions, cur_item, prev_item);
1211012110
pfree(oc);
1211112111
if (prev_item)
1211212112
cur_item = lnext(prev_item);
1211312113
else
12114-
cur_item = list_head(on_commits);
12114+
cur_item = list_head(pg_on_commit_actions);
1211512115
}
1211612116
else
1211712117
{
@@ -12139,7 +12139,7 @@ AtEOSubXact_on_commit_actions(bool isCommit, SubTransactionId mySubid,
1213912139
ListCell *prev_item;
1214012140

1214112141
prev_item = NULL;
12142-
cur_item = list_head(on_commits);
12142+
cur_item = list_head(pg_on_commit_actions);
1214312143

1214412144
while (cur_item != NULL)
1214512145
{
@@ -12148,12 +12148,12 @@ AtEOSubXact_on_commit_actions(bool isCommit, SubTransactionId mySubid,
1214812148
if (!isCommit && oc->creating_subid == mySubid)
1214912149
{
1215012150
/* cur_item must be removed */
12151-
on_commits = list_delete_cell(on_commits, cur_item, prev_item);
12151+
pg_on_commit_actions = list_delete_cell(pg_on_commit_actions, cur_item, prev_item);
1215212152
pfree(oc);
1215312153
if (prev_item)
1215412154
cur_item = lnext(prev_item);
1215512155
else
12156-
cur_item = list_head(on_commits);
12156+
cur_item = list_head(pg_on_commit_actions);
1215712157
}
1215812158
else
1215912159
{

src/include/commands/tablecmds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "storage/lock.h"
2222
#include "utils/relcache.h"
2323

24+
extern List* pg_on_commit_actions;
2425

2526
extern ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
2627
ObjectAddress *typaddress);

src/pl/plpgsql/src/pl_exec.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
11711171
MemoryContext oldcontext = CurrentMemoryContext;
11721172
ExprContext *old_eval_econtext = estate->eval_econtext;
11731173
ErrorData *save_cur_error = estate->cur_error;
1174+
bool error_inside_commit = false;
11741175

11751176
estate->err_text = gettext_noop("during autonomous statement block entry");
11761177

@@ -1209,6 +1210,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
12091210

12101211
old_shared_estate = shared_simple_eval_estate;
12111212
shared_simple_eval_estate = NULL;
1213+
error_inside_commit = true;
12121214
CommitTransactionCommand();
12131215
shared_simple_eval_estate = old_shared_estate;
12141216

@@ -1230,13 +1232,16 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
12301232
edata = CopyErrorData();
12311233
FlushErrorState();
12321234

1233-
plpgsql_destroy_econtext(estate);
1234-
1235-
old_shared_estate = shared_simple_eval_estate;
1236-
shared_simple_eval_estate = NULL;
1235+
if (!error_inside_commit)
1236+
{
1237+
plpgsql_destroy_econtext(estate);
1238+
1239+
old_shared_estate = shared_simple_eval_estate;
1240+
shared_simple_eval_estate = NULL;
1241+
}
12371242
AbortCurrentTransaction();
12381243
shared_simple_eval_estate = old_shared_estate;
1239-
1244+
12401245
estate->eval_econtext = old_eval_econtext;
12411246

12421247
if (block->exceptions)

0 commit comments

Comments
 (0)