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

Commit195e81a

Browse files
committed
Find postgresql.auto.conf in PGDATA even when postgresql.conf is elsewhere.
The original coding for ALTER SYSTEM made a fundamentally bogus assumptionthat postgresql.auto.conf could be sought relative to the main config fileif we hadn't yet determined the value of data_directory. This fails forcommon arrangements with the config file elsewhere, as reported byChristoph Berg.The simplest fix is to not try to read postgresql.auto.conf until afterSelectConfigFiles has chosen (and locked down) the data_directory setting.Because of the logic in ProcessConfigFile for handling resetting of GUCsthat've been removed from the config file, we cannot easily read the mainand auto config files separately; so this patch adopts a brute forceapproach of reading the main config file twice during postmaster startup.That's a tad ugly, but the actual time cost is likely to be negligible,and there's no time for a more invasive redesign before beta.With this patch, any attempt to set data_directory via ALTER SYSTEMwill be silently ignored. It would probably be better to throw anerror, but that can be dealt with later. This bug, however, wouldprevent any testing of ALTER SYSTEM by a significant fraction of theuserbase, so it seems important to get it fixed before beta.
1 parent12e611d commit195e81a

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

‎src/backend/utils/misc/guc-file.l

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ ProcessConfigFile(GucContext context)
120120
*head,
121121
*tail;
122122
inti;
123-
char*ErrorConfFile;
124-
char*CallingFileName;
123+
char*ErrorConfFile = ConfigFileName;
125124
126125
/*
127126
* Config files are processed on startup (by the postmaster only)
@@ -136,9 +135,7 @@ ProcessConfigFile(GucContext context)
136135
*/
137136
elevel = IsUnderPostmaster ? DEBUG2 : LOG;
138137
139-
ErrorConfFile = ConfigFileName;
140-
141-
/* Parse the file into a list of option names and values */
138+
/* Parse the main config file into a list of option names and values */
142139
head = tail = NULL;
143140
144141
if (!ParseConfigFile(ConfigFileName, NULL, true, 0, elevel, &head, &tail))
@@ -149,17 +146,14 @@ ProcessConfigFile(GucContext context)
149146
}
150147
151148
/*
152-
* Parsefile PG_AUTOCONF_FILENAME afterpostgresql.conf to replace
153-
* parameters set by ALTER SYSTEM command.This file is present in
154-
* data directory,however when called during initdb data directory is not
155-
*set till this point, so use ConfigFile path which will be same.
149+
* Parsethe PG_AUTOCONF_FILENAMEfile, if present,afterthe main file
150+
*to replace anyparameters set by ALTER SYSTEM command. Because this
151+
*file is in thedata directory,we can't read it until the DataDir has
152+
*been set.
156153
*/
157-
if (data_directory)
158-
CallingFileName = NULL;
159-
else
160-
CallingFileName = ConfigFileName;
161-
162-
if (!ParseConfigFile(PG_AUTOCONF_FILENAME, CallingFileName, false, 0, elevel, &head, &tail))
154+
if (DataDir &&
155+
!ParseConfigFile(PG_AUTOCONF_FILENAME,NULL,false,0, elevel,
156+
&head, &tail))
163157
{
164158
/* Syntax error(s) detected in the file, so bail out */
165159
error =true;
@@ -397,7 +391,7 @@ ProcessConfigFile(GucContext context)
397391
/*
398392
* Given a configuration file or directory location that may be a relative
399393
* path, return an absolute one. We consider the location to be relative to
400-
* the directory holding the calling file.
394+
* the directory holding the calling file, or to DataDir if no calling file.
401395
*/
402396
staticchar *
403397
AbsoluteConfigLocation(constchar *location,constchar *calling_file)
@@ -417,10 +411,8 @@ AbsoluteConfigLocation(const char *location, const char *calling_file)
417411
}
418412
else
419413
{
420-
/*
421-
* calling_file is NULL, we make an absolute path from $PGDATA
422-
*/
423-
join_path_components(abs_path, data_directory, location);
414+
AssertState(DataDir);
415+
join_path_components(abs_path, DataDir, location);
424416
canonicalize_path(abs_path);
425417
}
426418
returnpstrdup(abs_path);

‎src/backend/utils/misc/guc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,6 +4363,14 @@ SelectConfigFiles(const char *userDoption, const char *progname)
43634363
*/
43644364
SetConfigOption("data_directory",DataDir,PGC_POSTMASTER,PGC_S_OVERRIDE);
43654365

4366+
/*
4367+
* Now read the config file a second time, allowing any settings in
4368+
* the PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly,
4369+
* but since we have to determine the DataDir before we can find the
4370+
* autoconf file, the alternatives seem worse.)
4371+
*/
4372+
ProcessConfigFile(PGC_POSTMASTER);
4373+
43664374
/*
43674375
* If timezone_abbreviations wasn't set in the configuration file, install
43684376
* the default value. We do it this way because we can't safely install a

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp