On 7/28/26 16:08, Jan Nidzwetzki wrote:
> ...
> 
> As discussed upthread, here's the follow-up patch to validate and
> reject clearly bogus reltuples at import.
> 
> Currently, the function relation_statistics_update_internal() validates
> the incoming reltuples only with
> 
>    if (reltuples < -1.0) { ereport(WARNING, ...); result = false; }
> 
> This means that both Infinity and NaN values pass this test since
> neither is less than -1.0. As a result, non-finite values are accepted
> and stored in pg_class.reltuples.
> 
> The patch rejects non-finite reltuples the same non-fatal way the
> existing out-of-range check does: ereport(WARNING), set result = false,
> and skip that field, so an otherwise-valid stats import (or pg_upgrade)
> still proceeds and only the bad value is dropped.
> 
> It also adds a regression test to stats_import covering the rejected
> values (Infinity, -Infinity, NaN) and confirming that a legitimate -1
> is still accepted.
> 
> The statistics import functions are new in v18, so this applies to v18+.
> 

Thanks! I've now pushed both this fix and the fix for the GIN build.

I agree we don't need to do anything about "bogus" values between -1.0
and 0.0, because as you say, that should be treated as "unknown" (same
as -1.0).

I'll make sure we mention this (and the suggestion to run an explicit
ANALYZE on possibly-affected tables) in the release notes.


regards

-- 
Tomas Vondra



Reply via email to