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).
This commit is contained in:
parent
f994bf965d
commit
ddc36df7af
@ -6961,6 +6961,8 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
@ -6997,8 +6999,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf)
|
|||||||
{
|
{
|
||||||
struct config_real *conf = (struct config_real *) gconf;
|
struct config_real *conf = (struct config_real *) gconf;
|
||||||
|
|
||||||
/* Could lose precision here? */
|
fprintf(fp, "%.17g", *conf->variable);
|
||||||
fprintf(fp, "%f", *conf->variable);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -7022,7 +7023,12 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf)
|
|||||||
|
|
||||||
fputc(0, fp);
|
fputc(0, fp);
|
||||||
|
|
||||||
fwrite(&gconf->source, sizeof(gconf->source), 1, 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -7125,8 +7131,10 @@ read_nondefault_variables(void)
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *varname,
|
char *varname,
|
||||||
*varvalue;
|
*varvalue,
|
||||||
int varsource;
|
*varsourcefile;
|
||||||
|
int varsourceline;
|
||||||
|
GucSource varsource;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open file
|
* Open file
|
||||||
@ -7151,16 +7159,26 @@ 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 (fread(&varsource, sizeof(varsource), 1, fp) == 0)
|
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))
|
||||||
elog(FATAL, "invalid format of exec config params file");
|
elog(FATAL, "invalid format of exec config params file");
|
||||||
|
|
||||||
(void) set_config_option(varname, varvalue, record->context,
|
(void) set_config_option(varname, varvalue,
|
||||||
varsource, GUC_ACTION_SET, true);
|
record->context, varsource,
|
||||||
|
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user