On Mon, 2021-05-03 at 15:07 -0700, Peter Geoghegan wrote: > It seems senseless to *require* table AMs to support something like a > bitmap scan.
I thought about this some more, and this framing is backwards. ItemPointers are fundamental to the table AM API: they are passed in to required methods, and expected to be returned[1]. Bitmap scans are optional, but that should be determined by whether the author wants to implement the bitmap scan methods of their table AM. The fine details of ItemPointer representation should not be making the decision for them. We still need to answer the core question that started this thread: what the heck is an ItemPointer, anyway? After looking at itemptr.h, off.h, ginpostinglist.c and tidbitmap.c, it seems that an ItemPointer is a block number from [0, 0xFFFFFFFe]; and an offset number from [1, MaxHeapTuplesPerPage] which is by default [1, 291]. Attached is a patch that clarifies what I've found so far and gives clear guidance to table AM authors. Before I commit this I'll make sure that following the guidance actually works for the columnar AM. Regards, Jeff Davis [1] Even for the current version of columnar, which doesn't support indexes or updates, we implemented a hack to provide dummy TIDs because some places expect them (see analyze.c:compare_rows()).
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 9f1e4a1ac96..7e5d65d48c3 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -229,6 +229,19 @@ typedef struct TM_IndexDeleteOp TM_IndexStatus *status; } TM_IndexDeleteOp; +/* + * ItemPointers returned by a table access method should obey these + * limits. Some other parts of the system make assumtions about the range of + * offsets that they will encounter (see: ginpostinglist.c, tidbitmap.c). + * + * NB: if these limits are lifted in the future, non-heap table access methods + * may break or require a REINDEX. + */ +#define TABLE_ITEMPTR_MIN_BLOCKNO 0 +#define TABLE_ITEMPTR_MAX_BLOCKNO MaxBlockNumber +#define TABLE_ITEMPTR_MIN_OFFSET 1 +#define TABLE_ITEMPTR_MAX_OFFSET MaxHeapTuplesPerPage + /* "options" flag bits for table_tuple_insert */ /* TABLE_INSERT_SKIP_WAL was 0x0001; RelationNeedsWAL() now governs */ #define TABLE_INSERT_SKIP_FSM 0x0002