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

Commit9ba78fb

Browse files
committed
Don't allow data_directory to be set in postgresql.auto.conf by ALTER SYSTEM.
data_directory could be set both in postgresql.conf and postgresql.auto.conf so far.This could cause some problematic situations like circular definition. To avoid suchsituations, this commit forbids a user to set data_directory in postgresql.auto.conf.Backpatch this to 9.4 where ALTER SYSTEM command was introduced.Amit Kapila, reviewed by Abhijit Menon-Sen, with minor adjustments by me.
1 parentdf8b7bc commit9ba78fb

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

‎doc/src/sgml/ref/alter_system.sgml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ ALTER SYSTEM SET <replaceable class="PARAMETER">configuration_parameter</replace
7676
</variablelist>
7777
</refsect1>
7878

79+
<refsect1>
80+
<title>Notes</title>
81+
82+
<para>
83+
This command can't be used to set <xref linkend="guc-data-directory">
84+
and any parameters (e.g., <link linkend="runtime-config-preset">preset options</>)
85+
that are not allowed in <filename>postgresql.conf</>.
86+
</para>
87+
</refsect1>
88+
7989
<refsect1>
8090
<title>Examples</title>
8191

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,10 +3095,14 @@ static struct config_string ConfigureNamesString[] =
30953095
},
30963096

30973097
{
3098+
/*
3099+
* Can't be set by ALTER SYSTEM as it can lead to recursive definition
3100+
* of data_directory.
3101+
*/
30983102
{"data_directory",PGC_POSTMASTER,FILE_LOCATIONS,
30993103
gettext_noop("Sets the server's data directory."),
31003104
NULL,
3101-
GUC_SUPERUSER_ONLY
3105+
GUC_SUPERUSER_ONLY |GUC_DISALLOW_IN_AUTO_FILE
31023106
},
31033107
&data_directory,
31043108
NULL,
@@ -6735,12 +6739,17 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
67356739
(errcode(ERRCODE_UNDEFINED_OBJECT),
67366740
errmsg("unrecognized configuration parameter \"%s\"",name)));
67376741

6742+
/*
6743+
* Don't allow the parameters which can't be set in configuration
6744+
* files to be set in PG_AUTOCONF_FILENAME file.
6745+
*/
67386746
if ((record->context==PGC_INTERNAL)||
6739-
(record->flags&GUC_DISALLOW_IN_FILE))
6740-
ereport(ERROR,
6741-
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
6742-
errmsg("parameter \"%s\" cannot be changed",
6743-
name)));
6747+
(record->flags&GUC_DISALLOW_IN_FILE)||
6748+
(record->flags&GUC_DISALLOW_IN_AUTO_FILE))
6749+
ereport(ERROR,
6750+
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
6751+
errmsg("parameter \"%s\" cannot be changed",
6752+
name)));
67446753

67456754
if (!validate_conf_option(record,name,value,PGC_S_FILE,
67466755
ERROR, true,NULL,

‎src/include/utils/guc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ typedef enum
195195
#defineGUC_UNIT_TIME0x7000/* mask for MS, S, MIN */
196196

197197
#defineGUC_NOT_WHILE_SEC_REST0x8000/* can't set if security restricted */
198+
#defineGUC_DISALLOW_IN_AUTO_FILE0x00010000/* can't set in PG_AUTOCONF_FILENAME */
198199

199200
/* GUC vars that are actually declared in guc.c, rather than elsewhere */
200201
externboollog_duration;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp