diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 854136e..fde4fb7 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -1165,7 +1165,7 @@ heap_beginscan(Relation relation, Snapshot snapshot, scan->rs_base.rs_flags &= ~SO_ALLOW_PAGEMODE; /* - * For seqscan and sample scans in a serializable transaction, acquire a + * For seqscan, sample scans and tid scan in a serializable transaction, acquire a * predicate lock on the entire relation. This is required not only to * lock all the matching tuples, but also to conflict with new insertions * into the table. In an indexscan, we take page locks on the index pages @@ -1177,7 +1177,7 @@ heap_beginscan(Relation relation, Snapshot snapshot, * to be at least page-level granularity, but we'd need to add per-tuple * locking for that. */ - if (scan->rs_base.rs_flags & (SO_TYPE_SEQSCAN | SO_TYPE_SAMPLESCAN)) + if (scan->rs_base.rs_flags & (SO_TYPE_SEQSCAN | SO_TYPE_SAMPLESCAN | SO_TYPE_TIDSCAN)) { /* * Ensure a missing snapshot is noticed reliably, even if the diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c index 16802b8..f91f717 100644 --- a/src/backend/executor/nodeTidscan.c +++ b/src/backend/executor/nodeTidscan.c @@ -143,7 +143,7 @@ TidListEval(TidScanState *tidstate) */ if (tidstate->ss.ss_currentScanDesc == NULL) tidstate->ss.ss_currentScanDesc = - table_beginscan(tidstate->ss.ss_currentRelation, + table_beginscan_tid(tidstate->ss.ss_currentRelation, tidstate->ss.ps.state->es_snapshot, 0, NULL); scan = tidstate->ss.ss_currentScanDesc; diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 696451f..f2c069e 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -47,18 +47,19 @@ typedef enum ScanOptions SO_TYPE_SEQSCAN = 1 << 0, SO_TYPE_BITMAPSCAN = 1 << 1, SO_TYPE_SAMPLESCAN = 1 << 2, - SO_TYPE_ANALYZE = 1 << 3, + SO_TYPE_TIDSCAN = 1 << 3, + SO_TYPE_ANALYZE = 1 << 4, /* several of SO_ALLOW_* may be specified */ /* allow or disallow use of access strategy */ - SO_ALLOW_STRAT = 1 << 4, + SO_ALLOW_STRAT = 1 << 5, /* report location to syncscan logic? */ - SO_ALLOW_SYNC = 1 << 5, + SO_ALLOW_SYNC = 1 << 6, /* verify visibility page-at-a-time? */ - SO_ALLOW_PAGEMODE = 1 << 6, + SO_ALLOW_PAGEMODE = 1 << 7, /* unregister snapshot at scan end? */ - SO_TEMP_SNAPSHOT = 1 << 7 + SO_TEMP_SNAPSHOT = 1 << 8 } ScanOptions; /* @@ -830,6 +831,22 @@ table_beginscan_sampling(Relation rel, Snapshot snapshot, } /* + * table_beginscan_tid is an alternative entry point for setting up a + * TableScanDesc for a Tid scan. Although that scan technology is + * really quite unlike a standard seqscan, there is just enough commonality to + * make it worth using the same data structure. + */ +static inline TableScanDesc +table_beginscan_tid(Relation rel, Snapshot snapshot, + int nkeys, struct ScanKeyData *key) +{ + uint32 flags = SO_TYPE_TIDSCAN | + SO_ALLOW_STRAT | SO_ALLOW_SYNC | SO_ALLOW_PAGEMODE; + + return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags); +} + +/* * table_beginscan_analyze is an alternative entry point for setting up a * TableScanDesc for an ANALYZE scan. As with bitmap scans, it's worth using * the same data structure although the behavior is rather different.