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_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_TIDSCAN = 1 << 3,
  SO_TYPE_ANALYZE = 1 << 4, SO_ALLOW_STRAT = 1 << 5, SO_ALLOW_SYNC = 1 << 6, SO_ALLOW_PAGEMODE = 1 << 7,
  SO_TEMP_SNAPSHOT = 1 << 8
}
 
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_tid (Relation rel, Snapshot snapshot)
 
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 Oid table_relation_toast_am (Relation rel)
 
static void table_relation_fetch_toast_slice (Relation toastrel, Oid valueid, int32 attrsize, int32 sliceoffset, int32 slicelength, struct varlena *result)
 
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 133 of file tableam.h.

Referenced by CopyFrom(), and transientrel_startup().

◆ TABLE_INSERT_NO_LOGICAL

#define TABLE_INSERT_NO_LOGICAL   0x0008

Definition at line 134 of file tableam.h.

◆ TABLE_INSERT_SKIP_FSM

#define TABLE_INSERT_SKIP_FSM   0x0002

Definition at line 132 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 138 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 144 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_TIDSCAN 
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_TIDSCAN = 1 << 3,
51  SO_TYPE_ANALYZE = 1 << 4,
52 
53  /* several of SO_ALLOW_* may be specified */
54  /* allow or disallow use of access strategy */
55  SO_ALLOW_STRAT = 1 << 5,
56  /* report location to syncscan logic? */
57  SO_ALLOW_SYNC = 1 << 6,
58  /* verify visibility page-at-a-time? */
59  SO_ALLOW_PAGEMODE = 1 << 7,
60 
61  /* unregister snapshot at scan end? */
62  SO_TEMP_SNAPSHOT = 1 << 8
63 } 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 69 of file tableam.h.

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

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:415
int errcode(int sqlerrcode)
Definition: elog.c:610
#define OidIsValid(objectId)
Definition: c.h:644
#define NAMEDATALEN
Oid MyDatabaseId
Definition: globals.c:85
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
#define NOTICE
Definition: elog.h:37
Oid get_table_am_oid(const char *amname, bool missing_ok)
Definition: amcmds.c:173
#define newval
bool IsTransactionState(void)
Definition: xact.c:356
int errmsg(const char *fmt,...)
Definition: elog.c:824

◆ GetHeapamTableAmRoutine()

const TableAmRoutine* GetHeapamTableAmRoutine ( void  )

Definition at line 2545 of file heapam_handler.c.

References heapam_methods.

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

