331 #define HEAP_MIN_FILLFACTOR 10
332 #define HEAP_DEFAULT_FILLFACTOR 100
338 #define RelationGetToastTupleTarget(relation, defaulttarg) \
339 ((relation)->rd_options ? \
340 ((StdRdOptions *) (relation)->rd_options)->toast_tuple_target : (defaulttarg))
346 #define RelationGetFillFactor(relation, defaultff) \
347 ((relation)->rd_options ? \
348 ((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff))
354 #define RelationGetTargetPageUsage(relation, defaultff) \
355 (BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100)
361 #define RelationGetTargetPageFreeSpace(relation, defaultff) \
362 (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100)
369 #define RelationIsUsedAsCatalogTable(relation) \
370 ((relation)->rd_options && \
371 ((relation)->rd_rel->relkind == RELKIND_RELATION || \
372 (relation)->rd_rel->relkind == RELKIND_MATVIEW) ? \
373 ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false)
380 #define RelationGetParallelWorkers(relation, defaultpw) \
381 ((relation)->rd_options ? \
382 ((StdRdOptions *) (relation)->rd_options)->parallel_workers : (defaultpw))
409 #define RelationIsSecurityView(relation) \
410 (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
411 (relation)->rd_options ? \
412 ((ViewOptions *) (relation)->rd_options)->security_barrier : false)
419 #define RelationHasSecurityInvoker(relation) \
420 (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
421 (relation)->rd_options ? \
422 ((ViewOptions *) (relation)->rd_options)->security_invoker : false)
429 #define RelationHasCheckOption(relation) \
430 (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
431 (relation)->rd_options && \
432 ((ViewOptions *) (relation)->rd_options)->check_option != \
433 VIEW_OPTION_CHECK_OPTION_NOT_SET)
440 #define RelationHasLocalCheckOption(relation) \
441 (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
442 (relation)->rd_options && \
443 ((ViewOptions *) (relation)->rd_options)->check_option == \
444 VIEW_OPTION_CHECK_OPTION_LOCAL)
451 #define RelationHasCascadedCheckOption(relation) \
452 (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
453 (relation)->rd_options && \
454 ((ViewOptions *) (relation)->rd_options)->check_option == \
455 VIEW_OPTION_CHECK_OPTION_CASCADED)
461 #define RelationIsValid(relation) PointerIsValid(relation)
463 #define InvalidRelation ((Relation) NULL)
472 #define RelationHasReferenceCountZero(relation) \
473 ((bool)((relation)->rd_refcnt == 0))
482 #define RelationGetForm(relation) ((relation)->rd_rel)
488 #define RelationGetRelid(relation) ((relation)->rd_id)
494 #define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
500 #define IndexRelationGetNumberOfAttributes(relation) \
501 ((relation)->rd_index->indnatts)
507 #define IndexRelationGetNumberOfKeyAttributes(relation) \
508 ((relation)->rd_index->indnkeyatts)
514 #define RelationGetDescr(relation) ((relation)->rd_att)
522 #define RelationGetRelationName(relation) \
523 (NameStr((relation)->rd_rel->relname))
529 #define RelationGetNamespace(relation) \
530 ((relation)->rd_rel->relnamespace)
537 #define RelationIsMapped(relation) \
538 (RELKIND_HAS_STORAGE((relation)->rd_rel->relkind) && \
539 ((relation)->rd_rel->relfilenode == InvalidOid))
568 #define RelationCloseSmgr(relation) \
570 if ((relation)->rd_smgr != NULL) \
572 smgrclose((relation)->rd_smgr); \
573 Assert((relation)->rd_smgr == NULL); \
585 #define RelationGetTargetBlock(relation) \
586 ( (relation)->rd_smgr != NULL ? (relation)->rd_smgr->smgr_targblock : InvalidBlockNumber )
592 #define RelationSetTargetBlock(relation, targblock) \
594 RelationGetSmgr(relation)->smgr_targblock = (targblock); \
601 #define RelationIsPermanent(relation) \
602 ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
612 #define RelationNeedsWAL(relation) \
613 (RelationIsPermanent(relation) && (XLogIsNeeded() || \
614 (relation->rd_createSubid == InvalidSubTransactionId && \
615 relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId)))
621 #define RelationUsesLocalBuffers(relation) \
622 ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
632 #define RELATION_IS_LOCAL(relation) \
633 ((relation)->rd_islocaltemp || \
634 (relation)->rd_createSubid != InvalidSubTransactionId)
642 #define RELATION_IS_OTHER_TEMP(relation) \
643 ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP && \
644 !(relation)->rd_islocaltemp)
653 #define RelationIsScannable(relation) ((relation)->rd_rel->relispopulated)
661 #define RelationIsPopulated(relation) ((relation)->rd_rel->relispopulated)
668 #define RelationIsAccessibleInLogicalDecoding(relation) \
669 (XLogLogicalInfoActive() && \
670 RelationNeedsWAL(relation) && \
671 (IsCatalogRelation(relation) || RelationIsUsedAsCatalogTable(relation)))
685 #define RelationIsLogicallyLogged(relation) \
686 (XLogLogicalInfoActive() && \
687 RelationNeedsWAL(relation) && \
688 (relation)->rd_rel->relkind != RELKIND_FOREIGN_TABLE && \
689 !IsCatalogRelation(relation))
FormData_pg_class * Form_pg_class
FormData_pg_index * Form_pg_index
struct LockRelId LockRelId
void RelationDecrementReferenceCount(Relation rel)
@ VIEW_OPTION_CHECK_OPTION_NOT_SET
@ VIEW_OPTION_CHECK_OPTION_LOCAL
@ VIEW_OPTION_CHECK_OPTION_CASCADED
struct ForeignKeyCacheInfo ForeignKeyCacheInfo
static SMgrRelation RelationGetSmgr(Relation rel)
void RelationIncrementReferenceCount(Relation rel)
struct StdRdOptions StdRdOptions
struct ViewOptions ViewOptions
struct LockInfoData LockInfoData
struct AutoVacOpts AutoVacOpts
struct RelationData RelationData
@ STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO
@ STDRD_OPTION_VACUUM_INDEX_CLEANUP_OFF
@ STDRD_OPTION_VACUUM_INDEX_CLEANUP_ON
void smgrsetowner(SMgrRelation *owner, SMgrRelation reln)
SMgrRelation smgropen(RelFileNode rnode, BackendId backend)
int multixact_freeze_max_age
float8 vacuum_scale_factor
float8 vacuum_ins_scale_factor
int multixact_freeze_table_age
int multixact_freeze_min_age
float8 analyze_scale_factor
Oid conpfeqop[INDEX_MAX_KEYS]
AttrNumber confkey[INDEX_MAX_KEYS]
AttrNumber conkey[INDEX_MAX_KEYS]
MemoryContext rd_partkeycxt
const struct TableAmRoutine * rd_tableam
TransactionId rd_partdesc_nodetached_xmin
struct IndexAmRoutine * rd_indam
SubTransactionId rd_newRelfilenodeSubid
SubTransactionId rd_firstRelfilenodeSubid
struct RowSecurityDesc * rd_rsdesc
PartitionDesc rd_partdesc
RegProcedure * rd_support
PartitionDesc rd_partdesc_nodetached
PublicationDesc * rd_pubdesc
struct FdwRoutine * rd_fdwroutine
struct HeapTupleData * rd_indextuple
MemoryContext rd_partcheckcxt
SubTransactionId rd_createSubid
MemoryContext rd_indexcxt
struct FmgrInfo * rd_supportinfo
SubTransactionId rd_droppedSubid
MemoryContext rd_rulescxt
struct PgStat_TableStatus * pgstat_info
StdRdOptIndexCleanup vacuum_index_cleanup
ViewOptCheckOption check_option