diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index ee38040..d5966a9 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -44,6 +44,7 @@ enum { static unsigned int ConfigFileLineno; static const char *GUC_flex_fatal_errmsg; static sigjmp_buf *GUC_flex_fatal_jmp; +static char *tmp_data_directory; /* flex fails to supply a prototype for yylex, so provide one */ int GUC_yylex(void); @@ -122,6 +123,8 @@ ProcessConfigFile(GucContext context) int i; char *ErrorConfFile; char *CallingFileName; + char AutoConfFileName[MAXPGPATH]; + char *datadir; /* * Config files are processed on startup (by the postmaster only) @@ -155,11 +158,28 @@ ProcessConfigFile(GucContext context) * set till this point, so use ConfigFile path which will be same. */ if (data_directory) + { + snprintf(AutoConfFileName,sizeof(AutoConfFileName),"%s", + PG_AUTOCONF_FILENAME); CallingFileName = NULL; + } + else if (tmp_data_directory) + { + datadir = make_absolute_path(tmp_data_directory); + join_path_components(AutoConfFileName, datadir, + PG_AUTOCONF_FILENAME); + canonicalize_path(AutoConfFileName); + free(datadir); + CallingFileName = NULL; + } else + { + snprintf(AutoConfFileName,sizeof(AutoConfFileName),"%s", + PG_AUTOCONF_FILENAME); CallingFileName = ConfigFileName; + } - if (!ParseConfigFile(PG_AUTOCONF_FILENAME, CallingFileName, false, 0, elevel, &head, &tail)) + if (!ParseConfigFile(AutoConfFileName, CallingFileName, false, 0, elevel, &head, &tail)) { /* Syntax error(s) detected in the file, so bail out */ error = true; @@ -654,6 +674,15 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, } else { + /* + * In case of postmaster start for processing PG_AUTOCONF_FILENAME, + * we need to know the value of data_directory which is available + * only after processing of configuration files. Store it's value + * for use till data_directory is set. + */ + if (guc_name_compare(opt_name, "data_directory") == 0) + tmp_data_directory = opt_value; + /* ordinary variable, append to list */ item = palloc(sizeof *item); item->name = opt_name;