2546 {
2547  return &heapam_methods;
2548 }
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:223
void(* relation_estimate_size)(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac)
Definition: tableam.h:618
#define IsA(nodeptr, _type_)
Definition: nodes.h:580
Size(* parallelscan_estimate)(Relation rel)
Definition: tableam.h:237
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:389
struct IndexFetchTableData *(* index_fetch_begin)(Relation rel)
Definition: tableam.h:268
void(* index_fetch_reset)(struct IndexFetchTableData *data)
Definition: tableam.h:274
void(* scan_end)(TableScanDesc scan)
Definition: tableam.h:210
bool(* scan_sample_next_block)(TableScanDesc scan, struct SampleScanState *scanstate)
Definition: tableam.h:702
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:318
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:345
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:244
void(* tuple_insert_speculative)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate, uint32 specToken)
Definition: tableam.h:361
void(* scan_rescan)(TableScanDesc scan, struct ScanKeyData *key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition: tableam.h:216
void(* tuple_insert)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:356
#define ERROR
Definition: elog.h:43
void(* tuple_complete_speculative)(Relation rel, TupleTableSlot *slot, uint32 specToken, bool succeeded)
Definition: tableam.h:369
bool(* scan_bitmap_next_block)(TableScanDesc scan, struct TBMIterateResult *tbmres)
Definition: tableam.h:659
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:200
void(* multi_insert)(Relation rel, TupleTableSlot **slots, int nslots, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:375
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:673
void(* relation_copy_data)(Relation rel, const RelFileNode *newrnode)
Definition: tableam.h:469
void(* parallelscan_reinitialize)(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:251
uintptr_t Datum
Definition: postgres.h:367
bool(* relation_needs_toast_table)(Relation rel)
Definition: tableam.h:582
#define OidFunctionCall0(functionId)
Definition: fmgr.h:660
void(* index_fetch_end)(struct IndexFetchTableData *data)
Definition: tableam.h:279
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:401
#define Assert(condition)
Definition: c.h:738
void(* tuple_get_latest_tid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:333
bool(* tuple_satisfies_snapshot)(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
Definition: tableam.h:340
bool(* scan_sample_next_tuple)(TableScanDesc scan, struct SampleScanState *scanstate, TupleTableSlot *slot)
Definition: tableam.h:718
#define DatumGetPointer(X)
Definition: postgres.h:549
bool(* tuple_tid_valid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:326
#define elog(elevel,...)
Definition: elog.h:214
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:301
TM_Result(* tuple_delete)(Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
Definition: tableam.h:379

◆ simple_table_tuple_delete()

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

Definition at line 279 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().

280 {
281  TM_Result result;
282  TM_FailureData tmfd;
283 
284  result = table_tuple_delete(rel, tid,
285  GetCurrentCommandId(true),
286  snapshot, InvalidSnapshot,
287  true /* wait for commit */ ,
288  &tmfd, false /* changingPart */ );
289 
290  switch (result)
291  {
292  case TM_SelfModified:
293  /* Tuple was already updated in current command? */
294  elog(ERROR, "tuple already updated by self");
295  break;
296 
297  case TM_Ok:
298  /* done successfully */
299  break;
300 
301  case TM_Updated:
302  elog(ERROR, "tuple concurrently updated");
303  break;
304 
305  case TM_Deleted:
306  elog(ERROR, "tuple concurrently deleted");
307  break;
308 
309  default:
310  elog(ERROR, "unrecognized table_tuple_delete status: %u", result);
311  break;
312  }
313 }
#define ERROR
Definition: elog.h:43
#define InvalidSnapshot
Definition: snapshot.h:123
TM_Result
Definition: tableam.h:69
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:1241
Definition: tableam.h:75
#define elog(elevel,...)
Definition: elog.h:214
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:746

◆ simple_table_tuple_insert()

void simple_table_tuple_insert ( Relation  rel,
TupleTableSlot slot 
)

Definition at line 265 of file tableam.c.

References GetCurrentCommandId(), and table_tuple_insert().

Referenced by ExecSimpleRelationInsert(), and table_scan_sample_next_tuple().

266 {
267  table_tuple_insert(rel, slot, GetCurrentCommandId(true), 0, NULL);
268 }
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:1152
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:746

◆ simple_table_tuple_update()

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

Definition at line 324 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().

328 {
329  TM_Result result;
330  TM_FailureData tmfd;
331  LockTupleMode lockmode;
332 
333  result = table_tuple_update(rel, otid, slot,
334  GetCurrentCommandId(true),
335  snapshot, InvalidSnapshot,
336  true /* wait for commit */ ,
337  &tmfd, &lockmode, update_indexes);
338 
339  switch (result)
340  {
341  case TM_SelfModified:
342  /* Tuple was already updated in current command? */
343  elog(ERROR, "tuple already updated by self");
344  break;
345 
346  case TM_Ok:
347  /* done successfully */
348  break;
349 
350  case TM_Updated:
351  elog(ERROR, "tuple concurrently updated");
352  break;
353 
354  case TM_Deleted:
355  elog(ERROR, "tuple concurrently deleted");
356  break;
357 
358  default:
359  elog(ERROR, "unrecognized table_tuple_update status: %u", result);
360  break;
361  }
362 
363 }
LockTupleMode
Definition: lockoptions.h:49
#define ERROR
Definition: elog.h:43
#define InvalidSnapshot
Definition: snapshot.h:123
TM_Result
Definition: tableam.h:69
Definition: tableam.h:75
#define elog(elevel,...)
Definition: elog.h:214
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:746
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:1285

◆ table_beginscan()

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

Definition at line 754 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(), DefineQueryRewrite(), heapam_relation_copy_for_cluster(), pgrowlocks(), pgstat_collect_oids(), RelationFindReplTupleSeq(), SeqNext(), validateCheckConstraint(), validateDomainConstraint(), and validateForeignKeyConstraint().

756 {
757  uint32 flags = SO_TYPE_SEQSCAN |
759 
760  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
761 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:200
unsigned int uint32
Definition: c.h:367
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_beginscan_analyze()

static TableScanDesc table_beginscan_analyze ( Relation  rel)
inlinestatic

Definition at line 851 of file tableam.h.

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

Referenced by acquire_sample_rows().

852 {
853  uint32 flags = SO_TYPE_ANALYZE;
854 
855  return rel->rd_tableam->scan_begin(rel, NULL, 0, NULL, NULL, flags);
856 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:200
unsigned int uint32
Definition: c.h:367
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_beginscan_bm()

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

Definition at line 799 of file tableam.h.

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

Referenced by ExecInitBitmapHeapScan().

801 {
803 
804  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
805 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:200
unsigned int uint32
Definition: c.h:367
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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(), 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:367
#define RelationGetRelid(relation)
Definition: rel.h:456

◆ 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:367
#define Assert(condition)
Definition: c.h:738
#define SnapshotAny
Definition: snapmgr.h:69
#define RelationGetRelid(relation)
Definition: rel.h:456

◆ 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 815 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().

819 {
820  uint32 flags = SO_TYPE_SAMPLESCAN;
821 
822  if (allow_strat)
823  flags |= SO_ALLOW_STRAT;
824  if (allow_sync)
825  flags |= SO_ALLOW_SYNC;
826  if (allow_pagemode)
827  flags |= SO_ALLOW_PAGEMODE;
828 
829  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
830 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:200
unsigned int uint32
Definition: c.h:367
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 778 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().

781 {
783 
784  if (allow_strat)
785  flags |= SO_ALLOW_STRAT;
786  if (allow_sync)
787  flags |= SO_ALLOW_SYNC;
788 
789  return rel->rd_tableam->scan_begin(rel, snapshot, nkeys, key, NULL, flags);
790 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:200
unsigned int uint32
Definition: c.h:367
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_beginscan_tid()

static TableScanDesc table_beginscan_tid ( Relation  rel,
Snapshot  snapshot 
)
inlinestatic

Definition at line 838 of file tableam.h.

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

Referenced by currtid_byrelname(), currtid_byreloid(), and TidListEval().

839 {
840  uint32 flags = SO_TYPE_TIDSCAN;
841 
842  return rel->rd_tableam->scan_begin(rel, snapshot, 0, NULL, NULL, flags);
843 }
TableScanDesc(* scan_begin)(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, ParallelTableScanDesc pscan, uint32 flags)
Definition: tableam.h:200
unsigned int uint32
Definition: c.h:367
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_block_parallelscan_estimate()

Size table_block_parallelscan_estimate ( Relation  rel)

Definition at line 372 of file tableam.c.

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

373 {
374  return sizeof(ParallelBlockTableScanDescData);
375 }
struct ParallelBlockTableScanDescData ParallelBlockTableScanDescData

◆ table_block_parallelscan_initialize()

Size table_block_parallelscan_initialize ( Relation  rel,
ParallelTableScanDesc  pscan 
)

Definition at line 378 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().

379 {
381 
382  bpscan->base.phs_relid = RelationGetRelid(rel);
383  bpscan->phs_nblocks = RelationGetNumberOfBlocks(rel);
384  /* compare phs_syncscan initialization to similar logic in initscan */
386  !RelationUsesLocalBuffers(rel) &&
387  bpscan->phs_nblocks > NBuffers / 4;
388  SpinLockInit(&bpscan->phs_mutex);
390  pg_atomic_init_u64(&bpscan->phs_nallocated, 0);
391 
392  return sizeof(ParallelBlockTableScanDescData);
393 }
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:211
#define InvalidBlockNumber
Definition: block.h:33
#define RelationUsesLocalBuffers(relation)
Definition: rel.h:572
int NBuffers
Definition: globals.c:131
#define RelationGetRelid(relation)
Definition: rel.h:456

◆ table_block_parallelscan_nextpage()

BlockNumber table_block_parallelscan_nextpage ( Relation  rel,
ParallelBlockTableScanDesc  pbscan 
)

Definition at line 454 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().

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

References pg_atomic_write_u64(), and ParallelBlockTableScanDescData::phs_nallocated.

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

397 {
399 
400  pg_atomic_write_u64(&bpscan->phs_nallocated, 0);
401 }
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 411 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().

412 {
413  BlockNumber sync_startpage = InvalidBlockNumber;
414 
415 retry:
416  /* Grab the spinlock. */
417  SpinLockAcquire(&pbscan->phs_mutex);
418 
419  /*
420  * If the scan's startblock has not yet been initialized, we must do so
421  * now. If this is not a synchronized scan, we just start at block 0, but
422  * if it is a synchronized scan, we must get the starting position from
423  * the synchronized scan machinery. We can't hold the spinlock while
424  * doing that, though, so release the spinlock, get the information we
425  * need, and retry. If nobody else has initialized the scan in the
426  * meantime, we'll fill in the value we fetched on the second time
427  * through.
428  */
429  if (pbscan->phs_startblock == InvalidBlockNumber)
430  {
431  if (!pbscan->base.phs_syncscan)
432  pbscan->phs_startblock = 0;
433  else if (sync_startpage != InvalidBlockNumber)
434  pbscan->phs_startblock = sync_startpage;
435  else
436  {
437  SpinLockRelease(&pbscan->phs_mutex);
438  sync_startpage = ss_get_location(rel, pbscan->phs_nblocks);
439  goto retry;
440  }
441  }
442  SpinLockRelease(&pbscan->phs_mutex);
443 }
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 552 of file tableam.c.

References get_rel_data_width(), RelationData::rd_rel, and RelationGetNumberOfBlocks.

Referenced by heapam_estimate_rel_size(), and table_scan_sample_next_tuple().

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

◆ table_block_relation_size()

uint64 table_block_relation_size ( Relation  rel,
ForkNumber  forkNumber 
)

Definition at line 512 of file tableam.c.

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

Referenced by SampleHeapTupleVisible(), and table_scan_sample_next_tuple().

513 {
514  uint64 nblocks = 0;
515 
516  /* Open it at the smgr level if not already done */
517  RelationOpenSmgr(rel);
518 
519  /* InvalidForkNumber indicates returning the size for all forks */
520  if (forkNumber == InvalidForkNumber)
521  {
522  for (int i = 0; i < MAX_FORKNUM; i++)
523  nblocks += smgrnblocks(rel->rd_smgr, i);
524  }
525  else
526  nblocks = smgrnblocks(rel->rd_smgr, forkNumber);
527 
528  return nblocks * BLCKSZ;
529 }
struct SMgrRelationData * rd_smgr
Definition: rel.h:57
#define RelationOpenSmgr(relation)
Definition: rel.h:513
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
Definition: smgr.c:538
#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 1104 of file tableam.h.

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

Referenced by _bt_xid_horizon(), and index_compute_xid_horizon_for_tuples().

1107 {
1108  return rel->rd_tableam->compute_xid_horizon_for_tuples(rel, items, nitems);
1109 }
TransactionId(* compute_xid_horizon_for_tuples)(Relation rel, ItemPointerData *items, int nitems)
Definition: tableam.h:345
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_endscan()

static void table_endscan ( TableScanDesc  scan)
inlinestatic

Definition at line 862 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(), RemoveSubscriptionRel(), RenameTableSpace(), systable_endscan(), ThereIsAtLeastOneRole(), vac_truncate_clog(), validateCheckConstraint(), validateDomainConstraint(), and validateForeignKeyConstraint().

863 {
864  scan->rs_rd->rd_tableam->scan_end(scan);
865 }
void(* scan_end)(TableScanDesc scan)
Definition: tableam.h:210
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1345 of file tableam.h.

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

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

1346 {
1347  /* optional callback */
1348  if (rel->rd_tableam && rel->rd_tableam->finish_bulk_insert)
1350 }
void(* finish_bulk_insert)(Relation rel, int options)
Definition: tableam.h:423
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1559 of file tableam.h.

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

Referenced by summarize_range().

1570 {
1571  return table_rel->rd_tableam->index_build_range_scan(table_rel,
1572  index_rel,
1573  index_info,
1574  allow_sync,
1575  anyvisible,
1576  progress,
1577  start_blockno,
1578  numblocks,
1579  callback,
1580  callback_state,
1581  scan);
1582 }
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:234
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1526 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().

1534 {
1535  return table_rel->rd_tableam->index_build_range_scan(table_rel,
1536  index_rel,
1537  index_info,
1538  allow_sync,
1539  false,
1540  progress,
1541  0,
1543  callback,
1544  callback_state,
1545  scan);
1546 }
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:234
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
#define InvalidBlockNumber
Definition: block.h:33

◆ table_index_fetch_begin()

static IndexFetchTableData* table_index_fetch_begin ( Relation  rel)
inlinestatic

Definition at line 965 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().

966 {
967  return rel->rd_tableam->index_fetch_begin(rel);
968 }
struct IndexFetchTableData *(* index_fetch_begin)(Relation rel)
Definition: tableam.h:268
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_index_fetch_end()

static void table_index_fetch_end ( struct IndexFetchTableData scan)
inlinestatic

Definition at line 984 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().

985 {
986  scan->rel->rd_tableam->index_fetch_end(scan);
987 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
void(* index_fetch_end)(struct IndexFetchTableData *data)
Definition: tableam.h:279
Relation rel
Definition: relscan.h:91

◆ table_index_fetch_reset()

static void table_index_fetch_reset ( struct IndexFetchTableData scan)
inlinestatic

Definition at line 975 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().

976 {
977  scan->rel->rd_tableam->index_fetch_reset(scan);
978 }
void(* index_fetch_reset)(struct IndexFetchTableData *data)
Definition: tableam.h:274
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1014 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().

1019 {
1020 
1021  return scan->rel->rd_tableam->index_fetch_tuple(scan, tid, snapshot,
1022  slot, call_again,
1023  all_dead);
1024 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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:301

◆ table_index_fetch_tuple_check()

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

Definition at line 205 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().

209 {
210  IndexFetchTableData *scan;
211  TupleTableSlot *slot;
212  bool call_again = false;
213  bool found;
214 
215  slot = table_slot_create(rel, NULL);
216  scan = table_index_fetch_begin(rel);
217  found = table_index_fetch_tuple(scan, tid, snapshot, slot, &call_again,
218  all_dead);
219  table_index_fetch_end(scan);
221 
222  return found;
223 }
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
Definition: tableam.c:77
static IndexFetchTableData * table_index_fetch_begin(Relation rel)
Definition: tableam.h:965
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:1014
static void table_index_fetch_end(struct IndexFetchTableData *scan)
Definition: tableam.h:984

◆ 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 1590 of file tableam.h.

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

Referenced by validate_index().

1595 {
1596  table_rel->rd_tableam->index_validate_scan(table_rel,
1597  index_rel,
1598  index_info,
1599  snapshot,
1600  state);
1601 }
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:171

◆ 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 1207 of file tableam.h.

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

Referenced by CopyMultiInsertBufferFlush().

1209 {
1210  rel->rd_tableam->multi_insert(rel, slots, nslots,
1211  cid, options, bistate);
1212 }
void(* multi_insert)(Relation rel, TupleTableSlot **slots, int nslots, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:375
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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:237
Size EstimateSnapshotSpace(Snapshot snap)
Definition: snapmgr.c:2078
Size add_size(Size s1, Size s2)
Definition: shmem.c:498
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
#define IsMVCCSnapshot(snapshot)
Definition: snapmgr.h:97
#define Assert(condition)
Definition: c.h:738
size_t Size
Definition: c.h:466
#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:244
void SerializeSnapshot(Snapshot snapshot, char *start_address)
Definition: snapmgr.c:2102
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
#define IsMVCCSnapshot(snapshot)
Definition: snapmgr.h:97
#define Assert(condition)
Definition: c.h:738
size_t Size
Definition: c.h:466
#define SnapshotAny
Definition: snapmgr.h:69

◆ table_parallelscan_reinitialize()

static void table_parallelscan_reinitialize ( Relation  rel,
ParallelTableScanDesc  pscan 
)
inlinestatic

Definition at line 947 of file tableam.h.

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

Referenced by ExecSeqScanReInitializeDSM().

948 {
949  rel->rd_tableam->parallelscan_reinitialize(rel, pscan);
950 }
void(* parallelscan_reinitialize)(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:251
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_relation_copy_data()

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

Definition at line 1400 of file tableam.h.

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

Referenced by ATExecSetTableSpace().

1401 {
1402  rel->rd_tableam->relation_copy_data(rel, newrnode);
1403 }
void(* relation_copy_data)(Relation rel, const RelFileNode *newrnode)
Definition: tableam.h:469
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1427 of file tableam.h.

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

Referenced by copy_table_data().

1436 {
1437  OldTable->rd_tableam->relation_copy_for_cluster(OldTable, NewTable, OldIndex,
1438  use_sort, OldestXmin,
1439  xid_cutoff, multi_cutoff,
1440  num_tuples, tups_vacuumed,
1441  tups_recently_dead);
1442 }
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:332
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1688 of file tableam.h.

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

Referenced by estimate_rel_size().

1691 {
1692  rel->rd_tableam->relation_estimate_size(rel, attr_widths, pages, tuples,
1693  allvisfrac);
1694 }
void(* relation_estimate_size)(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac)
Definition: tableam.h:618
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_relation_fetch_toast_slice()

static void table_relation_fetch_toast_slice ( Relation  toastrel,
Oid  valueid,
int32  attrsize,
int32  sliceoffset,
int32  slicelength,
struct varlena result 
)
inlinestatic

Definition at line 1667 of file tableam.h.

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

Referenced by toast_fetch_datum(), and toast_fetch_datum_slice().

1670 {
1671  toastrel->rd_tableam->relation_fetch_toast_slice(toastrel, valueid,
1672  attrsize,
1673  sliceoffset, slicelength,
1674  result);
1675 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
void(* relation_fetch_toast_slice)(Relation toastrel, Oid valueid, int32 attrsize, int32 sliceoffset, int32 slicelength, struct varlena *result)
Definition: tableam.h:596

◆ table_relation_needs_toast_table()

static bool table_relation_needs_toast_table ( Relation  rel)
inlinestatic

Definition at line 1628 of file tableam.h.

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

Referenced by needs_toast_table().

1629 {
1630  return rel->rd_tableam->relation_needs_toast_table(rel);
1631 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1388 of file tableam.h.

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

Referenced by heap_truncate_one_rel().

1389 {
1391 }
void(* relation_nontransactional_truncate)(Relation rel)
Definition: tableam.h:461
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1371 of file tableam.h.

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

Referenced by heap_create(), and RelationSetNewRelfilenode().

1376 {
1377  rel->rd_tableam->relation_set_new_filenode(rel, newrnode, persistence,
1378  freezeXid, minmulti);
1379 }
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:171

◆ table_relation_size()

static uint64 table_relation_size ( Relation  rel,
ForkNumber  forkNumber 
)
inlinestatic

Definition at line 1619 of file tableam.h.

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

Referenced by RelationGetNumberOfBlocksInFork().

1620 {
1621  return rel->rd_tableam->relation_size(rel, forkNumber);
1622 }
uint64(* relation_size)(Relation rel, ForkNumber forkNumber)
Definition: tableam.h:572
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_relation_toast_am()

static Oid table_relation_toast_am ( Relation  rel)
inlinestatic

Definition at line 1638 of file tableam.h.

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

Referenced by create_toast_table().

1639 {
1640  return rel->rd_tableam->relation_toast_am(rel);
1641 }
Oid(* relation_toast_am)(Relation rel)
Definition: tableam.h:589
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_relation_vacuum()

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

Definition at line 1456 of file tableam.h.

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

Referenced by vacuum_rel().

1458 {
1459  rel->rd_tableam->relation_vacuum(rel, params, bstrategy);
1460 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 871 of file tableam.h.

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

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

873 {
874  scan->rs_rd->rd_tableam->scan_rescan(scan, key, false, false, false, false);
875 }
void(* scan_rescan)(TableScanDesc scan, struct ScanKeyData *key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition: tableam.h:216
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 886 of file tableam.h.

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

Referenced by tablesample_init().

888 {
889  scan->rs_rd->rd_tableam->scan_rescan(scan, key, true,
890  allow_strat, allow_sync,
891  allow_pagemode);
892 }
void(* scan_rescan)(TableScanDesc scan, struct ScanKeyData *key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition: tableam.h:216
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1471 of file tableam.h.

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

Referenced by acquire_sample_rows().

1473 {
1474  return scan->rs_rd->rd_tableam->scan_analyze_next_block(scan, blockno,
1475  bstrategy);
1476 }
bool(* scan_analyze_next_block)(TableScanDesc scan, BlockNumber blockno, BufferAccessStrategy bstrategy)
Definition: tableam.h:520
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1489 of file tableam.h.

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

Referenced by acquire_sample_rows().

1492 {
1493  return scan->rs_rd->rd_tableam->scan_analyze_next_tuple(scan, OldestXmin,
1494  liverows, deadrows,
1495  slot);
1496 }
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:332
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1712 of file tableam.h.

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

Referenced by BitmapHeapNext().

1714 {
1715  return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
1716  tbmres);
1717 }
bool(* scan_bitmap_next_block)(TableScanDesc scan, struct TBMIterateResult *tbmres)
Definition: tableam.h:659
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1728 of file tableam.h.

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

Referenced by BitmapHeapNext().

1731 {
1732  return scan->rs_rd->rd_tableam->scan_bitmap_next_tuple(scan,
1733  tbmres,
1734  slot);
1735 }
bool(* scan_bitmap_next_tuple)(TableScanDesc scan, struct TBMIterateResult *tbmres, TupleTableSlot *slot)
Definition: tableam.h:673
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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 1747 of file tableam.h.

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

Referenced by tablesample_getnext().

1749 {
1750  return scan->rs_rd->rd_tableam->scan_sample_next_block(scan, scanstate);
1751 }
bool(* scan_sample_next_block)(TableScanDesc scan, struct SampleScanState *scanstate)
Definition: tableam.h:702
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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:738
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:738
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_tuple_routing(), check_default_partition_contents(), check_exclusion_or_unique_constraint(), CopyFrom(), CopyMultiInsertInfoNextFreeSlot(), CopyTo(), DefineQueryRewrite(), EvalPlanQualSlot(), ExecInitModifyTable(), ExecInitPartitionInfo(), ExecInitRoutingInfo(), FindReplTupleInLocalRel(), 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:482
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:321

◆ table_tuple_complete_speculative()

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

Definition at line 1185 of file tableam.h.

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

Referenced by ExecInsert().

1187 {
1188  rel->rd_tableam->tuple_complete_speculative(rel, slot, specToken,
1189  succeeded);
1190 }
void(* tuple_complete_speculative)(Relation rel, TupleTableSlot *slot, uint32 specToken, bool succeeded)
Definition: tableam.h:369
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1241 of file tableam.h.

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

Referenced by ExecDelete(), and simple_table_tuple_delete().

1244 {
1245  return rel->rd_tableam->tuple_delete(rel, tid, cid,
1246  snapshot, crosscheck,
1247  wait, tmfd, changingPart);
1248 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
TM_Result(* tuple_delete)(Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
Definition: tableam.h:379

◆ table_tuple_fetch_row_version()

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

Definition at line 1054 of file tableam.h.

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

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

1058 {
1059  return rel->rd_tableam->tuple_fetch_row_version(rel, tid, snapshot, slot);
1060 }
bool(* tuple_fetch_row_version)(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
Definition: tableam.h:318
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ table_tuple_get_latest_tid()

void table_tuple_get_latest_tid ( TableScanDesc  scan,
ItemPointer  tid 
)

Definition at line 232 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().

233 {
234  Relation rel = scan->rs_rd;
235  const TableAmRoutine *tableam = rel->rd_tableam;
236 
237  /*
238  * Since this can be called with user-supplied TID, don't trust the input
239  * too much.
240  */
241  if (!tableam->tuple_tid_valid(scan, tid))
242  ereport(ERROR,
243  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
244  errmsg("tid (%u, %u) is not valid for relation \"%s\"",
247  RelationGetRelationName(rel))));
248 
249  tableam->tuple_get_latest_tid(scan, tid);
250 }
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
int errcode(int sqlerrcode)
Definition: elog.c:610
#define ERROR
Definition: elog.h:43
#define RelationGetRelationName(relation)
Definition: rel.h:490
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
#define ereport(elevel,...)
Definition: elog.h:144
void(* tuple_get_latest_tid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:333
Relation rs_rd
Definition: relscan.h:34
bool(* tuple_tid_valid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:326
int errmsg(const char *fmt,...)
Definition: elog.c:824
#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 1152 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().

1154 {
1155  rel->rd_tableam->tuple_insert(rel, slot, cid, options,
1156  bistate);
1157 }
void(* tuple_insert)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:356
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1171 of file tableam.h.

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

Referenced by ExecInsert().

1175 {
1176  rel->rd_tableam->tuple_insert_speculative(rel, slot, cid, options,
1177  bistate, specToken);
1178 }
void(* tuple_insert_speculative)(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate, uint32 specToken)
Definition: tableam.h:361
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

◆ 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 1330 of file tableam.h.

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

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

1334 {
1335  return rel->rd_tableam->tuple_lock(rel, tid, snapshot, slot,
1336  cid, mode, wait_policy,
1337  flags, tmfd);
1338 }
static PgChecksumMode mode
Definition: pg_checksums.c:61
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
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:401

◆ table_tuple_satisfies_snapshot()

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

Definition at line 1092 of file tableam.h.

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

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

1094 {
1095  return rel->rd_tableam->tuple_satisfies_snapshot(rel, slot, snapshot);
1096 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
bool(* tuple_satisfies_snapshot)(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
Definition: tableam.h:340

◆ table_tuple_tid_valid()

static bool table_tuple_tid_valid ( TableScanDesc  scan,
ItemPointer  tid 
)
inlinestatic

Definition at line 1071 of file tableam.h.

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

Referenced by TidListEval().

1072 {
1073  return scan->rs_rd->rd_tableam->tuple_tid_valid(scan, tid);
1074 }
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171
Relation rs_rd
Definition: relscan.h:34
bool(* tuple_tid_valid)(TableScanDesc scan, ItemPointer tid)
Definition: tableam.h:326

◆ 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 1285 of file tableam.h.

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

Referenced by ExecUpdate(), and simple_table_tuple_update().

1289 {
1290  return rel->rd_tableam->tuple_update(rel, otid, slot,
1291  cid, snapshot, crosscheck,
1292  wait, tmfd,
1293  lockmode, update_indexes);
1294 }
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:389
const struct TableAmRoutine * rd_tableam
Definition: rel.h:171

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().