From 8e038d3439ad9b588943a4eff84eba33f5b26244 Mon Sep 17 00:00:00 2001 From: HuSen8891 Date: Wed, 13 Mar 2024 20:17:25 +0800 Subject: [PATCH] Add inline function 'table_scan_flags' for table AM to get the scan flags. --- src/backend/access/aocs/aocsam_handler.c | 2 +- src/backend/access/appendonly/appendonlyam.c | 2 +- src/backend/access/heap/heapam.c | 2 +- src/include/access/heapam.h | 2 +- src/include/access/tableam.h | 12 +++++++++++- src/include/cdb/cdbappendonlyam.h | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/backend/access/aocs/aocsam_handler.c b/src/backend/access/aocs/aocsam_handler.c index a156921c774..883219e69b1 100644 --- a/src/backend/access/aocs/aocsam_handler.c +++ b/src/backend/access/aocs/aocsam_handler.c @@ -757,7 +757,7 @@ aoco_getnextslot(TableScanDesc scan, ScanDirection direction, TupleTableSlot *sl return false; } -static int +static uint32 aoco_scan_flags(Relation rel) { return 0; diff --git a/src/backend/access/appendonly/appendonlyam.c b/src/backend/access/appendonly/appendonlyam.c index 0d75c348d11..d4681bd4aa3 100755 --- a/src/backend/access/appendonly/appendonlyam.c +++ b/src/backend/access/appendonly/appendonlyam.c @@ -1799,7 +1799,7 @@ appendonly_getnextslot(TableScanDesc scan, ScanDirection direction, TupleTableSl return false; } -int +uint32 appendonly_scan_flags(Relation relation) { return 0; diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 918c20c7643..b275cb3b96a 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -1621,7 +1621,7 @@ heap_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction, return true; } -int +uint32 heap_scan_flags(Relation relation) { return 0; diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 9a7601c40af..d1006572444 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -135,7 +135,7 @@ extern void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid, extern bool heap_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot); -extern int heap_scan_flags(Relation relation); +extern uint32 heap_scan_flags(Relation relation); extern bool heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf); extern bool heap_fetch_extended(Relation relation, Snapshot snapshot, diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index e36cfce3eb8..f272625eb36 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -395,7 +395,7 @@ typedef struct TableAmRoutine * AM can support, return the flags represented the supported features of * scan. */ - int (*scan_flags) (Relation rel); + uint32 (*scan_flags) (Relation rel); /* ------------------------------------------------------------------------ * Parallel table scan related functions. @@ -1245,6 +1245,16 @@ table_scan_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction, slot); } +/* + * Return the flags represented the supported features of table AM scan. + */ +static inline uint32 +table_scan_flags(Relation rel) +{ + if (rel->rd_tableam->scan_flags) + return rel->rd_tableam->scan_flags(rel); + return 0; +} /* ---------------------------------------------------------------------------- * Parallel table scan related functions. diff --git a/src/include/cdb/cdbappendonlyam.h b/src/include/cdb/cdbappendonlyam.h index 2d0e3987da5..d12ed86fda1 100644 --- a/src/include/cdb/cdbappendonlyam.h +++ b/src/include/cdb/cdbappendonlyam.h @@ -445,7 +445,7 @@ extern void appendonly_endscan(TableScanDesc scan); extern bool appendonly_getnextslot(TableScanDesc scan, ScanDirection direction, TupleTableSlot *slot); -extern int appendonly_scan_flags(Relation relation); +extern uint32 appendonly_scan_flags(Relation relation); extern AppendOnlyFetchDesc appendonly_fetch_init( Relation relation, Snapshot snapshot,