00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef SMGR_H
00015 #define SMGR_H
00016
00017 #include "fmgr.h"
00018 #include "storage/block.h"
00019 #include "storage/relfilenode.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 typedef struct SMgrRelationData
00041 {
00042
00043 RelFileNodeBackend smgr_rnode;
00044
00045
00046 struct SMgrRelationData **smgr_owner;
00047
00048
00049
00050
00051
00052
00053
00054
00055 BlockNumber smgr_targblock;
00056 BlockNumber smgr_fsm_nblocks;
00057 BlockNumber smgr_vm_nblocks;
00058
00059
00060
00061
00062
00063
00064
00065 int smgr_which;
00066
00067
00068 struct _MdfdVec *md_fd[MAX_FORKNUM + 1];
00069
00070
00071 struct SMgrRelationData *next_unowned_reln;
00072 } SMgrRelationData;
00073
00074 typedef SMgrRelationData *SMgrRelation;
00075
00076 #define SmgrIsTemp(smgr) \
00077 RelFileNodeBackendIsTemp((smgr)->smgr_rnode)
00078
00079 extern void smgrinit(void);
00080 extern SMgrRelation smgropen(RelFileNode rnode, BackendId backend);
00081 extern bool smgrexists(SMgrRelation reln, ForkNumber forknum);
00082 extern void smgrsetowner(SMgrRelation *owner, SMgrRelation reln);
00083 extern void smgrclose(SMgrRelation reln);
00084 extern void smgrcloseall(void);
00085 extern void smgrclosenode(RelFileNodeBackend rnode);
00086 extern void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
00087 extern void smgrdounlink(SMgrRelation reln, bool isRedo);
00088 extern void smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo);
00089 extern void smgrdounlinkfork(SMgrRelation reln, ForkNumber forknum, bool isRedo);
00090 extern void smgrextend(SMgrRelation reln, ForkNumber forknum,
00091 BlockNumber blocknum, char *buffer, bool skipFsync);
00092 extern void smgrprefetch(SMgrRelation reln, ForkNumber forknum,
00093 BlockNumber blocknum);
00094 extern void smgrread(SMgrRelation reln, ForkNumber forknum,
00095 BlockNumber blocknum, char *buffer);
00096 extern void smgrwrite(SMgrRelation reln, ForkNumber forknum,
00097 BlockNumber blocknum, char *buffer, bool skipFsync);
00098 extern BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum);
00099 extern void smgrtruncate(SMgrRelation reln, ForkNumber forknum,
00100 BlockNumber nblocks);
00101 extern void smgrimmedsync(SMgrRelation reln, ForkNumber forknum);
00102 extern void smgrpreckpt(void);
00103 extern void smgrsync(void);
00104 extern void smgrpostckpt(void);
00105 extern void AtEOXact_SMgr(void);
00106
00107
00108
00109
00110
00111 extern void mdinit(void);
00112 extern void mdclose(SMgrRelation reln, ForkNumber forknum);
00113 extern void mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
00114 extern bool mdexists(SMgrRelation reln, ForkNumber forknum);
00115 extern void mdunlink(RelFileNodeBackend rnode, ForkNumber forknum, bool isRedo);
00116 extern void mdextend(SMgrRelation reln, ForkNumber forknum,
00117 BlockNumber blocknum, char *buffer, bool skipFsync);
00118 extern void mdprefetch(SMgrRelation reln, ForkNumber forknum,
00119 BlockNumber blocknum);
00120 extern void mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
00121 char *buffer);
00122 extern void mdwrite(SMgrRelation reln, ForkNumber forknum,
00123 BlockNumber blocknum, char *buffer, bool skipFsync);
00124 extern BlockNumber mdnblocks(SMgrRelation reln, ForkNumber forknum);
00125 extern void mdtruncate(SMgrRelation reln, ForkNumber forknum,
00126 BlockNumber nblocks);
00127 extern void mdimmedsync(SMgrRelation reln, ForkNumber forknum);
00128 extern void mdpreckpt(void);
00129 extern void mdsync(void);
00130 extern void mdpostckpt(void);
00131
00132 extern void SetForwardFsyncRequests(void);
00133 extern void RememberFsyncRequest(RelFileNode rnode, ForkNumber forknum,
00134 BlockNumber segno);
00135 extern void ForgetRelationFsyncRequests(RelFileNode rnode, ForkNumber forknum);
00136 extern void ForgetDatabaseFsyncRequests(Oid dbid);
00137
00138
00139 extern Datum smgrout(PG_FUNCTION_ARGS);
00140 extern Datum smgrin(PG_FUNCTION_ARGS);
00141 extern Datum smgreq(PG_FUNCTION_ARGS);
00142 extern Datum smgrne(PG_FUNCTION_ARGS);
00143
00144 #endif