PostgreSQL Source Code  git master
genam.c File Reference
#include "postgres.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/relscan.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "catalog/index.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/rls.h"
#include "utils/ruleutils.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Include dependency graph for genam.c:

Go to the source code of this file.

Functions

IndexScanDesc RelationGetIndexScan (Relation indexRelation, int nkeys, int norderbys)
 
void IndexScanEnd (IndexScanDesc scan)
 
char * BuildIndexValueDescription (Relation indexRelation, Datum *values, bool *isnull)
 
TransactionId index_compute_xid_horizon_for_tuples (Relation irel, Relation hrel, Buffer ibuf, OffsetNumber *itemnos, int nitems)
 
SysScanDesc systable_beginscan (Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
 
HeapTuple systable_getnext (SysScanDesc sysscan)
 
bool systable_recheck_tuple (SysScanDesc sysscan, HeapTuple tup)
 
void systable_endscan (SysScanDesc sysscan)
 
SysScanDesc systable_beginscan_ordered (Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, ScanKey key)
 
HeapTuple systable_getnext_ordered (SysScanDesc sysscan, ScanDirection direction)
 
void systable_endscan_ordered (SysScanDesc sysscan)
 

Function Documentation

◆ BuildIndexValueDescription()

char* BuildIndexValueDescription ( Relation  indexRelation,
Datum values,
bool isnull 
)

Definition at line 176 of file genam.c.

References ACL_SELECT, ACLCHECK_OK, appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, attnum, buf, check_enable_rls(), StringInfoData::data, getTypeOutputInfo(), GetUserId(), i, IndexRelationGetNumberOfKeyAttributes, initStringInfo(), InvalidAttrNumber, InvalidOid, OidOutputFunctionCall(), pg_attribute_aclcheck(), pg_class_aclcheck(), pg_get_indexdef_columns(), RelationData::rd_index, RelationData::rd_opcintype, RelationGetRelid, RLS_ENABLED, and val.

Referenced by _bt_check_unique(), check_exclusion_or_unique_constraint(), and comparetup_index_btree().

178 {
180  Form_pg_index idxrec;
181  int indnkeyatts;
182  int i;
183  int keyno;
184  Oid indexrelid = RelationGetRelid(indexRelation);
185  Oid indrelid;
186  AclResult aclresult;
187 
188  indnkeyatts = IndexRelationGetNumberOfKeyAttributes(indexRelation);
189 
190  /*
191  * Check permissions- if the user does not have access to view all of the
192  * key columns then return NULL to avoid leaking data.
193  *
194  * First check if RLS is enabled for the relation. If so, return NULL to
195  * avoid leaking data.
196  *
197  * Next we need to check table-level SELECT access and then, if there is
198  * no access there, check column-level permissions.
199  */
200  idxrec = indexRelation->rd_index;
201  indrelid = idxrec->indrelid;
202  Assert(indexrelid == idxrec->indexrelid);
203 
204  /* RLS check- if RLS is enabled then we don't return anything. */
205  if (check_enable_rls(indrelid, InvalidOid, true) == RLS_ENABLED)
206  return NULL;
207 
208  /* Table-level SELECT is enough, if the user has it */
209  aclresult = pg_class_aclcheck(indrelid, GetUserId(), ACL_SELECT);
210  if (aclresult != ACLCHECK_OK)
211  {
212  /*
213  * No table-level access, so step through the columns in the index and
214  * make sure the user has SELECT rights on all of them.
215  */
216  for (keyno = 0; keyno < indnkeyatts; keyno++)
217  {
218  AttrNumber attnum = idxrec->indkey.values[keyno];
219 
220  /*
221  * Note that if attnum == InvalidAttrNumber, then this is an index
222  * based on an expression and we return no detail rather than try
223  * to figure out what column(s) the expression includes and if the
224  * user has SELECT rights on them.
225  */
226  if (attnum == InvalidAttrNumber ||
227  pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
229  {
230  /* No access, so clean up and return */
231  return NULL;
232  }
233  }
234  }
235 
236  initStringInfo(&buf);
237  appendStringInfo(&buf, "(%s)=(",
238  pg_get_indexdef_columns(indexrelid, true));
239 
240  for (i = 0; i < indnkeyatts; i++)
241  {
242  char *val;
243 
244  if (isnull[i])
245  val = "null";
246  else
247  {
248  Oid foutoid;
249  bool typisvarlena;
250 
251  /*
252  * The provided data is not necessarily of the type stored in the
253  * index; rather it is of the index opclass's input type. So look
254  * at rd_opcintype not the index tupdesc.
255  *
256  * Note: this is a bit shaky for opclasses that have pseudotype
257  * input types such as ANYARRAY or RECORD. Currently, the
258  * typoutput functions associated with the pseudotypes will work
259  * okay, but we might have to try harder in future.
260  */
261  getTypeOutputInfo(indexRelation->rd_opcintype[i],
262  &foutoid, &typisvarlena);
263  val = OidOutputFunctionCall(foutoid, values[i]);
264  }
265 
266  if (i > 0)
267  appendStringInfoString(&buf, ", ");
268  appendStringInfoString(&buf, val);
269  }
270 
271  appendStringInfoChar(&buf, ')');
272 
273  return buf.data;
274 }
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Definition: lsyscache.c:2674
AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode)
Definition: aclchk.c:4515
Oid GetUserId(void)
Definition: miscinit.c:380
char * pg_get_indexdef_columns(Oid indexrelid, bool pretty)
Definition: ruleutils.c:1169
unsigned int Oid
Definition: postgres_ext.h:31
Form_pg_index rd_index
Definition: rel.h:143
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
static char * buf
Definition: pg_test_fsync.c:67
#define IndexRelationGetNumberOfKeyAttributes(relation)
Definition: rel.h:441
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:188
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
FormData_pg_index * Form_pg_index
Definition: pg_index.h:66
AclResult
Definition: acl.h:177
#define ACL_SELECT
Definition: parsenodes.h:75
#define InvalidOid
Definition: postgres_ext.h:36
int16 attnum
Definition: pg_attribute.h:79
int check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
Definition: rls.c:52
#define Assert(condition)
Definition: c.h:739
#define InvalidAttrNumber
Definition: attnum.h:23
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4629
static Datum values[MAXATTR]
Definition: bootstrap.c:167
char * OidOutputFunctionCall(Oid functionId, Datum val)
Definition: fmgr.c:1655
int i
Oid * rd_opcintype
Definition: rel.h:159
int16 AttrNumber
Definition: attnum.h:21
#define RelationGetRelid(relation)
Definition: rel.h:422
long val
Definition: informix.c:664

◆ index_compute_xid_horizon_for_tuples()

TransactionId index_compute_xid_horizon_for_tuples ( Relation  irel,
Relation  hrel,
Buffer  ibuf,
OffsetNumber itemnos,
int  nitems 
)

Definition at line 281 of file genam.c.

References BufferGetPage, i, InvalidTransactionId, ItemPointerCopy, PageGetItem, PageGetItemId, palloc(), pfree(), IndexTupleData::t_tid, and table_compute_xid_horizon_for_tuples().

Referenced by _bt_delitems_delete(), _hash_vacuum_one_page(), and gistprunepage().

286 {
287  ItemPointerData *ttids =
288  (ItemPointerData *) palloc(sizeof(ItemPointerData) * nitems);
289  TransactionId latestRemovedXid = InvalidTransactionId;
290  Page ipage = BufferGetPage(ibuf);
291  IndexTuple itup;
292 
293  /* identify what the index tuples about to be deleted point to */
294  for (int i = 0; i < nitems; i++)
295  {
296  ItemId iitemid;
297 
298  iitemid = PageGetItemId(ipage, itemnos[i]);
299  itup = (IndexTuple) PageGetItem(ipage, iitemid);
300 
301  ItemPointerCopy(&itup->t_tid, &ttids[i]);
302  }
303 
304  /* determine the actual xid horizon */
305  latestRemovedXid =
306  table_compute_xid_horizon_for_tuples(hrel, ttids, nitems);
307 
308  pfree(ttids);
309 
310  return latestRemovedXid;
311 }
uint32 TransactionId
Definition: c.h:514
ItemPointerData t_tid
Definition: itup.h:37
static TransactionId table_compute_xid_horizon_for_tuples(Relation rel, ItemPointerData *items, int nitems)
Definition: tableam.h:1071
void pfree(void *pointer)
Definition: mcxt.c:1056
IndexTupleData * IndexTuple
Definition: itup.h:53
#define InvalidTransactionId
Definition: transam.h:31
#define BufferGetPage(buffer)
Definition: bufmgr.h:159
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
void * palloc(Size size)
Definition: mcxt.c:949
int i
#define PageGetItem(page, itemId)
Definition: bufpage.h:340
Pointer Page
Definition: bufpage.h:78
#define ItemPointerCopy(fromPointer, toPointer)
Definition: itemptr.h:161

◆ IndexScanEnd()

void IndexScanEnd ( IndexScanDesc  scan)

Definition at line 144 of file genam.c.

References IndexScanDescData::keyData, IndexScanDescData::orderByData, and pfree().

Referenced by index_endscan().

145 {
146  if (scan->keyData != NULL)
147  pfree(scan->keyData);
148  if (scan->orderByData != NULL)
149  pfree(scan->orderByData);
150 
151  pfree(scan);
152 }
struct ScanKeyData * orderByData
Definition: relscan.h:108
void pfree(void *pointer)
Definition: mcxt.c:1056
struct ScanKeyData * keyData
Definition: relscan.h:107

◆ RelationGetIndexScan()

IndexScanDesc RelationGetIndexScan ( Relation  indexRelation,
int  nkeys,
int  norderbys 
)

Definition at line 80 of file genam.c.

References IndexScanDescData::heapRelation, IndexScanDescData::ignore_killed_tuples, IndexScanDescData::indexRelation, InvalidSnapshot, IndexScanDescData::keyData, IndexScanDescData::kill_prior_tuple, IndexScanDescData::numberOfKeys, IndexScanDescData::numberOfOrderBys, IndexScanDescData::opaque, IndexScanDescData::orderByData, palloc(), TransactionStartedDuringRecovery(), IndexScanDescData::xactStartedInRecovery, IndexScanDescData::xs_heapfetch, IndexScanDescData::xs_hitup, IndexScanDescData::xs_hitupdesc, IndexScanDescData::xs_itup, IndexScanDescData::xs_itupdesc, IndexScanDescData::xs_snapshot, and IndexScanDescData::xs_want_itup.

Referenced by blbeginscan(), brinbeginscan(), btbeginscan(), dibeginscan(), ginbeginscan(), gistbeginscan(), hashbeginscan(), and spgbeginscan().

81 {
82  IndexScanDesc scan;
83 
84  scan = (IndexScanDesc) palloc(sizeof(IndexScanDescData));
85 
86  scan->heapRelation = NULL; /* may be set later */
87  scan->xs_heapfetch = NULL;
88  scan->indexRelation = indexRelation;
89  scan->xs_snapshot = InvalidSnapshot; /* caller must initialize this */
90  scan->numberOfKeys = nkeys;
91  scan->numberOfOrderBys = norderbys;
92 
93  /*
94  * We allocate key workspace here, but it won't get filled until amrescan.
95  */
96  if (nkeys > 0)
97  scan->keyData = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys);
98  else
99  scan->keyData = NULL;
100  if (norderbys > 0)
101  scan->orderByData = (ScanKey) palloc(sizeof(ScanKeyData) * norderbys);
102  else
103  scan->orderByData = NULL;
104 
105  scan->xs_want_itup = false; /* may be set later */
106 
107  /*
108  * During recovery we ignore killed tuples and don't bother to kill them
109  * either. We do this because the xmin on the primary node could easily be
110  * later than the xmin on the standby node, so that what the primary
111  * thinks is killed is supposed to be visible on standby. So for correct
112  * MVCC for queries during recovery we must ignore these hints and check
113  * all tuples. Do *not* set ignore_killed_tuples to true when running in a
114  * transaction that was started during recovery. xactStartedInRecovery
115  * should not be altered by index AMs.
116  */
117  scan->kill_prior_tuple = false;
120 
121  scan->opaque = NULL;
122 
123  scan->xs_itup = NULL;
124  scan->xs_itupdesc = NULL;
125  scan->xs_hitup = NULL;
126  scan->xs_hitupdesc = NULL;
127 
128  return scan;
129 }
bool TransactionStartedDuringRecovery(void)
Definition: xact.c:954
struct ScanKeyData * orderByData
Definition: relscan.h:108
IndexTuple xs_itup
Definition: relscan.h:127
struct TupleDescData * xs_itupdesc
Definition: relscan.h:128
struct TupleDescData * xs_hitupdesc
Definition: relscan.h:130
struct SnapshotData * xs_snapshot
Definition: relscan.h:104
bool ignore_killed_tuples
Definition: relscan.h:114
Relation indexRelation
Definition: relscan.h:103
Relation heapRelation
Definition: relscan.h:102
bool xactStartedInRecovery
Definition: relscan.h:115
ScanKeyData * ScanKey
Definition: skey.h:75
#define InvalidSnapshot
Definition: snapshot.h:123
IndexFetchTableData * xs_heapfetch
Definition: relscan.h:135
struct ScanKeyData * keyData
Definition: relscan.h:107
void * palloc(Size size)
Definition: mcxt.c:949
HeapTuple xs_hitup
Definition: relscan.h:129
bool kill_prior_tuple
Definition: relscan.h:113
int numberOfOrderBys
Definition: relscan.h:106
struct IndexScanDescData * IndexScanDesc
Definition: genam.h:87

