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

Commit7ca3a0f

Browse files
committed
Whack some sense into the configuration-file-location patch.
Refactor code into something reasonably understandable, causeuse of the feature to not fail in standalone backends or inEXEC_BACKEND case, fix sloppy guc.c table entries, make thedocumentation minimally usable.
1 parentf4f6caa commit7ca3a0f

File tree

12 files changed

+310
-277
lines changed

12 files changed

+310
-277
lines changed

‎doc/src/sgml/ref/postgres-ref.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/postgres-ref.sgml,v 1.43 2004/02/03 17:34:02 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/postgres-ref.sgml,v 1.44 2004/10/08 01:36:32 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -357,7 +357,7 @@ PostgreSQL documentation
357357

358358
<listitem>
359359
<para>
360-
Default datadirection location
360+
Default datadirectory location
361361
</para>
362362
</listitem>
363363
</varlistentry>

‎doc/src/sgml/ref/postmaster.sgml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/postmaster.sgml,v 1.52 2004/09/20 00:04:19 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/postmaster.sgml,v 1.53 2004/10/08 01:36:32 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -67,27 +67,22 @@ PostgreSQL documentation
6767
One <command>postmaster</command> always manages the data
6868
from exactly one database cluster. A database cluster is a
6969
collection of databases that is stored at a common file system
70-
location. When the <command>postmaster</command> starts it needs
71-
to know the location of the database cluster files (<quote>data
72-
area</quote>).
70+
location (the <quote>data area</quote>).
7371
More than one <command>postmaster</command> process can run on a system
74-
at one time as long as they use different data areas and different
72+
at one time, so long as they use different data areas and different
7573
communication ports (see below). A data area is created with <xref
7674
linkend="app-initdb">.
7775
</para>
7876

7977
<para>
80-
The <quote>data area</> is specified by the <option>-D</option> option
78+
When the <command>postmaster</command> starts it needs
79+
to know the location of the data area.
80+
The location must be specified by the <option>-D</option> option
8181
or the <envar>PGDATA</envar> environment variable; there is no default.
82-
Typically, it points to a directory created by <application>
83-
initdb</>. However, for administrative flexibility, you can
84-
point to a directory containing only configuration files:
85-
<filename>postgresql.conf</>, <filename>pg_hba.conf</>, and
86-
<filename>pg_ident.conf</>. You can then set
87-
<filename>postgresql.conf</>'s <varname>pgdata</> variable to point to the
88-
data directory. You can also point just to the server configuration file
89-
like <filename>postgresql.conf</> and set its variables to point to the
90-
other configuration files and the data directory.
82+
Typically, <option>-D</option> or <envar>PGDATA</envar> points
83+
directly to the data area directory created by <application>initdb</>.
84+
Other possible file layouts are discussed in
85+
<xref linkend="runtime-config-file-locations">.
9186
</para>
9287
</refsect1>
9388

@@ -154,8 +149,9 @@ PostgreSQL documentation
154149
<term><option>-D <replaceable class="parameter">datadir</replaceable></option></term>
155150
<listitem>
156151
<para>
157-
Specifies the file system location of the data directory. See
158-
discussion above.
152+
Specifies the file system location of the data directory or
153+
configuration file(s). See
154+
<xref linkend="runtime-config-file-locations"> for details.
159155
</para>
160156
</listitem>
161157
</varlistentry>
@@ -394,7 +390,7 @@ PostgreSQL documentation
394390

395391
<listitem>
396392
<para>
397-
Default datadirection location
393+
Default datadirectory location
398394
</para>
399395
</listitem>
400396
</varlistentry>

‎doc/src/sgml/runtime.sgml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.285 2004/09/29 06:27:11 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.286 2004/10/08 01:36:31 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -564,17 +564,16 @@ SET ENABLE_SEQSCAN TO OFF;
564564
any desired selection condition.
565565
</para>
566566

567-
<sect2 id="runtime-config-configuration-files">
568-
<title>Configuration Files</title>
567+
<sect2 id="runtime-config-file-locations">
568+
<title>File Locations</title>
569569

570570
<variablelist>
571-
572571
<varlistentry id="guc-pgdata" xreflabel="pgdata">
573572
<term><varname>pgdata</varname> (<type>string</type>)</term>
574573
<listitem>
575574
<para>
576-
Specifies the directory to use for data storage (everything except
577-
configuration files).
575+
Specifies the directory to use for data storage.
576+
This option can only be set at server start.
578577
</para>
579578
</listitem>
580579
</varlistentry>
@@ -585,6 +584,8 @@ SET ENABLE_SEQSCAN TO OFF;
585584
<para>
586585
Specifies the file name to use for configuration of host-based
587586
authentication (HBA).
587+
This option can only be set at server start or in the
588+
<filename>postgresql.conf</filename> file.
588589
</para>
589590
</listitem>
590591
</varlistentry>
@@ -595,6 +596,8 @@ SET ENABLE_SEQSCAN TO OFF;
595596
<para>
596597
Specifies the file name to use for configuration of
597598
<application>ident</> authentication.
599+
This option can only be set at server start or in the
600+
<filename>postgresql.conf</filename> file.
598601
</para>
599602
</listitem>
600603
</varlistentry>
@@ -605,11 +608,50 @@ SET ENABLE_SEQSCAN TO OFF;
605608
<para>
606609
Specifies the location of an additional <application>postmaster</>
607610
process-id (PID) file for use by server administration programs.
611+
This option can only be set at server start.
608612
</para>
609613
</listitem>
610614
</varlistentry>
611-
612615
</variablelist>
616+
617+
<para>
618+
In a default installation, none of the above options is set explicitly
619+
in the <filename>postgresql.conf</filename> file. In this case, the
620+
data directory is specified by the <option>-D</option> command-line
621+
option or the <envar>PGDATA</envar> environment variable; there is no
622+
default for it. The configuration files are all placed within the
623+
data directory.
624+
</para>
625+
626+
<para>
627+
It is also possible to separate the configuration files from the data
628+
directory, which can ease administration. (In particular it is often
629+
easier to ensure that the configuration files are properly backed-up
630+
when they are kept separate.) To do this, the <option>-D</option>
631+
command-line option or <envar>PGDATA</envar> environment variable
632+
must point to the directory containing the configuration files,
633+
and the <varname>pgdata</> option is set in
634+
<filename>postgresql.conf</filename> (or on the command line) to show
635+
where the data directory is actually located.
636+
</para>
637+
638+
<para>
639+
If you wish, you can also make the <option>-D</option>
640+
command-line option or <envar>PGDATA</envar> environment variable
641+
point directly to the master configuration file (which then need not be
642+
named <filename>postgresql.conf</filename>). The <varname>pgdata</>
643+
option must be set to determine the data directory location.
644+
The other configuration files will by default be sought
645+
in the data directory.
646+
</para>
647+
648+
<para>
649+
With any of these approaches, you can specify the locations of the
650+
secondary configuration files (<filename>pg_hba.conf</> and
651+
<filename>pg_ident.conf</>) by setting <varname>hba_conf</> and/or
652+
<varname>ident_conf</> in the master configuration file. These options
653+
override the normal locations and names of the secondary files.
654+
</para>
613655
</sect2>
614656

615657
<sect2 id="runtime-config-connection">

‎src/backend/bootstrap/bootstrap.c

Lines changed: 9 additions & 28 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.193 2004/08/29 05:06:41 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.194 2004/10/08 01:36:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -210,7 +210,7 @@ BootstrapMain(int argc, char *argv[])
210210
char*dbname;
211211
intflag;
212212
intxlogop=BS_XLOG_NOP;
213-
char*userPGDATA=NULL;
213+
char*userDoption=NULL;
214214

215215
/*
216216
* initialize globals
@@ -240,10 +240,7 @@ BootstrapMain(int argc, char *argv[])
240240
/* Set defaults, to be overriden by explicit options below */
241241
dbname=NULL;
242242
if (!IsUnderPostmaster)
243-
{
244243
InitializeGUCOptions();
245-
userPGDATA=getenv("PGDATA");/* Null if no PGDATA variable */
246-
}
247244

