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

Commit9117e55

Browse files
committed
Tweak original coding so that we can determine the platform-specific
shared_buffers and max_connections values to use before we run thebootstrap process. Without this, initdb would fail on platforms wherethe hardwired default values are too large. (We could get around thatby making the hardwired defaults tiny, perhaps, but why slow downbootstrap by starving it for buffers...)
1 parent683f4d0 commit9117e55

File tree

2 files changed

+82
-54
lines changed

2 files changed

+82
-54
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 42 additions & 13 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-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.160 2003/05/28 18:19:09 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.161 2003/07/15 00:11:13 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -187,15 +187,16 @@ err_out(void)
187187
}
188188

189189
/* usage:
190-
usage help for the bootstrapbacken
191-
*/
190+
*usage help for the bootstrapbackend
191+
*/
192192
staticvoid
193193
usage(void)
194194
{
195195
fprintf(stderr,
196196
gettext("Usage:\n"
197-
" postgres -boot [-d level] [-D datadir] [-F] [-o file] [-x num] dbname\n"
198-
" -d 1-5 debug mode\n"
197+
" postgres -boot [OPTION]... DBNAME\n"
198+
" -c NAME=VALUE set run-time parameter\n"
199+
" -d 1-5 debug level\n"
199200
" -D datadir data directory\n"
200201
" -F turn off fsync\n"
201202
" -o file send debug output to file\n"
@@ -253,7 +254,7 @@ BootstrapMain(int argc, char *argv[])
253254
* variable */
254255
}
255256

256-
while ((flag=getopt(argc,argv,"B:d:D:Fo:p:x:"))!=-1)
257+
while ((flag=getopt(argc,argv,"B:c:d:D:Fo:p:x:-:"))!=-1)
257258
{
258259
switch (flag)
259260
{
@@ -303,6 +304,27 @@ BootstrapMain(int argc, char *argv[])
303304
case'B':
304305
SetConfigOption("shared_buffers",optarg,PGC_POSTMASTER,PGC_S_ARGV);
305306
break;
307+
case'c':
308+
case'-':
309+
{
310+
char*name,
311+
*value;
312+
313+
ParseLongOption(optarg,&name,&value);
314+
if (!value)
315+
{
316+
if (flag=='-')
317+
elog(ERROR,"--%s requires argument",optarg);
318+
else
319+
elog(ERROR,"-c %s requires argument",optarg);
320+
}
321+
322+
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
323+
free(name);
324+
if (value)
325+
free(value);
326+
break;
327+
}
306328
default:
307329
usage();
308330
break;
@@ -408,7 +430,6 @@ BootstrapMain(int argc, char *argv[])
408430
switch (xlogop)
409431
{
410432
caseBS_XLOG_NOP:
411-
StartupXLOG();
412433
break;
413434

414435
caseBS_XLOG_BOOTSTRAP:
@@ -445,6 +466,15 @@ BootstrapMain(int argc, char *argv[])
445466
*/
446467
InitPostgres(dbname,NULL);
447468

469+
/*
470+
* In NOP mode, all we really want to do is create shared memory and
471+
* semaphores (just to prove we can do it with the current GUC settings).
472+
* So, quit now.
473+
*/
474+
if (xlogop==BS_XLOG_NOP)
475+
proc_exit(0);
476+
477+
/* Initialize stuff for bootstrap-file processing */
448478
for (i=0;i<MAXATTR;i++)
449479
{
450480
attrtypes[i]= (Form_pg_attribute)NULL;
@@ -456,7 +486,7 @@ BootstrapMain(int argc, char *argv[])
456486
hashtable[i]=NULL;
457487

458488
/*
459-
* abort processing resumes here
489+
* abort processing resumes here (this is probably dead code?)
460490
*/
461491
if (sigsetjmp(Warn_restart,1)!=0)
462492
{
@@ -465,20 +495,19 @@ BootstrapMain(int argc, char *argv[])
465495
}
466496

467497
/*
468-
* process input.
469-
*/
470-
471-
/*
498+
* Process bootstrap input.
499+
*
472500
* the sed script boot.sed renamed yyparse to Int_yyparse for the
473501
* bootstrap parser to avoid conflicts with the normal SQL parser
474502
*/
475503
Int_yyparse();
476504

505+
/* Perform a checkpoint to ensure everything's down to disk */
477506
SetProcessingMode(NormalProcessing);
478507
CreateCheckPoint(true, true);
479508
SetProcessingMode(BootstrapProcessing);
480509

481-
/*clean upprocessing */
510+
/*Clean upand exit */
482511
StartTransactionCommand();
483512
cleanup();
484513

‎src/bin/initdb/initdb.sh

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2828
# Portions Copyright (c) 1994, Regents of the University of California
2929
#
30-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.194 2003/07/14 20:00:23 tgl Exp $
30+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.195 2003/07/1500:11:14 tgl Exp $
3131
#
3232
#-------------------------------------------------------------------------
3333

@@ -536,61 +536,27 @@ else
536536
fi
537537
fi
538538

539-
540-
##########################################################################
541-
#
542-
# RUN BKI SCRIPT IN BOOTSTRAP MODE TO CREATE TEMPLATE1
543-
544-
# common backend options
545-
PGSQL_OPT="-F -D$PGDATA"
546-
547-
if ["$debug"= yes ]
548-
then
549-
BOOTSTRAP_TALK_ARG="-d 5"
550-
fi
551-
552-
553-
$ECHO_N"creating template1 database in$PGDATA/base/1..."$ECHO_C
554-
555-
rm -rf"$PGDATA"/base/1|| exit_nicely
556-
mkdir"$PGDATA"/base/1|| exit_nicely
557-
558539
# Top level PG_VERSION is checked by bootstrapper, so make it first
559-
echo"$short_version">"$PGDATA/PG_VERSION"|| exit_nicely
540+
echo"$short_version">"$PGDATA/PG_VERSION"|| exit_nicely
560541

561-
cat"$POSTGRES_BKI" \
562-
| sed -e"s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \
563-
-e"s/ENCODING/$ENCODINGID/g" \
564-
|
565-
(
566-
LC_COLLATE=`pg_getlocale COLLATE`
567-
LC_CTYPE=`pg_getlocale CTYPE`
568-
export LC_COLLATE
569-
export LC_CTYPE
570-
unset LC_ALL
571-
"$PGPATH"/postgres -boot -x1$PGSQL_OPT$BOOTSTRAP_TALK_ARG template1
572-
) \
573-
|| exit_nicely
574-
575-
# Make the per-database PGVERSION for template1 only after init'ing it
576-
echo"$short_version">"$PGDATA/base/1/PG_VERSION"|| exit_nicely
577-
578-
echo"ok"
579542

580543
##########################################################################
581544
#
582545
# DETERMINE PLATFORM-SPECIFIC CONFIG SETTINGS
583546
#
584547
# Use reasonable values if kernel will let us, else scale back
585548

549+
# common backend options
550+
PGSQL_OPT="-F -D$PGDATA"
551+
586552
cp /dev/null"$PGDATA"/postgresql.conf|| exit_nicely
587553

588554
$ECHO_N"selecting default shared_buffers..."$ECHO_C
589555

590556
fornbuffersin 1000 900 800 700 600 500 400 300 200 100 50
591557
do
592558
TEST_OPT="$PGSQL_OPT -c shared_buffers=$nbuffers -c max_connections=5"
593-
if"$PGPATH"/postgres$TEST_OPT template1</dev/null>/dev/null2>&1
559+
if"$PGPATH"/postgres-boot -x0$TEST_OPT template1</dev/null>/dev/null2>&1
594560
then
595561
break
596562
fi
@@ -603,7 +569,7 @@ $ECHO_N "selecting default max_connections... "$ECHO_C
603569
fornconnsin 100 50 40 30 20 10
604570
do
605571
TEST_OPT="$PGSQL_OPT -c shared_buffers=$nbuffers -c max_connections=$nconns"
606-
if"$PGPATH"/postgres$TEST_OPT template1</dev/null>/dev/null2>&1
572+
if"$PGPATH"/postgres-boot -x0$TEST_OPT template1</dev/null>/dev/null2>&1
607573
then
608574
break
609575
fi
@@ -632,6 +598,39 @@ chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
632598

633599
echo"ok"
634600

601+
##########################################################################
602+
#
603+
# RUN BKI SCRIPT IN BOOTSTRAP MODE TO CREATE TEMPLATE1
604+
605+
if ["$debug"= yes ]
606+
then
607+
BOOTSTRAP_TALK_ARG="-d 5"
608+
fi
609+
610+
$ECHO_N"creating template1 database in$PGDATA/base/1..."$ECHO_C
611+
612+
rm -rf"$PGDATA"/base/1|| exit_nicely
613+
mkdir"$PGDATA"/base/1|| exit_nicely
614+
615+
cat"$POSTGRES_BKI" \
616+
| sed -e"s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \
617+
-e"s/ENCODING/$ENCODINGID/g" \
618+
|
619+
(
620+
LC_COLLATE=`pg_getlocale COLLATE`
621+
LC_CTYPE=`pg_getlocale CTYPE`
622+
export LC_COLLATE
623+
export LC_CTYPE
624+
unset LC_ALL
625+
"$PGPATH"/postgres -boot -x1$PGSQL_OPT$BOOTSTRAP_TALK_ARG template1
626+
) \
627+
|| exit_nicely
628+
629+
# Make the per-database PGVERSION for template1 only after init'ing it
630+
echo"$short_version">"$PGDATA/base/1/PG_VERSION"|| exit_nicely
631+
632+
echo"ok"
633+
635634
##########################################################################
636635
#
637636
# CREATE VIEWS and other things

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp