From 020ba6afb87287d782477054949d77954377d347 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas.vondra@postgresql.org>
Date: Thu, 5 Jan 2023 20:11:49 +0100
Subject: [PATCH 1/2] Fix stale comment in postgres_fdw

A comment was left behind referencing a bit (sample rate adjustment)
removed from 8ad51b5f44. So clean that up, and while at it also remove
clamping of the sample rate which should not be necessary without the
clamping, and just check that with an assert.
---
 contrib/postgres_fdw/postgres_fdw.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 332b4a5cdeb..65822b8a9aa 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -5204,10 +5204,11 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,
 			sample_frac = targrows / reltuples;
 
 			/*
-			 * Ensure the sampling rate is between 0.0 and 1.0, even after the
-			 * 10% adjustment above.  (Clamping to 0.0 is just paranoia.)
+			 * We should never get sampling rate outside the valid range
+			 * (between 0.0 and 1.0), because those cases should be covered
+			 * by the previous branch that sets ANALYZE_SAMPLE_OFF.
 			 */
-			sample_frac = Min(1.0, Max(0.0, sample_frac));
+			Assert(sample_frac == Min(1.0, Max(0.0, sample_frac)));
 		}
 	}
 
-- 
2.39.0

