Hi, On 2021-09-18 02:51:09 +0300, Alexander Korotkov wrote: > On Tue, Sep 14, 2021 at 6:53 AM Tom Lane <t...@sss.pgh.pa.us> wrote: > > Without having looked at the details, I think using a forward-declare > > to avoid including relcache.h in visibilitymap.h might be a reasonably > > non-painful fix. > > I like that idea, but I didn't find an appropriate existing header for > forward-declaration of Relation. relation.h isn't suitable, because > it includes primnodes.h. A separate header for just > forward-definition of Relation seems too much.
I was just thinking of doing something like the attached. > > TOH, in the long run it might be worth the effort > > to split visibilitymap.h to separate useful file-contents knowledge > > from backend function declarations. > > I've drafted a patch splitting visibilitymap_maros.h from > visibilitymap.h. What do you think? I'd name it visibilitymapdefs.h or such, mostly because that's what other headers are named like... Greetings, Andres Freund
diff --git i/src/include/access/visibilitymap.h w/src/include/access/visibilitymap.h index 57362c36876..d7f7f30b1fb 100644 --- i/src/include/access/visibilitymap.h +++ w/src/include/access/visibilitymap.h @@ -17,7 +17,6 @@ #include "access/xlogdefs.h" #include "storage/block.h" #include "storage/buf.h" -#include "utils/relcache.h" /* Number of bits for one heap page */ #define BITS_PER_HEAPBLOCK 2 @@ -27,6 +26,7 @@ #define VISIBILITYMAP_ALL_FROZEN 0x02 #define VISIBILITYMAP_VALID_BITS 0x03 /* OR of all valid visibilitymap * flags bits */ +struct RelationData; /* Macros for visibilitymap test */ #define VM_ALL_VISIBLE(r, b, v) \ @@ -34,17 +34,17 @@ #define VM_ALL_FROZEN(r, b, v) \ ((visibilitymap_get_status((r), (b), (v)) & VISIBILITYMAP_ALL_FROZEN) != 0) -extern bool visibilitymap_clear(Relation rel, BlockNumber heapBlk, +extern bool visibilitymap_clear(struct RelationData *rel, BlockNumber heapBlk, Buffer vmbuf, uint8 flags); -extern void visibilitymap_pin(Relation rel, BlockNumber heapBlk, +extern void visibilitymap_pin(struct RelationData *rel, BlockNumber heapBlk, Buffer *vmbuf); extern bool visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf); -extern void visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf, +extern void visibilitymap_set(struct RelationData *rel, BlockNumber heapBlk, Buffer heapBuf, XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid, uint8 flags); -extern uint8 visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf); -extern void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen); -extern BlockNumber visibilitymap_prepare_truncate(Relation rel, +extern uint8 visibilitymap_get_status(struct RelationData *rel, BlockNumber heapBlk, Buffer *vmbuf); +extern void visibilitymap_count(struct RelationData *rel, BlockNumber *all_visible, BlockNumber *all_frozen); +extern BlockNumber visibilitymap_prepare_truncate(struct RelationData *rel, BlockNumber nheapblocks); #endif /* VISIBILITYMAP_H */ diff --git i/src/include/utils/relcache.h w/src/include/utils/relcache.h index f772855ac69..d2c17575f65 100644 --- i/src/include/utils/relcache.h +++ w/src/include/utils/relcache.h @@ -14,7 +14,6 @@ #ifndef RELCACHE_H #define RELCACHE_H -#include "postgres.h" #include "access/tupdesc.h" #include "nodes/bitmapset.h"