◆ systable_beginscan()

SysScanDesc systable_beginscan ( Relation  heapRelation,
Oid  indexId,
bool  indexOK,
Snapshot  snapshot,
int  nkeys,
ScanKey  key 
)

Definition at line 352 of file genam.c.

References AccessShareLock, elog, ERROR, GetCatalogSnapshot(), SysScanDescData::heap_rel, i, IgnoreSystemIndexes, index_beginscan(), index_open(), index_rescan(), IndexRelationGetNumberOfAttributes, SysScanDescData::irel, SysScanDescData::iscan, palloc(), RelationData::rd_index, RegisterSnapshot(), ReindexIsProcessingIndex(), RelationGetRelid, SysScanDescData::scan, ScanKeyData::sk_attno, SysScanDescData::slot, SysScanDescData::snapshot, table_beginscan_strat(), and table_slot_create().

Referenced by AfterTriggerSetState(), AlterConstraintNamespaces(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDropConstraint(), AlterDomainValidateConstraint(), AlterExtensionNamespace(), AlterPolicy(), AlterSeqNamespaces(), AlterSetting(), ApplyExtensionUpdates(), ApplySetting(), ATExecAddOf(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecDropConstraint(), ATExecValidateConstraint(), ATPrepChangePersistence(), AttrDefaultFetch(), change_owner_fix_column_acls(), change_owner_recurse_to_sequences(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), CheckConstraintFetch(), checkSharedDependencies(), ChooseConstraintName(), CloneFkReferenced(), CloneRowTriggersToPartition(), ConstraintNameExists(), ConstraintNameIsUsed(), copyTemplateDependencies(), CountDBSubscriptions(), CreateComments(), CreateInheritance(), CreatePolicy(), CreateSharedComments(), CreateTrigger(), DefineOpClass(), DefineTSConfiguration(), DeleteAttributeTuples(), DeleteComments(), deleteDependencyRecordsFor(), deleteDependencyRecordsForClass(), DeleteInheritsTuple(), DeleteInitPrivs(), deleteOneObject(), DeleteSecurityLabel(), DeleteSharedComments(), DeleteSharedSecurityLabel(), DeleteSystemAttributeTuples(), drop_parent_dependency(), DropCastById(), DropConfigurationMapping(), dropDatabaseDependencies(), DropRole(), DropTransformById(), EnableDisableTrigger(), EnumValuesDelete(), exec_object_restorecon(), ExecAlterExtensionStmt(), ExecGrant_Largeobject(), extension_config_remove(), fetch_statentries_for_relation(), find_composite_type_dependencies(), find_inheritance_children(), find_language_template(), findDependentObjects(), get_catalog_object_by_oid(), get_constraint_index(), get_database_oid(), get_db_info(), get_domain_constraint_oid(), get_extension_name(), get_extension_oid(), get_extension_schema(), get_index_constraint(), get_index_ref_constraints(), get_object_address_attrdef(), get_partition_parent_worker(), get_pkey_attnames(), get_primary_key_attnos(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_idx_constraint_oid(), get_relation_policy_oid(), get_rels_with_domain(), get_trigger_oid(), GetAllTablesPublications(), GetComment(), GetDatabaseTuple(), GetDatabaseTupleByOid(), GetDefaultOpClass(), getExtensionOfObject(), GetNewOidWithIndex(), getObjectDescription(), getObjectIdentityParts(), getOwnedSequences_internal(), GetParentedForeignKeyRefs(), GetPublicationRelations(), GetSecurityLabel(), GetSharedSecurityLabel(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), has_superclass(), heap_truncate_find_FKs(), index_concurrently_swap(), IndexSetParentIndex(), isObjectPinned(), isSharedObjectPinned(), LargeObjectDrop(), LargeObjectExists(), load_domaintype_info(), load_enum_cache_data(), LookupOpclassInfo(), makeConfigurationDependencies(), MakeConfigurationMapping(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), movedb(), myLargeObjectExists(), pg_extension_config_dump(), pg_extension_ownercheck(), pg_get_constraintdef_worker(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_largeobject_aclmask_snapshot(), pg_largeobject_ownercheck(), RangeDelete(), recordExtensionInitPrivWorker(), recordExtObjInitPriv(), relation_has_policies(), RelationBuildPartitionDesc(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationGetIndexList(), RelationGetStatExtList(), RelationRemoveInheritance(), RelidByRelfilenode(), RemoveAmOpEntryById(), RemoveAmProcEntryById(), RemoveAttrDefault(), RemoveAttrDefaultById(), RemoveCollationById(), RemoveDefaultACLById(), RemoveExtensionById(), RemoveInheritance(), RemovePolicyById(), RemoveRewriteRuleById(), RemoveRoleFromObjectACL(), RemoveRoleFromObjectPolicy(), RemoveStatistics(), RemoveTriggerById(), RemoveTSConfigurationById(), rename_policy(), renametrig(), replorigin_create(), ScanPgRelation(), SearchCatCacheList(), SearchCatCacheMiss(), sepgsql_attribute_post_create(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_proc_setattr(), sepgsql_relation_post_create(), sepgsql_relation_setattr(), sepgsql_relation_setattr_extra(), sepgsql_schema_post_create(), sequenceIsOwned(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), shdepDropDependency(), shdepDropOwned(), shdepReassignOwned(), toastrel_valueid_exists(), tryAttachPartitionForeignKey(), typeInheritsFrom(), vac_update_datfrozenxid(), and validatePartitionedIndex().

357 {
358  SysScanDesc sysscan;
359  Relation irel;
360 
361  if (indexOK &&
363  !ReindexIsProcessingIndex(indexId))
364  irel = index_open(indexId, AccessShareLock);
365  else
366  irel = NULL;
367 
368  sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData));
369 
370  sysscan->heap_rel = heapRelation;
371  sysscan->irel = irel;
372  sysscan->slot = table_slot_create(heapRelation, NULL);
373 
374  if (snapshot == NULL)
375  {
376  Oid relid = RelationGetRelid(heapRelation);
377 
378  snapshot = RegisterSnapshot(GetCatalogSnapshot(relid));
379  sysscan->snapshot = snapshot;
380  }
381  else
382  {
383  /* Caller is responsible for any snapshot. */
384  sysscan->snapshot = NULL;
385  }
386 
387  if (irel)
388  {
389  int i;
390 
391  /* Change attribute numbers to be index column numbers. */
392  for (i = 0; i < nkeys; i++)
393  {
394  int j;
395 
396  for (j = 0; j < IndexRelationGetNumberOfAttributes(irel); j++)
397  {
398  if (key[i].sk_attno == irel->rd_index->indkey.values[j])
399  {
400  key[i].sk_attno = j + 1;
401  break;
402  }
403  }
404  if (j == IndexRelationGetNumberOfAttributes(irel))
405  elog(ERROR, "column is not in index");
406  }
407 
408  sysscan->iscan = index_beginscan(heapRelation, irel,
409  snapshot, nkeys, 0);
410  index_rescan(sysscan->iscan, key, nkeys, NULL, 0);
411  sysscan->scan = NULL;
412  }
413  else
414  {
415  /*
416  * We disallow synchronized scans when forced to use a heapscan on a
417  * catalog. In most cases the desired rows are near the front, so
418  * that the unpredictable start point of a syncscan is a serious
419  * disadvantage; and there are no compensating advantages, because
420  * it's unlikely that such scans will occur in parallel.
421  */
422  sysscan->scan = table_beginscan_strat(heapRelation, snapshot,
423  nkeys, key,
424  true, false);
425  sysscan->iscan = NULL;
426  }
427 
428  return sysscan;
429 }
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
Definition: tableam.c:77
Relation irel
Definition: relscan.h:169
struct SysScanDescData * SysScanDesc
Definition: genam.h:88
Relation heap_rel
Definition: relscan.h:168
Snapshot RegisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:865
struct SnapshotData * snapshot
Definition: relscan.h:172
Snapshot GetCatalogSnapshot(Oid relid)
Definition: snapmgr.c:442
#define AccessShareLock
Definition: lockdefs.h:36
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:289
bool IgnoreSystemIndexes
Definition: miscinit.c:77
unsigned int Oid
Definition: postgres_ext.h:31
struct IndexScanDescData * iscan
Definition: relscan.h:171
struct TupleTableSlot * slot
Definition: relscan.h:173
static TableScanDesc table_beginscan_strat(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, bool allow_strat, bool allow_sync)
Definition: tableam.h:760
Form_pg_index rd_index
Definition: rel.h:143
#define ERROR
Definition: elog.h:43
struct TableScanDescData * scan
Definition: relscan.h:170
#define IndexRelationGetNumberOfAttributes(relation)
Definition: rel.h:434
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:228
int i
bool ReindexIsProcessingIndex(Oid indexOid)
Definition: index.c:3792
#define RelationGetRelid(relation)
Definition: rel.h:422
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:126
AttrNumber sk_attno
Definition: skey.h:67
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, int norderbys)
Definition: indexam.c:197

◆ systable_beginscan_ordered()

SysScanDesc systable_beginscan_ordered ( Relation  heapRelation,
Relation  indexRelation,
Snapshot  snapshot,
int  nkeys,
ScanKey  key 
)

Definition at line 565 of file genam.c.

References elog, ERROR, GetCatalogSnapshot(), SysScanDescData::heap_rel, i, IgnoreSystemIndexes, index_beginscan(), index_rescan(), IndexRelationGetNumberOfAttributes, SysScanDescData::irel, SysScanDescData::iscan, palloc(), RelationData::rd_index, RegisterSnapshot(), ReindexIsProcessingIndex(), RelationGetRelationName, RelationGetRelid, SysScanDescData::scan, ScanKeyData::sk_attno, SysScanDescData::slot, SysScanDescData::snapshot, table_slot_create(), and WARNING.

Referenced by BuildEventTriggerCache(), enum_endpoint(), enum_range_internal(), inv_getsize(), inv_read(), inv_truncate(), inv_write(), lookup_ts_config_cache(), toast_delete_datum(), toast_fetch_datum(), and toast_fetch_datum_slice().

569 {
570  SysScanDesc sysscan;
571  int i;
572 
573  /* REINDEX can probably be a hard error here ... */
574  if (ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))
575  elog(ERROR, "cannot do ordered scan on index \"%s\", because it is being reindexed",
576  RelationGetRelationName(indexRelation));
577  /* ... but we only throw a warning about violating IgnoreSystemIndexes */
579  elog(WARNING, "using index \"%s\" despite IgnoreSystemIndexes",
580  RelationGetRelationName(indexRelation));
581 
582  sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData));
583 
584  sysscan->heap_rel = heapRelation;
585  sysscan->irel = indexRelation;
586  sysscan->slot = table_slot_create(heapRelation, NULL);
587 
588  if (snapshot == NULL)
589  {
590  Oid relid = RelationGetRelid(heapRelation);
591 
592  snapshot = RegisterSnapshot(GetCatalogSnapshot(relid));
593  sysscan->snapshot = snapshot;
594  }
595  else
596  {
597  /* Caller is responsible for any snapshot. */
598  sysscan->snapshot = NULL;
599  }
600 
601  /* Change attribute numbers to be index column numbers. */
602  for (i = 0; i < nkeys; i++)
603  {
604  int j;
605 
606  for (j = 0; j < IndexRelationGetNumberOfAttributes(indexRelation); j++)
607  {
608  if (key[i].sk_attno == indexRelation->rd_index->indkey.values[j])
609  {
610  key[i].sk_attno = j + 1;
611  break;
612  }
613  }
614  if (j == IndexRelationGetNumberOfAttributes(indexRelation))
615  elog(ERROR, "column is not in index");
616  }
617 
618  sysscan->iscan = index_beginscan(heapRelation, indexRelation,
619  snapshot, nkeys, 0);
620  index_rescan(sysscan->iscan, key, nkeys, NULL, 0);
621  sysscan->scan = NULL;
622 
623  return sysscan;
624 }
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
Definition: tableam.c:77
Relation irel
Definition: relscan.h:169
struct SysScanDescData * SysScanDesc
Definition: genam.h:88
Relation heap_rel
Definition: relscan.h:168
Snapshot RegisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:865
struct SnapshotData * snapshot
Definition: relscan.h:172
Snapshot GetCatalogSnapshot(Oid relid)
Definition: snapmgr.c:442
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:289
bool IgnoreSystemIndexes
Definition: miscinit.c:77
unsigned int Oid
Definition: postgres_ext.h:31
struct IndexScanDescData * iscan
Definition: relscan.h:171
struct TupleTableSlot * slot
Definition: relscan.h:173
Form_pg_index rd_index
Definition: rel.h:143
#define ERROR
Definition: elog.h:43
struct TableScanDescData * scan
Definition: relscan.h:170
#define IndexRelationGetNumberOfAttributes(relation)
Definition: rel.h:434
#define RelationGetRelationName(relation)
Definition: rel.h:456
#define WARNING
Definition: elog.h:40
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:228
int i
bool ReindexIsProcessingIndex(Oid indexOid)
Definition: index.c:3792
#define RelationGetRelid(relation)
Definition: rel.h:422
AttrNumber sk_attno
Definition: skey.h:67
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, int norderbys)
Definition: indexam.c:197

