diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index c9f6392354..adbaea5ca7 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -1779,7 +1779,8 @@ EnsurePortalSnapshotExists(void) /* Otherwise, we'd better have an active Portal */ portal = ActivePortal; - Assert(portal != NULL); + if (unlikely(portal == NULL)) + elog(ERROR, "cannot execute SQL without an outer snapshot or portal"); Assert(portal->portalSnapshot == NULL); /* Create a new snapshot and make it active */