miscadmin.h 7.1 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * miscadmin.h
4 5 6 7 8 9
 *	  this file contains general postgres administration and initialization
 *	  stuff that used to be spread out between the following files:
 *		globals.h						global variables
 *		pdir.h							directory path crud
 *		pinit.h							postgres initialization
 *		pmod.h							processing modes
10 11
 *
 *
B
Add:  
Bruce Momjian 已提交
12 13
 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
 * Portions Copyright (c) 1994, Regents of the University of California
14
 *
15
 * $Id: miscadmin.h,v 1.74 2000/11/25 22:34:13 momjian Exp $
16 17
 *
 * NOTES
18 19
 *	  some of the information in this file will be moved to
 *	  other files.
20 21 22 23 24 25
 *
 *-------------------------------------------------------------------------
 */
#ifndef MISCADMIN_H
#define MISCADMIN_H

26
#include <sys/types.h>			/* For pid_t */
27

28
#include "postgres.h"
B
Bruce Momjian 已提交
29
#include "storage/ipc.h"
30

31
/*****************************************************************************
32
 *	  globals.h --															 *
33 34 35 36 37
 *****************************************************************************/

/*
 * from postmaster/postmaster.c
 */
38
extern int	PostmasterMain(int argc, char *argv[]);
39 40 41 42

/*
 * from utils/init/globals.c
 */
43 44 45
extern bool Noversion;
extern bool Quiet;
extern bool QueryCancel;
46
extern char *DataDir;
47

B
Bruce Momjian 已提交
48
extern int	MyProcPid;
49 50
extern struct Port *MyProcPort;
extern long MyCancelKey;
M
 
Marc G. Fournier 已提交
51

52
extern char OutputFileName[];
53 54 55 56 57 58

/*
 * done in storage/backendid.h for now.
 *
 * extern BackendId    MyBackendId;
 */
59 60 61
extern bool MyDatabaseIdIsInitialized;
extern Oid	MyDatabaseId;
extern bool TransactionInitWasProcessed;
62

63
extern bool IsUnderPostmaster;
64

65
extern int	DebugLvl;
66

67
/* Date/Time Configuration
68 69
 *
 * Constants to pass info from runtime environment:
70 71 72
 *	USE_POSTGRES_DATES specifies traditional postgres format for output.
 *	USE_ISO_DATES specifies ISO-compliant format for output.
 *	USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
73
 *	USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
74 75
 *
 * DateStyle specifies preference for date formatting for output.
76
 * EuroDates if client prefers dates interpreted and written w/European conventions.
77 78 79
 *
 * HasCTZSet if client timezone is specified by client.
 * CDayLight is the apparent daylight savings time status.
80 81 82 83
 * CTimeZone is the timezone offset in seconds.
 * CTZName is the timezone label.
 */

84
#define MAXTZLEN		10		/* max TZ name len, not counting tr. null */
85

86 87 88
#define USE_POSTGRES_DATES		0
#define USE_ISO_DATES			1
#define USE_SQL_DATES			2
89
#define USE_GERMAN_DATES		3
90

91 92 93 94 95 96
extern int	DateStyle;
extern bool EuroDates;
extern bool HasCTZSet;
extern bool CDayLight;
extern int	CTimeZone;
extern char CTZName[];
97

98 99
extern char FloatFormat[];
extern char DateFormat[];
100

101
extern bool enableFsync;
B
Bruce Momjian 已提交
102
extern bool allowSystemTableMods;
103
extern int	SortMem;
104

105 106 107 108
/* a few postmaster startup options are exported here so the
   configuration file processor has access to them */

extern bool NetServer;
109
extern bool EnableSSL;
110
extern bool SilentMode;
111 112
extern int MaxBackends;
extern int NBuffers;
B
Bruce Momjian 已提交
113
extern int PostPortNumber;
114 115 116 117 118
extern int Unix_socket_permissions;
extern char *Unix_socket_group;
extern char *UnixSocketDir;
extern char *Virtual_host;

119

120
/*****************************************************************************
121 122
 *	  pdir.h --																 *
 *			POSTGRES directory path definitions.							 *
123 124
 *****************************************************************************/

125 126 127
extern char *DatabaseName;
extern char *DatabasePath;

128
/* in utils/misc/database.c */
129 130
extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path);
extern char *ExpandDatabasePath(const char *path);
131

132
/* now in utils/init/miscinit.c */
133 134
extern void SetDatabaseName(const char *name);
extern void SetDatabasePath(const char *path);
135

136 137 138
extern char *GetUserName(Oid userid);

extern Oid GetUserId(void);
139
extern void SetUserId(Oid userid);
140 141 142 143
extern Oid GetSessionUserId(void);
extern void SetSessionUserId(Oid userid);
extern void SetSessionUserIdFromUserName(const char *username);

144 145
extern void SetDataDir(const char *dir);

146
extern int	FindExec(char *full_path, const char *argv0, const char *binary_name);
147
extern int	CheckPathAccess(char *path, char *name, int open_mode);
148

149
#ifdef CYR_RECODE
150
extern char *convertstr(unsigned char *buff, int len, int dest);
151 152
#endif

153
/*****************************************************************************
154 155
 *	  pmod.h --																 *
 *			POSTGRES processing mode definitions.							 *
156 157 158
 *****************************************************************************/
/*
 * Description:
159
 *		There are three processing modes in POSTGRES.  They are
160
 * "BootstrapProcessing or "bootstrap," InitProcessing or
161 162
 * "initialization," and NormalProcessing or "normal."
 *
163
 * The first two processing modes are used during special times. When the
164
 * system state indicates bootstrap processing, transactions are all given
165
 * transaction id "one" and are consequently guarenteed to commit. This mode
166 167
 * is used during the initial generation of template databases.
 *
168 169
 * Initialization mode until all normal initialization is complete.
 * Some code behaves differently when executed in this mode to enable
170 171 172
 * system bootstrapping.
 *
 * If a POSTGRES binary is in normal mode, then all code may be executed
173
 * normally.
174 175
 */

176 177 178 179 180
typedef enum ProcessingMode
{
	BootstrapProcessing,		/* bootstrap creation of template database */
	InitProcessing,				/* initializing system */
	NormalProcessing			/* normal processing */
181
} ProcessingMode;
182 183 184


/*****************************************************************************
185 186
 *	  pinit.h --															 *
 *			POSTGRES initialization and cleanup definitions.				 *
187 188 189
 *****************************************************************************/
/*
 * Note:
190
 *		XXX AddExitHandler not defined yet.
191 192
 */

193
typedef int16 ExitStatus;
194

195 196
#define NormalExitStatus		(0)
#define FatalExitStatus			(127)
197 198 199 200
/* XXX are there any other meaningful exit codes? */

/* in utils/init/postinit.c */

201
extern int	lockingOff;
202

203
extern void InitPostgres(const char *dbname, const char *username);
204
extern void BaseInit(void);
205 206 207 208 209 210 211 212 213 214 215 216

/* one of the ways to get out of here */
#define ExitPostgres(status) proc_exec(status)

/* processing mode support stuff */
extern ProcessingMode Mode;

#define IsBootstrapProcessingMode() ((bool)(Mode == BootstrapProcessing))
#define IsInitProcessingMode() ((bool)(Mode == InitProcessing))
#define IsNormalProcessingMode() ((bool)(Mode == NormalProcessing))

#define SetProcessingMode(mode) \
217 218 219 220 221
	do { \
		AssertArg(mode == BootstrapProcessing || mode == InitProcessing || \
				  mode == NormalProcessing); \
		Mode = mode; \
	} while(0)
222

223
#define GetProcessingMode() Mode
224

H
Hiroshi Inoue 已提交
225 226 227
extern void IgnoreSystemIndexes(bool mode);
extern bool IsIgnoringSystemIndexes(void);
extern bool IsCacheInitialized(void);
228
extern void SetWaitingForLock(bool);
229

230
/*
T
Tatsuo Ishii 已提交
231 232 233 234 235 236 237 238
 * "postmaster.pid" is a file containing postmaster's pid, being
 * created uder $PGDATA upon postmaster's starting up. When postmaster
 * shuts down, it will be unlinked.
*/
#define PIDFNAME	"postmaster.pid"

extern void SetPidFname(char *datadir);
extern void UnlinkPidFile(void);
239
extern int	SetPidFile(pid_t pid);
T
Tatsuo Ishii 已提交
240

241 242 243

extern void ValidatePgVersion(const char *path);

244
#endif	 /* MISCADMIN_H */