agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Reject non-finite reltuples when restoring stats
3+ messages / 1 participants
[nested] [flat]

* pgsql: Reject non-finite reltuples when restoring stats
@ 2026-07-30 14:47  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Tomas Vondra @ 2026-07-30 14:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@planetscale.com>
Discussion: https://postgr.es/m/518BA772-8026-412A-AA8F-A7FE4C6B3717@planetscale.com
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7cb9060dcde08ca63df1f0d701b0674e0e8ae811

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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Reject non-finite reltuples when restoring stats
@ 2026-07-30 14:47  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Tomas Vondra @ 2026-07-30 14:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@planetscale.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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Reject non-finite reltuples when restoring stats
@ 2026-07-30 14:47  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Tomas Vondra @ 2026-07-30 14:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@planetscale.com>
Discussion: https://postgr.es/m/518BA772-8026-412A-AA8F-A7FE4C6B3717@planetscale.com
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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-07-30 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-30 14:47 pgsql: Reject non-finite reltuples when restoring stats Tomas Vondra <tomas.vondra@postgresql.org>
2026-07-30 14:47 pgsql: Reject non-finite reltuples when restoring stats Tomas Vondra <tomas.vondra@postgresql.org>
2026-07-30 14:47 pgsql: Reject non-finite reltuples when restoring stats Tomas Vondra <tomas.vondra@postgresql.org>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox