miscadmin.h 6.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 12 13
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
14
 * $Id: miscadmin.h,v 1.26 1998/06/09 17:13:06 momjian Exp $
15 16
 *
 * NOTES
17 18
 *	  some of the information in this file will be moved to
 *	  other files.
19 20 21 22 23 24 25
 *
 *-------------------------------------------------------------------------
 */
#ifndef MISCADMIN_H
#define MISCADMIN_H

/*****************************************************************************
26
 *	  globals.h --															 *
27 28 29 30 31
 *****************************************************************************/

/*
 * from postmaster/postmaster.c
 */
32
extern int	PostmasterMain(int argc, char *argv[]);
33 34 35 36

/*
 * from utils/init/globals.c
 */
37
extern int	Portfd;
38 39 40
extern bool	Noversion;
extern bool	Quiet;
extern bool	QueryCancel;
41
extern char *DataDir;
42

B
Bruce Momjian 已提交
43 44
extern int	MyProcPid;

45
extern char OutputFileName[];
46 47 48 49 50 51 52

/*
 * done in storage/backendid.h for now.
 *
 * extern BackendId    MyBackendId;
 * extern BackendTag   MyBackendTag;
 */
53 54 55
extern bool MyDatabaseIdIsInitialized;
extern Oid	MyDatabaseId;
extern bool TransactionInitWasProcessed;
56

57
extern bool IsUnderPostmaster;
58

59
extern short DebugLvl;
60

61
/* Date/Time Configuration
62 63
 *
 * Constants to pass info from runtime environment:
64 65 66
 *	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.
67
 *	USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
68 69
 *
 * DateStyle specifies preference for date formatting for output.
70
 * EuroDates if client prefers dates interpreted and written w/European conventions.
71 72 73
 *
 * HasCTZSet if client timezone is specified by client.
 * CDayLight is the apparent daylight savings time status.
74 75 76 77
 * CTimeZone is the timezone offset in seconds.
 * CTZName is the timezone label.
 */

78
#define MAXTZLEN		7
79

80 81 82
#define USE_POSTGRES_DATES		0
#define USE_ISO_DATES			1
#define USE_SQL_DATES			2
83
#define USE_GERMAN_DATES		3
84

85 86 87 88 89 90
extern int	DateStyle;
extern bool EuroDates;
extern bool HasCTZSet;
extern bool CDayLight;
extern int	CTimeZone;
extern char CTZName[];
91

92 93
extern char FloatFormat[];
extern char DateFormat[];
94

95 96
extern int	fsyncOff;
extern int	SortMem;
97

98
extern Oid	LastOidProcessed;	/* for query rewrite */
99 100 101

#define MAX_PARSE_BUFFER 8192

102 103 104
/*
 *		default number of buffers in buffer pool
 *
105 106 107 108
 */
#define NDBUFS 64

/*****************************************************************************
109 110
 *	  pdir.h --																 *
 *			POSTGRES directory path definitions.							 *
111 112
 *****************************************************************************/

113 114 115
extern char *DatabaseName;
extern char *DatabasePath;

116 117
/* in utils/misc/database.c */
extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
118
extern int	GetDatabaseInfo(char *name, Oid *owner, char *path);
119 120
extern char *ExpandDatabasePath(char *path);

121
/* now in utils/init/miscinit.c */
122 123 124 125 126 127
extern void SetDatabaseName(char *name);
extern void SetDatabasePath(char *path);
extern char *getpgusername(void);
extern void SetPgUserName(void);
extern Oid	GetUserId(void);
extern void SetUserId(void);
128 129
extern int	ValidateBinary(char *path);
extern int	FindExec(char *backend, char *argv0, char *binary_name);
130
extern int	CheckPathAccess(char *path, char *name, int open_mode);
131

132 133
/* lower case version for case-insensitive SQL referenced in pg_proc.h */
#define GetPgUserName() getpgusername()
134 135

/*****************************************************************************
136 137
 *	  pmod.h --																 *
 *			POSTGRES processing mode definitions.							 *
138 139 140
 *****************************************************************************/
/*
 * Description:
141
 *		There are four processing modes in POSTGRES.  They are NoProcessing
142 143 144
 * or "none," BootstrapProcessing or "bootstrap," InitProcessing or
 * "initialization," and NormalProcessing or "normal."
 *
145
 *		If a POSTGRES binary is in normal mode, then all code may be executed
146 147 148 149
 * normally.  In the none mode, only bookkeeping code may be called.  In
 * particular, access method calls may not occur in this mode since the
 * execution state is outside a transaction.
 *
150
 *		The final two processing modes are used during special times.  When the
151
 * system state indicates bootstrap processing, transactions are all given
152
 * transaction id "one" and are consequently guarenteed to commit.	This mode
153 154 155
 * is used during the initial generation of template databases.
 *
 * Finally, the execution state is in initialization mode until all normal
156
 * initialization is complete.	Some code behaves differently when executed in
157 158 159
 * this mode to enable system bootstrapping.
 */

160 161 162 163 164 165
typedef enum ProcessingMode
{
	NoProcessing,				/* "nothing" can be done */
	BootstrapProcessing,		/* bootstrap creation of template database */
	InitProcessing,				/* initializing system */
	NormalProcessing			/* normal processing */
166
} ProcessingMode;
167 168 169


/*****************************************************************************
170 171
 *	  pinit.h --															 *
 *			POSTGRES initialization and cleanup definitions.				 *
172 173 174
 *****************************************************************************/
/*
 * Note:
175
 *		XXX AddExitHandler not defined yet.
176 177
 */

178
typedef int16 ExitStatus;
179

180 181
#define NormalExitStatus		(0)
#define FatalExitStatus			(127)
182 183 184 185
/* XXX are there any other meaningful exit codes? */

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

186
extern bool PostgresIsInitialized;
187

188
extern void InitPostgres(char *name);
189 190

/* in miscinit.c */
191 192 193 194 195 196 197 198 199
extern void ExitPostgres(ExitStatus status);
extern void StatusBackendExit(int status);
extern void StatusPostmasterExit(int status);

extern bool IsNoProcessingMode(void);
extern bool IsBootstrapProcessingMode(void);
extern bool IsInitProcessingMode(void);
extern bool IsNormalProcessingMode(void);
extern void SetProcessingMode(ProcessingMode mode);
200 201
extern ProcessingMode GetProcessingMode(void);

202
#endif							/* MISCADMIN_H */