| From: | Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Reject non-finite reltuples when restoring stats |
| Date: | 2026-07-30 14:47:29 |
| Message-ID: | E1wpS2j-00000000xzv-3v1K@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <jan(at)planetscale(dot)com>
Discussion: https://postgr.es/m/518BA772-8026-412A-AA8F-A7FE4C6B3717@planetscale.com
Backpatch-through: 18
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/068447dcd9d7def7b58531078d167c280d9d1861
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-07-30 14:47:38 | pgsql: Reject non-finite reltuples when restoring stats |
| Previous Message | Tomas Vondra | 2026-07-30 14:47:18 | pgsql: Reject non-finite reltuples when restoring stats |