PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
rel.h File Reference
#include "access/tupdesc.h"
#include "access/xlog.h"
#include "catalog/pg_class.h"
#include "catalog/pg_index.h"
#include "catalog/pg_publication.h"
#include "fmgr.h"
#include "nodes/bitmapset.h"
#include "rewrite/prs2lock.h"
#include "storage/block.h"
#include "storage/relfilenode.h"
#include "utils/relcache.h"
#include "utils/reltrigger.h"
Include dependency graph for rel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LockRelId
 
struct  LockInfoData
 
struct  PartitionKeyData
 
struct  RelationData
 
struct  ForeignKeyCacheInfo
 
struct  AutoVacOpts
 
struct  StdRdOptions
 
struct  ViewOptions
 

Macros

#define HEAP_MIN_FILLFACTOR   10
 
#define HEAP_DEFAULT_FILLFACTOR   100
 
#define RelationGetFillFactor(relation, defaultff)
 
#define RelationGetTargetPageUsage(relation, defaultff)   (BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100)
 
#define RelationGetTargetPageFreeSpace(relation, defaultff)   (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100)
 
#define RelationIsUsedAsCatalogTable(relation)
 
#define RelationGetParallelWorkers(relation, defaultpw)
 
#define RelationIsSecurityView(relation)
 
#define RelationHasCheckOption(relation)
 
#define RelationHasLocalCheckOption(relation)
 
#define RelationHasCascadedCheckOption(relation)
 
#define RelationIsValid(relation)   PointerIsValid(relation)
 
#define InvalidRelation   ((Relation) NULL)
 
#define RelationHasReferenceCountZero(relation)   ((bool)((relation)->rd_refcnt == 0))
 
#define RelationGetForm(relation)   ((relation)->rd_rel)
 
#define RelationGetRelid(relation)   ((relation)->rd_id)
 
#define RelationGetNumberOfAttributes(relation)   ((relation)->rd_rel->relnatts)
 
#define RelationGetDescr(relation)   ((relation)->rd_att)
 
#define RelationGetRelationName(relation)   (NameStr((relation)->rd_rel->relname))
 
#define RelationGetNamespace(relation)   ((relation)->rd_rel->relnamespace)
 
#define RelationIsMapped(relation)   ((relation)->rd_rel->relfilenode == InvalidOid)
 
#define RelationOpenSmgr(relation)
 
#define RelationCloseSmgr(relation)
 
#define RelationGetTargetBlock(relation)   ( (relation)->rd_smgr != NULL ? (relation)->rd_smgr->smgr_targblock : InvalidBlockNumber )
 
#define RelationSetTargetBlock(relation, targblock)
 
#define RelationNeedsWAL(relation)   ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
 
#define RelationUsesLocalBuffers(relation)   ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
 
#define RELATION_IS_LOCAL(relation)
 
#define RELATION_IS_OTHER_TEMP(relation)
 
#define RelationIsScannable(relation)   ((relation)->rd_rel->relispopulated)
 
#define RelationIsPopulated(relation)   ((relation)->rd_rel->relispopulated)
 
#define RelationIsAccessibleInLogicalDecoding(relation)
 
#define RelationIsLogicallyLogged(relation)
 
#define RelationGetPartitionKey(relation)   ((relation)->rd_partkey)
 
#define RelationGetPartitionDesc(relation)   ((relation)->rd_partdesc)
 

Typedefs

typedef struct LockRelId LockRelId
 
typedef struct LockInfoData LockInfoData
 
typedef LockInfoDataLockInfo
 
typedef struct PartitionKeyData PartitionKeyData
 
typedef struct PartitionKeyDataPartitionKey
 
typedef struct RelationData RelationData
 
typedef struct ForeignKeyCacheInfo ForeignKeyCacheInfo
 
typedef struct AutoVacOpts AutoVacOpts
 
typedef struct StdRdOptions StdRdOptions
 
typedef struct ViewOptions ViewOptions
 

Functions

static int get_partition_strategy (PartitionKey key)
 
static int get_partition_natts (PartitionKey key)
 
static Listget_partition_exprs (PartitionKey key)
 
static int16 get_partition_col_attnum (PartitionKey key, int col)
 
static Oid get_partition_col_typid (PartitionKey key, int col)
 
static int32 get_partition_col_typmod (PartitionKey key, int col)
 
void RelationIncrementReferenceCount (Relation rel)
 
void RelationDecrementReferenceCount (Relation rel)
 
bool RelationHasUnloggedIndex (Relation rel)
 
ListRelationGetRepsetList (Relation rel)
 

Macro Definition Documentation

#define HEAP_DEFAULT_FILLFACTOR   100
#define HEAP_MIN_FILLFACTOR   10

Definition at line 282 of file rel.h.

#define InvalidRelation   ((Relation) NULL)

