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, 16 Aug 2016 04:03:21 +0000 (09:33 +0530)
Per report by Agoston David

src/backend/commands/tablecmds.c

index fe169f35853a2a8ab3b9824b4967f8aafec1d219..024924e485d2526ae72109cb3414e6759b426eb8 100644 (file)
@@ -12396,6 +12396,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);