576{
578 {
579 rel->rd_smgr =
smgropen(rel->rd_locator, rel->rd_backend);
581 }
582 return rel->rd_smgr;
583}
584
585
586
587
588
589static inline void
591{
593 {
597 }
598}
599#endif
600
601
602
603
604
605
606
607
608
609#define RelationGetTargetBlock(relation) \
610 ( (relation)->rd_smgr != NULL ? (relation)->rd_smgr->smgr_targblock : InvalidBlockNumber )
611
612
613
614
615
616#define RelationSetTargetBlock(relation, targblock) \
617 do { \
618 RelationGetSmgr(relation)->smgr_targblock = (targblock); \
619 } while (0)
620
621
622
623
624
625#define RelationIsPermanent(relation) \
626 ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
627
628
629
630
631
632
633
634
635
636#define RelationNeedsWAL(relation) \
637 (RelationIsPermanent(relation) && (XLogIsNeeded() || \
638 (relation->rd_createSubid == InvalidSubTransactionId && \
639 relation->rd_firstRelfilelocatorSubid == InvalidSubTransactionId)))
640
641
642
643
644
645#define RelationUsesLocalBuffers(relation) \
646 ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
647
648
649
650
651
652
653
654
655
656#define RELATION_IS_LOCAL(relation) \
657 ((relation)->rd_islocaltemp || \
658 (relation)->rd_createSubid != InvalidSubTransactionId)
659
660
661
662
663
664
665
666#define RELATION_IS_OTHER_TEMP(relation) \
667 ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP && \
668 !(relation)->rd_islocaltemp)
669
670
671
672
673
674
675
676
677#define RelationIsScannable(relation) ((relation)->rd_rel->relispopulated)
678
679
680
681
682
683
684
685#define RelationIsPopulated(relation) ((relation)->rd_rel->relispopulated)
686
687
688
689
690
691
692#define RelationIsAccessibleInLogicalDecoding(relation) \
693 (XLogLogicalInfoActive() && \
694 RelationNeedsWAL(relation) && \
695 (IsCatalogRelation(relation) || RelationIsUsedAsCatalogTable(relation)))
696
697
698
699
700
701
702
703
704
705
706
707
708
709#define RelationIsLogicallyLogged(relation) \
710 (XLogLogicalInfoActive() && \
711 RelationNeedsWAL(relation) && \
712 (relation)->rd_rel->relkind != RELKIND_FOREIGN_TABLE && \
713 !IsCatalogRelation(relation))
714
715
718
719#endif
void RelationDecrementReferenceCount(Relation rel)
void RelationIncrementReferenceCount(Relation rel)
static void RelationCloseSmgr(Relation relation)
SMgrRelation smgropen(RelFileLocator rlocator, ProcNumber backend)
void smgrpin(SMgrRelation reln)
void smgrunpin(SMgrRelation reln)
void smgrclose(SMgrRelation reln)