Definition at line 388 of file rel.h.

#define RELATION_IS_LOCAL (   relation)
Value:
((relation)->rd_islocaltemp || \
(relation)->rd_createSubid != InvalidSubTransactionId)
#define InvalidSubTransactionId
Definition: c.h:400

Definition at line 520 of file rel.h.

Referenced by _bt_getbuf(), BloomNewBuffer(), brin_getinsertbuffer(), btvacuumscan(), GinNewBuffer(), ginvacuumcleanup(), gistNewBuffer(), gistvacuumcleanup(), RelationGetBufferForTuple(), revmap_physical_extend(), SpGistNewBuffer(), and spgvacuumscan().

#define RelationCloseSmgr (   relation)
Value:
do { \
if ((relation)->rd_smgr != NULL) \
{ \
smgrclose((relation)->rd_smgr); \
Assert((relation)->rd_smgr == NULL); \
} \
} while (0)
void smgrclose(SMgrRelation reln)
Definition: smgr.c:296
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671

Definition at line 469 of file rel.h.

Referenced by RelationCacheInvalidate(), RelationClearRelation(), RelationCloseSmgrByOid(), RelationDestroyRelation(), RelationDropStorage(), and RelationReloadIndexInfo().

#define RelationGetDescr (   relation)    ((relation)->rd_att)

Definition at line 425 of file rel.h.

Referenced by _bt_check_unique(), _bt_checkkeys(), _bt_compare(), _bt_load(), _bt_mkscankey(), _hash_checkqual(), acquire_inherited_sample_rows(), AddEnumLabel(), AddRelationNewConstraints(), AddRoleMems(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDefault(), AlterDomainNotNull(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPolicy(), AlterPublicationOptions(), AlterRole(), AlterSchemaOwner_internal(), AlterSetting(), AlterSubscription(), AlterTableSpaceOptions(), AlterTSDictionary(), AlterTypeOwnerInternal(), AlterUserMapping(), AppendAttributeTuples(), apply_handle_delete(), apply_handle_insert(), apply_handle_update(), ApplyExtensionUpdates(), ApplySetting(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAttachPartition(), ATExecChangeOwner(), ATExecDetachPartition(), ATExecDropNotNull(), ATExecGenericOptions(), ATExecSetOptions(), ATExecSetRelOptions(), ATGetQueueEntry(), ATPrepAlterColumnType(), ATRewriteTable(), BeginCopy(), BeginCopyFrom(), brin_build_desc(), brin_page_items(), btbeginscan(), btinsert(), build_row_from_class(), BuildEventTriggerCache(), CatalogCacheInitializeCache(), CatalogIndexInsert(), change_owner_fix_column_acls(), check_exclusion_or_unique_constraint(), check_selective_binary_conversion(), CheckAttributeType(), CollationCreate(), comparetup_index_btree(), compute_index_stats(), ConstructTupleDescriptor(), conversion_error_callback(), copy_heap_data(), CopyFrom(), copyTemplateDependencies(), CopyTo(), copytup_index(), create_proc_lang(), CreateAccessMethod(), CreateCast(), CreateComments(), CreateConstraintEntry(), createdb(), CreatePolicy(), CreatePublication(), CreateRole(), CreateSharedComments(), CreateSubscription(), CreateTransform(), currtid_for_view(), DefineQueryRewrite(), DefineSequence(), DelRoleMems(), deparseAnalyzeSql(), deparseTargetList(), do_autovacuum(), DoCopy(), EnumValuesCreate(), errtablecol(), EventTriggerSQLDropAddObject(), ExecAlterExtensionStmt(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecCheckPlanOutput(), ExecConstraints(), ExecDelete(), ExecFindPartition(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitBitmapHeapScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitIndexScan(), ExecInitTidScan(), ExecInsert(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecSetupPartitionTupleRouting(), ExecWithCheckOptions(), extension_config_remove(), ExtractReplicaIdentity(), file_acquire_sample_rows(), find_language_template(), generateClonedIndexStmt(), get_actual_variable_range(), get_file_fdw_attribute_options(), get_object_address_attrdef(), get_primary_key_attnos(), GetComment(), GetSecurityLabel(), GetSharedSecurityLabel(), hashbuildCallback(), hashinsert(), heapgettup(), heapgettup_pagemode(), HeapSatisfiesHOTandKeyUpdate(), IndexBuildHeapRangeScan(), IndexCheckExclusion(), initGinState(), InitializeAttributeOids(), InitScanRelation(), InsertPgAttributeTuple(), InsertPgClassTuple(), InsertRule(), inv_truncate(), inv_write(), LargeObjectCreate(), load_typcache_tupdesc(), logicalrep_rel_open(), logicalrep_write_attrs(), logicalrep_write_tuple(), make_inh_translation_list(), make_new_heap(), make_tuple_from_result_row(), make_viewdef(), MakeConfigurationMapping(), map_partition_varattnos(), MergeAttributes(), MergeAttributesIntoExisting(), MergeConstraintsIntoExisting(), movedb(), NextCopyFrom(), OperatorCreate(), pg_decode_change(), pg_event_trigger_ddl_commands(), pg_extension_config_dump(), pg_identify_object(), pg_largeobject_aclmask_snapshot(), pgoutput_change(), pltcl_build_tuple_result(), pltcl_trigger_handler(), postgresAcquireSampleRowsFunc(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresBeginForeignScan(), postgresPlanForeignModify(), ProcedureCreate(), publication_add_relation(), RangeCreate(), readtup_index(), recordExtensionInitPrivWorker(), recordExtObjInitPriv(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationFindReplTupleSeq(), RelationGetPartitionDispatchInfo(), RelationNameGetTupleDesc(), RelidByRelfilenode(), RemoveRoleFromObjectPolicy(), RenameRole(), ReorderBufferToastAppendChunk(), ReorderBufferToastReplace(), replorigin_create(), ri_KeysEqual(), sepgsql_relation_setattr_extra(), set_relation_column_names(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), slot_fill_defaults(), spgbeginscan(), StoreCatalogInheritance1(), StorePartitionBound(), StorePartitionKey(), transformTableLikeClause(), TriggerEnabled(), tuplesort_putindextuplevalues(), TypeCreate(), unique_key_recheck(), update_attstats(), UpdateIndexRelation(), validate_index_heapscan(), validateCheckConstraint(), and validateDomainConstraint().

#define RelationGetFillFactor (   relation,
  defaultff 
)
Value:
((relation)->rd_options ? \
((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff))

Definition at line 289 of file rel.h.

Referenced by _bt_findsplitloc().

#define RelationGetParallelWorkers (   relation,
  defaultpw 
)
Value:
((relation)->rd_options ? \
((StdRdOptions *) (relation)->rd_options)->parallel_workers : (defaultpw))

Definition at line 323 of file rel.h.

Referenced by get_relation_info().

#define RelationGetPartitionDesc (   relation)    ((relation)->rd_partdesc)

Definition at line 629 of file rel.h.

Referenced by check_new_partition_bound(), and RelationGetPartitionDispatchInfo().

#define RelationGetRelationName (   relation)    (NameStr((relation)->rd_rel->relname))

Definition at line 433 of file rel.h.

Referenced by _bt_buildadd(), _bt_check_unique(), _bt_checkpage(), _bt_findinsertloc(), _bt_findsplitloc(), _bt_first(), _bt_get_endpoint(), _bt_getroot(), _bt_getrootheight(), _bt_gettrueroot(), _bt_insert_parent(), _bt_insertonpg(), _bt_lock_branch_parent(), _bt_mark_page_halfdead(), _bt_moveright(), _bt_newroot(), _bt_pagedel(), _bt_split(), _bt_start_vacuum(), _bt_unlink_halfdead_page(), _bt_walk_left(), _hash_checkpage(), _hash_datum2hashkey_type(), _hash_getnewbuf(), _hash_initbitmap(), _hash_metapinit(), _hash_pgaddtup(), acquire_inherited_sample_rows(), acquire_sample_rows(), add_with_check_options(), addRangeTableEntryForRelation(), AddRelationNewConstraints(), AlterDomainNotNull(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterPolicy(), AlterTableNamespace(), analyze_rel(), apply_handle_delete(), apply_handle_update(), ATAddForeignKeyConstraint(), AtEOSubXact_cleanup(), AtEOXact_cleanup(), ATExecAddColumn(), ATExecAddConstraint(), ATExecAddIndexConstraint(), ATExecAddInherit(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecChangeOwner(), ATExecClusterOn(), ATExecColumnDefault(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropNotNull(), ATExecDropOf(), ATExecGenericOptions(), ATExecReplicaIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecSetTableSpace(), ATExecValidateConstraint(), ATPrepAlterColumnType(), ATPrepChangePersistence(), ATPrepSetStatistics(), ATRewriteTable(), ATRewriteTables(), ATSimplePermissions(), AttrDefaultFetch(), ATTypedTableRecursion(), ATWrongRelkindError(), BeginCopy(), BeginCopyFrom(), BeginCopyTo(), blbuild(), brin_doinsert(), brin_doupdate(), brin_getinsertbuffer(), brin_summarize_new_values(), brinbuild(), bt_metap(), bt_page_items(), bt_page_stats(), btbuild(), build_row_from_class(), CatalogCacheInitializeCache(), check_exclusion_or_unique_constraint(), check_for_column_name_collision(), check_index_is_clusterable(), check_object_ownership(), check_publication_add_relation(), CheckCmdReplicaIdentity(), CheckConstraintFetch(), checkFkeyPermissions(), checkInsertTargets(), CheckTableNotInUse(), CheckValidResultRel(), CheckValidRowMarkRel(), closerel(), collect_corrupt_items(), CommentObject(), comparetup_index_btree(), conversion_error_callback(), copy_heap_data(), CopyFrom(), CopyGetAttnums(), count_nondeletable_pages(), CreateFakeRelcacheEntry(), CreateInheritance(), CreatePolicy(), CreateTrigger(), currtid_byrelname(), currtid_byreloid(), currval_oid(), DefineIndex(), DefineQueryRewrite(), DefineRelation(), DefineVirtualRelation(), deparseRelation(), do_analyze_rel(), do_setval(), DoCopy(), EnableDisableTrigger(), entryExecPlaceToPage(), entrySplitPage(), errtable(), EvalPlanQualFetch(), EvalPlanQualFetchRowMarks(), ExecCheckIndexConstraints(), ExecConstraints(), ExecLockRows(), ExecOpenScanRelation(), ExecRefreshMatView(), ExecSecLabelStmt(), ExecuteTruncate(), ExtractReplicaIdentity(), file_acquire_sample_rows(), find_composite_type_dependencies(), fireRIRrules(), generate_partition_qual(), generate_relation_name(), generateClonedIndexStmt(), get_actual_variable_range(), get_object_address_publication_rel(), get_raw_page_internal(), get_rel_from_relname(), get_relation_by_qualified_name(), GetNewOid(), gin_clean_pending_list(), ginbuild(), ginFinishSplit(), GinFormTuple(), ginHeapTupleFastInsert(), ginNewScanKey(), ginVacuumEntryPage(), gistbuild(), gistbulkdelete(), gistcheckpage(), gistdoinsert(), gistFindPath(), gistfixsplit(), gistplacetopage(), gistrescan(), gistSplit(), gistUserPicksplit(), hash_bitmap_info(), hashbuild(), hashgettuple(), heap_acquire_tuplock(), heap_get_latest_tid(), heap_lock_tuple(), heap_open(), heap_openrv(), heap_openrv_extended(), index_build(), index_check_primary_key(), index_getprocinfo(), index_open(), IndexBuildHeapRangeScan(), init_sequence(), initGinState(), lastval(), lazy_cleanup_index(), lazy_scan_heap(), lazy_truncate_heap(), lazy_vacuum_heap(), lazy_vacuum_index(), lazy_vacuum_rel(), load_relcache_init_file(), logicalrep_write_rel(), make_inh_translation_list(), MergeAttributes(), MergeAttributesIntoExisting(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), nextval_internal(), pg_sequence_last_value(), pg_truncate_visibility_map(), pgrowlocks(), pgstat_relation(), pgstatginindex_internal(), pgstathashindex(), pgstatindex_impl(), pgstattuple_approx_internal(), plpgsql_exec_trigger(), pltcl_init_load_unknown(), postgresAcquireSampleRowsFunc(), PrintRelCacheLeakWarning(), process_owned_by(), publication_add_relation(), PublicationAddTables(), PublicationDropTables(), quoteRelationName(), read_seq_tuple(), RebuildConstraintComment(), refresh_by_match_merge(), relation_mark_replica_identity(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationCacheInitializePhase3(), RelationGetBufferForTuple(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationInitIndexAccessInfo(), RelationInitPhysicalAddr(), RemoveConstraintById(), RemoveInheritance(), RemovePolicyById(), RemoveRoleFromObjectPolicy(), RemoveTriggerById(), rename_policy(), renameatt_internal(), RenameRewriteRule(), renametrig(), report_triggers(), ResourceOwnerForgetRelationRef(), revmap_physical_extend(), RewriteQuery(), rewriteTargetView(), ri_FetchConstraintInfo(), RI_FKey_check(), RI_Initial_Check(), ri_ReportViolation(), sepgsql_relation_setattr_extra(), spgbuild(), spgdoinsert(), spgGetCache(), spgprocesspending(), SPI_getrelname(), ss_get_location(), ss_report_location(), StoreAttrDefault(), StoreRelCheck(), systable_beginscan_ordered(), test_rls_hooks_permissive(), test_rls_hooks_restrictive(), toast_fetch_datum(), toast_fetch_datum_slice(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), transformIndexConstraint(), transformOnConflictArbiter(), transformPartitionBound(), transformPartitionCmd(), transformTableLikeClause(), transformUpdateTargetList(), triggered_change_notification(), truncate_check_rel(), vacuum_rel(), vacuumLeafPage(), validate_index_heapscan(), validateDomainConstraint(), visibilitymap_clear(), visibilitymap_get_status(), visibilitymap_set(), visibilitymap_truncate(), writeListPage(), and XactLockTableWaitErrorCb().

#define RelationGetRelid (   relation)    ((relation)->rd_id)

Definition at line 413 of file rel.h.

Referenced by acquire_inherited_sample_rows(), acquire_sample_rows(), addRangeTableEntry(), addRangeTableEntryForRelation(), AddRelationNewConstraints(), afterTriggerInvokeEvents(), AfterTriggerSaveEvent(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterPublicationTables(), AlterSchemaOwner_internal(), AlterSeqNamespaces(), AlterTableNamespaceInternal(), analyze_rel(), ATAddCheckConstraint(), ATAddForeignKeyConstraint(), ATExecAddColumn(), ATExecAddConstraint(), ATExecAddIndex(), ATExecAddInherit(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecAttachPartition(), ATExecCmd(), ATExecColumnDefault(), ATExecDetachPartition(), ATExecDisableRowSecurity(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropInherit(), ATExecDropNotNull(), ATExecDropOf(), ATExecEnableRowSecurity(), ATExecForceNoForceRowSecurity(), ATExecGenericOptions(), ATExecReplicaIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecSetTableSpace(), ATExecValidateConstraint(), ATGetQueueEntry(), ATPrepAlterColumnType(), ATPrepChangePersistence(), ATPrepSetStatistics(), ATRewriteTable(), ATSimplePermissions(), ATSimpleRecursion(), AttrDefaultFetch(), bringetbitmap(), brinvacuumcleanup(), build_replindex_scan_key(), BuildIndexInfo(), BuildIndexValueDescription(), CacheInvalidateHeapTuple(), CacheInvalidateRelcache(), check_for_column_name_collision(), check_index_is_clusterable(), check_object_ownership(), CheckConstraintFetch(), checkFkeyPermissions(), CheckTableNotInUse(), compute_function_hashkey(), ComputePartitionAttrs(), CopyFrom(), create_estate_for_relation(), create_toast_table(), createForeignKeyTriggers(), CreateInheritance(), CreateTrigger(), currtid_byrelname(), currtid_byreloid(), DefineIndex(), DefineRelation(), deparseAnalyzeSql(), deparseRelation(), do_analyze_rel(), DoCopy(), EnableDisableRule(), EnableDisableTrigger(), errtablecol(), ExecConstraints(), ExecDelete(), ExecFindPartition(), ExecGetTriggerResultRel(), ExecInsert(), ExecInsertIndexTuples(), ExecModifyTable(), ExecProcessReturning(), ExecUpdate(), ExecuteTruncate(), ExecWithCheckOptions(), file_acquire_sample_rows(), fileAnalyzeForeignTable(), fileBeginForeignScan(), fileExplainForeignScan(), fireRIRrules(), ForeignNext(), formrdesc(), generate_partition_qual(), generate_relation_name(), generateClonedIndexStmt(), get_catalog_object_by_oid(), get_object_address_attrdef(), get_object_address_attribute(), get_object_address_publication_rel(), get_object_address_relobject(), get_partition_for_tuple(), get_pkey_attnames(), get_rel_data_width(), get_rel_from_relname(), get_relation_by_qualified_name(), get_relation_foreign_keys(), get_relation_info(), get_rels_with_domain(), GetFdwRoutineForRelation(), GetRelationPublicationActions(), GetTupleForTrigger(), heap_abort_speculative(), heap_beginscan_catalog(), heap_beginscan_internal(), heap_beginscan_parallel(), heap_create_with_catalog(), heap_delete(), heap_fetch(), heap_get_latest_tid(), heap_hot_search_buffer(), heap_lock_tuple(), heap_page_is_all_visible(), heap_parallelscan_initialize(), heap_prepare_insert(), heap_prune_chain(), heap_truncate_check_FKs(), heap_update(), heapgetpage(), index_beginscan_parallel(), index_build(), index_check_primary_key(), index_constraint_create(), index_create(), index_parallelscan_initialize(), index_update_stats(), IndexCheckExclusion(), IsCatalogRelation(), IsSystemRelation(), lazy_scan_heap(), lazy_vacuum_rel(), logical_heap_rewrite_flush_mappings(), logical_rewrite_log_mapping(), logicalrep_write_delete(), logicalrep_write_insert(), logicalrep_write_rel(), logicalrep_write_update(), MergeAttributes(), MergeAttributesIntoExisting(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), OpenTableList(), pg_decode_change(), pgoutput_change(), pgrowlocks(), pgstat_report_analyze(), plpython_call_handler(), pltcl_trigger_handler(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresIsForeignRelUpdatable(), PrepareToInvalidateCacheTuple(), process_owned_by(), publication_add_relation(), PublicationAddTables(), PublicationDropTables(), rebuild_relation(), reindex_relation(), relation_has_policies(), relation_mark_replica_identity(), RelationBuildDesc(), RelationBuildLocalRelation(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationCacheInitializePhase3(), RelationCacheInvalidate(), RelationClearRelation(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationGetIndexList(), RelationInitIndexAccessInfo(), RelationInitLockInfo(), RelationInitPhysicalAddr(), RelationReloadIndexInfo(), RelationSetNewRelfilenode(), RemoveInheritance(), RewriteQuery(), ri_FetchConstraintInfo(), RI_Initial_Check(), search_plan_tree(), SetMatViewPopulatedState(), SetRelationNumChecks(), statapprox_heap(), StoreAttrDefault(), StorePartitionBound(), StorePartitionKey(), StoreRelCheck(), systable_beginscan(), systable_beginscan_ordered(), systable_recheck_tuple(), TidListCreate(), toast_get_valid_index(), toast_open_indexes(), toast_save_datum(), toastrel_valueid_exists(), transformIndexConstraint(), transformOnConflictArbiter(), transformPartitionBound(), transformTableLikeClause(), truncate_check_rel(), vac_update_relstats(), vacuum_rel(), validateForeignKeyConstraint(), and write_relcache_init_file().

#define RelationGetTargetBlock (   relation)    ( (relation)->rd_smgr != NULL ? (relation)->rd_smgr->smgr_targblock : InvalidBlockNumber )
#define RelationGetTargetPageFreeSpace (   relation,
  defaultff 
)    (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100)
#define RelationGetTargetPageUsage (   relation,
  defaultff 
)    (BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100)

Definition at line 297 of file rel.h.

Referenced by _hash_metapinit().

#define RelationHasCascadedCheckOption (   relation)
Value:
((relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option_offset != 0 ? \
strcmp((char *) (relation)->rd_options + \
((ViewOptions *) (relation)->rd_options)->check_option_offset, \
"cascaded") == 0 : false)

Definition at line 374 of file rel.h.

Referenced by rewriteTargetView().

#define RelationHasCheckOption (   relation)
Value:
((relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option_offset != 0)

Definition at line 353 of file rel.h.

Referenced by rewriteTargetView().

#define RelationHasLocalCheckOption (   relation)
Value:
((relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option_offset != 0 ? \
strcmp((char *) (relation)->rd_options + \
((ViewOptions *) (relation)->rd_options)->check_option_offset, \
"local") == 0 : false)

Definition at line 362 of file rel.h.

#define RelationHasReferenceCountZero (   relation)    ((bool)((relation)->rd_refcnt == 0))
#define RelationIsAccessibleInLogicalDecoding (   relation)
Value:
RelationNeedsWAL(relation) && \
bool IsCatalogRelation(Relation relation)
Definition: catalog.c:91
#define XLogLogicalInfoActive()
Definition: xlog.h:162
#define RelationIsUsedAsCatalogTable(relation)
Definition: rel.h:312
#define RelationNeedsWAL(relation)
Definition: rel.h:502

Definition at line 556 of file rel.h.

Referenced by GetOldestXmin(), heap_delete(), heap_insert(), heap_multi_insert(), heap_page_prune_opt(), heap_update(), logical_begin_heap_rewrite(), and RelationInitPhysicalAddr().

#define RelationIsLogicallyLogged (   relation)
Value:
RelationNeedsWAL(relation) && \
!IsCatalogRelation(relation))
bool IsCatalogRelation(Relation relation)
Definition: catalog.c:91
#define XLogLogicalInfoActive()
Definition: xlog.h:162
#define RelationNeedsWAL(relation)
Definition: rel.h:502

Definition at line 572 of file rel.h.

Referenced by ExtractReplicaIdentity(), heap_insert(), heap_multi_insert(), log_heap_update(), and ReorderBufferCommit().

#define RelationIsMapped (   relation)    ((relation)->rd_rel->relfilenode == InvalidOid)
#define RelationIsPopulated (   relation)    ((relation)->rd_rel->relispopulated)

Definition at line 549 of file rel.h.

Referenced by cluster_rel(), and ExecRefreshMatView().

#define RelationIsScannable (   relation)    ((relation)->rd_rel->relispopulated)

Definition at line 541 of file rel.h.

Referenced by ExecOpenScanRelation().

#define RelationIsSecurityView (   relation)
Value:
((relation)->rd_options ? \
((ViewOptions *) (relation)->rd_options)->security_barrier : false)

Definition at line 344 of file rel.h.

Referenced by ApplyRetrieveRule(), and rewriteTargetView().

#define RelationIsUsedAsCatalogTable (   relation)
Value:
((relation)->rd_options && \
((relation)->rd_rel->relkind == RELKIND_RELATION || \
(relation)->rd_rel->relkind == RELKIND_MATVIEW) ? \
((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
#define RELKIND_MATVIEW
Definition: pg_class.h:167
#define RELKIND_RELATION
Definition: pg_class.h:160

Definition at line 312 of file rel.h.

Referenced by ATRewriteTables(), and transformOnConflictArbiter().

#define RelationNeedsWAL (   relation)    ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)

Definition at line 502 of file rel.h.

Referenced by _bt_delitems_delete(), _bt_delitems_vacuum(), _bt_drop_lock_and_maybe_pin(), _bt_getbuf(), _bt_getroot(), _bt_insertonpg(), _bt_leafbuild(), _bt_load(), _bt_mark_page_halfdead(), _bt_newroot(), _bt_split(), _bt_unlink_halfdead_page(), addLeafTuple(), AlterSequence(), brin_doinsert(), brin_doupdate(), brinbuild(), check_publication_add_relation(), copy_heap_data(), createPostingTree(), dataBeginPlaceToPageLeaf(), dataExecPlaceToPageInternal(), dataExecPlaceToPageLeaf(), DefineIndex(), do_setval(), doPickSplit(), end_heap_rewrite(), entryExecPlaceToPage(), fill_seq_with_data(), FreeSpaceMapTruncateRel(), GenericXLogStart(), get_relation_info(), ginbuild(), ginDeletePage(), ginHeapTupleFastInsert(), ginPlaceToPage(), ginUpdateStats(), ginVacuumPostingTreeLeaf(), gistbuild(), gistbulkdelete(), gistdoinsert(), gistplacetopage(), gistvacuumpage(), heap_abort_speculative(), heap_delete(), heap_finish_speculative(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_page_prune(), heap_sync(), heap_update(), lazy_scan_heap(), lazy_vacuum_page(), log_heap_clean(), log_heap_freeze(), log_heap_update(), moveLeafs(), nextval_internal(), pg_truncate_visibility_map(), RelationTruncate(), revmap_physical_extend(), shiftList(), spgAddNodeAction(), spgbuild(), spgSplitNodeAction(), vacuum_log_cleanup_info(), vacuumLeafPage(), vacuumLeafRoot(), vacuumRedirectAndPlaceholder(), visibilitymap_set(), visibilitymap_truncate(), writeListPage(), and xlogVacuumPage().

#define RelationOpenSmgr (   relation)
Value:
do { \
if ((relation)->rd_smgr == NULL) \
smgrsetowner(&((relation)->rd_smgr), smgropen((relation)->rd_node, (relation)->rd_backend)); \
} while (0)
SMgrRelation smgropen(RelFileNode rnode, BackendId backend)
Definition: smgr.c:137
#define NULL
Definition: c.h:226
void smgrsetowner(SMgrRelation *owner, SMgrRelation reln)
Definition: smgr.c:193

Definition at line 457 of file rel.h.

Referenced by _bt_blwritepage(), _bt_load(), _hash_alloc_buckets(), ATExecSetTableSpace(), end_heap_rewrite(), FlushRelationBuffers(), FreeSpaceMapTruncateRel(), fsm_extend(), fsm_readbuf(), heap_create(), heap_create_init_fork(), index_build(), pg_prewarm(), pg_truncate_visibility_map(), PrefetchBuffer(), raw_heap_insert(), ReadBufferExtended(), RelationGetNumberOfBlocksInFork(), RelationTruncate(), visibilitymap_truncate(), vm_extend(), and vm_readbuf().

#define RelationSetTargetBlock (   relation,
  targblock 
)
Value:
do { \
RelationOpenSmgr(relation); \
(relation)->rd_smgr->smgr_targblock = (targblock); \
} while (0)
#define RelationOpenSmgr(relation)
Definition: rel.h:457

Definition at line 492 of file rel.h.

Referenced by brin_getinsertbuffer(), and RelationGetBufferForTuple().

#define RelationUsesLocalBuffers (   relation)    ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)

Typedef Documentation

Definition at line 47 of file rel.h.

Definition at line 77 of file rel.h.

Function Documentation

static int16 get_partition_col_attnum ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 608 of file rel.h.

References PartitionKeyData::partattrs.

Referenced by ATExecAttachPartition(), ATExecDropNotNull(), and is_partition_attr().

609 {
610  return key->partattrs[col];
611 }
AttrNumber * partattrs
Definition: rel.h:56
static Oid get_partition_col_typid ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 614 of file rel.h.

References PartitionKeyData::parttypid.

Referenced by transformPartitionBound().

615 {
616  return key->parttypid[col];
617 }
Oid * parttypid
Definition: rel.h:69
static int32 get_partition_col_typmod ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 620 of file rel.h.

References PartitionKeyData::parttypmod.

Referenced by transformPartitionBound().

621 {
622  return key->parttypmod[col];
623 }
int32 * parttypmod
Definition: rel.h:70
static List* get_partition_exprs ( PartitionKey  key)
inlinestatic

Definition at line 599 of file rel.h.

References PartitionKeyData::partexprs.

Referenced by is_partition_attr(), and transformPartitionBound().

600 {
601  return key->partexprs;
602 }
List * partexprs
Definition: rel.h:58
static int get_partition_natts ( PartitionKey  key)
inlinestatic

Definition at line 593 of file rel.h.

References PartitionKeyData::partnatts.

Referenced by ATExecAttachPartition(), ATExecDropNotNull(), is_partition_attr(), and transformPartitionBound().

594 {
595  return key->partnatts;
596 }
int16 partnatts
Definition: rel.h:55
static int get_partition_strategy ( PartitionKey  key)
inlinestatic

Definition at line 587 of file rel.h.

References PartitionKeyData::strategy.

Referenced by ATExecDropNotNull(), and transformPartitionBound().

588 {
589  return key->strategy;
590 }
char strategy
Definition: rel.h:54
void RelationDecrementReferenceCount ( Relation  rel)

Definition at line 2135 of file relcache.c.

References Assert, CurrentResourceOwner, IsBootstrapProcessingMode, RelationData::rd_refcnt, and ResourceOwnerForgetRelationRef().

Referenced by heap_endscan(), index_endscan(), RelationCacheInitializePhase3(), RelationClose(), and RelationFlushRelation().

2136 {
2137  Assert(rel->rd_refcnt > 0);
2138  rel->rd_refcnt -= 1;
2141 }
ResourceOwner CurrentResourceOwner
Definition: resowner.c:138
void ResourceOwnerForgetRelationRef(ResourceOwner owner, Relation rel)
Definition: resowner.c:1028
#define Assert(condition)
Definition: c.h:671
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:365
int rd_refcnt
Definition: rel.h:88
List* RelationGetRepsetList ( Relation  rel)
bool RelationHasUnloggedIndex ( Relation  rel)

Definition at line 5892 of file relcache.c.

References elog, ERROR, GETSTRUCT, HASH_AM_OID, HeapTupleIsValid, lfirst_oid, list_free(), ObjectIdGetDatum, RelationGetIndexList(), ReleaseSysCache(), RELOID, RELPERSISTENCE_UNLOGGED, and SearchSysCache1.

5893 {
5894  List *indexoidlist;
5895  ListCell *indexoidscan;
5896  bool result = false;
5897 
5898  indexoidlist = RelationGetIndexList(rel);
5899 
5900  foreach(indexoidscan, indexoidlist)
5901  {
5902  Oid indexoid = lfirst_oid(indexoidscan);
5903  HeapTuple tp;
5904  Form_pg_class reltup;
5905 
5906  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(indexoid));
5907  if (!HeapTupleIsValid(tp))
5908  elog(ERROR, "cache lookup failed for relation %u", indexoid);
5909  reltup = (Form_pg_class) GETSTRUCT(tp);
5910 
5911  if (reltup->relpersistence == RELPERSISTENCE_UNLOGGED
5912  || reltup->relam == HASH_AM_OID)
5913  result = true;
5914 
5915  ReleaseSysCache(tp);
5916 
5917  if (result == true)
5918  break;
5919  }
5920 
5921  list_free(indexoidlist);
5922 
5923  return result;
5924 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define RELPERSISTENCE_UNLOGGED
Definition: pg_class.h:171
unsigned int Oid
Definition: postgres_ext.h:31
#define HASH_AM_OID
Definition: pg_am.h:73
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4336
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
void list_free(List *list)
Definition: list.c:1133
#define elog
Definition: elog.h:219
Definition: pg_list.h:45
#define lfirst_oid(lc)
Definition: pg_list.h:108
void RelationIncrementReferenceCount ( Relation  rel)

Definition at line 2122 of file relcache.c.

References CurrentResourceOwner, IsBootstrapProcessingMode, RelationData::rd_refcnt, ResourceOwnerEnlargeRelationRefs(), and ResourceOwnerRememberRelationRef().

Referenced by heap_beginscan_internal(), index_beginscan_internal(), RelationBuildLocalRelation(), RelationCacheInitializePhase3(), RelationFlushRelation(), and RelationIdGetRelation().

2123 {
2125  rel->rd_refcnt += 1;
2128 }
ResourceOwner CurrentResourceOwner
Definition: resowner.c:138
void ResourceOwnerRememberRelationRef(ResourceOwner owner, Relation rel)
Definition: resowner.c:1019
void ResourceOwnerEnlargeRelationRefs(ResourceOwner owner)
Definition: resowner.c:1008
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:365
int rd_refcnt
Definition: rel.h:88