13
13
*
14
14
*
15
15
* IDENTIFICATION
16
- * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.82 2004/05/25 01:00:20 momjian Exp $
16
+ * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.83 2004/05/27 15:07:40 momjian Exp $
17
17
*
18
18
*-------------------------------------------------------------------------
19
19
*/
23
23
#include <pwd.h>
24
24
#include <unistd.h>
25
25
26
- #if defined(__alpha )&& defined(__osf__ )/* no __alpha__ ? */
26
+ #if defined(__alpha )&& defined(__osf__ )/* no __alpha__ ? */
27
27
#include <sys/sysinfo.h>
28
28
#include "machine/hal_sysinfo.h"
29
29
#define ASSEMBLER
50
50
main (int argc ,char * argv [])
51
51
{
52
52
int len ;
53
+
53
54
#ifndef WIN32
54
55
struct passwd * pw ;
55
56
#endif
@@ -67,7 +68,7 @@ main(int argc, char *argv[])
67
68
* without help. Avoid adding more here, if you can.
68
69
*/
69
70
70
- #if defined(__alpha )/* no __alpha__ ? */
71
+ #if defined(__alpha )/* no __alpha__ ? */
71
72
#ifdef NOFIXADE
72
73
int buffer []= {SSIN_UACPROC ,UAC_SIGBUS };
73
74
#endif /* NOFIXADE */
@@ -77,7 +78,7 @@ main(int argc, char *argv[])
77
78
#endif /* __alpha */
78
79
79
80
#ifdef WIN32
80
- char * env_locale ;
81
+ char * env_locale ;
81
82
#endif
82
83
83
84
#if defined(NOFIXADE )|| defined(NOPRINTADE )
@@ -86,7 +87,7 @@ main(int argc, char *argv[])
86
87
syscall (SYS_sysmips ,MIPS_FIXADE ,0 ,NULL ,NULL ,NULL );
87
88
#endif
88
89
89
- #if defined(__alpha )/* no __alpha__ ? */
90
+ #if defined(__alpha )/* no __alpha__ ? */
90
91
if (setsysinfo (SSI_NVPAIRS ,buffer ,1 , (caddr_t )NULL ,
91
92
(unsigned long )NULL )< 0 )
92
93
fprintf (stderr ,gettext ("%s: setsysinfo failed: %s\n" ),
@@ -96,15 +97,15 @@ main(int argc, char *argv[])
96
97
97
98
#if defined(WIN32 )
98
99
{
99
- WSADATA wsaData ;
100
- int err ;
100
+ WSADATA wsaData ;
101
+ int err ;
101
102
102
103
/* Make output streams unbuffered by default */
103
- setvbuf (stdout ,NULL ,_IONBF ,0 );
104
- setvbuf (stderr ,NULL ,_IONBF ,0 );
104
+ setvbuf (stdout ,NULL ,_IONBF ,0 );
105
+ setvbuf (stderr ,NULL ,_IONBF ,0 );
105
106
106
107
/* Prepare Winsock */
107
- err = WSAStartup (MAKEWORD (2 ,2 ),& wsaData );
108
+ err = WSAStartup (MAKEWORD (2 ,2 ),& wsaData );
108
109
if (err != 0 )
109
110
{
110
111
fprintf (stderr ,"%s: WSAStartup failed: %d\n" ,
@@ -129,47 +130,48 @@ main(int argc, char *argv[])
129
130
130
131
/*
131
132
* Remember the physical location of the initially given argv[] array
132
- * for possible use by ps display. On some platforms, the argv[]
133
- * storage must be overwritten in order to set the process title for ps.
134
- * In such cases save_ps_display_args makes and returns a new copy of
135
- * the argv[] array.
133
+ * for possible use by ps display. On some platforms, the argv[]
134
+ * storage must be overwritten in order to set the process title for
135
+ *ps. In such cases save_ps_display_args makes and returns a new copy
136
+ *of the argv[] array.
136
137
*
137
138
* save_ps_display_args may also move the environment strings to make
138
- * extra room. Therefore this should be done as early as possible during
139
- * startup, to avoid entanglements with code that might save a getenv()
140
- * result pointer.
139
+ * extra room. Therefore this should be done as early as possible
140
+ *during startup, to avoid entanglements with code that might save a
141
+ *getenv() result pointer.
141
142
*/
142
143
argv = save_ps_display_args (argc ,argv );
143
144
144
145
/*
145
146
* Set up locale information from environment.Note that LC_CTYPE and
146
147
* LC_COLLATE will be overridden later from pg_control if we are in an
147
148
* already-initialized database. We set them here so that they will
148
- * be available to fill pg_control during initdb. LC_MESSAGES will get
149
- * set later during GUC option processing, but we set it here to allow
150
- * startup error messages to be localized.
149
+ * be available to fill pg_control during initdb. LC_MESSAGES will
150
+ *get set later during GUC option processing, but we set it here to
151
+ *allow startup error messages to be localized.
151
152
*/
152
153
153
154
set_pglocale (argv [0 ],"postgres" );
154
155
155
156
#ifdef WIN32
156
- /*
157
- * Windows uses codepages rather than the environment, so we work around
158
- * that by querying the environment explicitly first for LC_COLLATE
159
- * and LC_CTYPE. We have to do this because initdb passes those values
160
- * in the environment. If there is nothing there we fall back on the
161
- * codepage.
157
+
158
+ /*
159
+ * Windows uses codepages rather than the environment, so we work
160
+ * around that by querying the environment explicitly first for
161
+ * LC_COLLATE and LC_CTYPE. We have to do this because initdb passes
162
+ * those values in the environment. If there is nothing there we fall
163
+ * back on the codepage.
162
164
*/
163
165
164
166
if ((env_locale = getenv ("LC_COLLATE" ))!= NULL )
165
- setlocale (LC_COLLATE ,env_locale );
167
+ setlocale (LC_COLLATE ,env_locale );
166
168
else
167
- setlocale (LC_COLLATE ,"" );
169
+ setlocale (LC_COLLATE ,"" );
168
170
169
171
if ((env_locale = getenv ("LC_CTYPE" ))!= NULL )
170
- setlocale (LC_CTYPE ,env_locale );
172
+ setlocale (LC_CTYPE ,env_locale );
171
173
else
172
- setlocale (LC_CTYPE ,"" );
174
+ setlocale (LC_CTYPE ,"" );
173
175
#else
174
176
setlocale (LC_COLLATE ,"" );
175
177
setlocale (LC_CTYPE ,"" );
@@ -213,7 +215,7 @@ main(int argc, char *argv[])
213
215
gettext ("\"root\" execution of the PostgreSQL server is not permitted.\n"
214
216
"The server must be started under an unprivileged user ID to prevent\n"
215
217
"possible system security compromise. See the documentation for\n"
216
- "more information on how to properly start the server.\n"
218
+ "more information on how to properly start the server.\n"
217
219
));
218
220
exit (1 );
219
221
}
@@ -241,14 +243,14 @@ main(int argc, char *argv[])
241
243
/*
242
244
* Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain,
243
245
* SubPostmasterMain, pgstat_main, pgstat_mainChild or BootstrapMain
244
- * depending on the program name (and possibly first argument) we
245
- *were called with. The lack of consistency here is historical.
246
+ * depending on the program name (and possibly first argument) we were
247
+ * called with. The lack of consistency here is historical.
246
248
*/
247
249
len = strlen (argv [0 ]);
248
250
249
251
if ((len >=10 && strcmp (argv [0 ]+ len - 10 ,"postmaster" )== 0 )
250
252
#ifdef WIN32
251
- || (len >=14 && strcmp (argv [0 ]+ len - 14 ,"postmaster.exe" )== 0 )
253
+ || (len >=14 && strcmp (argv [0 ]+ len - 14 ,"postmaster.exe" )== 0 )
252
254
#endif
253
255
)
254
256
{
@@ -264,9 +266,11 @@ main(int argc, char *argv[])
264
266
exit (BootstrapMain (argc - 1 ,argv + 1 ));
265
267
266
268
#ifdef EXEC_BACKEND
269
+
267
270
/*
268
- * If the first argument is "-forkexec", then invoke SubPostmasterMain. Note
269
- * we remove "-forkexec" from the arguments passed on to SubPostmasterMain.
271
+ * If the first argument is "-forkexec", then invoke
272
+ * SubPostmasterMain. Note we remove "-forkexec" from the arguments
273
+ * passed on to SubPostmasterMain.
270
274
*/
271
275
if (argc > 1 && strcmp (argv [1 ],"-forkexec" )== 0 )
272
276
{
@@ -275,16 +279,16 @@ main(int argc, char *argv[])
275
279
}
276
280
277
281
/*
278
- * If the first argument is "-statBuf", then invoke pgstat_main.
282
+ * If the first argument is "-statBuf", then invoke pgstat_main.
279
283
*/
280
284
if (argc > 1 && strcmp (argv [1 ],"-statBuf" )== 0 )
281
285
{
282
- pgstat_main (argc ,argv );
286
+ pgstat_main (argc ,argv );
283
287
exit (0 );
284
288
}
285
289
286
290
/*
287
- * If the first argument is "-statCol", then invoke pgstat_mainChild.
291
+ * If the first argument is "-statCol", then invoke pgstat_mainChild.
288
292
*/
289
293
if (argc > 1 && strcmp (argv [1 ],"-statCol" )== 0 )
290
294
{