PostgreSQL Source Code  git master
tableam.h File Reference
#include "access/relscan.h"
#include "access/sdir.h"
#include "utils/guc.h"
#include "utils/rel.h"
#include "utils/snapshot.h"
Include dependency graph for tableam.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  TM_FailureData
 
struct  TableAmRoutine
 

Macros

#define DEFAULT_TABLE_ACCESS_METHOD   "heap"
 
#define TABLE_INSERT_SKIP_WAL   0x0001
 
#define TABLE_INSERT_SKIP_FSM   0x0002
 
#define TABLE_INSERT_FROZEN   0x0004
 
#define TABLE_INSERT_NO_LOGICAL   0x0008
 
#define TUPLE_LOCK_FLAG_LOCK_UPDATE_IN_PROGRESS   (1 << 0)
 
#define TUPLE_LOCK_FLAG_FIND_LAST_VERSION   (1 << 1)
 

Typedefs

typedef enum ScanOptions ScanOptions
 
typedef enum TM_Result TM_Result
 
typedef struct TM_FailureData TM_FailureData
 
typedef void(* IndexBuildCallback) (Relation index, ItemPointer tid, Datum *values, bool *isnull, bool tupleIsAlive, void *state)
 
typedef struct TableAmRoutine TableAmRoutine
 

Enumerations

enum  ScanOptions {
  SO_TYPE_SEQSCAN = 1 << 0, SO_TYPE_BITMAPSCAN = 1 << 1, SO_TYPE_SAMPLESCAN = 1 << 2, SO_TYPE_ANALYZE = 1 << 3,
  SO_ALLOW_STRAT = 1 << 4, SO_ALLOW_SYNC = 1 << 5, SO_ALLOW_PAGEMODE = 1 << 6, SO_TEMP_SNAPSHOT = 1 << 7
}
 
enum  TM_Result {
  TM_Ok, TM_Invisible, TM_SelfModified, TM_Updated,
  TM_Deleted, TM_BeingModified, TM_WouldBlock
}
 

Functions

const TupleTableSlotOpstable_slot_callbacks (Relation rel)
 
TupleTableSlottable_slot_create (Relation rel, List **reglist)
 
static TableScanDesc table_beginscan (Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key)
 
TableScanDesc table_beginscan_catalog (Relation rel, int nkeys, struct ScanKeyData *key)
 
static TableScanDesc table_beginscan_strat (Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, bool allow_strat, bool allow_sync)
 
static TableScanDesc table_beginscan_bm (Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key)
 
static TableScanDesc table_beginscan_sampling (Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, bool allow_strat, bool allow_sync, bool allow_pagemode)
 
static TableScanDesc table_beginscan_analyze (Relation rel)
 
static void table_endscan (TableScanDesc scan)
 
static void table_rescan (TableScanDesc scan, struct ScanKeyData *key)
 
static void table_rescan_set_params (TableScanDesc scan, struct ScanKeyData *key, bool allow_strat, bool allow_sync, bool allow_pagemode)
 
void table_scan_update_snapshot (TableScanDesc scan, Snapshot snapshot)
 
