Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaeddc2a

Browse files
committed
Continued rearrangement to permit pgstat + BootstrapMain processes to be
fork/exec'd, in the same mode as the previous patch for backends.Claudio Natoli
1 parent3e32e94 commitaeddc2a

File tree

7 files changed

+345
-159
lines changed

7 files changed

+345
-159
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.171 2003/12/20 17:31:21 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.172 2003/12/25 03:52:50 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -48,6 +48,11 @@
4848

4949
#defineALLOC(t,c)((t *) calloc((unsigned)(c), sizeof(t)))
5050

51+
#ifdefEXEC_BACKEND
52+
typedefstructPortPort;
53+
externvoidSSDataBaseInit(int);
54+
externvoidread_backend_variables(pid_t,Port*);
55+
#endif
5156

5257
externintInt_yyparse(void);
5358
statichashnode*AddStr(char*str,intstrlength,intmderef);
@@ -238,7 +243,7 @@ BootstrapMain(int argc, char *argv[])
238243
*
239244
* If we are running under the postmaster, this is done already.
240245
*/
241-
if (!IsUnderPostmaster/* when exec|| ExecBackend */)
246+
if (!IsUnderPostmaster||ExecBackend)
242247
MemoryContextInit();
243248

244249
/*
@@ -247,7 +252,7 @@ BootstrapMain(int argc, char *argv[])
247252

248253
/* Set defaults, to be overriden by explicit options below */
249254
dbname=NULL;
250-
if (!IsUnderPostmaster/* when exec || ExecBackend */)
255+
if (!IsUnderPostmaster)
251256
{
252257
InitializeGUCOptions();
253258
potential_DataDir=getenv("PGDATA");/* Null if no PGDATA
@@ -285,24 +290,11 @@ BootstrapMain(int argc, char *argv[])
285290
xlogop=atoi(optarg);
286291
break;
287292
case'p':
288-
{
289-
/* indicates fork from postmaster */
290293
#ifdefEXEC_BACKEND
291-
char*p;
292-
293-
sscanf(optarg,"%lu,%p,",
294-
&UsedShmemSegID,
295-
&UsedShmemSegAddr);
296-
p=strchr(optarg,',');
297-
if (p)
298-
p=strchr(p+1,',');
299-
if (p)
300-
dbname=strdup(p+1);
301-
#else
302-
dbname=strdup(optarg);
294+
IsUnderPostmaster= true;
303295
#endif
296+
dbname=strdup(optarg);
304297
break;
305-
}
306298
case'B':
307299
SetConfigOption("shared_buffers",optarg,PGC_POSTMASTER,PGC_S_ARGV);
308300
break;
@@ -347,12 +339,7 @@ BootstrapMain(int argc, char *argv[])
347339
if (!dbname||argc!=optind)
348340
usage();
349341

350-
#ifdefEXEC_BACKEND
351-
if (IsUnderPostmaster&&MyProc/* ordinary backend */ )
352-
AttachSharedMemoryAndSemaphores();
353-
#endif
354-
355-
if (!IsUnderPostmaster/* when exec || ExecBackend */ )
342+
if (!IsUnderPostmaster||ExecBackend)
356343
{
357344
if (!potential_DataDir)
358345
{
@@ -376,6 +363,9 @@ BootstrapMain(int argc, char *argv[])
376363
{
377364
#ifdefEXEC_BACKEND
378365
read_nondefault_variables();
366+
read_backend_variables(getpid(),NULL);
367+
368+
SSDataBaseInit(xlogop);
379369
#endif
380370
}
381371
else
@@ -427,6 +417,10 @@ BootstrapMain(int argc, char *argv[])
427417
SetProcessingMode(BootstrapProcessing);
428418
IgnoreSystemIndexes(true);
429419

420+
#ifdefEXEC_BACKEND
421+
if (IsUnderPostmaster)
422+
AttachSharedMemoryAndSemaphores();
423+
#endif
430424
XLOGPathInit();
431425

432426
BaseInit();

‎src/backend/main/main.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.68 2003/12/23 00:34:04 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.69 2003/12/25 03:52:50 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -39,6 +39,7 @@
3939
#include"tcop/tcopprot.h"
4040
#include"utils/help_config.h"
4141
#include"utils/ps_status.h"
42+
#include"pgstat.h"
4243

4344

4445

@@ -202,9 +203,9 @@ main(int argc, char *argv[])
202203

203204
/*
204205
* Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain,
205-
* or BootstrapMain depending on the program name (and possibly first
206-
* argument) we were called with. The lack of consistency here is
207-
* historical.
206+
*pgstat_main, pgstat_mainChildor BootstrapMain depending on the
207+
*program name (and possibly firstargument) we were called with.
208+
*The lack of consistency here ishistorical.
208209
*/
209210
len=strlen(new_argv[0]);
210211

@@ -221,6 +222,28 @@ main(int argc, char *argv[])
221222
if (argc>1&&strcmp(new_argv[1],"-boot")==0)
222223
exit(BootstrapMain(argc-1,new_argv+1));
223224

225+
#ifdefEXEC_BACKEND
226+
/*
227+
* If the first argument is "-statBuf", then invoke pgstat_main. Note
228+
* we remove "-statBuf" from the arguments passed on to pgstat_main.
229+
*/
230+
if (argc>1&&strcmp(new_argv[1],"-statBuf")==0)
231+
{
232+
pgstat_main(argc-2,new_argv+2);
233+
exit(0);
234+
}
235+
236+
/*
237+
* If the first argument is "-statCol", then invoke pgstat_mainChild. Note
238+
* we remove "-statCol" from the arguments passed on to pgstat_mainChild.
239+
*/
240+
if (argc>1&&strcmp(new_argv[1],"-statCol")==0)
241+
{
242+
pgstat_mainChild(argc-2,new_argv+2);
243+
exit(0);
244+
}
245+
#endif
246+
224247
/*
225248
* If the first argument is "--describe-config", then invoke runtime
226249
* configuration option display mode.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp