]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't try to open visibilitymap when analyzing a foreign table
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 8 Dec 2023 07:16:21 +0000 (09:16 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 8 Dec 2023 07:16:21 +0000 (09:16 +0200)
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

src/backend/commands/analyze.c
src/backend/storage/smgr/smgr.c

index e264ffdcf2883efc3f6fdfb4f30a470f40e36a05..1f4a9516814ab76a4c21ef5325f886eb04d45292 100644 (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,
index 5d0f3d515c311a4a3f4b5dc0c294d7dea3f7e56c..4c552649336ee92157c34b629de7bba4557b6447 100644 (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 */