◆ systable_endscan()

void systable_endscan ( SysScanDesc  sysscan)

Definition at line 525 of file genam.c.

References AccessShareLock, ExecDropSingleTupleTableSlot(), index_close(), index_endscan(), SysScanDescData::irel, SysScanDescData::iscan, pfree(), SysScanDescData::scan, SysScanDescData::slot, SysScanDescData::snapshot, table_endscan(), and UnregisterSnapshot().

Referenced by AfterTriggerSetState(), AlterConstraintNamespaces(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDropConstraint(), AlterDomainValidateConstraint(), AlterExtensionNamespace(), AlterPolicy(), AlterSeqNamespaces(), AlterSetting(), ApplyExtensionUpdates(), ApplySetting(), ATExecAddOf(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecDropConstraint(), ATExecValidateConstraint(), ATPrepChangePersistence(), AttrDefaultFetch(), change_owner_fix_column_acls(), change_owner_recurse_to_sequences(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), CheckConstraintFetch(), checkSharedDependencies(), ChooseConstraintName(), CloneFkReferenced(), CloneRowTriggersToPartition(), ConstraintNameExists(), ConstraintNameIsUsed(), copyTemplateDependencies(), CountDBSubscriptions(), CreateComments(), CreateInheritance(), CreatePolicy(), CreateSharedComments(), CreateTrigger(), DefineOpClass(), DefineTSConfiguration(), DeleteAttributeTuples(), DeleteComments(), deleteDependencyRecordsFor(), deleteDependencyRecordsForClass(), DeleteInheritsTuple(), DeleteInitPrivs(), deleteOneObject(), DeleteSecurityLabel(), DeleteSharedComments(), DeleteSharedSecurityLabel(), DeleteSystemAttributeTuples(), drop_parent_dependency(), DropCastById(), DropConfigurationMapping(), dropDatabaseDependencies(), DropRole(), DropTransformById(), EnableDisableTrigger(), EnumValuesDelete(), exec_object_restorecon(), ExecAlterExtensionStmt(), ExecGrant_Largeobject(), extension_config_remove(), fetch_statentries_for_relation(), find_composite_type_dependencies(), find_inheritance_children(), find_language_template(), findDependentObjects(), get_catalog_object_by_oid(), get_constraint_index(), get_database_oid(), get_db_info(), get_domain_constraint_oid(), get_extension_name(), get_extension_oid(), get_extension_schema(), get_index_constraint(), get_index_ref_constraints(), get_object_address_attrdef(), get_partition_parent_worker(), get_pkey_attnames(), get_primary_key_attnos(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_idx_constraint_oid(), get_relation_policy_oid(), get_rels_with_domain(), get_trigger_oid(), GetAllTablesPublications(), GetComment(), GetDatabaseTuple(), GetDatabaseTupleByOid(), GetDefaultOpClass(), getExtensionOfObject(), GetNewOidWithIndex(), getObjectDescription(), getObjectIdentityParts(), getOwnedSequences_internal(), GetParentedForeignKeyRefs(), GetPublicationRelations(), GetSecurityLabel(), GetSharedSecurityLabel(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), has_superclass(), heap_truncate_find_FKs(), index_concurrently_swap(), IndexSetParentIndex(), isObjectPinned(), isSharedObjectPinned(), LargeObjectDrop(), LargeObjectExists(), load_domaintype_info(), load_enum_cache_data(), LookupOpclassInfo(), makeConfigurationDependencies(), MakeConfigurationMapping(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), movedb(), myLargeObjectExists(), pg_extension_config_dump(), pg_extension_ownercheck(), pg_get_constraintdef_worker(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_largeobject_aclmask_snapshot(), pg_largeobject_ownercheck(), RangeDelete(), recordExtensionInitPrivWorker(), recordExtObjInitPriv(), relation_has_policies(), RelationBuildPartitionDesc(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationGetIndexList(), RelationGetStatExtList(), RelationRemoveInheritance(), RelidByRelfilenode(), RemoveAmOpEntryById(), RemoveAmProcEntryById(), RemoveAttrDefault(), RemoveAttrDefaultById(), RemoveCollationById(), RemoveDefaultACLById(), RemoveExtensionById(), RemoveInheritance(), RemovePolicyById(), RemoveRewriteRuleById(), RemoveRoleFromObjectACL(), RemoveRoleFromObjectPolicy(), RemoveStatistics(), RemoveTriggerById(), RemoveTSConfigurationById(), rename_policy(), renametrig(), replorigin_create(), ScanPgRelation(), SearchCatCacheList(), SearchCatCacheMiss(), sepgsql_attribute_post_create(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_proc_setattr(), sepgsql_relation_post_create(), sepgsql_relation_setattr(), sepgsql_relation_setattr_extra(), sepgsql_schema_post_create(), sequenceIsOwned(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), shdepDropDependency(), shdepDropOwned(), shdepReassignOwned(), toastrel_valueid_exists(), tryAttachPartitionForeignKey(), typeInheritsFrom(), vac_update_datfrozenxid(), and validatePartitionedIndex().

526 {
527  if (sysscan->slot)
528  {
530  sysscan->slot = NULL;
531  }
532 
533  if (sysscan->irel)
534  {
535  index_endscan(sysscan->iscan);
536  index_close(sysscan->irel, AccessShareLock);
537  }
538  else
539  table_endscan(sysscan->scan);
540 
541  if (sysscan->snapshot)
542  UnregisterSnapshot(sysscan->snapshot);
543 
544  pfree(sysscan);
545 }
Relation irel
Definition: relscan.h:169
struct SnapshotData * snapshot
Definition: relscan.h:172
#define AccessShareLock
Definition: lockdefs.h:36
struct IndexScanDescData * iscan
Definition: relscan.h:171
struct TupleTableSlot * slot
Definition: relscan.h:173
void pfree(void *pointer)
Definition: mcxt.c:1056
struct TableScanDescData * scan
Definition: relscan.h:170
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:1224
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:315
void UnregisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:907
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:152
static void table_endscan(TableScanDesc scan)
Definition: tableam.h:831

◆ systable_endscan_ordered()

void systable_endscan_ordered ( SysScanDesc  sysscan)

Definition at line 649 of file genam.c.

References Assert, ExecDropSingleTupleTableSlot(), index_endscan(), SysScanDescData::irel, SysScanDescData::iscan, pfree(), SysScanDescData::slot, SysScanDescData::snapshot, and UnregisterSnapshot().

Referenced by BuildEventTriggerCache(), enum_endpoint(), enum_range_internal(), inv_getsize(), inv_read(), inv_truncate(), inv_write(), lookup_ts_config_cache(), toast_delete_datum(), toast_fetch_datum(), and toast_fetch_datum_slice().

650 {
651  if (sysscan->slot)
652  {
654  sysscan->slot = NULL;
655  }
656 
657  Assert(sysscan->irel);
658  index_endscan(sysscan->iscan);
659  if (sysscan->snapshot)
660  UnregisterSnapshot(sysscan->snapshot);
661  pfree(sysscan);
662 }
Relation irel
Definition: relscan.h:169
struct SnapshotData * snapshot
Definition: relscan.h:172
struct IndexScanDescData * iscan
Definition: relscan.h:171
struct TupleTableSlot * slot
Definition: relscan.h:173
void pfree(void *pointer)
Definition: mcxt.c:1056
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:1224
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:315
void UnregisterSnapshot(Snapshot snapshot)
Definition: snapmgr.c:907
#define Assert(condition)
Definition: c.h:739

◆ systable_getnext()

HeapTuple systable_getnext ( SysScanDesc  sysscan)

Definition at line 444 of file genam.c.

References Assert, elog, ERROR, ExecFetchSlotHeapTuple(), ForwardScanDirection, index_getnext_slot(), SysScanDescData::irel, SysScanDescData::iscan, SysScanDescData::scan, SysScanDescData::slot, table_scan_getnextslot(), and IndexScanDescData::xs_recheck.

Referenced by AfterTriggerSetState(), AlterConstraintNamespaces(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDropConstraint(), AlterDomainValidateConstraint(), AlterExtensionNamespace(), AlterPolicy(), AlterSeqNamespaces(), AlterSetting(), ApplyExtensionUpdates(), ApplySetting(), ATExecAddOf(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecDropConstraint(), ATExecValidateConstraint(), ATPrepChangePersistence(), AttrDefaultFetch(), change_owner_fix_column_acls(), change_owner_recurse_to_sequences(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), CheckConstraintFetch(), checkSharedDependencies(), ChooseConstraintName(), CloneFkReferenced(), CloneRowTriggersToPartition(), ConstraintNameExists(), ConstraintNameIsUsed(), copyTemplateDependencies(), CountDBSubscriptions(), CreateComments(), CreateInheritance(), CreatePolicy(), CreateSharedComments(), CreateTrigger(), DefineOpClass(), DefineTSConfiguration(), DeleteAttributeTuples(), DeleteComments(), deleteDependencyRecordsFor(), deleteDependencyRecordsForClass(), DeleteInheritsTuple(), DeleteInitPrivs(), deleteOneObject(), DeleteSecurityLabel(), DeleteSharedComments(), DeleteSharedSecurityLabel(), DeleteSystemAttributeTuples(), drop_parent_dependency(), DropCastById(), DropConfigurationMapping(), dropDatabaseDependencies(), DropRole(), DropTransformById(), EnableDisableTrigger(), EnumValuesDelete(), exec_object_restorecon(), ExecAlterExtensionStmt(), ExecGrant_Largeobject(), extension_config_remove(), fetch_statentries_for_relation(), find_composite_type_dependencies(), find_inheritance_children(), find_language_template(), findDependentObjects(), get_catalog_object_by_oid(), get_constraint_index(), get_database_oid(), get_db_info(), get_domain_constraint_oid(), get_extension_name(), get_extension_oid(), get_extension_schema(), get_index_constraint(), get_index_ref_constraints(), get_object_address_attrdef(), get_partition_parent_worker(), get_pkey_attnames(), get_primary_key_attnos(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_idx_constraint_oid(), get_relation_policy_oid(), get_rels_with_domain(), get_trigger_oid(), GetAllTablesPublications(), GetComment(), GetDatabaseTuple(), GetDatabaseTupleByOid(), GetDefaultOpClass(), getExtensionOfObject(), GetNewOidWithIndex(), getObjectDescription(), getObjectIdentityParts(), getOwnedSequences_internal(), GetParentedForeignKeyRefs(), GetPublicationRelations(), GetSecurityLabel(), GetSharedSecurityLabel(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), has_superclass(), heap_truncate_find_FKs(), index_concurrently_swap(), IndexSetParentIndex(), isObjectPinned(), isSharedObjectPinned(), LargeObjectDrop(), LargeObjectExists(), load_domaintype_info(), load_enum_cache_data(), LookupOpclassInfo(), makeConfigurationDependencies(), MakeConfigurationMapping(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), movedb(), myLargeObjectExists(), pg_extension_config_dump(), pg_extension_ownercheck(), pg_get_constraintdef_worker(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_largeobject_aclmask_snapshot(), pg_largeobject_ownercheck(), RangeDelete(), recordExtensionInitPrivWorker(), recordExtObjInitPriv(), relation_has_policies(), RelationBuildPartitionDesc(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationGetIndexList(), RelationGetStatExtList(), RelationRemoveInheritance(), RelidByRelfilenode(), RemoveAmOpEntryById(), RemoveAmProcEntryById(), RemoveAttrDefault(), RemoveAttrDefaultById(), RemoveCollationById(), RemoveDefaultACLById(), RemoveExtensionById(), RemoveInheritance(), RemovePolicyById(), RemoveRewriteRuleById(), RemoveRoleFromObjectACL(), RemoveRoleFromObjectPolicy(), RemoveStatistics(), RemoveTriggerById(), RemoveTSConfigurationById(), rename_policy(), renametrig(), replorigin_create(), ScanPgRelation(), SearchCatCacheList(), SearchCatCacheMiss(), sepgsql_attribute_post_create(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_proc_setattr(), sepgsql_relation_post_create(), sepgsql_relation_setattr(), sepgsql_relation_setattr_extra(), sepgsql_schema_post_create(), sequenceIsOwned(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), shdepDropDependency(), shdepDropOwned(), shdepReassignOwned(), toastrel_valueid_exists(), tryAttachPartitionForeignKey(), typeInheritsFrom(), vac_update_datfrozenxid(), and validatePartitionedIndex().

445 {
446  HeapTuple htup = NULL;
447 
448  if (sysscan->irel)
449  {
450  if (index_getnext_slot(sysscan->iscan, ForwardScanDirection, sysscan->slot))
451  {
452  bool shouldFree;
453 
454  htup = ExecFetchSlotHeapTuple(sysscan->slot, false, &shouldFree);
455  Assert(!shouldFree);
456 
457  /*
458  * We currently don't need to support lossy index operators for
459  * any system catalog scan. It could be done here, using the scan
460  * keys to drive the operator calls, if we arranged to save the
461  * heap attnums during systable_beginscan(); this is practical
462  * because we still wouldn't need to support indexes on
463  * expressions.
464  */
465  if (sysscan->iscan->xs_recheck)
466  elog(ERROR, "system catalog scans with lossy index conditions are not implemented");
467  }
468  }
469  else
470  {
471  if (table_scan_getnextslot(sysscan->scan, ForwardScanDirection, sysscan->slot))
472  {
473  bool shouldFree;
474 
475  htup = ExecFetchSlotHeapTuple(sysscan->slot, false, &shouldFree);
476  Assert(!shouldFree);
477  }
478  }
479 
480  return htup;
481 }
Relation irel
Definition: relscan.h:169
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
Definition: tableam.h:872
struct IndexScanDescData * iscan
Definition: relscan.h:171
struct TupleTableSlot * slot
Definition: relscan.h:173
#define ERROR
Definition: elog.h:43
struct TableScanDescData * scan
Definition: relscan.h:170
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1614
#define Assert(condition)
Definition: c.h:739
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
Definition: indexam.c:607
#define elog(elevel,...)
Definition: elog.h:228

◆ systable_getnext_ordered()

HeapTuple systable_getnext_ordered ( SysScanDesc  sysscan,
ScanDirection  direction 
)

Definition at line 630 of file genam.c.

References Assert, elog, ERROR, ExecFetchSlotHeapTuple(), index_getnext_slot(), SysScanDescData::irel, SysScanDescData::iscan, SysScanDescData::slot, and IndexScanDescData::xs_recheck.

Referenced by BuildEventTriggerCache(), enum_endpoint(), enum_range_internal(), inv_getsize(), inv_read(), inv_truncate(), inv_write(), lookup_ts_config_cache(), toast_delete_datum(), toast_fetch_datum(), and toast_fetch_datum_slice().

631 {
632  HeapTuple htup = NULL;
633 
634  Assert(sysscan->irel);
635  if (index_getnext_slot(sysscan->iscan, direction, sysscan->slot))
636  htup = ExecFetchSlotHeapTuple(sysscan->slot, false, NULL);
637 
638  /* See notes in systable_getnext */
639  if (htup && sysscan->iscan->xs_recheck)
640  elog(ERROR, "system catalog scans with lossy index conditions are not implemented");
641 
642  return htup;
643 }
Relation irel
Definition: relscan.h:169
struct IndexScanDescData * iscan
Definition: relscan.h:171
struct TupleTableSlot * slot
Definition: relscan.h:173
#define ERROR
Definition: elog.h:43
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1614
#define Assert(condition)
Definition: c.h:739
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
Definition: indexam.c:607
#define elog(elevel,...)
Definition: elog.h:228

◆ systable_recheck_tuple()

bool systable_recheck_tuple ( SysScanDesc  sysscan,
HeapTuple  tup 
)

Definition at line 497 of file genam.c.

References Assert, ExecFetchSlotHeapTuple(), GetCatalogSnapshot(), SysScanDescData::heap_rel, RelationGetRelid, SysScanDescData::slot, and table_tuple_satisfies_snapshot().

Referenced by findDependentObjects().

498 {
499  Snapshot freshsnap;
500  bool result;
501 
502  Assert(tup == ExecFetchSlotHeapTuple(sysscan->slot, false, NULL));
503 
504  /*
505  * Trust that table_tuple_satisfies_snapshot() and its subsidiaries
506  * (commonly LockBuffer() and HeapTupleSatisfiesMVCC()) do not themselves
507  * acquire snapshots, so we need not register the snapshot. Those
508  * facilities are too low-level to have any business scanning tables.
509  */
510  freshsnap = GetCatalogSnapshot(RelationGetRelid(sysscan->heap_rel));
511 
512  result = table_tuple_satisfies_snapshot(sysscan->heap_rel,
513  sysscan->slot,
514  freshsnap);
515 
516  return result;
517 }
Relation heap_rel
Definition: relscan.h:168
Snapshot GetCatalogSnapshot(Oid relid)
Definition: snapmgr.c:442
struct TupleTableSlot * slot
Definition: relscan.h:173
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1614
static bool table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
Definition: tableam.h:1059
#define Assert(condition)
Definition: c.h:739
#define RelationGetRelid(relation)
Definition: rel.h:422