miscadmin.h 6.13 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.18 1997/12/04 23:58:01 thomas 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 38 39 40 41
extern int	Portfd;
extern int	Noversion;
extern int	MasterPid;
extern int	Quiet;
extern char *DataDir;
42

43
extern char OutputFileName[];
44 45 46 47 48 49 50

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

55 56
extern bool IsUnderPostmaster;
extern bool IsPostmaster;
57

58
extern short DebugLvl;
59

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

77
#define MAXTZLEN		7
78

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

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

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

94 95
extern int	fsyncOff;
extern int	SortMem;
96

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

#define MAX_PARSE_BUFFER 8192

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

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

112 113 114 115 116
/* in utils/misc/database.c */
extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
extern int GetDatabaseInfo(char *name, Oid *owner, char *path);
extern char *ExpandDatabasePath(char *path);

117
/* now in utils/init/miscinit.c */
118 119 120 121 122 123 124 125 126 127 128
extern char *GetDatabasePath(void);
extern char *GetDatabaseName(void);
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);
extern int	ValidateBackend(char *path);
extern int	FindBackend(char *backend, char *argv0);
extern int	CheckPathAccess(char *path, char *name, int open_mode);
129

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

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

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


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

176
typedef int16 ExitStatus;
177

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

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

184
extern bool PostgresIsInitialized;
185

186
extern void InitPostgres(char *name);
187 188

/* in miscinit.c */
189 190 191 192 193 194 195 196 197
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);
198 199
extern ProcessingMode GetProcessingMode(void);

200
#endif							/* MISCADMIN_H */