]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_control.h
pgindent run.
[postgresql] / src / include / catalog / pg_control.h
1 /*-------------------------------------------------------------------------
2  *
3  * pg_control.h
4  *        The system control file "pg_control" is not a heap relation.
5  *        However, we define it here so that the format is documented.
6  *
7  *
8  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $Id: pg_control.h,v 1.10 2002/09/04 20:31:37 momjian Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #ifndef PG_CONTROL_H
16 #define PG_CONTROL_H
17
18 #include <time.h>
19
20 #include "access/xlogdefs.h"
21 #include "utils/pg_crc.h"
22
23
24 /* Version identifier for this pg_control format */
25 #define PG_CONTROL_VERSION      72
26
27 /*
28  * Body of CheckPoint XLOG records.  This is declared here because we keep
29  * a copy of the latest one in pg_control for possible disaster recovery.
30  */
31 typedef struct CheckPoint
32 {
33         XLogRecPtr      redo;                   /* next RecPtr available when we */
34         /* began to create CheckPoint */
35         /* (i.e. REDO start point) */
36         XLogRecPtr      undo;                   /* first record of oldest in-progress */
37         /* transaction when we started */
38         /* (i.e. UNDO end point) */
39         StartUpID       ThisStartUpID;  /* current SUI */
40         TransactionId nextXid;          /* next free XID */
41         Oid                     nextOid;                /* next free OID */
42         time_t          time;                   /* time stamp of checkpoint */
43 } CheckPoint;
44
45 /* XLOG info values for XLOG rmgr */
46 #define XLOG_CHECKPOINT_SHUTDOWN                0x00
47 #define XLOG_CHECKPOINT_ONLINE                  0x10
48 #define XLOG_NEXTOID                                    0x30
49
50
51 /* System status indicator */
52 typedef enum DBState
53 {
54         DB_STARTUP = 0,
55         DB_SHUTDOWNED,
56         DB_SHUTDOWNING,
57         DB_IN_RECOVERY,
58         DB_IN_PRODUCTION
59 } DBState;
60
61 #define LOCALE_NAME_BUFLEN      128
62
63 /*
64  * Contents of pg_control.
65  *
66  * NOTE: try to keep this under 512 bytes so that it will fit on one physical
67  * sector of typical disk drives.  This reduces the odds of corruption due to
68  * power failure midway through a write.  Currently it fits comfortably,
69  * but we could probably reduce LOCALE_NAME_BUFLEN if things get tight.
70  */
71
72 typedef struct ControlFileData
73 {
74         crc64           crc;                    /* CRC for remainder of struct */
75
76         /*
77          * Version identifier information.      Keep these fields at the front,
78          * especially pg_control_version; they won't be real useful if they
79          * move around.
80          *
81          * pg_control_version identifies the format of pg_control itself.
82          * catalog_version_no identifies the format of the system catalogs.
83          *
84          * There are additional version identifiers in individual files; for
85          * example, WAL logs contain per-page magic numbers that can serve as
86          * version cues for the WAL log.
87          */
88         uint32          pg_control_version;             /* PG_CONTROL_VERSION */
89         uint32          catalog_version_no;             /* see catversion.h */
90
91         /*
92          * System status data
93          */
94         DBState         state;                  /* see enum above */
95         time_t          time;                   /* time stamp of last pg_control update */
96         uint32          logId;                  /* current log file id */
97         uint32          logSeg;                 /* current log file segment, + 1 */
98         XLogRecPtr      checkPoint;             /* last check point record ptr */
99         XLogRecPtr      prevCheckPoint; /* previous check point record ptr */
100
101         CheckPoint      checkPointCopy; /* copy of last check point record */
102
103         /*
104          * This data is used to make sure that configuration of this database
105          * is compatible with the backend executable.
106          */
107         uint32          blcksz;                 /* block size for this DB */
108         uint32          relseg_size;    /* blocks per segment of large relation */
109
110         uint32          nameDataLen;    /* catalog name field width */
111         uint32          funcMaxArgs;    /* maximum number of function arguments */
112
113         /* flag indicating internal format of timestamp, interval, time */
114         uint32          enableIntTimes; /* int64 storage enabled? */
115
116         /* active locales */
117         uint32          localeBuflen;
118         char            lc_collate[LOCALE_NAME_BUFLEN];
119         char            lc_ctype[LOCALE_NAME_BUFLEN];
120 } ControlFileData;
121
122 #endif   /* PG_CONTROL_H */