]> granicus.if.org Git - postgresql/blob - src/include/miscadmin.h
74c8bf71f19d5b34ef9cb28114572e41219cee0d
[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  *              pdir.h                                                  directory path crud
8  *              pinit.h                                                 postgres initialization
9  *              pmod.h                                                  processing modes
10  *
11  *
12  * Copyright (c) 1994, Regents of the University of California
13  *
14  * $Id: miscadmin.h,v 1.28 1998/07/24 03:32:13 scrappy Exp $
15  *
16  * NOTES
17  *        some of the information in this file will be moved to
18  *        other files.
19  *
20  *-------------------------------------------------------------------------
21  */
22 #ifndef MISCADMIN_H
23 #define MISCADMIN_H
24
25 /*****************************************************************************
26  *        globals.h --                                                                                                                   *
27  *****************************************************************************/
28
29 /*
30  * from postmaster/postmaster.c
31  */
32 extern int      PostmasterMain(int argc, char *argv[]);
33
34 /*
35  * from utils/init/globals.c
36  */
37 extern int      Portfd;
38 extern bool     Noversion;
39 extern bool     Quiet;
40 extern bool     QueryCancel;
41 extern char *DataDir;
42
43 extern int      MyProcPid;
44
45 extern long     MyCancelKey;
46
47 extern char OutputFileName[];
48
49 /*
50  * done in storage/backendid.h for now.
51  *
52  * extern BackendId    MyBackendId;
53  * extern BackendTag   MyBackendTag;
54  */
55 extern bool MyDatabaseIdIsInitialized;
56 extern Oid      MyDatabaseId;
57 extern bool TransactionInitWasProcessed;
58
59 extern bool IsUnderPostmaster;
60
61 extern short DebugLvl;
62
63 /* Date/Time Configuration
64  *
65  * Constants to pass info from runtime environment:
66  *      USE_POSTGRES_DATES specifies traditional postgres format for output.
67  *      USE_ISO_DATES specifies ISO-compliant format for output.
68  *      USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
69  *      USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
70  *
71  * DateStyle specifies preference for date formatting for output.
72  * EuroDates if client prefers dates interpreted and written w/European conventions.
73  *
74  * HasCTZSet if client timezone is specified by client.
75  * CDayLight is the apparent daylight savings time status.
76  * CTimeZone is the timezone offset in seconds.
77  * CTZName is the timezone label.
78  */
79
80 #define MAXTZLEN                7
81
82 #define USE_POSTGRES_DATES              0
83 #define USE_ISO_DATES                   1
84 #define USE_SQL_DATES                   2
85 #define USE_GERMAN_DATES                3
86
87 extern int      DateStyle;
88 extern bool EuroDates;
89 extern bool HasCTZSet;
90 extern bool CDayLight;
91 extern int      CTimeZone;
92 extern char CTZName[];
93
94 extern char FloatFormat[];
95 extern char DateFormat[];
96
97 extern int      fsyncOff;
98 extern int      SortMem;
99
100 extern Oid      LastOidProcessed;       /* for query rewrite */
101
102 #define MAX_PARSE_BUFFER 8192
103
104 /*
105  *              default number of buffers in buffer pool
106  *
107  */
108 #define NDBUFS 64
109
110 /*****************************************************************************
111  *        pdir.h --                                                                                                                              *
112  *                      POSTGRES directory path definitions.                                                     *
113  *****************************************************************************/
114
115 extern char *DatabaseName;
116 extern char *DatabasePath;
117
118 /* in utils/misc/database.c */
119 #ifdef MB
120 extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding);
121 #else
122 extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
123 #endif
124 extern int      GetDatabaseInfo(char *name, Oid *owner, char *path);
125 extern char *ExpandDatabasePath(char *path);
126
127 /* now in utils/init/miscinit.c */
128 extern void SetDatabaseName(char *name);
129 extern void SetDatabasePath(char *path);
130 /* even if MB is not enabled, this function is neccesary
131  * since pg_proc.h does have.
132  */
133 extern const char *getdatabaseencoding(void);
134
135 extern char *getpgusername(void);
136 extern void SetPgUserName(void);
137 extern Oid      GetUserId(void);
138 extern void SetUserId(void);
139 extern int      ValidateBinary(char *path);
140 extern int      FindExec(char *backend, char *argv0, char *binary_name);
141 extern int      CheckPathAccess(char *path, char *name, int open_mode);
142
143 /* lower case version for case-insensitive SQL referenced in pg_proc.h */
144 #define GetPgUserName() getpgusername()
145
146 /*****************************************************************************
147  *        pmod.h --                                                                                                                              *
148  *                      POSTGRES processing mode definitions.                                                    *
149  *****************************************************************************/
150 /*
151  * Description:
152  *              There are four processing modes in POSTGRES.  They are NoProcessing
153  * or "none," BootstrapProcessing or "bootstrap," InitProcessing or
154  * "initialization," and NormalProcessing or "normal."
155  *
156  *              If a POSTGRES binary is in normal mode, then all code may be executed
157  * normally.  In the none mode, only bookkeeping code may be called.  In
158  * particular, access method calls may not occur in this mode since the
159  * execution state is outside a transaction.
160  *
161  *              The final two processing modes are used during special times.  When the
162  * system state indicates bootstrap processing, transactions are all given
163  * transaction id "one" and are consequently guarenteed to commit.      This mode
164  * is used during the initial generation of template databases.
165  *
166  * Finally, the execution state is in initialization mode until all normal
167  * initialization is complete.  Some code behaves differently when executed in
168  * this mode to enable system bootstrapping.
169  */
170
171 typedef enum ProcessingMode
172 {
173         NoProcessing,                           /* "nothing" can be done */
174         BootstrapProcessing,            /* bootstrap creation of template database */
175         InitProcessing,                         /* initializing system */
176         NormalProcessing                        /* normal processing */
177 } ProcessingMode;
178
179
180 /*****************************************************************************
181  *        pinit.h --                                                                                                                     *
182  *                      POSTGRES initialization and cleanup definitions.                                 *
183  *****************************************************************************/
184 /*
185  * Note:
186  *              XXX AddExitHandler not defined yet.
187  */
188
189 typedef int16 ExitStatus;
190
191 #define NormalExitStatus                (0)
192 #define FatalExitStatus                 (127)
193 /* XXX are there any other meaningful exit codes? */
194
195 /* in utils/init/postinit.c */
196
197 extern bool PostgresIsInitialized;
198
199 extern void InitPostgres(char *name);
200
201 /* in miscinit.c */
202 extern void ExitPostgres(ExitStatus status);
203 extern void StatusBackendExit(int status);
204 extern void StatusPostmasterExit(int status);
205
206 extern bool IsNoProcessingMode(void);
207 extern bool IsBootstrapProcessingMode(void);
208 extern bool IsInitProcessingMode(void);
209 extern bool IsNormalProcessingMode(void);
210 extern void SetProcessingMode(ProcessingMode mode);
211 extern ProcessingMode GetProcessingMode(void);
212
213 #endif                                                  /* MISCADMIN_H */