]> granicus.if.org Git - postgresql/blob - src/include/miscadmin.h
Use new utils/version.c instead of backend/utils/init/magic.c.
[postgresql] / src / include / miscadmin.h
1 /*-------------------------------------------------------------------------
2  *
3  * miscadmin.h--
4  *    this file contains general postgres administration and initialization
5  *    stuff that used to be spread out between the following files:
6  *      globals.h                       global variables
7  *      magic.h                         PG_RELEASE, PG_VERSION, etc defines
8  *      pdir.h                          directory path crud
9  *      pinit.h                         postgres initialization
10  *      pmod.h                          processing modes
11  *
12  *
13  * Copyright (c) 1994, Regents of the University of California
14  *
15  * $Id: miscadmin.h,v 1.3 1996/11/12 06:47:10 bryanh Exp $
16  *
17  * NOTES
18  *    some of the information in this file will be moved to
19  *    other files.
20  *
21  *-------------------------------------------------------------------------
22  */
23 #ifndef MISCADMIN_H
24 #define MISCADMIN_H
25
26 /*****************************************************************************
27  *    globals.h --                                                           *
28  *****************************************************************************/
29
30 /*
31  * from postmaster/postmaster.c
32  */
33 extern int PostmasterMain(int argc, char* argv[]);
34
35 /*
36  * from utils/init/globals.c
37  */
38 extern int Portfd;
39 extern int Noversion;    /* moved from magic.c  */
40 extern int MasterPid;    /* declared and defined in utils/initglobals.c */
41 extern int Quiet;
42 extern char *DataDir;   
43
44 extern char       OutputFileName[];
45 extern void       InitGlobals(void);
46
47 /*
48  * done in storage/backendid.h for now.
49  *
50  * extern BackendId    MyBackendId;
51  * extern BackendTag   MyBackendTag;
52  */
53 extern bool         MyDatabaseIdIsInitialized;
54 extern Oid          MyDatabaseId;
55 extern bool         TransactionInitWasProcessed;
56
57 extern bool         IsUnderPostmaster;
58 extern bool         IsPostmaster;
59
60 extern short        DebugLvl;
61
62 extern Oid          LastOidProcessed;   /* for query rewrite */
63
64 #define MAX_PARSE_BUFFER 8192
65
66 /* 
67  *      default number of buffers in buffer pool
68  * 
69  */
70 #define NDBUFS 64
71
72 /*****************************************************************************
73  *    pdir.h --                                                              *
74  *          POSTGRES directory path definitions.                             *
75  *****************************************************************************/
76
77 /* now in utils/init/miscinit.c */
78 extern char *GetDatabasePath(void);
79 extern char *GetDatabaseName(void);
80 extern void SetDatabaseName(char *name);
81 extern void SetDatabasePath(char *path);
82 extern char *GetPgUserName(void);
83 extern void SetPgUserName(void);
84 extern Oid GetUserId(void);
85 extern void SetUserId(void);
86 extern char *GetPGHome(void);
87 extern char *GetPGData(void);
88 extern int ValidateBackend(char *path);
89 extern int FindBackend(char *backend, char *argv0);
90 extern int CheckPathAccess(char *path, char *name, int open_mode);
91
92
93 /*****************************************************************************
94  *    pmod.h --                                                              *
95  *          POSTGRES processing mode definitions.                            *
96  *****************************************************************************/
97 /*
98  * Description:
99  *      There are four processing modes in POSTGRES.  They are NoProcessing
100  * or "none," BootstrapProcessing or "bootstrap," InitProcessing or
101  * "initialization," and NormalProcessing or "normal."
102  *
103  *      If a POSTGRES binary is in normal mode, then all code may be executed
104  * normally.  In the none mode, only bookkeeping code may be called.  In
105  * particular, access method calls may not occur in this mode since the
106  * execution state is outside a transaction.
107  *
108  *      The final two processing modes are used during special times.  When the
109  * system state indicates bootstrap processing, transactions are all given
110  * transaction id "one" and are consequently guarenteed to commit.  This mode
111  * is used during the initial generation of template databases.
112  *
113  * Finally, the execution state is in initialization mode until all normal
114  * initialization is complete.  Some code behaves differently when executed in
115  * this mode to enable system bootstrapping.
116  */
117
118 typedef enum ProcessingMode {
119     NoProcessing,               /* "nothing" can be done */
120     BootstrapProcessing,        /* bootstrap creation of template database */
121     InitProcessing,             /* initializing system */
122     NormalProcessing            /* normal processing */
123 } ProcessingMode;
124
125
126 /*****************************************************************************
127  *    pinit.h --                                                             *
128  *          POSTGRES initialization and cleanup definitions.                 *
129  *****************************************************************************/
130 /*
131  * Note:
132  *      XXX AddExitHandler not defined yet.
133  */
134
135 typedef int16   ExitStatus;
136
137 #define NormalExitStatus        (0)
138 #define FatalExitStatus         (127)
139 /* XXX are there any other meaningful exit codes? */
140
141 /* in utils/init/postinit.c */
142 extern void InitMyDatabaseId(void);
143 extern void InitUserid(void);
144 extern void InitCommunication(void);
145 extern void InitStdio(void);
146
147 extern bool PostgresIsInitialized;
148
149 extern void InitPostgres(char *name);
150
151 /* in miscinit.c */
152 extern void ExitPostgres(ExitStatus status);
153 extern void AbortPostgres(void);
154 extern void StatusBackendExit(int status);
155 extern void StatusPostmasterExit(int status);
156
157 extern bool IsNoProcessingMode(void);
158 extern bool IsBootstrapProcessingMode(void);
159 extern bool IsInitProcessingMode(void);
160 extern bool IsNormalProcessingMode(void);
161 extern void SetProcessingMode(ProcessingMode mode);
162 extern ProcessingMode GetProcessingMode(void);
163
164 #endif  /* MISCADMIN_H */