Fix stale comment about sample_frac adjustment
authorTomas Vondra <[email protected]>
Fri, 6 Jan 2023 13:47:02 +0000 (14:47 +0100)
committerTomas Vondra <[email protected]>
Fri, 6 Jan 2023 13:47:23 +0000 (14:47 +0100)
A comment was left behind referencing sample rate adjustment removed
from 8ad51b5f44. So clean that up. While at it also remove the sample
rate clamping which should not be necessary without the clamping, and
just check that with an assert.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/951485.1672461744%40sss.pgh.pa.us

contrib/postgres_fdw/postgres_fdw.c

index 332b4a5cdeb37e8502a29740c81b1fdaac7a40ba..f8461bf18dcfc396d00c94e56e602c474cb15ea5 100644 (file)
@@ -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 >= 0.0 && sample_frac <= 1.0);
        }
    }