248245
/* Ignore the initial -boot argument, if present */
249246
if (argc>1&&strcmp(argv[1],"-boot")==0)
@@ -257,7 +254,7 @@ BootstrapMain(int argc, char *argv[])
257254
switch (flag)
258255
{
259256
case'D':
260-
userPGDATA=optarg;
257+
userDoption=optarg;
261258
break;
262259
case'd':
263260
{
@@ -328,24 +325,6 @@ BootstrapMain(int argc, char *argv[])
328325
if (!dbname||argc!=optind)
329326
usage();
330327

331-
if (!IsUnderPostmaster)
332-
{
333-
if (!userPGDATA)
334-
{
335-
write_stderr("%s does not know where to find the database system data.\n"
336-
"You must specify the directory that contains the database system\n"
337-
"either by specifying the -D invocation option or by setting the\n"
338-
"PGDATA environment variable.\n",
339-
argv[0]);
340-
proc_exit(1);
341-
}
342-
SetDataDir(userPGDATA);
343-
}
344-
345-
/* Validate we have been given a reasonable-looking DataDir */
346-
Assert(DataDir);
347-
ValidatePgVersion(DataDir);
348-
349328
/*
350329
* Identify myself via ps
351330
*/
@@ -372,12 +351,14 @@ BootstrapMain(int argc, char *argv[])
372351
/* Acquire configuration parameters, unless inherited from postmaster */
373352
if (!IsUnderPostmaster)
374353
{
375-
ProcessConfigFile(PGC_POSTMASTER);
376-
377-
/* If timezone is not set, determine what the OS uses */
378-
pg_timezone_initialize();
354+
if (!SelectConfigFiles(userDoption,argv[0]))
355+
proc_exit(1);
379356
}
380357

358+
/* Validate we have been given a reasonable-looking DataDir */
359+
Assert(DataDir);
360+
ValidatePgVersion(DataDir);
361+
381362
/* If standalone, create lockfile for data directory */
382363
if (!IsUnderPostmaster)
383364
CreateDataDirLockFile(DataDir, false);

‎src/backend/libpq/hba.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.130 2004/09/18 01:22:58 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.131 2004/10/08 01:36:34 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1044,16 +1044,16 @@ load_hba(void)
10441044
if (hba_lines||hba_line_nums)
10451045
free_lines(&hba_lines,&hba_line_nums);
10461046

1047-
/* HBA filename in config file */
10481047
if (guc_hbafile)
1048+
{
1049+
/* HBA filename specified in config file */
10491050
conf_file=pstrdup(guc_hbafile);
1051+
}
10501052
else
10511053
{
1052-
char*confloc= (user_pgconfig_is_dir) ?user_pgconfig :DataDir;
1053-
10541054
/* put together the full pathname to the config file */
1055-
conf_file=palloc(strlen(confloc)+strlen(CONF_FILE)+2);
1056-
sprintf(conf_file,"%s/%s",confloc,CONF_FILE);
1055+
conf_file=palloc(strlen(ConfigDir)+strlen(CONF_FILE)+2);
1056+
sprintf(conf_file,"%s/%s",ConfigDir,CONF_FILE);
10571057
}
10581058

10591059
file=AllocateFile(conf_file,"r");
@@ -1198,16 +1198,15 @@ load_ident(void)
11981198
if (ident_lines||ident_line_nums)
11991199
free_lines(&ident_lines,&ident_line_nums);
12001200

1201-
/* IDENT filename in config file */
12021201
if (guc_identfile)
1202+
{
1203+
/* IDENT filename specified in config file */
12031204
map_file=pstrdup(guc_identfile);
1205+
}
12041206
else
12051207
{
1206-
/* put together the full pathname to the map file */
1207-
char*confloc= (user_pgconfig_is_dir) ?user_pgconfig :DataDir;
1208-
1209-
map_file= (char*)palloc(strlen(confloc)+strlen(USERMAP_FILE)+2);
1210-
sprintf(map_file,"%s/%s",confloc,USERMAP_FILE);
1208+
map_file=palloc(strlen(ConfigDir)+strlen(USERMAP_FILE)+2);
1209+
sprintf(map_file,"%s/%s",ConfigDir,USERMAP_FILE);
12111210
}
12121211

12131212
file=AllocateFile(map_file,"r");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp