Make sure ON COMMIT actions are invoked only when transaction is still valid
authorPavan Deolasee <[email protected]>
Tue, 16 Aug 2016 04:01:29 +0000 (09:31 +0530)
committerPavan Deolasee <[email protected]>
Tue, 18 Oct 2016 10:07:43 +0000 (15:37 +0530)
Per report by Agoston David

src/backend/commands/tablecmds.c

index 5e7b301656e0007756c30d2e57eaea93ad883c28..d63c60c94657446c749a2305b453356015b0994b 100644 (file)
@@ -12257,6 +12257,16 @@ PreCommit_on_commit_actions(void)
        ListCell   *l;
        List       *oids_to_truncate = NIL;
 
+#ifdef XCP
+       /*
+        * If we are being called outside a valid transaction, do nothing. This can
+        * only happen when the function gets called while we are still processing
+        * CommitTransaction/PrepareTransaction
+        */
+       if (GetTopTransactionIdIfAny() == InvalidTransactionId)
+               return;
+#endif
+
        foreach(l, on_commits)
        {
                OnCommitItem *oc = (OnCommitItem *) lfirst(l);