mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-03 06:57:01 +02:00
Code improvements for ALTER SYSTEM .. SET.
Move FreeConfigVariables() later to make sure ErrorConfFile is valid when we use it, and get rid of an unnecessary string copy operation. Amit Kapila, kibitzed by me.
This commit is contained in:
parent
2bb1f14b89
commit
05ff5062da
@ -120,7 +120,6 @@ ProcessConfigFile(GucContext context)
|
|||||||
*head,
|
*head,
|
||||||
*tail;
|
*tail;
|
||||||
int i;
|
int i;
|
||||||
char ConfigAutoFileName[MAXPGPATH];
|
|
||||||
char *ErrorConfFile;
|
char *ErrorConfFile;
|
||||||
char *CallingFileName;
|
char *CallingFileName;
|
||||||
|
|
||||||
@ -155,17 +154,16 @@ ProcessConfigFile(GucContext context)
|
|||||||
* data directory, however when called during initdb data directory is not
|
* data directory, however when called during initdb data directory is not
|
||||||
* set till this point, so use ConfigFile path which will be same.
|
* set till this point, so use ConfigFile path which will be same.
|
||||||
*/
|
*/
|
||||||
snprintf(ConfigAutoFileName,sizeof(ConfigAutoFileName),"%s", PG_AUTOCONF_FILENAME);
|
|
||||||
if (data_directory)
|
if (data_directory)
|
||||||
CallingFileName = NULL;
|
CallingFileName = NULL;
|
||||||
else
|
else
|
||||||
CallingFileName = ConfigFileName;
|
CallingFileName = ConfigFileName;
|
||||||
|
|
||||||
if (!ParseConfigFile(ConfigAutoFileName, CallingFileName, false, 0, elevel, &head, &tail))
|
if (!ParseConfigFile(PG_AUTOCONF_FILENAME, CallingFileName, false, 0, elevel, &head, &tail))
|
||||||
{
|
{
|
||||||
/* Syntax error(s) detected in the file, so bail out */
|
/* Syntax error(s) detected in the file, so bail out */
|
||||||
error = true;
|
error = true;
|
||||||
ErrorConfFile = ConfigAutoFileName;
|
ErrorConfFile = PG_AUTOCONF_FILENAME;
|
||||||
goto cleanup_list;
|
goto cleanup_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,8 +366,6 @@ ProcessConfigFile(GucContext context)
|
|||||||
PgReloadTime = GetCurrentTimestamp();
|
PgReloadTime = GetCurrentTimestamp();
|
||||||
|
|
||||||
cleanup_list:
|
cleanup_list:
|
||||||
FreeConfigVariables(head);
|
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
/* During postmaster startup, any error is fatal */
|
/* During postmaster startup, any error is fatal */
|
||||||
@ -389,6 +385,13 @@ ProcessConfigFile(GucContext context)
|
|||||||
errmsg("configuration file \"%s\" contains errors; no changes were applied",
|
errmsg("configuration file \"%s\" contains errors; no changes were applied",
|
||||||
ErrorConfFile)));
|
ErrorConfFile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calling FreeConfigVariables() any earlier than this can cause problems,
|
||||||
|
* because ErrorConfFile could be pointing to a string that will be freed
|
||||||
|
* here.
|
||||||
|
*/
|
||||||
|
FreeConfigVariables(head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user