diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index 9cccc87..d1da7df 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -520,6 +520,7 @@ RevalidateCachedQuery(CachedPlanSource *plansource)
 	 * don't have invalidatable plans, so we'd not get here for such a
 	 * command.
 	 */
+	Assert(analyze_requires_snapshot(plansource->raw_parse_tree));
 	snapshot_set = false;
 	if (!ActiveSnapshotSet())
 	{
@@ -757,13 +758,11 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
 
 	/*
 	 * If a snapshot is already set (the normal case), we can just use
-	 * that for parsing/planning.  But if it isn't, install one.  Note: no
-	 * point in checking whether parse analysis requires a snapshot;
-	 * utility commands don't have invalidatable plans, so we'd not get
-	 * here for such a command.
+	 * that for parsing/planning.  But if it isn't, install one.
 	 */
 	snapshot_set = false;
-	if (!ActiveSnapshotSet())
+	if (!ActiveSnapshotSet() &&
+		analyze_requires_snapshot(plansource->raw_parse_tree))
 	{
 		PushActiveSnapshot(GetTransactionSnapshot());
 		snapshot_set = true;
