Don't try to open visibilitymap when analyzing a foreign table

It's harmless, visibilitymap_count() returns 0 if the file doesn't
exist. But it's also very pointless. I noticed this when I added an
assertion in smgropen() that the relnumber is valid.

Discussion: https://www.postgresql.org/message-id/621a52fd-3cd8-4f5d-a561-d510b853bbaf@iki.fi
This commit is contained in:
Heikki Linnakangas 2023-12-08 09:16:21 +02:00
parent cd7f19da34
commit 049ef3398d
2 changed files with 6 additions and 1 deletions

View File

@ -634,7 +634,10 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
{
BlockNumber relallvisible;
visibilitymap_count(onerel, &relallvisible, NULL);
if (RELKIND_HAS_STORAGE(onerel->rd_rel->relkind))
visibilitymap_count(onerel, &relallvisible, NULL);
else
relallvisible = 0;
/* Update pg_class for table relation */
vac_update_relstats(onerel,

View File

@ -153,6 +153,8 @@ smgropen(RelFileLocator rlocator, BackendId backend)
SMgrRelation reln;
bool found;
Assert(RelFileNumberIsValid(rlocator.relNumber));
if (SMgrRelationHash == NULL)
{
/* First time through: initialize the hash table */