Re: Allowing REINDEX to have an optional name
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Simon Riggs <simon.riggs@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Bernd Helmle <mailings@oopsware.de>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Date: 2022-07-17T06:19:47Z
Lists: pgsql-hackers
Attachments
- v6-0001-Rework-and-add-more-stuff-for-REINDEX-SYSTEM-DATA.patch (text/x-diff) patch v6-0001
On Fri, Jul 15, 2022 at 06:21:22PM +0100, Simon Riggs wrote:
> That's fixed it on the CFbot. Over to you, Michael. Thanks.
Sure. I have looked over that, and this looks fine overall. I have
made two changes though.
if (objectKind == REINDEX_OBJECT_SYSTEM &&
- !IsSystemClass(relid, classtuple))
+ !IsCatalogRelationOid(relid))
+ continue;
+ else if (objectKind == REINDEX_OBJECT_DATABASE &&
+ IsCatalogRelationOid(relid))
The patch originally relied on IsSystemClass() to decide if a relation
is a catalog table or not. This is not wrong in itself because
ReindexMultipleTables() discards RELKIND_TOAST a couple of lines
above, but I think that we should switch to IsCatalogRelationOid() as
that's the line drawn to check for the catalog-ness of a relation.
The second thing is test coverage. Using a REINDEX DATABASE/SYSTEM
within the main regression test suite is not a good idea, but we
already have those commands running in the reindexdb suite so I could
not resist expanding the test section to track and check relfilenode
changes through four relations for these cases:
- Catalog index.
- Catalog toast index.
- User table index.
- User toast index.
The relfilenodes of those relations are saved in a table and
cross-checked with the contents of pg_class after each REINDEX, on
SYSTEM or DATABASE. There are no new heavy commands, so it does not
make the test longer.
With all that, I finish with the attached. Does that look fine to
you?
--
Michael
Commits
-
Tweak a bit the new TAP tests of REINDEX DATABASE/SYSTEM
- 2b99ce10c2bc 16.0 landed
-
Rework logic and simplify syntax of REINDEX DATABASE/SYSTEM
- 2cbc3c17a5c1 16.0 landed
-
Add more tests for REINDEX DATABASE/SYSTEM with relfilenode changes
- 5fb5b6c4c176 16.0 landed