diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index ed43920264..a3c27d9d74 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -1758,7 +1758,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 */