diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 3a03dcbc4ee..b1d07079a8f 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -1782,7 +1782,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 */