pgsql: Don't lose partitioned table reltuples=0 after relhassubclass=f.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't lose partitioned table reltuples=0 after relhassubclass=f.
Date: 2024-07-13 15:11:06
Message-ID: E1sSeOw-001VzJ-43@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't lose partitioned table reltuples=0 after relhassubclass=f.

ANALYZE sets relhassubclass=f when a partitioned table no longer has
partitions. An ANALYZE doing that proceeded to apply the inplace update
of pg_class.reltuples to the old pg_class tuple instead of the new
tuple, losing that reltuples=0 change if the ANALYZE committed.
Non-partitioning inheritance trees were unaffected. Back-patch to v14,
where commit 375aed36ad83f0e021e9bdd3a0034c0c992c66dc introduced
maintenance of partitioned table pg_class.reltuples.

Reported by Alexander Lakhin.

Discussion: https://postgr.es/m/a295b499-dcab-6a99-c06e-01cf60593344@gmail.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b415e95a8a7ccb4fe9276e2ca453f4ae69466c1

Modified Files
--------------
src/backend/commands/analyze.c | 7 ++++-
src/test/regress/expected/sanity_check.out | 2 ++
src/test/regress/expected/vacuum.out | 47 ++++++++++++++++++++++++++++++
src/test/regress/sql/vacuum.sql | 29 ++++++++++++++++++
4 files changed, 84 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2024-07-13 20:24:06 pgsql: Use correct collate.windows.win1252.out
Previous Message Andrew Dunstan 2024-07-13 12:15:11 pgsql: Make sure to run pg_isready on correct port