Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Mon, Jan 27, 2014 at 12:49 PM, Fujii Masao wrote: > On Mon, Jan 27, 2014 at 11:53 AM, Michael Paquier > wrote: >> On Mon, Jan 27, 2014 at 11:29 AM, Michael Paquier >> wrote: >>> Hi, >>> >>> Please find attached an updated patch (context diffs) improving the >>> comments related to ALTER SYSTEM. This patch does nothing for the >>> suffix tmp/temp used in a couple of places of the code, it only >>> corrects some typos and makes the comments more consistent with >>> current code. >> And I almost forgot the second patch simply changing the suffix from >> temp to tmp for the temporary conf file... Now attached. >> Regards, > > Thanks for the patches! Committed. Thanks. -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Mon, Jan 27, 2014 at 11:53 AM, Michael Paquier wrote: > On Mon, Jan 27, 2014 at 11:29 AM, Michael Paquier > wrote: >> Hi, >> >> Please find attached an updated patch (context diffs) improving the >> comments related to ALTER SYSTEM. This patch does nothing for the >> suffix tmp/temp used in a couple of places of the code, it only >> corrects some typos and makes the comments more consistent with >> current code. > And I almost forgot the second patch simply changing the suffix from > temp to tmp for the temporary conf file... Now attached. > Regards, Thanks for the patches! Committed. Regards, -- Fujii Masao -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Mon, Jan 27, 2014 at 11:29 AM, Michael Paquier wrote: > Hi, > > Please find attached an updated patch (context diffs) improving the > comments related to ALTER SYSTEM. This patch does nothing for the > suffix tmp/temp used in a couple of places of the code, it only > corrects some typos and makes the comments more consistent with > current code. And I almost forgot the second patch simply changing the suffix from temp to tmp for the temporary conf file... Now attached. Regards, -- Michael *** a/src/backend/replication/basebackup.c --- b/src/backend/replication/basebackup.c *** *** 834,840 sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces) /* skip auto conf temporary file */ if (strncmp(de->d_name, ! PG_AUTOCONF_FILENAME ".temp", sizeof(PG_AUTOCONF_FILENAME) + 4) == 0) continue; --- 834,840 /* skip auto conf temporary file */ if (strncmp(de->d_name, ! PG_AUTOCONF_FILENAME ".tmp", sizeof(PG_AUTOCONF_FILENAME) + 4) == 0) continue; *** a/src/backend/utils/misc/guc.c --- b/src/backend/utils/misc/guc.c *** *** 6671,6677 AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) canonicalize_path(AutoConfFileName); snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s", AutoConfFileName, !"temp"); /* * one backend is allowed to operate on postgresql.auto.conf file, to --- 6671,6677 canonicalize_path(AutoConfFileName); snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s", AutoConfFileName, !"tmp"); /* * one backend is allowed to operate on postgresql.auto.conf file, to -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
Hi, Please find attached an updated patch (context diffs) improving the comments related to ALTER SYSTEM. This patch does nothing for the suffix tmp/temp used in a couple of places of the code, it only corrects some typos and makes the comments more consistent with current code. The inconsistencies with the temporary file suffixes should be tackled in a separate patch/thread. Thanks, -- Michael *** a/src/backend/utils/misc/guc-file.l --- b/src/backend/utils/misc/guc-file.l *** *** 149,155 ProcessConfigFile(GucContext context) } /* !* Parse postgresql.auto.conf file after postgresql.conf to replace * parameters set by ALTER SYSTEM command. This file is present in * data directory, however when called during initdb data directory is not * set till this point, so use ConfigFile path which will be same. --- 149,155 } /* !* Parse file PG_AUTOCONF_FILENAME after postgresql.conf to replace * parameters set by ALTER SYSTEM command. This file is present in * data directory, however when called during initdb data directory is not * set till this point, so use ConfigFile path which will be same. *** a/src/backend/utils/misc/guc.c --- b/src/backend/utils/misc/guc.c *** *** 6457,6465 flatten_set_variable_args(const char *name, List *args) } /* ! * Writes updated configuration parameter values into ! * postgresql.auto.conf.temp file. It traverses the list of parameters ! * and quote the string values before writing them to temporaray file. */ static void write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) --- 6457,6465 } /* ! * Write updated configuration parameter values into a temporary file. ! * this function traverses the list of parameters and quotes the string ! * values before writing them. */ static void write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) *** *** 6468,6475 write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) StringInfoData buf; initStringInfo(&buf); ! appendStringInfoString(&buf, "# Do not edit this file manually! \n"); ! appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command. \n"); /* * write the file header message before contents, so that if there is no --- 6468,6475 StringInfoData buf; initStringInfo(&buf); ! appendStringInfoString(&buf, "# Do not edit this file manually!\n"); ! appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command.\n"); /* * write the file header message before contents, so that if there is no *** *** 6517,6523 write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) /* * This function takes list of all configuration parameters in ! * postgresql.auto.conf and parameter to be updated as input arguments and * replace the updated configuration parameter value in a list. If the * parameter to be updated is new then it is appended to the list of * parameters. --- 6517,6523 /* * This function takes list of all configuration parameters in ! * PG_AUTOCONF_FILENAME and parameter to be updated as input arguments and * replace the updated configuration parameter value in a list. If the * parameter to be updated is new then it is appended to the list of * parameters. *** *** 6595,6607 replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, * and write them all to the automatic configuration file. * * The configuration parameters are written to a temporary ! * file then renamed to the final name. The template for the ! * temporary file is postgresql.auto.conf.temp. * * An LWLock is used to serialize writing to the same file. * * In case of an error, we leave the original automatic ! * configuration file (postgresql.auto.conf) intact. */ void AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) --- 6595,6606 * and write them all to the automatic configuration file. * * The configuration parameters are written to a temporary ! * file then renamed to the final name. * * An LWLock is used to serialize writing to the same file. * * In case of an error, we leave the original automatic ! * configuration file (PG_AUTOCONF_FILENAME) intact. */ void AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) *** *** 6664,6671 AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) /* !* Use data directory as reference path for postgresql.auto.conf and it's !* corresponding temp file */ join_path_components(AutoConfFileName, data_directory, PG_AUTOCONF_FILENAME); canonicalize_path(AutoConfFileName); --- 6663,6670 -
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Tue, Jan 21, 2014 at 7:02 PM, Michael Paquier wrote: > On Wed, Jan 22, 2014 at 5:29 AM, Alvaro Herrera > wrote: >> I agree with Michael that having pg_basebackup be aware of the ".temp" >> suffix is ugly; for instance if we were to fix it to ".tmp" in ALTER >> SYSTEM but forgot to change pg_basebackup, the check would be >> immediately broken. But on the other hand I'm not sure why it's such a >> problem for pg_basebackup that it needs to be checking in the first >> place -- how about we rip that out? > Coupled with the addition of a pgsql_tmp prefix to the temp > configuration file name would work, yes we could remove this check > part. > >> Perhaps the temp file needs to be in pgsql_tmp? (Do we need to worry >> about cross-filesystem links if we do? I mean, do we support mounting >> pgsql_tmp separately?) > Using pgsql_tmp looks a bit weird as well, as this prefix is used only > for temporary files doing database-related operations, and ALTER > SYSTEM is not one. Doing that this would need a mention in the docs at > least: > http://www.postgresql.org/docs/devel/static/storage-file-layout.html > Thoughts? I think moving the temp file to a different directory than the permanent file is a non-starter. As Alvaro says, that could be on a different file system, and then attempting to rename() the file into place would fail. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Wed, Jan 22, 2014 at 1:15 AM, Robert Haas wrote: > On Tue, Jan 21, 2014 at 7:47 AM, Michael Paquier > wrote: After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I noticed a couple of typo mistakes as well as (I think) a weird way of using the temporary auto-configuration name postgresql.auto.conf.temp in two different places, resulting in the patch attached. >>> >>> .tmp suffix is used at couple other places in code as well. >>> snapmgr.c >>> XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp"); >>> receivelog.c >>> snprintf(tmppath, MAXPGPATH, "%s.tmp", path); >>> >>> Although similar suffix is used at other places, but still I think it might >>> be >>> better to define for current case as here prefix (postgresql.auto.conf) is >>> also >>> fixed and chances of getting it changed are less. However even if we don't >>> do, it might be okay as we are using such suffixes at other places as well. >> In the case of snapmgr.c and receivelog.c, the operations are kept >> local, so it does not matter much if this way of naming is done as all >> the operations for a temporary file are kept within the same, isolated >> function. However, the case of postgresql.auto.conf.temp is different: >> this temporary file name is used as well for a check in basebackup.c, >> so I imagine that it would be better to centralize this information in >> a single place. Now this name is only used in two places, but who >> knows if some additional checks here are there won't be needed for >> this temp file... >> postgresql.auto.conf.temp is also located at the root of PGDATA, so it >> might be surprising for the user to find it even if there are few >> chances that it can happen. > > I don't think there's any real reason to defined > PG_AUTOCONF_FILENAME_TEMP. pg_stat_statements just writes > PGSS_DUMP_FILE ".tmp" and that hasn't been a problem that I know of. > I do wonder why ALTER SYSTEM SET is spelling the suffix "temp" instead > of "tmp". +1 for changing '.temp' to '.tmp'. I think its bit arguable whether to change it to define or not (different people can have different opinion on this matter), but certainly changing it to .tmp is an improvement, as we use .tmp at other places as well. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Wed, Jan 22, 2014 at 5:29 AM, Alvaro Herrera wrote: > I agree with Michael that having pg_basebackup be aware of the ".temp" > suffix is ugly; for instance if we were to fix it to ".tmp" in ALTER > SYSTEM but forgot to change pg_basebackup, the check would be > immediately broken. But on the other hand I'm not sure why it's such a > problem for pg_basebackup that it needs to be checking in the first > place -- how about we rip that out? Coupled with the addition of a pgsql_tmp prefix to the temp configuration file name would work, yes we could remove this check part. > Perhaps the temp file needs to be in pgsql_tmp? (Do we need to worry > about cross-filesystem links if we do? I mean, do we support mounting > pgsql_tmp separately?) Using pgsql_tmp looks a bit weird as well, as this prefix is used only for temporary files doing database-related operations, and ALTER SYSTEM is not one. Doing that this would need a mention in the docs at least: http://www.postgresql.org/docs/devel/static/storage-file-layout.html Thoughts? Regards, -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
Robert Haas escribió: > I don't think there's any real reason to defined > PG_AUTOCONF_FILENAME_TEMP. pg_stat_statements just writes > PGSS_DUMP_FILE ".tmp" and that hasn't been a problem that I know of. > I do wonder why ALTER SYSTEM SET is spelling the suffix "temp" instead > of "tmp". I agree with Michael that having pg_basebackup be aware of the ".temp" suffix is ugly; for instance if we were to fix it to ".tmp" in ALTER SYSTEM but forgot to change pg_basebackup, the check would be immediately broken. But on the other hand I'm not sure why it's such a problem for pg_basebackup that it needs to be checking in the first place -- how about we rip that out? Perhaps the temp file needs to be in pgsql_tmp? (Do we need to worry about cross-filesystem links if we do? I mean, do we support mounting pgsql_tmp separately?) -- Álvaro Herrerahttp://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Tue, Jan 21, 2014 at 7:47 AM, Michael Paquier wrote: >>> After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I >>> noticed a couple of typo mistakes as well as (I think) a weird way of >>> using the temporary auto-configuration name postgresql.auto.conf.temp >>> in two different places, resulting in the patch attached. >> >> .tmp suffix is used at couple other places in code as well. >> snapmgr.c >> XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp"); >> receivelog.c >> snprintf(tmppath, MAXPGPATH, "%s.tmp", path); >> >> Although similar suffix is used at other places, but still I think it might >> be >> better to define for current case as here prefix (postgresql.auto.conf) is >> also >> fixed and chances of getting it changed are less. However even if we don't >> do, it might be okay as we are using such suffixes at other places as well. > In the case of snapmgr.c and receivelog.c, the operations are kept > local, so it does not matter much if this way of naming is done as all > the operations for a temporary file are kept within the same, isolated > function. However, the case of postgresql.auto.conf.temp is different: > this temporary file name is used as well for a check in basebackup.c, > so I imagine that it would be better to centralize this information in > a single place. Now this name is only used in two places, but who > knows if some additional checks here are there won't be needed for > this temp file... > postgresql.auto.conf.temp is also located at the root of PGDATA, so it > might be surprising for the user to find it even if there are few > chances that it can happen. I don't think there's any real reason to defined PG_AUTOCONF_FILENAME_TEMP. pg_stat_statements just writes PGSS_DUMP_FILE ".tmp" and that hasn't been a problem that I know of. I do wonder why ALTER SYSTEM SET is spelling the suffix "temp" instead of "tmp". -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Mon, Jan 20, 2014 at 2:12 PM, Amit Kapila wrote: > On Sat, Jan 18, 2014 at 7:59 PM, Michael Paquier > wrote: >> Hi all, >> >> After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I >> noticed a couple of typo mistakes as well as (I think) a weird way of >> using the temporary auto-configuration name postgresql.auto.conf.temp >> in two different places, resulting in the patch attached. > > .tmp suffix is used at couple other places in code as well. > snapmgr.c > XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp"); > receivelog.c > snprintf(tmppath, MAXPGPATH, "%s.tmp", path); > > Although similar suffix is used at other places, but still I think it might be > better to define for current case as here prefix (postgresql.auto.conf) is > also > fixed and chances of getting it changed are less. However even if we don't > do, it might be okay as we are using such suffixes at other places as well. In the case of snapmgr.c and receivelog.c, the operations are kept local, so it does not matter much if this way of naming is done as all the operations for a temporary file are kept within the same, isolated function. However, the case of postgresql.auto.conf.temp is different: this temporary file name is used as well for a check in basebackup.c, so I imagine that it would be better to centralize this information in a single place. Now this name is only used in two places, but who knows if some additional checks here are there won't be needed for this temp file... postgresql.auto.conf.temp is also located at the root of PGDATA, so it might be surprising for the user to find it even if there are few chances that it can happen. >> It might be an overkill to use a dedicated variable for the temporary >> autoconfiguration file (here PG_AUTOCONF_FILENAME_TEMP), but I found >> kind of weird the way things are currently done on master branch. IMO, >> it would reduce bug possibilities to have everything managed with a >> single variable. >> >> Typos at least should be fixed :) > > - appendStringInfoString(&buf, "# Do not edit this file manually! \n"); > - appendStringInfoString(&buf, "# It will be overwritten by ALTER > SYSTEM command. \n"); > + appendStringInfoString(&buf, "# Do not edit this file manually!\n"); > + appendStringInfoString(&buf, "# It will be overwritten by ALTER > SYSTEM command.\n"); > > Same change in initdb.c is missing. Thanks, I missed it. -- Michael commit a8cf33deb3c46c4f56f1e617bbd3142cbbd66f1b Author: Michael Paquier Date: Tue Jan 21 21:44:30 2014 +0900 Fix typos and temporary file management in ALTER SYSTEM Using a temporary file uniquely defined in a single place reduces the occurence of bugs related to it. Some typos are fixed at the same time. diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index fc35f5b..a31bcdf 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -834,11 +834,10 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces) /* skip auto conf temporary file */ if (strncmp(de->d_name, - PG_AUTOCONF_FILENAME ".temp", - sizeof(PG_AUTOCONF_FILENAME) + 4) == 0) + PG_AUTOCONF_FILENAME_TEMP, + sizeof(PG_AUTOCONF_FILENAME_TEMP)) == 0) continue; - /* * If there's a backup_label file, it belongs to a backup started by * the user with pg_start_backup(). It is *not* correct for this diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 1217098..7da52bf 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -6457,9 +6457,9 @@ flatten_set_variable_args(const char *name, List *args) } /* - * Writes updated configuration parameter values into - * postgresql.auto.conf.temp file. It traverses the list of parameters - * and quote the string values before writing them to temporaray file. + * Write updated configuration parameter values into + * file PG_AUTOCONF_FILENAME_TEMP. It traverses the list of parameters + * and quotes the string values before writing them to temporary file. */ static void write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) @@ -6468,8 +6468,8 @@ write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) StringInfoData buf; initStringInfo(&buf); - appendStringInfoString(&buf, "# Do not edit this file manually! \n"); - appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command. \n"); + appendStringInfoString(&buf, "# Do not edit this file manually!\n"); + appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command.\n"); /* * write the file header message before contents, so that if there is no @@ -6596,7 +6596,7 @@ replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, * * The configuration parameters are written to a temporary * file then renamed to the final name. The template for the - * temporary f
Re: [HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
On Sat, Jan 18, 2014 at 7:59 PM, Michael Paquier wrote: > Hi all, > > After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I > noticed a couple of typo mistakes as well as (I think) a weird way of > using the temporary auto-configuration name postgresql.auto.conf.temp > in two different places, resulting in the patch attached. .tmp suffix is used at couple other places in code as well. snapmgr.c XactExportFilePath(pathtmp, topXid, list_length(exportedSnapshots), ".tmp"); receivelog.c snprintf(tmppath, MAXPGPATH, "%s.tmp", path); Although similar suffix is used at other places, but still I think it might be better to define for current case as here prefix (postgresql.auto.conf) is also fixed and chances of getting it changed are less. However even if we don't do, it might be okay as we are using such suffixes at other places as well. > It might be an overkill to use a dedicated variable for the temporary > autoconfiguration file (here PG_AUTOCONF_FILENAME_TEMP), but I found > kind of weird the way things are currently done on master branch. IMO, > it would reduce bug possibilities to have everything managed with a > single variable. > > Typos at least should be fixed :) - appendStringInfoString(&buf, "# Do not edit this file manually! \n"); - appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command. \n"); + appendStringInfoString(&buf, "# Do not edit this file manually!\n"); + appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command.\n"); Same change in initdb.c is missing. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] ALTER SYSTEM SET typos and fix for temporary file name management
Hi all, After going through commit 65d6e4c (introducing ALTER SYSTEM SET), I noticed a couple of typo mistakes as well as (I think) a weird way of using the temporary auto-configuration name postgresql.auto.conf.temp in two different places, resulting in the patch attached. It might be an overkill to use a dedicated variable for the temporary autoconfiguration file (here PG_AUTOCONF_FILENAME_TEMP), but I found kind of weird the way things are currently done on master branch. IMO, it would reduce bug possibilities to have everything managed with a single variable. Typos at least should be fixed :) Regards, -- Michael commit 9886e788b27c8fce895ccea4c83ddd223bc2 Author: Michael Paquier Date: Sat Jan 18 13:38:59 2014 +0900 Fix typos and temporary file management in ALTER SYSTEM Using a temporary file uniquely defined in a single place reduces the occurence of bugs related to it. Some typos are fixed at the same time. diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index fc35f5b..a31bcdf 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -834,11 +834,10 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces) /* skip auto conf temporary file */ if (strncmp(de->d_name, - PG_AUTOCONF_FILENAME ".temp", - sizeof(PG_AUTOCONF_FILENAME) + 4) == 0) + PG_AUTOCONF_FILENAME_TEMP, + sizeof(PG_AUTOCONF_FILENAME_TEMP)) == 0) continue; - /* * If there's a backup_label file, it belongs to a backup started by * the user with pg_start_backup(). It is *not* correct for this diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 1217098..7da52bf 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -6457,9 +6457,9 @@ flatten_set_variable_args(const char *name, List *args) } /* - * Writes updated configuration parameter values into - * postgresql.auto.conf.temp file. It traverses the list of parameters - * and quote the string values before writing them to temporaray file. + * Write updated configuration parameter values into + * file PG_AUTOCONF_FILENAME_TEMP. It traverses the list of parameters + * and quotes the string values before writing them to temporary file. */ static void write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) @@ -6468,8 +6468,8 @@ write_auto_conf_file(int fd, const char *filename, ConfigVariable **head_p) StringInfoData buf; initStringInfo(&buf); - appendStringInfoString(&buf, "# Do not edit this file manually! \n"); - appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command. \n"); + appendStringInfoString(&buf, "# Do not edit this file manually!\n"); + appendStringInfoString(&buf, "# It will be overwritten by ALTER SYSTEM command.\n"); /* * write the file header message before contents, so that if there is no @@ -6596,7 +6596,7 @@ replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, * * The configuration parameters are written to a temporary * file then renamed to the final name. The template for the - * temporary file is postgresql.auto.conf.temp. + * temporary file is PG_AUTOCONF_FILENAME_TEMP. * * An LWLock is used to serialize writing to the same file. * @@ -6662,16 +6662,16 @@ AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) ereport(ERROR, (errmsg("invalid value for parameter \"%s\": \"%s\"", name, value))); - /* * Use data directory as reference path for postgresql.auto.conf and it's - * corresponding temp file + * corresponding temp file. */ - join_path_components(AutoConfFileName, data_directory, PG_AUTOCONF_FILENAME); + join_path_components(AutoConfFileName, data_directory, + PG_AUTOCONF_FILENAME); canonicalize_path(AutoConfFileName); - snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s", - AutoConfFileName, - "temp"); + join_path_components(AutoConfTmpFileName, data_directory, + PG_AUTOCONF_FILENAME_TEMP); + canonicalize_path(AutoConfTmpFileName); /* * one backend is allowed to operate on postgresql.auto.conf file, to @@ -6713,7 +6713,7 @@ AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) */ replace_auto_config_value(&head, &tail, AutoConfFileName, name, value); - /* Write and sync the New contents to postgresql.auto.conf.temp file */ + /* Write and sync the New contents to file PG_AUTOCONF_FILENAME_TEMP */ write_auto_conf_file(Tmpfd, AutoConfTmpFileName, &head); close(Tmpfd); diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index 20c5ff0..a4c2e3f 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -304,6 +304,12 @@ /* * Automatic configuration file name for ALTER SYSTEM. * This file will be used to store values of configuration parameters - * set by ALTER SYSTEM command + * set by ALTER SYSTEM command. */ #define PG