aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/mmgr/portalmem.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index 5983aedb121..369e1817093 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -415,8 +415,8 @@ MarkPortalDone(Portal portal)
* well do that now, since the portal can't be executed any more.
*
* In some cases involving execution of a ROLLBACK command in an already
- * aborted transaction, this prevents an assertion failure caused by
- * reaching AtCleanup_Portals with the cleanup hook still unexecuted.
+ * aborted transaction, this is necessary, or we'd reach AtCleanup_Portals
+ * with the cleanup hook still unexecuted.
*/
if (PointerIsValid(portal->cleanup))
{
@@ -443,8 +443,8 @@ MarkPortalFailed(Portal portal)
* well do that now, since the portal can't be executed any more.
*
* In some cases involving cleanup of an already aborted transaction, this
- * prevents an assertion failure caused by reaching AtCleanup_Portals with
- * the cleanup hook still unexecuted.
+ * is necessary, or we'd reach AtCleanup_Portals with the cleanup hook
+ * still unexecuted.
*/
if (PointerIsValid(portal->cleanup))
{
@@ -842,8 +842,15 @@ AtCleanup_Portals(void)
if (portal->portalPinned)
portal->portalPinned = false;
- /* We had better not be calling any user-defined code here */
- Assert(portal->cleanup == NULL);
+ /*
+ * We had better not call any user-defined code during cleanup, so if
+ * the cleanup hook hasn't been run yet, too bad; we'll just skip it.
+ */
+ if (PointerIsValid(portal->cleanup))
+ {
+ elog(WARNING, "skipping cleanup for portal \"%s\"", portal->name);
+ portal->cleanup = NULL;
+ }
/* Zap it. */
PortalDrop(portal, false);
@@ -1026,8 +1033,15 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
if (portal->portalPinned)
portal->portalPinned = false;
- /* We had better not be calling any user-defined code here */
- Assert(portal->cleanup == NULL);
+ /*
+ * We had better not call any user-defined code during cleanup, so if
+ * the cleanup hook hasn't been run yet, too bad; we'll just skip it.
+ */
+ if (PointerIsValid(portal->cleanup))
+ {
+ elog(WARNING, "skipping cleanup for portal \"%s\"", portal->name);
+ portal->cleanup = NULL;
+ }
/* Zap it. */
PortalDrop(portal, false);