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
pull/151/head
Heikki Linnakangas 2 years ago
parent cd7f19da34
commit 049ef3398d
  1. 3
      src/backend/commands/analyze.c
  2. 2
      src/backend/storage/smgr/smgr.c

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

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

Loading…
Cancel
Save