Reject non-finite reltuples when restoring stats When restoring relation stats, pg_restore_relation_stats() rejected calls with (reltuples < -1.0). But that is insufficient - Infinity and NaN values both pass that check, and get stored in pg_class verbatim. This can have various undesirable consequences.
Fixed by rejecting non-finite reltuple values, in the same non-fatal way as for the existing checks (emit WARNING and skip the update). Adds a regression test to stats_import for these non-finite values, and to check the -1.0 special value is still accepted. Backpatch to 18, where pg_restore_relation_stats() was introduced. Patch by Jan Nidzwetzki, minor commit message tweaks by me. Author: Jan Nidzwetzki <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 18 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a0369dd8448fba99d22068f533764bf2fb001278 Modified Files -------------- src/backend/statistics/relation_stats.c | 11 ++++- src/test/regress/expected/stats_import.out | 79 ++++++++++++++++++++++++++++++ src/test/regress/sql/stats_import.sql | 43 ++++++++++++++++ 3 files changed, 132 insertions(+), 1 deletion(-)
