Commit 4bcb82a7 authored by Tom Lane's avatar Tom Lane

Add sourcefile/sourceline data to EXEC_BACKEND GUC transmission files.

This oversight meant that on Windows, the pg_settings view would not
display source file or line number information for values coming from
postgresql.conf, unless the backend had received a SIGHUP since starting.

In passing, also make the error detection in read_nondefault_variables a
tad more thorough, and fix it to not lose precision on float GUCs (these
changes are already in HEAD as of my previous commit).
parent 9f5836d2
...@@ -7264,6 +7264,8 @@ _ShowOption(struct config_generic * record, bool use_units) ...@@ -7264,6 +7264,8 @@ _ShowOption(struct config_generic * record, bool use_units)
* *
* variable name, string, null terminated * variable name, string, null terminated
* variable value, string, null terminated * variable value, string, null terminated
* variable sourcefile, string, null terminated (empty if none)
* variable sourceline, integer
* variable source, integer * variable source, integer
* variable scontext, integer * variable scontext, integer
*/ */
...@@ -7325,6 +7327,11 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf) ...@@ -7325,6 +7327,11 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf)
fputc(0, fp); fputc(0, fp);
if (gconf->sourcefile)
fprintf(fp, "%s", gconf->sourcefile);
fputc(0, fp);
fwrite(&gconf->sourceline, 1, sizeof(gconf->sourceline), fp);
fwrite(&gconf->source, 1, sizeof(gconf->source), fp); fwrite(&gconf->source, 1, sizeof(gconf->source), fp);
fwrite(&gconf->scontext, 1, sizeof(gconf->scontext), fp); fwrite(&gconf->scontext, 1, sizeof(gconf->scontext), fp);
} }
...@@ -7417,7 +7424,9 @@ read_nondefault_variables(void) ...@@ -7417,7 +7424,9 @@ read_nondefault_variables(void)
{ {
FILE *fp; FILE *fp;
char *varname, char *varname,
*varvalue; *varvalue,
*varsourcefile;
int varsourceline;
GucSource varsource; GucSource varsource;
GucContext varscontext; GucContext varscontext;
...@@ -7444,9 +7453,14 @@ read_nondefault_variables(void) ...@@ -7444,9 +7453,14 @@ read_nondefault_variables(void)
break; break;
if ((record = find_option(varname, true, FATAL)) == NULL) if ((record = find_option(varname, true, FATAL)) == NULL)
elog(FATAL, "failed to locate variable %s in exec config params file", varname); elog(FATAL, "failed to locate variable \"%s\" in exec config params file", varname);
if ((varvalue = read_string_with_null(fp)) == NULL) if ((varvalue = read_string_with_null(fp)) == NULL)
elog(FATAL, "invalid format of exec config params file"); elog(FATAL, "invalid format of exec config params file");
if ((varsourcefile = read_string_with_null(fp)) == NULL)
elog(FATAL, "invalid format of exec config params file");
if (fread(&varsourceline, 1, sizeof(varsourceline), fp) != sizeof(varsourceline))
elog(FATAL, "invalid format of exec config params file");
if (fread(&varsource, 1, sizeof(varsource), fp) != sizeof(varsource)) if (fread(&varsource, 1, sizeof(varsource), fp) != sizeof(varsource))
elog(FATAL, "invalid format of exec config params file"); elog(FATAL, "invalid format of exec config params file");
if (fread(&varscontext, 1, sizeof(varscontext), fp) != sizeof(varscontext)) if (fread(&varscontext, 1, sizeof(varscontext), fp) != sizeof(varscontext))
...@@ -7455,8 +7469,12 @@ read_nondefault_variables(void) ...@@ -7455,8 +7469,12 @@ read_nondefault_variables(void)
(void) set_config_option(varname, varvalue, (void) set_config_option(varname, varvalue,
varscontext, varsource, varscontext, varsource,
GUC_ACTION_SET, true); GUC_ACTION_SET, true);
if (varsourcefile[0])
set_config_sourcefile(varname, varsourcefile, varsourceline);
free(varname); free(varname);
free(varvalue); free(varvalue);
free(varsourcefile);
} }
FreeFile(fp); FreeFile(fp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment