Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
relscan.h192 linesDownload Raw Back to access
1/*-------------------------------------------------------------------------2 *3 * relscan.h4 *	  POSTGRES relation scan descriptor definitions.5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/access/relscan.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef RELSCAN_H15#define RELSCAN_H16 17#include "access/htup_details.h"18#include "access/itup.h"19#include "port/atomics.h"20#include "storage/buf.h"21#include "storage/spin.h"22#include "utils/relcache.h"23 24 25struct ParallelTableScanDescData;26 27/*28 * Generic descriptor for table scans. This is the base-class for table scans,29 * which needs to be embedded in the scans of individual AMs.30 */31typedef struct TableScanDescData32{33	/* scan parameters */34	Relation	rs_rd;			/* heap relation descriptor */35	struct SnapshotData *rs_snapshot;	/* snapshot to see */36	int			rs_nkeys;		/* number of scan keys */37	struct ScanKeyData *rs_key; /* array of scan key descriptors */38 39	/* Range of ItemPointers for table_scan_getnextslot_tidrange() to scan. */40	ItemPointerData rs_mintid;41	ItemPointerData rs_maxtid;42 43	/*44	 * Information about type and behaviour of the scan, a bitmask of members45	 * of the ScanOptions enum (see tableam.h).46	 */47	uint32		rs_flags;48 49	struct ParallelTableScanDescData *rs_parallel;	/* parallel scan50													 * information */51} TableScanDescData;52typedef struct TableScanDescData *TableScanDesc;53 54/*55 * Shared state for parallel table scan.56 *57 * Each backend participating in a parallel table scan has its own58 * TableScanDesc in backend-private memory, and those objects all contain a59 * pointer to this structure.  The information here must be sufficient to60 * properly initialize each new TableScanDesc as workers join the scan, and it61 * must act as a information what to scan for those workers.62 */63typedef struct ParallelTableScanDescData64{65	Oid			phs_relid;		/* OID of relation to scan */66	bool		phs_syncscan;	/* report location to syncscan logic? */67	bool		phs_snapshot_any;	/* SnapshotAny, not phs_snapshot_data? */68	Size		phs_snapshot_off;	/* data for snapshot */69} ParallelTableScanDescData;70typedef struct ParallelTableScanDescData *ParallelTableScanDesc;71 72/*73 * Shared state for parallel table scans, for block oriented storage.74 */75typedef struct ParallelBlockTableScanDescData76{77	ParallelTableScanDescData base;78 79	BlockNumber phs_nblocks;	/* # blocks in relation at start of scan */80	slock_t		phs_mutex;		/* mutual exclusion for setting startblock */81	BlockNumber phs_startblock; /* starting block number */82	pg_atomic_uint64 phs_nallocated;	/* number of blocks allocated to83										 * workers so far. */84}			ParallelBlockTableScanDescData;85typedef struct ParallelBlockTableScanDescData *ParallelBlockTableScanDesc;86 87/*88 * Per backend state for parallel table scan, for block-oriented storage.89 */90typedef struct ParallelBlockTableScanWorkerData91{92	uint64		phsw_nallocated;	/* Current # of blocks into the scan */93	uint32		phsw_chunk_remaining;	/* # blocks left in this chunk */94	uint32		phsw_chunk_size;	/* The number of blocks to allocate in95									 * each I/O chunk for the scan */96} ParallelBlockTableScanWorkerData;97typedef struct ParallelBlockTableScanWorkerData *ParallelBlockTableScanWorker;98 99/*100 * Base class for fetches from a table via an index. This is the base-class101 * for such scans, which needs to be embedded in the respective struct for102 * individual AMs.103 */104typedef struct IndexFetchTableData105{106	Relation	rel;107} IndexFetchTableData;108 109/*110 * We use the same IndexScanDescData structure for both amgettuple-based111 * and amgetbitmap-based index scans.  Some fields are only relevant in112 * amgettuple-based scans.113 */114typedef struct IndexScanDescData115{116	/* scan parameters */117	Relation	heapRelation;	/* heap relation descriptor, or NULL */118	Relation	indexRelation;	/* index relation descriptor */119	struct SnapshotData *xs_snapshot;	/* snapshot to see */120	int			numberOfKeys;	/* number of index qualifier conditions */121	int			numberOfOrderBys;	/* number of ordering operators */122	struct ScanKeyData *keyData;	/* array of index qualifier descriptors */123	struct ScanKeyData *orderByData;	/* array of ordering op descriptors */124	bool		xs_want_itup;	/* caller requests index tuples */125	bool		xs_temp_snap;	/* unregister snapshot at scan end? */126 127	/* signaling to index AM about killing index tuples */128	bool		kill_prior_tuple;	/* last-returned tuple is dead */129	bool		ignore_killed_tuples;	/* do not return killed entries */130	bool		xactStartedInRecovery;	/* prevents killing/seeing killed131										 * tuples */132 133	/* index access method's private state */134	void	   *opaque;			/* access-method-specific info */135 136	/*137	 * In an index-only scan, a successful amgettuple call must fill either138	 * xs_itup (and xs_itupdesc) or xs_hitup (and xs_hitupdesc) to provide the139	 * data returned by the scan.  It can fill both, in which case the heap140	 * format will be used.141	 */142	IndexTuple	xs_itup;		/* index tuple returned by AM */143	struct TupleDescData *xs_itupdesc;	/* rowtype descriptor of xs_itup */144	HeapTuple	xs_hitup;		/* index data returned by AM, as HeapTuple */145	struct TupleDescData *xs_hitupdesc; /* rowtype descriptor of xs_hitup */146 147	ItemPointerData xs_heaptid; /* result */148	bool		xs_heap_continue;	/* T if must keep walking, potential149									 * further results */150	IndexFetchTableData *xs_heapfetch;151 152	bool		xs_recheck;		/* T means scan keys must be rechecked */153 154	/*155	 * When fetching with an ordering operator, the values of the ORDER BY156	 * expressions of the last returned tuple, according to the index.  If157	 * xs_recheckorderby is true, these need to be rechecked just like the158	 * scan keys, and the values returned here are a lower-bound on the actual159	 * values.160	 */161	Datum	   *xs_orderbyvals;162	bool	   *xs_orderbynulls;163	bool		xs_recheckorderby;164 165	/* parallel index scan information, in shared memory */166	struct ParallelIndexScanDescData *parallel_scan;167}			IndexScanDescData;168 169/* Generic structure for parallel scans */170typedef struct ParallelIndexScanDescData171{172	Oid			ps_relid;173	Oid			ps_indexid;174	Size		ps_offset;		/* Offset in bytes of am specific structure */175	char		ps_snapshot_data[FLEXIBLE_ARRAY_MEMBER];176}			ParallelIndexScanDescData;177 178struct TupleTableSlot;179 180/* Struct for storage-or-index scans of system tables */181typedef struct SysScanDescData182{183	Relation	heap_rel;		/* catalog being scanned */184	Relation	irel;			/* NULL if doing heap scan */185	struct TableScanDescData *scan; /* only valid in storage-scan case */186	struct IndexScanDescData *iscan;	/* only valid in index-scan case */187	struct SnapshotData *snapshot;	/* snapshot to unregister at end of scan */188	struct TupleTableSlot *slot;189}			SysScanDescData;190 191#endif							/* RELSCAN_H */192 
codekingpro/portable-devtools · Team Ai