static bool table_scan_getnextslot (TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
 
Size table_parallelscan_estimate (Relation rel, Snapshot snapshot)
 
void table_parallelscan_initialize (Relation rel, ParallelTableScanDesc pscan, Snapshot snapshot)
 
TableScanDesc table_beginscan_parallel (Relation rel, ParallelTableScanDesc pscan)
 
static void table_parallelscan_reinitialize (Relation rel, ParallelTableScanDesc pscan)
 
static IndexFetchTableDatatable_index_fetch_begin (Relation rel)
 
static void table_index_fetch_reset (struct IndexFetchTableData *scan)
 
static void table_index_fetch_end (struct IndexFetchTableData *scan)
 
static bool table_index_fetch_tuple (struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, bool *call_again, bool *all_dead)
 
bool table_index_fetch_tuple_check (Relation rel, ItemPointer tid, Snapshot snapshot, bool *all_dead)
 
static bool table_tuple_fetch_row_version (Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
 
static bool table_tuple_tid_valid (TableScanDesc scan, ItemPointer tid)
 
void table_tuple_get_latest_tid (TableScanDesc scan, ItemPointer tid)
 
static bool table_tuple_satisfies_snapshot (Relation rel, TupleTableSlot *slot, Snapshot snapshot)
 
static TransactionId table_compute_xid_horizon_for_tuples (Relation rel, ItemPointerData *items, int nitems)
 
static void table_tuple_insert (Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
 
static void table_tuple_insert_speculative (Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate, uint32 specToken)
 
static void table_tuple_complete_speculative (Relation rel, TupleTableSlot *slot, uint32 specToken, bool succeeded)
 
static void table_multi_insert (Relation rel, TupleTableSlot **slots, int nslots, CommandId cid, int options, struct BulkInsertStateData *bistate)
 
static TM_Result table_tuple_delete (Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
 
static TM_Result table_tuple_update (Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, bool *update_indexes)
 
static TM_Result table_tuple_lock (Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, uint8 flags, TM_FailureData *tmfd)
 
static void table_finish_bulk_insert (Relation rel, int options)
 
static void table_relation_set_new_filenode (Relation rel, const RelFileNode *newrnode, char persistence, TransactionId *freezeXid, MultiXactId *minmulti)
 
static void table_relation_nontransactional_truncate (Relation rel)
 
static void table_relation_copy_data (Relation rel, const RelFileNode *newrnode)
 
static void table_relation_copy_for_cluster (Relation OldTable, Relation NewTable, Relation OldIndex, bool use_sort, TransactionId OldestXmin, TransactionId *xid_cutoff, MultiXactId *multi_cutoff, double *num_tuples, double *tups_vacuumed, double *tups_recently_dead)
 
static void table_relation_vacuum (Relation rel, struct VacuumParams *params, BufferAccessStrategy bstrategy)
 
static bool table_scan_analyze_next_block (TableScanDesc scan, BlockNumber blockno, BufferAccessStrategy bstrategy)
 
static bool table_scan_analyze_next_tuple (TableScanDesc scan, TransactionId OldestXmin, double *liverows, double *deadrows, TupleTableSlot *slot)
 
static double table_index_build_scan (Relation table_rel, Relation index_rel, struct IndexInfo *index_info, bool allow_sync, bool progress, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
 
static double table_index_build_range_scan (Relation table_rel, Relation index_rel, struct IndexInfo *index_info, bool allow_sync, bool anyvisible, bool progress, BlockNumber start_blockno, BlockNumber numblocks, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
 
static void table_index_validate_scan (Relation table_rel, Relation index_rel, struct IndexInfo *index_info, Snapshot snapshot, struct ValidateIndexState *state)
 
static uint64 table_relation_size (Relation rel, ForkNumber forkNumber)
 
static bool table_relation_needs_toast_table (Relation rel)
 
static void table_relation_estimate_size (Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac)
 
static bool table_scan_bitmap_next_block (TableScanDesc scan, struct TBMIterateResult *tbmres)
 
static bool table_scan_bitmap_next_tuple (TableScanDesc scan, struct TBMIterateResult *tbmres, TupleTableSlot *slot)
 
static bool table_scan_sample_next_block (TableScanDesc scan, struct SampleScanState *scanstate)
 
static bool table_scan_sample_next_tuple (TableScanDesc scan, struct SampleScanState *scanstate, TupleTableSlot *slot)
 
void simple_table_tuple_insert (Relation rel, TupleTableSlot *slot)
 
void simple_table_tuple_delete (Relation rel, ItemPointer tid, Snapshot snapshot)
 
void simple_table_tuple_update (Relation rel, ItemPointer otid, TupleTableSlot *slot, Snapshot snapshot, bool *update_indexes)
 
Size table_block_parallelscan_estimate (Relation rel)
 
Size table_block_parallelscan_initialize (Relation rel, ParallelTableScanDesc pscan)
 
void table_block_parallelscan_reinitialize (Relation rel, ParallelTableScanDesc pscan)
 
BlockNumber table_block_parallelscan_nextpage (Relation rel, ParallelBlockTableScanDesc pbscan)
 
void table_block_parallelscan_startblock_init (Relation rel, ParallelBlockTableScanDesc pbscan)
 
uint64 table_block_relation_size (Relation rel, ForkNumber forkNumber)
 
void table_block_relation_estimate_size (Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac, Size overhead_bytes_per_tuple, Size usable_bytes_per_page)
 
const TableAmRoutineGetTableAmRoutine (Oid amhandler)
 
const TableAmRoutineGetHeapamTableAmRoutine (void)
 
bool check_default_table_access_method (char **newval, void **extra, GucSource source)
 

Variables

char * default_table_access_method
 
bool synchronize_seqscans
 

Macro Definition Documentation

◆ DEFAULT_TABLE_ACCESS_METHOD

#define DEFAULT_TABLE_ACCESS_METHOD   "heap"

Definition at line 27 of file tableam.h.

◆ TABLE_INSERT_FROZEN

#define TABLE_INSERT_FROZEN   0x0004

Definition at line 132 of file tableam.h.

Referenced by CopyFrom(), and transientrel_startup().

◆ TABLE_INSERT_NO_LOGICAL

#define TABLE_INSERT_NO_LOGICAL   0x0008

Definition at line 133 of file tableam.h.

◆ TABLE_INSERT_SKIP_FSM

#define TABLE_INSERT_SKIP_FSM   0x0002

Definition at line 131 of file tableam.h.

Referenced by ATRewriteTable(), CopyFrom(), intorel_startup(), and transientrel_startup().

◆ TABLE_INSERT_SKIP_WAL

#define TABLE_INSERT_SKIP_WAL   0x0001

Definition at line 130 of file tableam.h.

Referenced by ATRewriteTable(), CopyFrom(), intorel_startup(), and transientrel_startup().

◆ TUPLE_LOCK_FLAG_FIND_LAST_VERSION

#define TUPLE_LOCK_FLAG_FIND_LAST_VERSION   (1 << 1)

◆ TUPLE_LOCK_FLAG_LOCK_UPDATE_IN_PROGRESS

#define TUPLE_LOCK_FLAG_LOCK_UPDATE_IN_PROGRESS   (1 << 0)

Definition at line 137 of file tableam.h.

Referenced by ExecLockRows(), and heapam_tuple_lock().

Typedef Documentation

◆ IndexBuildCallback

typedef void(* IndexBuildCallback) (Relation index, ItemPointer tid, Datum *values, bool *isnull, bool tupleIsAlive, void *state)

Definition at line 143 of file tableam.h.

◆ ScanOptions

typedef enum ScanOptions ScanOptions

◆ TableAmRoutine

◆ TM_FailureData

◆ TM_Result

typedef enum TM_Result TM_Result

Enumeration Type Documentation

◆ ScanOptions

Enumerator
SO_TYPE_SEQSCAN 
SO_TYPE_BITMAPSCAN 
SO_TYPE_SAMPLESCAN 
SO_TYPE_ANALYZE 
SO_ALLOW_STRAT 
SO_ALLOW_SYNC 
SO_ALLOW_PAGEMODE 
SO_TEMP_SNAPSHOT 

Definition at line 44 of file tableam.h.

45 {
46  /* one of SO_TYPE_* may be specified */
47  SO_TYPE_SEQSCAN = 1 << 0,
48  SO_TYPE_BITMAPSCAN = 1 << 1,
49  SO_TYPE_SAMPLESCAN = 1 << 2,
50  SO_TYPE_ANALYZE = 1 << 3,
51 
52  /* several of SO_ALLOW_* may be specified */
53  /* allow or disallow use of access strategy */
54  SO_ALLOW_STRAT = 1 << 4,
55  /* report location to syncscan logic? */
56  SO_ALLOW_SYNC = 1 << 5,
57  /* verify visibility page-at-a-time? */
58  SO_ALLOW_PAGEMODE = 1 << 6,
59 
60  /* unregister snapshot at scan end? */
61  SO_TEMP_SNAPSHOT = 1 << 7
62 } ScanOptions;
ScanOptions
Definition: tableam.h:44

◆ TM_Result

enum TM_Result
Enumerator
TM_Ok 
TM_Invisible 
TM_SelfModified 
TM_Updated 
TM_Deleted 
TM_BeingModified 
TM_WouldBlock 

Definition at line 68 of file tableam.h.

69 {
70  /*
71  * Signals that the action succeeded (i.e. update/delete performed, lock
72  * was acquired)
73  */
74  TM_Ok,
75 
76  /* The affected tuple wasn't visible to the relevant snapshot */
78 
79  /* The affected tuple was already modified by the calling backend */
81 
82  /*
83  * The affected tuple was updated by another transaction. This includes
84  * the case where tuple was moved to another partition.
85  */
86  TM_Updated,
87 
88  /* The affected tuple was deleted by another transaction */
89  TM_Deleted,
90 
91  /*
92  * The affected tuple is currently being modified by another session. This
93  * will only be returned if table_(update/delete/lock_tuple) are
94  * instructed not to wait.
95  */
97 
98  /* lock couldn't be acquired, action skipped. Only used by lock_tuple */
100 } TM_Result;
TM_Result
Definition: tableam.h:68
Definition: tableam.h:74

Function Documentation

◆ check_default_table_access_method()

bool check_default_table_access_method ( char **  newval,
void **  extra,
GucSource  source 
)

Definition at line 111 of file tableamapi.c.

References ereport, errcode(), errmsg(), get_table_am_oid(), GUC_check_errdetail, InvalidOid, IsTransactionState(), MyDatabaseId, NAMEDATALEN, NOTICE, OidIsValid, and PGC_S_TEST.

Referenced by table_scan_sample_next_tuple().

112 {
113  if (**newval == '\0')
114  {
115  GUC_check_errdetail("%s cannot be empty.",
116  "default_table_access_method");
117  return false;
118  }
119 
120  if (strlen(*newval) >= NAMEDATALEN)
121  {
122  GUC_check_errdetail("%s is too long (maximum %d characters).",
123  "default_table_access_method", NAMEDATALEN - 1);
124  return false;
125  }
126 
127  /*
128  * If we aren't inside a transaction, or not connected to a database, we
129  * cannot do the catalog access necessary to verify the method. Must
130  * accept the value on faith.
131  */
133  {
134  if (!OidIsValid(get_table_am_oid(*newval, true)))
135  {
136  /*
137  * When source == PGC_S_TEST, don't throw a hard error for a
138  * nonexistent table access method, only a NOTICE. See comments in
139  * guc.h.
140  */
141  if (source == PGC_S_TEST)
142  {
143  ereport(NOTICE,
144  (errcode(ERRCODE_UNDEFINED_OBJECT),
145  errmsg("table access method \"%s\" does not exist",
146  *newval)));
147  }
148  else
149  {
150  GUC_check_errdetail("Table access method \"%s\" does not exist.",
151  *newval);
152  return false;
153  }
154  }
155  }
156 
157  return true;
158 }
#define GUC_check_errdetail
Definition: guc.h:414
int errcode(int sqlerrcode)
Definition: elog.c:608
#define OidIsValid(objectId)
Definition: c.h:645
#define NAMEDATALEN
#define ereport(elevel, rest)
Definition: elog.h:141
Oid MyDatabaseId
Definition: globals.c:85
#define InvalidOid
Definition: postgres_ext.h:36
#define NOTICE
Definition: elog.h:37
Oid get_table_am_oid(const char *amname, bool missing_ok)
Definition: amcmds.c:197
#define newval
bool IsTransactionState(void)
Definition: xact.c:355
int errmsg(const char *fmt,...)
Definition: elog.c:822

◆ GetHeapamTableAmRoutine()

const TableAmRoutine* GetHeapamTableAmRoutine ( void  )

Definition at line 2549 of file heapam_handler.c.

References heapam_methods.

Referenced by formrdesc(), heap_getnext(), and table_scan_sample_next_tuple().

2550 {
2551  return &heapam_methods;
2552 }
static const TableAmRoutine heapam_methods

◆ GetTableAmRoutine()

const TableAmRoutine* GetTableAmRoutine ( Oid  amhandler)

Definition at line 34 of file tableamapi.c.

References Assert, TableAmRoutine::compute_xid_horizon_for_tuples, DatumGetPointer, elog, ERROR, TableAmRoutine::index_build_range_scan, TableAmRoutine::index_fetch_begin, TableAmRoutine::index_fetch_end, TableAmRoutine::index_fetch_reset, TableAmRoutine::index_fetch_tuple, TableAmRoutine::index_validate_scan, IsA, TableAmRoutine::multi_insert, OidFunctionCall0, TableAmRoutine::parallelscan_estimate, TableAmRoutine::parallelscan_initialize, TableAmRoutine::parallelscan_reinitialize, TableAmRoutine::relation_copy_data, TableAmRoutine::relation_copy_for_cluster, TableAmRoutine::relation_estimate_size, TableAmRoutine::relation_needs_toast_table, TableAmRoutine::relation_nontransactional_truncate, TableAmRoutine::relation_set_new_filenode, TableAmRoutine::relation_size, TableAmRoutine::relation_vacuum, TableAmRoutine::scan_analyze_next_block, TableAmRoutine::scan_analyze_next_tuple, TableAmRoutine::scan_begin, TableAmRoutine::scan_bitmap_next_block, TableAmRoutine::scan_bitmap_next_tuple, TableAmRoutine::scan_end, TableAmRoutine::scan_getnextslot, TableAmRoutine::scan_rescan, TableAmRoutine::scan_sample_next_block, TableAmRoutine::scan_sample_next_tuple, TableAmRoutine::tuple_complete_speculative, TableAmRoutine::tuple_delete, TableAmRoutine::tuple_fetch_row_version, TableAmRoutine::tuple_get_latest_tid, TableAmRoutine::tuple_insert, TableAmRoutine::tuple_insert_speculative, TableAmRoutine::tuple_lock, TableAmRoutine::tuple_satisfies_snapshot, TableAmRoutine::tuple_tid_valid, and TableAmRoutine::tuple_update.

Referenced by InitTableAmRoutine(), and table_scan_sample_next_tuple().

35 {
36  Datum datum;
37  const TableAmRoutine *routine;
38 
39  datum = OidFunctionCall0(amhandler);
40  routine = (TableAmRoutine *) DatumGetPointer(datum);
41 
42  if (routine == NULL || !IsA(routine, TableAmRoutine))
43  elog(ERROR, "table access method handler %u did not return a TableAmRoutine struct",
44  amhandler);
45 
46  /*
47  * Assert that all required callbacks are present. That makes it a bit
48  * easier to keep AMs up to date, e.g. when forward porting them to a new
49  * major version.
50  */
51  Assert(routine->scan_begin != NULL);
52  Assert(routine->scan_end != NULL);
53  Assert(routine->scan_rescan != NULL);
54  Assert(routine->scan_getnextslot != NULL);
55 
56  Assert(routine->parallelscan_estimate != NULL);
57  Assert(routine->parallelscan_initialize != NULL);
58  Assert(routine->parallelscan_reinitialize != NULL);
59 
60  Assert(routine->index_fetch_begin != NULL);
61  Assert(routine->index_fetch_reset != NULL);
62  Assert(routine->index_fetch_end != NULL);
63  Assert(routine->index_fetch_tuple != NULL);
64 
65  Assert(routine->tuple_fetch_row_version != NULL);
66  Assert(routine->tuple_tid_valid != NULL);
67  Assert(routine->tuple_get_latest_tid != NULL);
68  Assert(routine->tuple_satisfies_snapshot != NULL);
69  Assert(routine->compute_xid_horizon_for_tuples != NULL);
70 
71  Assert(routine->tuple_insert != NULL);
72 
73  /*
74  * Could be made optional, but would require throwing error during
75  * parse-analysis.
76  */
77  Assert(routine->tuple_insert_speculative != NULL);
78  Assert(routine->tuple_complete_speculative != NULL);
79 
80  Assert(routine->multi_insert != NULL);
81  Assert(routine->tuple_delete != NULL);
82  Assert(routine->tuple_update != NULL);
83  Assert(routine->tuple_lock != NULL);
84 
85  Assert(routine->relation_set_new_filenode != NULL);
87  Assert(routine->relation_copy_data != NULL);
88  Assert(routine->relation_copy_for_cluster != NULL);
89  Assert(routine->relation_vacuum != NULL);
90  Assert(routine->scan_analyze_next_block != NULL);
91  Assert(routine->scan_analyze_next_tuple != NULL);
92  Assert(routine->index_build_range_scan != NULL);
93  Assert(routine->index_validate_scan != NULL);
94 
95  Assert(routine->relation_size != NULL);
96  Assert(routine->relation_needs_toast_table != NULL);
97 
98  Assert(routine->relation_estimate_size != NULL);
99 
100  /* optional, but one callback implies presence of the other */
101  Assert((routine->scan_bitmap_next_block == NULL) ==
102  (routine->scan_bitmap_next_tuple == NULL));
103  Assert(routine->scan_sample_next_block != NULL);
104  Assert(routine->scan_sample_next_tuple != NULL);
105 
106  return routine;
107 }
bool(* scan_getnextslot)(TableScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
Definition: tableam.h:222
void(* relation_estimate_size)(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac)
Definition: tableam.h:600
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
Size(* parallelscan_estimate)(Relation rel)
Definition: tableam.h:236
TM_Result(* tuple_update)(Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, bool *update_indexes)
Definition: tableam.h:388
struct IndexFetchTableData *(* index_fetch_begin)(Relation rel)
Definition: tableam.h:267
void(* index_fetch_reset)(struct IndexFetchTableData *data)
Definition: tableam.h:273
void(* scan_end)(TableScanDesc scan)
Definition: tableam.h:209
bool(* scan_sample_next_block)(TableScanDesc scan, struct SampleScanState *scanstate)
Definition: tableam.h:684
uint64(* relation_size)(Relation rel, ForkNumber forkNumber)
Definition: tableam.h:572
double(* index_build_range_scan)(Relation table_rel, Relation index_rel, struct IndexInfo *index_info, bool allow_sync, bool anyvisible, bool progress, BlockNumber start_blockno, BlockNumber numblocks, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
Definition: tableam.h:539
void(* index_validate_scan)(Relation table_rel, Relation index_rel, struct IndexInfo *index_info, Snapshot snapshot, struct ValidateIndexState *state)
Definition: tableam.h:552
bool(* tuple_fetch_row_version)(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
Definition: tableam.h:317
void(* relation_nontransactional_truncate)(Relation rel)
Definition: tableam.h:461
TransactionId(* compute_xid_horizon_for_tuples)(Relation rel, ItemPointerData *items, int nitems)
Definition: tableam.h:344
bool(* scan_analyze_next_block)(TableScanDesc scan, BlockNumber blockno, BufferAccessStrategy bstrategy)
Definition: tableam.h:520
Size(* parallelscan_initialize)(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:243
void(* tuple_insert_speculative)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate, uint32 specToken)
Definition: tableam.h:360
void(* scan_rescan)(TableScanDesc scan, struct ScanKeyData *key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition: tableam.h:215
void(* tuple_insert)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:355
#define ERROR
Definition: elog.h:43
void(* tuple_complete_speculative)(Relation rel, TupleTableSlot *slot, uint32 specToken, bool succeeded)
Definition: tableam.h:368
bool(* scan_bitmap_next_block)(TableScanDesc scan, struct TBMIterateResult *tbmres)
Definition: tableam.h:641
void(* relation_set_new_filenode)(Relation rel, const RelFileNode *newrnode, char persistence, TransactionId *freezeXid, MultiXactId *minmulti)
Definition: tableam.h:447
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:199
void(* multi_insert)(Relation rel, TupleTableSlot **slots, int nslots, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:374
void(* relation_copy_for_cluster)(Relation NewTable, Relation OldTable, Relation OldIndex, bool use_sort, TransactionId OldestXmin, TransactionId *xid_cutoff, MultiXactId *multi_cutoff, double *num_tuples, double *tups_vacuumed, double *tups_recently_dead)
Definition: tableam.h:473
bool(* scan_analyze_next_tuple)(TableScanDesc scan, TransactionId OldestXmin, double *liverows, double *deadrows, TupleTableSlot *slot)
Definition: tableam.h:532
bool(* scan_bitmap_next_tuple)(TableScanDesc scan, struct TBMIterateResult *tbmres, TupleTableSlot *slot)
Definition: tableam.h:655
void(* relation_copy_data)(Relation rel, const RelFileNode *newrnode)
Definition: tableam.h:469
void(* parallelscan_reinitialize)(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:250
uintptr_t Datum
Definition: postgres.h:367
bool(* relation_needs_toast_table)(Relation rel)
Definition: tableam.h:582
#define OidFunctionCall0(functionId)
Definition: fmgr.h:651
void(* index_fetch_end)(struct IndexFetchTableData *data)
Definition: tableam.h:278
TM_Result(* tuple_lock)(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, uint8 flags, TM_FailureData *tmfd)
Definition: tableam.h:400
#define Assert(condition)
Definition: c.h:739
void(* tuple_get_latest_tid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:332
bool(* tuple_satisfies_snapshot)(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
Definition: tableam.h:339
bool(* scan_sample_next_tuple)(TableScanDesc scan, struct SampleScanState *scanstate, TupleTableSlot *slot)
Definition: tableam.h:700
#define DatumGetPointer(X)
Definition: postgres.h:549
bool(* tuple_tid_valid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:325
#define elog(elevel,...)
Definition: elog.h:228
void(* relation_vacuum)(Relation onerel, struct VacuumParams *params, BufferAccessStrategy bstrategy)
Definition: tableam.h:499
bool(* index_fetch_tuple)(struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, bool *call_again, bool *all_dead)
Definition: tableam.h:300
TM_Result(* tuple_delete)(Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
Definition: tableam.h:378

◆ simple_table_tuple_delete()

void simple_table_tuple_delete ( Relation  rel,
ItemPointer  tid,
Snapshot  snapshot 
)

Definition at line 275 of file tableam.c.

References elog, ERROR, GetCurrentCommandId(), InvalidSnapshot, table_tuple_delete(), TM_Deleted, TM_Ok, TM_SelfModified, and TM_Updated.

Referenced by ExecSimpleRelationDelete(), and table_scan_sample_next_tuple().

276 {
277  TM_Result result;
278  TM_FailureData tmfd;
279 
280  result = table_tuple_delete(rel, tid,
281  GetCurrentCommandId(true),
282  snapshot, InvalidSnapshot,
283  true /* wait for commit */ ,
284  &tmfd, false /* changingPart */ );
285 
286  switch (result)
287  {
288  case TM_SelfModified:
289  /* Tuple was already updated in current command? */
290  elog(ERROR, "tuple already updated by self");
291  break;
292 
293  case TM_Ok:
294  /* done successfully */
295  break;
296 
297  case TM_Updated:
298  elog(ERROR, "tuple concurrently updated");
299  break;
300 
301  case TM_Deleted:
302  elog(ERROR, "tuple concurrently deleted");
303  break;
304 
305  default:
306  elog(ERROR, "unrecognized table_tuple_delete status: %u", result);
307  break;
308  }
309 }
#define ERROR
Definition: elog.h:43
#define InvalidSnapshot
Definition: snapshot.h:123
TM_Result
Definition: tableam.h:68
static TM_Result table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
Definition: tableam.h:1212
Definition: tableam.h:74
#define elog(elevel,...)
Definition: elog.h:228
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:745

◆ simple_table_tuple_insert()

void simple_table_tuple_insert ( Relation  rel,
TupleTableSlot slot 
)

Definition at line 261 of file tableam.c.

References GetCurrentCommandId(), and table_tuple_insert().

Referenced by ExecSimpleRelationInsert(), and table_scan_sample_next_tuple().

262 {
263  table_tuple_insert(rel, slot, GetCurrentCommandId(true), 0, NULL);
264 }
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:1123
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:745

◆ simple_table_tuple_update()

void simple_table_tuple_update ( Relation  rel,
ItemPointer  otid,
TupleTableSlot slot,
Snapshot  snapshot,
bool update_indexes 
)

Definition at line 320 of file tableam.c.

References elog, ERROR, GetCurrentCommandId(), InvalidSnapshot, table_tuple_update(), TM_Deleted, TM_Ok, TM_SelfModified, and TM_Updated.

Referenced by ExecSimpleRelationUpdate(), and table_scan_sample_next_tuple().

324 {
325  TM_Result result;
326  TM_FailureData tmfd;
327  LockTupleMode lockmode;
328 
329  result = table_tuple_update(rel, otid, slot,
330  GetCurrentCommandId(true),
331  snapshot, InvalidSnapshot,
332  true /* wait for commit */ ,
333  &tmfd, &lockmode, update_indexes);
334 
335  switch (result)
336  {
337  case TM_SelfModified:
338  /* Tuple was already updated in current command? */
339  elog(ERROR, "tuple already updated by self");
340  break;
341 
342  case TM_Ok:
343  /* done successfully */
344  break;
345 
346  case TM_Updated:
347  elog(ERROR, "tuple concurrently updated");
348  break;
349 
350  case TM_Deleted:
351  elog(ERROR, "tuple concurrently deleted");
352  break;
353 
354  default:
355  elog(ERROR, "unrecognized table_tuple_update status: %u", result);
356  break;
357  }
358 
359 }
LockTupleMode
Definition: lockoptions.h:49
#define ERROR
Definition: elog.h:43
#define InvalidSnapshot
Definition: snapshot.h:123
TM_Result
Definition: tableam.h:68
Definition: tableam.h:74
#define elog(elevel,...)
Definition: elog.h:228
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:745
static TM_Result table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, bool *update_indexes)
Definition: tableam.h:1256

◆ table_beginscan()

static TableScanDesc table_beginscan ( Relation  rel,
Snapshot  snapshot,
int  nkeys,
struct ScanKeyData key 
)
inlinestatic

Definition at line 736 of file tableam.h.

References sort-test::key, RelationData::rd_tableam, TableAmRoutine::scan_begin, SO_ALLOW_PAGEMODE, SO_ALLOW_STRAT, SO_ALLOW_SYNC, SO_TYPE_SEQSCAN, and table_beginscan_catalog().

Referenced by AlterDomainNotNull(), ATRewriteTable(), check_default_partition_contents(), CopyTo(), currtid_byrelname(), currtid_byreloid(), DefineQueryRewrite(), heapam_relation_copy_for_cluster(), pgrowlocks(), pgstat_collect_oids(), RelationFindReplTupleSeq(), SeqNext(), TidListEval(), validateCheckConstraint(), validateDomainConstraint(), and validateForeignKeyConstraint().

738 {
739  uint32 flags = SO_TYPE_SEQSCAN |
741 
742  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
743 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:199
unsigned int uint32
Definition: c.h:359
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_beginscan_analyze()

static TableScanDesc table_beginscan_analyze ( Relation  rel)
inlinestatic

Definition at line 820 of file tableam.h.

References RelationData::rd_tableam, TableAmRoutine::scan_begin, and SO_TYPE_ANALYZE.

Referenced by acquire_sample_rows().

821 {
822  uint32 flags = SO_TYPE_ANALYZE;
823 
824  return rel->rd_tableam->scan_begin(rel, NULL, 0, NULL, NULL, flags);
825 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:199
unsigned int uint32
Definition: c.h:359
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_beginscan_bm()

static TableScanDesc table_beginscan_bm ( Relation  rel,
Snapshot  snapshot,
int  nkeys,
struct ScanKeyData key 
)
inlinestatic

Definition at line 781 of file tableam.h.

References RelationData::rd_tableam, TableAmRoutine::scan_begin, SO_ALLOW_PAGEMODE, and SO_TYPE_BITMAPSCAN.

Referenced by ExecInitBitmapHeapScan().

783 {
785 
786  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
787 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:199
unsigned int uint32
Definition: c.h:359
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_beginscan_catalog()

TableScanDesc table_beginscan_catalog ( Relation  rel,
int  nkeys,
struct ScanKeyData key 
)

Definition at line 98 of file tableam.c.

References GetCatalogSnapshot(), RelationData::rd_tableam, RegisterSnapshot(), RelationGetRelid, TableAmRoutine::scan_begin, SO_ALLOW_PAGEMODE, SO_ALLOW_STRAT, SO_ALLOW_SYNC, SO_TEMP_SNAPSHOT, and SO_TYPE_SEQSCAN.

Referenced by AlterTableMoveAll(), AlterTableSpaceOptions(), boot_openrel(), check_db_file_conflict(), createdb(), do_autovacuum(), DropSetting(), DropTableSpace(), find_typed_table_dependencies(), get_all_vacuum_rels(), get_database_list(), get_subscription_list(), get_tables_to_cluster(), get_tablespace_name(), get_tablespace_oid(), GetAllTablesPublicationRelations(), getRelationsInNamespace(), gettype(), index_update_stats(), objectsInSchemaToOids(), ReindexMultipleTables(), remove_dbtablespaces(), RemoveConversionById(), RemoveSubscriptionRel(), RenameTableSpace(), table_beginscan(), ThereIsAtLeastOneRole(), and vac_truncate_clog().

99 {
100  uint32 flags = SO_TYPE_SEQSCAN |
102  Oid relid = RelationGetRelid(relation);
103  Snapshot snapshot = RegisterSnapshot(GetCatalogSnapshot(relid));
104 
105  return relation->rd_tableam->scan_begin(relation, snapshot, nkeys, key,
106  NULL, flags);
107 }
Snapshot RegisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:865
Snapshot GetCatalogSnapshot(Oid relid)
Definition: snapmgr.c:442
unsigned int Oid
Definition: postgres_ext.h:31
unsigned int uint32
Definition: c.h:359
#define RelationGetRelid(relation)
Definition: rel.h:422

◆ table_beginscan_parallel()

TableScanDesc table_beginscan_parallel ( Relation  rel,
ParallelTableScanDesc  pscan 
)

Definition at line 161 of file tableam.c.

References Assert, ParallelTableScanDescData::phs_relid, ParallelTableScanDescData::phs_snapshot_any, ParallelTableScanDescData::phs_snapshot_off, RelationData::rd_tableam, RegisterSnapshot(), RelationGetRelid, RestoreSnapshot(), TableAmRoutine::scan_begin, SnapshotAny, SO_ALLOW_PAGEMODE, SO_ALLOW_STRAT, SO_ALLOW_SYNC, SO_TEMP_SNAPSHOT, and SO_TYPE_SEQSCAN.

Referenced by _bt_parallel_scan_and_sort(), ExecSeqScanInitializeDSM(), ExecSeqScanInitializeWorker(), and table_scan_getnextslot().

162 {
163  Snapshot snapshot;
164  uint32 flags = SO_TYPE_SEQSCAN |
166 
167  Assert(RelationGetRelid(relation) == parallel_scan->phs_relid);
168 
169  if (!parallel_scan->phs_snapshot_any)
170  {
171  /* Snapshot was serialized -- restore it */
172  snapshot = RestoreSnapshot((char *) parallel_scan +
173  parallel_scan->phs_snapshot_off);
174  RegisterSnapshot(snapshot);
175  flags |= SO_TEMP_SNAPSHOT;
176  }
177  else
178  {
179  /* SnapshotAny passed by caller (not serialized) */
180  snapshot = SnapshotAny;
181  }
182 
183  return relation->rd_tableam->scan_begin(relation, snapshot, 0, NULL,
184  parallel_scan, flags);
185 }
Snapshot RestoreSnapshot(char *start_address)
Definition: snapmgr.c:2161
Snapshot RegisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:865
unsigned int uint32
Definition: c.h:359
#define Assert(condition)
Definition: c.h:739
#define SnapshotAny
Definition: snapmgr.h:69
#define RelationGetRelid(relation)
Definition: rel.h:422

◆ table_beginscan_sampling()

static TableScanDesc table_beginscan_sampling ( Relation  rel,
Snapshot  snapshot,
int  nkeys,
struct ScanKeyData key,
bool  allow_strat,
bool  allow_sync,
bool  allow_pagemode 
)
inlinestatic

Definition at line 797 of file tableam.h.

References RelationData::rd_tableam, TableAmRoutine::scan_begin, SO_ALLOW_PAGEMODE, SO_ALLOW_STRAT, SO_ALLOW_SYNC, and SO_TYPE_SAMPLESCAN.

Referenced by tablesample_init().

801 {
802  uint32 flags = SO_TYPE_SAMPLESCAN;
803 
804  if (allow_strat)
805  flags |= SO_ALLOW_STRAT;
806  if (allow_sync)
807  flags |= SO_ALLOW_SYNC;
808  if (allow_pagemode)
809  flags |= SO_ALLOW_PAGEMODE;
810 
811  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
812 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:199
unsigned int uint32
Definition: c.h:359
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_beginscan_strat()

static TableScanDesc table_beginscan_strat ( Relation  rel,
Snapshot  snapshot,
int  nkeys,
struct ScanKeyData key,
bool  allow_strat,
bool  allow_sync 
)
inlinestatic

Definition at line 760 of file tableam.h.

References RelationData::rd_tableam, TableAmRoutine::scan_begin, SO_ALLOW_PAGEMODE, SO_ALLOW_STRAT, SO_ALLOW_SYNC, and SO_TYPE_SEQSCAN.

Referenced by bt_check_every_level(), heapam_index_build_range_scan(), heapam_index_validate_scan(), IndexCheckExclusion(), pgstat_heap(), and systable_beginscan().

763 {
765 
766  if (allow_strat)
767  flags |= SO_ALLOW_STRAT;
768  if (allow_sync)
769  flags |= SO_ALLOW_SYNC;
770 
771  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
772 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:199
unsigned int uint32
Definition: c.h:359
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_block_parallelscan_estimate()

Size table_block_parallelscan_estimate ( Relation  rel)

Definition at line 368 of file tableam.c.

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

369 {
370  return sizeof(ParallelBlockTableScanDescData);
371 }
struct ParallelBlockTableScanDescData ParallelBlockTableScanDescData

◆ table_block_parallelscan_initialize()

Size table_block_parallelscan_initialize ( Relation  rel,
ParallelTableScanDesc  pscan 
)

Definition at line 374 of file tableam.c.

References ParallelBlockTableScanDescData::base, InvalidBlockNumber, NBuffers, pg_atomic_init_u64(), ParallelBlockTableScanDescData::phs_mutex, ParallelBlockTableScanDescData::phs_nallocated, ParallelBlockTableScanDescData::phs_nblocks, ParallelTableScanDescData::phs_relid, ParallelBlockTableScanDescData::phs_startblock, ParallelTableScanDescData::phs_syncscan, RelationGetNumberOfBlocks, RelationGetRelid, RelationUsesLocalBuffers, SpinLockInit, and synchronize_seqscans.

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

375 {
377 
378  bpscan->base.phs_relid = RelationGetRelid(rel);
379  bpscan->phs_nblocks = RelationGetNumberOfBlocks(rel);
380  /* compare phs_syncscan initialization to similar logic in initscan */
382  !RelationUsesLocalBuffers(rel) &&
383  bpscan->phs_nblocks > NBuffers / 4;
384  SpinLockInit(&bpscan->phs_mutex);
386  pg_atomic_init_u64(&bpscan->phs_nallocated, 0);
387 
388  return sizeof(ParallelBlockTableScanDescData);
389 }
pg_atomic_uint64 phs_nallocated
Definition: relscan.h:79
bool synchronize_seqscans
Definition: tableam.c:35
ParallelTableScanDescData base
Definition: relscan.h:74
struct ParallelBlockTableScanDescData * ParallelBlockTableScanDesc
Definition: relscan.h:82
struct ParallelBlockTableScanDescData ParallelBlockTableScanDescData
#define SpinLockInit(lock)
Definition: spin.h:60
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:415
#define RelationGetNumberOfBlocks(reln)
Definition: bufmgr.h:198
#define InvalidBlockNumber
Definition: block.h:33
#define RelationUsesLocalBuffers(relation)
Definition: rel.h:531
int NBuffers
Definition: globals.c:131
#define RelationGetRelid(relation)
Definition: rel.h:422

◆ table_block_parallelscan_nextpage()

BlockNumber table_block_parallelscan_nextpage ( Relation  rel,
ParallelBlockTableScanDesc  pbscan 
)

Definition at line 450 of file tableam.c.

References ParallelBlockTableScanDescData::base, InvalidBlockNumber, pg_atomic_fetch_add_u64(), ParallelBlockTableScanDescData::phs_nallocated, ParallelBlockTableScanDescData::phs_nblocks, ParallelBlockTableScanDescData::phs_startblock, ParallelTableScanDescData::phs_syncscan, and ss_report_location().

Referenced by heapgettup(), heapgettup_pagemode(), and table_scan_sample_next_tuple().

451 {
452  BlockNumber page;
453  uint64 nallocated;
454 
455  /*
456  * phs_nallocated tracks how many pages have been allocated to workers
457  * already. When phs_nallocated >= rs_nblocks, all blocks have been
458  * allocated.
459  *
460  * Because we use an atomic fetch-and-add to fetch the current value, the
461  * phs_nallocated counter will exceed rs_nblocks, because workers will
462  * still increment the value, when they try to allocate the next block but
463  * all blocks have been allocated already. The counter must be 64 bits
464  * wide because of that, to avoid wrapping around when rs_nblocks is close
465  * to 2^32.
466  *
467  * The actual page to return is calculated by adding the counter to the
468  * starting block number, modulo nblocks.
469  */
470  nallocated = pg_atomic_fetch_add_u64(&pbscan->phs_nallocated, 1);
471  if (nallocated >= pbscan->phs_nblocks)
472  page = InvalidBlockNumber; /* all blocks have been allocated */
473  else
474  page = (nallocated + pbscan->phs_startblock) % pbscan->phs_nblocks;
475 
476  /*
477  * Report scan location. Normally, we report the current page number.
478  * When we reach the end of the scan, though, we report the starting page,
479  * not the ending page, just so the starting positions for later scans
480  * doesn't slew backwards. We only report the position at the end of the
481  * scan once, though: subsequent callers will report nothing.
482  */
483  if (pbscan->base.phs_syncscan)
484  {
485  if (page != InvalidBlockNumber)
486  ss_report_location(rel, page);
487  else if (nallocated == pbscan->phs_nblocks)
488  ss_report_location(rel, pbscan->phs_startblock);
489  }
490 
491  return page;
492 }
pg_atomic_uint64 phs_nallocated
Definition: relscan.h:79
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition: atomics.h:467
ParallelTableScanDescData base
Definition: relscan.h:74
uint32 BlockNumber
Definition: block.h:31
#define InvalidBlockNumber
Definition: block.h:33
void ss_report_location(Relation rel, BlockNumber location)
Definition: syncscan.c:288

◆ table_block_parallelscan_reinitialize()

void table_block_parallelscan_reinitialize ( Relation  rel,
ParallelTableScanDesc  pscan 
)

Definition at line 392 of file tableam.c.

References pg_atomic_write_u64(), and ParallelBlockTableScanDescData::phs_nallocated.

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

393 {
395 
396  pg_atomic_write_u64(&bpscan->phs_nallocated, 0);
397 }
pg_atomic_uint64 phs_nallocated
Definition: relscan.h:79
struct ParallelBlockTableScanDescData * ParallelBlockTableScanDesc
Definition: relscan.h:82
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition: atomics.h:438

◆ table_block_parallelscan_startblock_init()

void table_block_parallelscan_startblock_init ( Relation  rel,
ParallelBlockTableScanDesc  pbscan 
)

Definition at line 407 of file tableam.c.

References ParallelBlockTableScanDescData::base, InvalidBlockNumber, ParallelBlockTableScanDescData::phs_mutex, ParallelBlockTableScanDescData::phs_nblocks, ParallelBlockTableScanDescData::phs_startblock, ParallelTableScanDescData::phs_syncscan, SpinLockAcquire, SpinLockRelease, and ss_get_location().

Referenced by heapgettup(), heapgettup_pagemode(), and table_scan_sample_next_tuple().

408 {
409  BlockNumber sync_startpage = InvalidBlockNumber;
410 
411 retry:
412  /* Grab the spinlock. */
413  SpinLockAcquire(&pbscan->phs_mutex);
414 
415  /*
416  * If the scan's startblock has not yet been initialized, we must do so
417  * now. If this is not a synchronized scan, we just start at block 0, but
418  * if it is a synchronized scan, we must get the starting position from
419  * the synchronized scan machinery. We can't hold the spinlock while
420  * doing that, though, so release the spinlock, get the information we
421  * need, and retry. If nobody else has initialized the scan in the
422  * meantime, we'll fill in the value we fetched on the second time
423  * through.
424  */
425  if (pbscan->phs_startblock == InvalidBlockNumber)
426  {
427  if (!pbscan->base.phs_syncscan)
428  pbscan->phs_startblock = 0;
429  else if (sync_startpage != InvalidBlockNumber)
430  pbscan->phs_startblock = sync_startpage;
431  else
432  {
433  SpinLockRelease(&pbscan->phs_mutex);
434  sync_startpage = ss_get_location(rel, pbscan->phs_nblocks);
435  goto retry;
436  }
437  }
438  SpinLockRelease(&pbscan->phs_mutex);
439 }
ParallelTableScanDescData base
Definition: relscan.h:74
uint32 BlockNumber
Definition: block.h:31
#define SpinLockAcquire(lock)
Definition: spin.h:62
BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks)
Definition: syncscan.c:253
#define SpinLockRelease(lock)
Definition: spin.h:64
#define InvalidBlockNumber
Definition: block.h:33

◆ table_block_relation_estimate_size()

void table_block_relation_estimate_size ( Relation  rel,
int32 attr_widths,
BlockNumber pages,
double *  tuples,
double *  allvisfrac,
Size  overhead_bytes_per_tuple,
Size  usable_bytes_per_page 
)

Definition at line 548 of file tableam.c.

References get_rel_data_width(), RelationData::rd_rel, relallvisible, RelationGetNumberOfBlocks, relpages, reltuples, and rint().

Referenced by heapam_estimate_rel_size(), and table_scan_sample_next_tuple().

553 {
554  BlockNumber curpages;
556  double reltuples;
558  double density;
559 
560  /* it should have storage, so we can call the smgr */
561  curpages = RelationGetNumberOfBlocks(rel);
562 
563  /* coerce values in pg_class to more desirable types */
564  relpages = (BlockNumber) rel->rd_rel->relpages;
565  reltuples = (double) rel->rd_rel->reltuples;
566  relallvisible = (BlockNumber) rel->rd_rel->relallvisible;
567 
568  /*
569  * HACK: if the relation has never yet been vacuumed, use a minimum size
570  * estimate of 10 pages. The idea here is to avoid assuming a
571  * newly-created table is really small, even if it currently is, because
572  * that may not be true once some data gets loaded into it. Once a vacuum
573  * or analyze cycle has been done on it, it's more reasonable to believe
574  * the size is somewhat stable.
575  *
576  * (Note that this is only an issue if the plan gets cached and used again
577  * after the table has been filled. What we're trying to avoid is using a
578  * nestloop-type plan on a table that has grown substantially since the
579  * plan was made. Normally, autovacuum/autoanalyze will occur once enough
580  * inserts have happened and cause cached-plan invalidation; but that
581  * doesn't happen instantaneously, and it won't happen at all for cases
582  * such as temporary tables.)
583  *
584  * We approximate "never vacuumed" by "has relpages = 0", which means this
585  * will also fire on genuinely empty relations. Not great, but
586  * fortunately that's a seldom-seen case in the real world, and it
587  * shouldn't degrade the quality of the plan too much anyway to err in
588  * this direction.
589  *
590  * If the table has inheritance children, we don't apply this heuristic.
591  * Totally empty parent tables are quite common, so we should be willing
592  * to believe that they are empty.
593  */
594  if (curpages < 10 &&
595  relpages == 0 &&
596  !rel->rd_rel->relhassubclass)
597  curpages = 10;
598 
599  /* report estimated # pages */
600  *pages = curpages;
601  /* quick exit if rel is clearly empty */
602  if (curpages == 0)
603  {
604  *tuples = 0;
605  *allvisfrac = 0;
606  return;
607  }
608 
609  /* estimate number of tuples from previous tuple density */
610  if (relpages > 0)
611  density = reltuples / (double) relpages;
612  else
613  {
614  /*
615  * When we have no data because the relation was truncated, estimate
616  * tuple width from attribute datatypes. We assume here that the
617  * pages are completely full, which is OK for tables (since they've
618  * presumably not been VACUUMed yet) but is probably an overestimate
619  * for indexes. Fortunately get_relation_info() can clamp the
620  * overestimate to the parent table's size.
621  *
622  * Note: this code intentionally disregards alignment considerations,
623  * because (a) that would be gilding the lily considering how crude
624  * the estimate is, (b) it creates platform dependencies in the
625  * default plans which are kind of a headache for regression testing,
626  * and (c) different table AMs might use different padding schemes.
627  */
628  int32 tuple_width;
629 
630  tuple_width = get_rel_data_width(rel, attr_widths);
631  tuple_width += overhead_bytes_per_tuple;
632  /* note: integer division is intentional here */
633  density = usable_bytes_per_page / tuple_width;
634  }
635  *tuples = rint(density * (double) curpages);
636 
637  /*
638  * We use relallvisible as-is, rather than scaling it up like we do for
639  * the pages and tuples counts, on the theory that any pages added since
640  * the last VACUUM are most likely not marked all-visible. But costsize.c
641  * wants it converted to a fraction.
642  */
643  if (relallvisible == 0 || curpages <= 0)
644  *allvisfrac = 0;
645  else if ((double) relallvisible >= curpages)
646  *allvisfrac = 1;
647  else
648  *allvisfrac = (double) relallvisible / curpages;
649 }
int32 relallvisible
Definition: pg_class.h:66
uint32 BlockNumber
Definition: block.h:31
Form_pg_class rd_rel
Definition: rel.h:83
int32 relpages
Definition: pg_class.h:60
signed int int32
Definition: c.h:347
double rint(double x)
Definition: rint.c:21
#define RelationGetNumberOfBlocks(reln)
Definition: bufmgr.h:198
int32 get_rel_data_width(Relation rel, int32 *attr_widths)
Definition: plancat.c:1087
float4 reltuples
Definition: pg_class.h:63

◆ table_block_relation_size()

uint64 table_block_relation_size ( Relation  rel,
ForkNumber  forkNumber 
)

Definition at line 508 of file tableam.c.

References i, InvalidForkNumber, MAX_FORKNUM, RelationData::rd_smgr, RelationOpenSmgr, and smgrnblocks().

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

509 {
510  uint64 nblocks = 0;
511 
512  /* Open it at the smgr level if not already done */
513  RelationOpenSmgr(rel);
514 
515  /* InvalidForkNumber indicates returning the size for all forks */
516  if (forkNumber == InvalidForkNumber)
517  {
518  for (int i = 0; i < MAX_FORKNUM; i++)
519  nblocks += smgrnblocks(rel->rd_smgr, i);
520  }
521  else
522  nblocks = smgrnblocks(rel->rd_smgr, forkNumber);
523 
524  return nblocks * BLCKSZ;
525 }
struct SMgrRelationData * rd_smgr
Definition: rel.h:56
#define RelationOpenSmgr(relation)
Definition: rel.h:479
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
Definition: smgr.c:555
#define MAX_FORKNUM
Definition: relpath.h:55
int i

◆ table_compute_xid_horizon_for_tuples()

static TransactionId table_compute_xid_horizon_for_tuples ( Relation  rel,
ItemPointerData items,
int  nitems 
)
inlinestatic

Definition at line 1071 of file tableam.h.

References TableAmRoutine::compute_xid_horizon_for_tuples, and RelationData::rd_tableam.

Referenced by index_compute_xid_horizon_for_tuples().

1074 {
1075  return rel->rd_tableam->compute_xid_horizon_for_tuples(rel, items, nitems);
1076 }
TransactionId(* compute_xid_horizon_for_tuples)(Relation rel, ItemPointerData *items, int nitems)
Definition: tableam.h:344
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_endscan()

static void table_endscan ( TableScanDesc  scan)
inlinestatic

Definition at line 831 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_end.

Referenced by acquire_sample_rows(), AlterDomainNotNull(), AlterTableMoveAll(), AlterTableSpaceOptions(), ATRewriteTable(), boot_openrel(), check_db_file_conflict(), check_default_partition_contents(), CopyTo(), createdb(), currtid_byrelname(), currtid_byreloid(), DefineQueryRewrite(), do_autovacuum(), DropSetting(), DropTableSpace(), ExecEndBitmapHeapScan(), ExecEndSampleScan(), ExecEndSeqScan(), ExecEndTidScan(), find_typed_table_dependencies(), get_all_vacuum_rels(), get_database_list(), get_subscription_list(), get_tables_to_cluster(), get_tablespace_name(), get_tablespace_oid(), GetAllTablesPublicationRelations(), getRelationsInNamespace(), gettype(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_relation_copy_for_cluster(), index_update_stats(), IndexCheckExclusion(), objectsInSchemaToOids(), pgrowlocks(), pgstat_collect_oids(), pgstat_heap(), ReindexMultipleTables(), RelationFindReplTupleSeq(), remove_dbtablespaces(), RemoveConversionById(), RemoveSubscriptionRel(), RenameTableSpace(), systable_endscan(), ThereIsAtLeastOneRole(), vac_truncate_clog(), validateCheckConstraint(), validateDomainConstraint(), and validateForeignKeyConstraint().

832 {
833  scan->rs_rd->rd_tableam->scan_end(scan);
834 }
void(* scan_end)(TableScanDesc scan)
Definition: tableam.h:209
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_finish_bulk_insert()

static void table_finish_bulk_insert ( Relation  rel,
int  options 
)
inlinestatic

Definition at line 1318 of file tableam.h.

References TableAmRoutine::finish_bulk_insert, and RelationData::rd_tableam.

Referenced by ATRewriteTable(), CopyMultiInsertBufferCleanup(), intorel_shutdown(), and transientrel_shutdown().

1319 {
1320  /* optional callback */
1321  if (rel->rd_tableam && rel->rd_tableam->finish_bulk_insert)
1323 }
void(* finish_bulk_insert)(Relation rel, int options)
Definition: tableam.h:423
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_index_build_range_scan()

static double table_index_build_range_scan ( Relation  table_rel,
Relation  index_rel,
struct IndexInfo index_info,
bool  allow_sync,
bool  anyvisible,
bool  progress,
BlockNumber  start_blockno,
BlockNumber  numblocks,
IndexBuildCallback  callback,
void *  callback_state,
TableScanDesc  scan 
)
inlinestatic

Definition at line 1532 of file tableam.h.

References TableAmRoutine::index_build_range_scan, and RelationData::rd_tableam.

Referenced by summarize_range().

1543 {
1544  return table_rel->rd_tableam->index_build_range_scan(table_rel,
1545  index_rel,
1546  index_info,
1547  allow_sync,
1548  anyvisible,
1549  progress,
1550  start_blockno,
1551  numblocks,
1552  callback,
1553  callback_state,
1554  scan);
1555 }
double(* index_build_range_scan)(Relation table_rel, Relation index_rel, struct IndexInfo *index_info, bool allow_sync, bool anyvisible, bool progress, BlockNumber start_blockno, BlockNumber numblocks, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
Definition: tableam.h:539
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
int progress
Definition: pgbench.c:235
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_index_build_scan()

static double table_index_build_scan ( Relation  table_rel,
Relation  index_rel,
struct IndexInfo index_info,
bool  allow_sync,
bool  progress,
IndexBuildCallback  callback,
void *  callback_state,
TableScanDesc  scan 
)
inlinestatic

Definition at line 1499 of file tableam.h.

References TableAmRoutine::index_build_range_scan, InvalidBlockNumber, and RelationData::rd_tableam.

Referenced by _bt_parallel_scan_and_sort(), _bt_spools_heapscan(), blbuild(), brinbuild(), bt_check_every_level(), ginbuild(), gistbuild(), hashbuild(), and spgbuild().

1507 {
1508  return table_rel->rd_tableam->index_build_range_scan(table_rel,
1509  index_rel,
1510  index_info,
1511  allow_sync,
1512  false,
1513  progress,
1514  0,
1516  callback,
1517  callback_state,
1518  scan);
1519 }
double(* index_build_range_scan)(Relation table_rel, Relation index_rel, struct IndexInfo *index_info, bool allow_sync, bool anyvisible, bool progress, BlockNumber start_blockno, BlockNumber numblocks, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
Definition: tableam.h:539
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
int progress
Definition: pgbench.c:235
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
#define InvalidBlockNumber
Definition: block.h:33

◆ table_index_fetch_begin()

static IndexFetchTableData* table_index_fetch_begin ( Relation  rel)
inlinestatic

Definition at line 934 of file tableam.h.

References TableAmRoutine::index_fetch_begin, and RelationData::rd_tableam.

Referenced by index_beginscan(), index_beginscan_parallel(), table_index_fetch_tuple_check(), and unique_key_recheck().

935 {
936  return rel->rd_tableam->index_fetch_begin(rel);
937 }
struct IndexFetchTableData *(* index_fetch_begin)(Relation rel)
Definition: tableam.h:267
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_index_fetch_end()

static void table_index_fetch_end ( struct IndexFetchTableData scan)
inlinestatic

Definition at line 953 of file tableam.h.

References TableAmRoutine::index_fetch_end, RelationData::rd_tableam, and IndexFetchTableData::rel.

Referenced by index_endscan(), table_index_fetch_tuple_check(), and unique_key_recheck().

954 {
955  scan->rel->rd_tableam->index_fetch_end(scan);
956 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
void(* index_fetch_end)(struct IndexFetchTableData *data)
Definition: tableam.h:278
Relation rel
Definition: relscan.h:91

◆ table_index_fetch_reset()

static void table_index_fetch_reset ( struct IndexFetchTableData scan)
inlinestatic

Definition at line 944 of file tableam.h.

References TableAmRoutine::index_fetch_reset, RelationData::rd_tableam, and IndexFetchTableData::rel.

Referenced by index_getnext_tid(), index_parallelrescan(), index_rescan(), and index_restrpos().

945 {
946  scan->rel->rd_tableam->index_fetch_reset(scan);
947 }
void(* index_fetch_reset)(struct IndexFetchTableData *data)
Definition: tableam.h:273
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rel
Definition: relscan.h:91

◆ table_index_fetch_tuple()

static bool table_index_fetch_tuple ( struct IndexFetchTableData scan,
ItemPointer  tid,
Snapshot  snapshot,
TupleTableSlot slot,
bool call_again,
bool all_dead 
)
inlinestatic

Definition at line 981 of file tableam.h.

References TableAmRoutine::index_fetch_tuple, RelationData::rd_tableam, IndexFetchTableData::rel, and table_index_fetch_tuple_check().

Referenced by index_fetch_heap(), table_index_fetch_tuple_check(), and unique_key_recheck().

986 {
987 
988  return scan->rel->rd_tableam->index_fetch_tuple(scan, tid, snapshot,
989  slot, call_again,
990  all_dead);
991 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rel
Definition: relscan.h:91
bool(* index_fetch_tuple)(struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, bool *call_again, bool *all_dead)
Definition: tableam.h:300

◆ table_index_fetch_tuple_check()

bool table_index_fetch_tuple_check ( Relation  rel,
ItemPointer  tid,
Snapshot  snapshot,
bool all_dead 
)

Definition at line 201 of file tableam.c.

References ExecDropSingleTupleTableSlot(), table_index_fetch_begin(), table_index_fetch_end(), table_index_fetch_tuple(), and table_slot_create().

Referenced by _bt_check_unique(), and table_index_fetch_tuple().

205 {
206  IndexFetchTableData *scan;
207  TupleTableSlot *slot;
208  bool call_again = false;
209  bool found;
210 
211  slot = table_slot_create(rel, NULL);
212  scan = table_index_fetch_begin(rel);
213  found = table_index_fetch_tuple(scan, tid, snapshot, slot, &call_again,
214  all_dead);
215  table_index_fetch_end(scan);
217 
218  return found;
219 }
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
Definition: tableam.c:77
static IndexFetchTableData * table_index_fetch_begin(Relation rel)
Definition: tableam.h:934
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:1224
static bool table_index_fetch_tuple(struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, bool *call_again, bool *all_dead)
Definition: tableam.h:981
static void table_index_fetch_end(struct IndexFetchTableData *scan)
Definition: tableam.h:953

◆ table_index_validate_scan()

static void table_index_validate_scan ( Relation  table_rel,
Relation  index_rel,
struct IndexInfo index_info,
Snapshot  snapshot,
struct ValidateIndexState state 
)
inlinestatic

Definition at line 1563 of file tableam.h.

References TableAmRoutine::index_validate_scan, and RelationData::rd_tableam.

Referenced by validate_index().

1568 {
1569  table_rel->rd_tableam->index_validate_scan(table_rel,
1570  index_rel,
1571  index_info,
1572  snapshot,
1573  state);
1574 }
void(* index_validate_scan)(Relation table_rel, Relation index_rel, struct IndexInfo *index_info, Snapshot snapshot, struct ValidateIndexState *state)
Definition: tableam.h:552
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_multi_insert()

static void table_multi_insert ( Relation  rel,
TupleTableSlot **  slots,
int  nslots,
CommandId  cid,
int  options,
struct BulkInsertStateData bistate 
)
inlinestatic

Definition at line 1178 of file tableam.h.

References TableAmRoutine::multi_insert, and RelationData::rd_tableam.

Referenced by CopyMultiInsertBufferFlush().

1180 {
1181  rel->rd_tableam->multi_insert(rel, slots, nslots,
1182  cid, options, bistate);
1183 }
void(* multi_insert)(Relation rel, TupleTableSlot **slots, int nslots, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:374
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_parallelscan_estimate()

Size table_parallelscan_estimate ( Relation  rel,
Snapshot  snapshot 
)

Definition at line 126 of file tableam.c.

References add_size(), Assert, EstimateSnapshotSpace(), IsMVCCSnapshot, TableAmRoutine::parallelscan_estimate, RelationData::rd_tableam, and SnapshotAny.

Referenced by _bt_parallel_estimate_shared(), ExecSeqScanEstimate(), and table_scan_getnextslot().

127 {
128  Size sz = 0;
129 
130  if (IsMVCCSnapshot(snapshot))
131  sz = add_size(sz, EstimateSnapshotSpace(snapshot));
132  else
133  Assert(snapshot == SnapshotAny);
134 
135  sz = add_size(sz, rel->rd_tableam->parallelscan_estimate(rel));
136 
137  return sz;
138 }
Size(* parallelscan_estimate)(Relation rel)
Definition: tableam.h:236
Size EstimateSnapshotSpace(Snapshot snap)
Definition: snapmgr.c:2078
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
#define IsMVCCSnapshot(snapshot)
Definition: snapmgr.h:97
#define Assert(condition)
Definition: c.h:739
size_t Size
Definition: c.h:467
#define SnapshotAny
Definition: snapmgr.h:69

◆ table_parallelscan_initialize()

void table_parallelscan_initialize ( Relation  rel,
ParallelTableScanDesc  pscan,
Snapshot  snapshot 
)

Definition at line 141 of file tableam.c.

References Assert, IsMVCCSnapshot, TableAmRoutine::parallelscan_initialize, ParallelTableScanDescData::phs_snapshot_any, ParallelTableScanDescData::phs_snapshot_off, RelationData::rd_tableam, SerializeSnapshot(), and SnapshotAny.

Referenced by _bt_begin_parallel(), ExecSeqScanInitializeDSM(), and table_scan_getnextslot().

143 {
144  Size snapshot_off = rel->rd_tableam->parallelscan_initialize(rel, pscan);
145 
146  pscan->phs_snapshot_off = snapshot_off;
147 
148  if (IsMVCCSnapshot(snapshot))
149  {
150  SerializeSnapshot(snapshot, (char *) pscan + pscan->phs_snapshot_off);
151  pscan->phs_snapshot_any = false;
152  }
153  else
154  {
155  Assert(snapshot == SnapshotAny);
156  pscan->phs_snapshot_any = true;
157  }
158 }
Size(* parallelscan_initialize)(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:243
void SerializeSnapshot(Snapshot snapshot, char *start_address)
Definition: snapmgr.c:2102
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
#define IsMVCCSnapshot(snapshot)
Definition: snapmgr.h:97
#define Assert(condition)
Definition: c.h:739
size_t Size
Definition: c.h:467
#define SnapshotAny
Definition: snapmgr.h:69

◆ table_parallelscan_reinitialize()

static void table_parallelscan_reinitialize ( Relation  rel,
ParallelTableScanDesc  pscan 
)
inlinestatic

Definition at line 916 of file tableam.h.

References TableAmRoutine::parallelscan_reinitialize, and RelationData::rd_tableam.

Referenced by ExecSeqScanReInitializeDSM().

917 {
918  rel->rd_tableam->parallelscan_reinitialize(rel, pscan);
919 }
void(* parallelscan_reinitialize)(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:250
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_copy_data()

static void table_relation_copy_data ( Relation  rel,
const RelFileNode newrnode 
)
inlinestatic

Definition at line 1373 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_copy_data.

Referenced by ATExecSetTableSpace().

1374 {
1375  rel->rd_tableam->relation_copy_data(rel, newrnode);
1376 }
void(* relation_copy_data)(Relation rel, const RelFileNode *newrnode)
Definition: tableam.h:469
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_copy_for_cluster()

static void table_relation_copy_for_cluster ( Relation  OldTable,
Relation  NewTable,
Relation  OldIndex,
bool  use_sort,
TransactionId  OldestXmin,
TransactionId xid_cutoff,
MultiXactId multi_cutoff,
double *  num_tuples,
double *  tups_vacuumed,
double *  tups_recently_dead 
)
inlinestatic

Definition at line 1400 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_copy_for_cluster.

Referenced by copy_table_data().

1409 {
1410  OldTable->rd_tableam->relation_copy_for_cluster(OldTable, NewTable, OldIndex,
1411  use_sort, OldestXmin,
1412  xid_cutoff, multi_cutoff,
1413  num_tuples, tups_vacuumed,
1414  tups_recently_dead);
1415 }
void(* relation_copy_for_cluster)(Relation NewTable, Relation OldTable, Relation OldIndex, bool use_sort, TransactionId OldestXmin, TransactionId *xid_cutoff, MultiXactId *multi_cutoff, double *num_tuples, double *tups_vacuumed, double *tups_recently_dead)
Definition: tableam.h:473
static TransactionId OldestXmin
Definition: vacuumlazy.c:145
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_estimate_size()

static void table_relation_estimate_size ( Relation  rel,
int32 attr_widths,
BlockNumber pages,
double *  tuples,
double *  allvisfrac 
)
inlinestatic

Definition at line 1617 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_estimate_size.

Referenced by estimate_rel_size().

1620 {
1621  rel->rd_tableam->relation_estimate_size(rel, attr_widths, pages, tuples,
1622  allvisfrac);
1623 }
void(* relation_estimate_size)(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac)
Definition: tableam.h:600
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_needs_toast_table()

static bool table_relation_needs_toast_table ( Relation  rel)
inlinestatic

Definition at line 1601 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_needs_toast_table.

Referenced by needs_toast_table().

1602 {
1603  return rel->rd_tableam->relation_needs_toast_table(rel);
1604 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
bool(* relation_needs_toast_table)(Relation rel)
Definition: tableam.h:582

◆ table_relation_nontransactional_truncate()

static void table_relation_nontransactional_truncate ( Relation  rel)
inlinestatic

Definition at line 1361 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_nontransactional_truncate.

Referenced by heap_truncate_one_rel().

1362 {
1364 }
void(* relation_nontransactional_truncate)(Relation rel)
Definition: tableam.h:461
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_set_new_filenode()

static void table_relation_set_new_filenode ( Relation  rel,
const RelFileNode newrnode,
char  persistence,
TransactionId freezeXid,
MultiXactId minmulti 
)
inlinestatic

Definition at line 1344 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_set_new_filenode.

Referenced by heap_create(), and RelationSetNewRelfilenode().

1349 {
1350  rel->rd_tableam->relation_set_new_filenode(rel, newrnode, persistence,
1351  freezeXid, minmulti);
1352 }
void(* relation_set_new_filenode)(Relation rel, const RelFileNode *newrnode, char persistence, TransactionId *freezeXid, MultiXactId *minmulti)
Definition: tableam.h:447
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_size()

static uint64 table_relation_size ( Relation  rel,
ForkNumber  forkNumber 
)
inlinestatic

Definition at line 1592 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_size.

Referenced by RelationGetNumberOfBlocksInFork().

1593 {
1594  return rel->rd_tableam->relation_size(rel, forkNumber);
1595 }
uint64(* relation_size)(Relation rel, ForkNumber forkNumber)
Definition: tableam.h:572
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_relation_vacuum()

static void table_relation_vacuum ( Relation  rel,
struct VacuumParams params,
BufferAccessStrategy  bstrategy 
)
inlinestatic

Definition at line 1429 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::relation_vacuum.

Referenced by vacuum_rel().

1431 {
1432  rel->rd_tableam->relation_vacuum(rel, params, bstrategy);
1433 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
void(* relation_vacuum)(Relation onerel, struct VacuumParams *params, BufferAccessStrategy bstrategy)
Definition: tableam.h:499

◆ table_rescan()

static void table_rescan ( TableScanDesc  scan,
struct ScanKeyData key 
)
inlinestatic

Definition at line 840 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_rescan.

Referenced by ExecReScanBitmapHeapScan(), ExecReScanSeqScan(), ExecReScanTidScan(), and RelationFindReplTupleSeq().

842 {
843  scan->rs_rd->rd_tableam->scan_rescan(scan, key, false, false, false, false);
844 }
void(* scan_rescan)(TableScanDesc scan, struct ScanKeyData *key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition: tableam.h:215
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_rescan_set_params()

static void table_rescan_set_params ( TableScanDesc  scan,
struct ScanKeyData key,
bool  allow_strat,
bool  allow_sync,
bool  allow_pagemode 
)
inlinestatic

Definition at line 855 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, TableAmRoutine::scan_rescan, and table_scan_update_snapshot().

Referenced by tablesample_init().

857 {
858  scan->rs_rd->rd_tableam->scan_rescan(scan, key, true,
859  allow_strat, allow_sync,
860  allow_pagemode);
861 }
void(* scan_rescan)(TableScanDesc scan, struct ScanKeyData *key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition: tableam.h:215
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_scan_analyze_next_block()

static bool table_scan_analyze_next_block ( TableScanDesc  scan,
BlockNumber  blockno,
BufferAccessStrategy  bstrategy 
)
inlinestatic

Definition at line 1444 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_analyze_next_block.

Referenced by acquire_sample_rows().

1446 {
1447  return scan->rs_rd->rd_tableam->scan_analyze_next_block(scan, blockno,
1448  bstrategy);
1449 }
bool(* scan_analyze_next_block)(TableScanDesc scan, BlockNumber blockno, BufferAccessStrategy bstrategy)
Definition: tableam.h:520
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_scan_analyze_next_tuple()

static bool table_scan_analyze_next_tuple ( TableScanDesc  scan,
TransactionId  OldestXmin,
double *  liverows,
double *  deadrows,
TupleTableSlot slot 
)
inlinestatic

Definition at line 1462 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_analyze_next_tuple.

Referenced by acquire_sample_rows().

1465 {
1466  return scan->rs_rd->rd_tableam->scan_analyze_next_tuple(scan, OldestXmin,
1467  liverows, deadrows,
1468  slot);
1469 }
bool(* scan_analyze_next_tuple)(TableScanDesc scan, TransactionId OldestXmin, double *liverows, double *deadrows, TupleTableSlot *slot)
Definition: tableam.h:532
static TransactionId OldestXmin
Definition: vacuumlazy.c:145
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_scan_bitmap_next_block()

static bool table_scan_bitmap_next_block ( TableScanDesc  scan,
struct TBMIterateResult tbmres 
)
inlinestatic

Definition at line 1641 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_bitmap_next_block.

Referenced by BitmapHeapNext().

1643 {
1644  return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
1645  tbmres);
1646 }
bool(* scan_bitmap_next_block)(TableScanDesc scan, struct TBMIterateResult *tbmres)
Definition: tableam.h:641
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_scan_bitmap_next_tuple()

static bool table_scan_bitmap_next_tuple ( TableScanDesc  scan,
struct TBMIterateResult tbmres,
TupleTableSlot slot 
)
inlinestatic

Definition at line 1657 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_bitmap_next_tuple.

Referenced by BitmapHeapNext().

1660 {
1661  return scan->rs_rd->rd_tableam->scan_bitmap_next_tuple(scan,
1662  tbmres,
1663  slot);
1664 }
bool(* scan_bitmap_next_tuple)(TableScanDesc scan, struct TBMIterateResult *tbmres, TupleTableSlot *slot)
Definition: tableam.h:655
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_scan_getnextslot()

static bool table_scan_getnextslot ( TableScanDesc  sscan,
ScanDirection  direction,
TupleTableSlot slot 
)
inlinestatic

◆ table_scan_sample_next_block()

static bool table_scan_sample_next_block ( TableScanDesc  scan,
struct SampleScanState scanstate 
)
inlinestatic

Definition at line 1676 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, and TableAmRoutine::scan_sample_next_block.

Referenced by tablesample_getnext().

1678 {
1679  return scan->rs_rd->rd_tableam->scan_sample_next_block(scan, scanstate);
1680 }
bool(* scan_sample_next_block)(TableScanDesc scan, struct SampleScanState *scanstate)
Definition: tableam.h:684
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34

◆ table_scan_sample_next_tuple()

◆ table_scan_update_snapshot()

void table_scan_update_snapshot ( TableScanDesc  scan,
Snapshot  snapshot 
)

Definition at line 110 of file tableam.c.

References Assert, IsMVCCSnapshot, RegisterSnapshot(), TableScanDescData::rs_flags, TableScanDescData::rs_snapshot, and SO_TEMP_SNAPSHOT.

Referenced by ExecBitmapHeapInitializeWorker(), and table_rescan_set_params().

111 {
112  Assert(IsMVCCSnapshot(snapshot));
113 
114  RegisterSnapshot(snapshot);
115  scan->rs_snapshot = snapshot;
116  scan->rs_flags |= SO_TEMP_SNAPSHOT;
117 }
Snapshot RegisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:865
uint32 rs_flags
Definition: relscan.h:43
#define IsMVCCSnapshot(snapshot)
Definition: snapmgr.h:97
#define Assert(condition)
Definition: c.h:739
struct SnapshotData * rs_snapshot
Definition: relscan.h:35

◆ table_slot_callbacks()

const TupleTableSlotOps* table_slot_callbacks ( Relation  rel)

Definition at line 44 of file tableam.c.

References Assert, RelationData::rd_rel, RelationData::rd_tableam, TableAmRoutine::slot_callbacks, TTSOpsHeapTuple, and TTSOpsVirtual.

Referenced by ATRewriteTable(), ExecGetReturningSlot(), ExecGetTriggerNewSlot(), ExecGetTriggerOldSlot(), ExecInitBitmapHeapScan(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitModifyTable(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitTidScan(), and table_slot_create().

45 {
46  const TupleTableSlotOps *tts_cb;
47 
48  if (relation->rd_tableam)
49  tts_cb = relation->rd_tableam->slot_callbacks(relation);
50  else if (relation->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
51  {
52  /*
53  * Historically FDWs expect to store heap tuples in slots. Continue
54  * handing them one, to make it less painful to adapt FDWs to new
55  * versions. The cost of a heap slot over a virtual slot is pretty
56  * small.
57  */
58  tts_cb = &TTSOpsHeapTuple;
59  }
60  else
61  {
62  /*
63  * These need to be supported, as some parts of the code (like COPY)
64  * need to create slots for such relations too. It seems better to
65  * centralize the knowledge that a heap slot is the right thing in
66  * that case here.
67  */
68  Assert(relation->rd_rel->relkind == RELKIND_VIEW ||
69  relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
70  tts_cb = &TTSOpsVirtual;
71  }
72 
73  return tts_cb;
74 }
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:83
#define Assert(condition)
Definition: c.h:739
const TupleTableSlotOps TTSOpsHeapTuple
Definition: execTuples.c:84

◆ table_slot_create()

TupleTableSlot* table_slot_create ( Relation  rel,
List **  reglist 
)

Definition at line 77 of file tableam.c.

References lappend(), MakeSingleTupleTableSlot(), RelationGetDescr, and table_slot_callbacks().

Referenced by acquire_sample_rows(), AlterDomainNotNull(), apply_handle_delete(), apply_handle_update(), check_default_partition_contents(), check_exclusion_or_unique_constraint(), CopyFrom(), CopyMultiInsertInfoNextFreeSlot(), CopyTo(), DefineQueryRewrite(), EvalPlanQualSlot(), ExecInitModifyTable(), ExecInitPartitionInfo(), ExecInitRoutingInfo(), get_actual_variable_range(), heapam_index_build_range_scan(), heapam_relation_copy_for_cluster(), IndexCheckExclusion(), RelationFindReplTupleSeq(), systable_beginscan(), systable_beginscan_ordered(), table_index_fetch_tuple_check(), unique_key_recheck(), validateCheckConstraint(), validateDomainConstraint(), and validateForeignKeyConstraint().

78 {
79  const TupleTableSlotOps *tts_cb;
80  TupleTableSlot *slot;
81 
82  tts_cb = table_slot_callbacks(relation);
83  slot = MakeSingleTupleTableSlot(RelationGetDescr(relation), tts_cb);
84 
85  if (reglist)
86  *reglist = lappend(*reglist, slot);
87 
88  return slot;
89 }
#define RelationGetDescr(relation)
Definition: rel.h:448
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1208
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition: tableam.c:44
List * lappend(List *list, void *datum)
Definition: list.c:322

◆ table_tuple_complete_speculative()

static void table_tuple_complete_speculative ( Relation  rel,
TupleTableSlot slot,
uint32  specToken,
bool  succeeded 
)
inlinestatic

Definition at line 1156 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_complete_speculative.

Referenced by ExecInsert().

1158 {
1159  rel->rd_tableam->tuple_complete_speculative(rel, slot, specToken,
1160  succeeded);
1161 }
void(* tuple_complete_speculative)(Relation rel, TupleTableSlot *slot, uint32 specToken, bool succeeded)
Definition: tableam.h:368
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_tuple_delete()

static TM_Result table_tuple_delete ( Relation  rel,
ItemPointer  tid,
CommandId  cid,
Snapshot  snapshot,
Snapshot  crosscheck,
bool  wait,
TM_FailureData tmfd,
bool  changingPart 
)
inlinestatic

Definition at line 1212 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_delete.

Referenced by ExecDelete(), and simple_table_tuple_delete().

1215 {
1216  return rel->rd_tableam->tuple_delete(rel, tid, cid,
1217  snapshot, crosscheck,
1218  wait, tmfd, changingPart);
1219 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
TM_Result(* tuple_delete)(Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
Definition: tableam.h:378

◆ table_tuple_fetch_row_version()

static bool table_tuple_fetch_row_version ( Relation  rel,
ItemPointer  tid,
Snapshot  snapshot,
TupleTableSlot slot 
)
inlinestatic

Definition at line 1021 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_fetch_row_version.

Referenced by AfterTriggerExecute(), EvalPlanQualFetchRowMark(), ExecCheckTIDVisible(), ExecDelete(), GetTupleForTrigger(), and TidNext().

1025 {
1026  return rel->rd_tableam->tuple_fetch_row_version(rel, tid, snapshot, slot);
1027 }
bool(* tuple_fetch_row_version)(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
Definition: tableam.h:317
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_tuple_get_latest_tid()

void table_tuple_get_latest_tid ( TableScanDesc  scan,
ItemPointer  tid 
)

Definition at line 228 of file tableam.c.

References ereport, errcode(), errmsg(), ERROR, ItemPointerGetBlockNumberNoCheck, ItemPointerGetOffsetNumberNoCheck, RelationData::rd_tableam, RelationGetRelationName, TableScanDescData::rs_rd, TableAmRoutine::tuple_get_latest_tid, and TableAmRoutine::tuple_tid_valid.

Referenced by currtid_byrelname(), currtid_byreloid(), table_tuple_tid_valid(), and TidNext().

229 {
230  Relation rel = scan->rs_rd;
231  const TableAmRoutine *tableam = rel->rd_tableam;
232 
233  /*
234  * Since this can be called with user-supplied TID, don't trust the input
235  * too much.
236  */
237  if (!tableam->tuple_tid_valid(scan, tid))
238  ereport(ERROR,
239  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
240  errmsg("tid (%u, %u) is not valid for relation \"%s\"",
243  RelationGetRelationName(rel))));
244 
245  tableam->tuple_get_latest_tid(scan, tid);
246 }
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
int errcode(int sqlerrcode)
Definition: elog.c:608
#define ERROR
Definition: elog.h:43
#define RelationGetRelationName(relation)
Definition: rel.h:456
#define ereport(elevel, rest)
Definition: elog.h:141
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
void(* tuple_get_latest_tid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:332
Relation rs_rd
Definition: relscan.h:34
bool(* tuple_tid_valid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:325
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define ItemPointerGetBlockNumberNoCheck(pointer)
Definition: itemptr.h:89

◆ table_tuple_insert()

static void table_tuple_insert ( Relation  rel,
TupleTableSlot slot,
CommandId  cid,
int  options,
struct BulkInsertStateData bistate 
)
inlinestatic

Definition at line 1123 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_insert.

Referenced by ATRewriteTable(), CopyFrom(), ExecInsert(), intorel_receive(), simple_table_tuple_insert(), and transientrel_receive().

1125 {
1126  rel->rd_tableam->tuple_insert(rel, slot, cid, options,
1127  bistate);
1128 }
void(* tuple_insert)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:355
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_tuple_insert_speculative()

static void table_tuple_insert_speculative ( Relation  rel,
TupleTableSlot slot,
CommandId  cid,
int  options,
struct BulkInsertStateData bistate,
uint32  specToken 
)
inlinestatic

Definition at line 1142 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_insert_speculative.

Referenced by ExecInsert().

1146 {
1147  rel->rd_tableam->tuple_insert_speculative(rel, slot, cid, options,
1148  bistate, specToken);
1149 }
void(* tuple_insert_speculative)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate, uint32 specToken)
Definition: tableam.h:360
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

◆ table_tuple_lock()

static TM_Result table_tuple_lock ( Relation  rel,
ItemPointer  tid,
Snapshot  snapshot,
TupleTableSlot slot,
CommandId  cid,
LockTupleMode  mode,
LockWaitPolicy  wait_policy,
uint8  flags,
TM_FailureData tmfd 
)
inlinestatic

Definition at line 1301 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_lock.

Referenced by ExecDelete(), ExecLockRows(), ExecOnConflictUpdate(), ExecUpdate(), GetTupleForTrigger(), RelationFindReplTupleByIndex(), and RelationFindReplTupleSeq().

1305 {
1306  return rel->rd_tableam->tuple_lock(rel, tid, snapshot, slot,
1307  cid, mode, wait_policy,
1308  flags, tmfd);
1309 }
static PgChecksumMode mode
Definition: pg_checksums.c:61
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
TM_Result(* tuple_lock)(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, uint8 flags, TM_FailureData *tmfd)
Definition: tableam.h:400

◆ table_tuple_satisfies_snapshot()

static bool table_tuple_satisfies_snapshot ( Relation  rel,
TupleTableSlot slot,
Snapshot  snapshot 
)
inlinestatic

Definition at line 1059 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_satisfies_snapshot.

Referenced by ExecCheckTupleVisible(), RI_FKey_check(), and systable_recheck_tuple().

1061 {
1062  return rel->rd_tableam->tuple_satisfies_snapshot(rel, slot, snapshot);
1063 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
bool(* tuple_satisfies_snapshot)(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
Definition: tableam.h:339

◆ table_tuple_tid_valid()

static bool table_tuple_tid_valid ( TableScanDesc  scan,
ItemPointer  tid 
)
inlinestatic

Definition at line 1038 of file tableam.h.

References RelationData::rd_tableam, TableScanDescData::rs_rd, table_tuple_get_latest_tid(), and TableAmRoutine::tuple_tid_valid.

Referenced by TidListEval().

1039 {
1040  return scan->rs_rd->rd_tableam->tuple_tid_valid(scan, tid);
1041 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140
Relation rs_rd
Definition: relscan.h:34
bool(* tuple_tid_valid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:325

◆ table_tuple_update()

static TM_Result table_tuple_update ( Relation  rel,
ItemPointer  otid,
TupleTableSlot slot,
CommandId  cid,
Snapshot  snapshot,
Snapshot  crosscheck,
bool  wait,
TM_FailureData tmfd,
LockTupleMode lockmode,
bool update_indexes 
)
inlinestatic

Definition at line 1256 of file tableam.h.

References RelationData::rd_tableam, and TableAmRoutine::tuple_update.

Referenced by ExecUpdate(), and simple_table_tuple_update().

1260 {
1261  return rel->rd_tableam->tuple_update(rel, otid, slot,
1262  cid, snapshot, crosscheck,
1263  wait, tmfd,
1264  lockmode, update_indexes);
1265 }
TM_Result(* tuple_update)(Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, bool *update_indexes)
Definition: tableam.h:388
const struct TableAmRoutine * rd_tableam
Definition: rel.h:140

Variable Documentation

◆ default_table_access_method

char* default_table_access_method

Definition at line 34 of file tableam.c.

Referenced by DefineRelation().

◆ synchronize_seqscans

bool synchronize_seqscans

Definition at line 35 of file tableam.c.

Referenced by initscan(), and table_block_parallelscan_initialize().