10000 Add sourcefile/sourceline data to EXEC_BACKEND GUC transmission files. · jaylevitt/postgres@5aa09d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5aa09d5

Browse files
committed
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).
1 parent 50af47f commit 5aa09d5

File tree

1 file changed

+27
-9
lines changed
  • src/backend/utils/misc

1 file changed

+27
-9
lines changed

src/backend/utils/misc/guc.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6743,6 +6743,8 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
67436743
*
67446744
* variable name, string, null terminated
67456745
* variable value, string, null terminated
6746+
* variable sourcefile, string, null terminated (empty if none)
6747+
* variable sourceline, integer
67466748
* variable source, integer
67476749
*/
67486750
static void
@@ -6779,8 +6781,7 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf)
67796781
{
67806782
struct config_real *conf = (struct config_real *) gconf;
67816783

6782-
/* Could lose precision here? */
6783-
fprintf(fp, "%f", *conf->variable);
6784+
fprintf(fp, "%.17g", *conf->variable);
67846785
}
67856786
break;
67866787

@@ -6804,7 +6805,12 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf)
68046805

68056806
fputc(0, fp);
68066807

6807-
fwrite(&gconf->source, sizeof(gconf->source), 1, fp);
6808+
if (gconf->sourcefile)
6809+
fprintf(fp, "%s", gconf->sourcefile);
6810+
fputc(0, fp);
6811+
6812+
fwrite(&gconf->sourceline, 1, sizeof(gconf->sourceline), fp);
6813+
fwrite(&gconf->source, 1, sizeof(gconf->source), fp);
68086814
}
68096815

68106816
void
@@ -6907,8 +6913,10 @@ read_nondefault_variables(void)
69076913
{
69086914
FILE *fp;
69096915
char *varname,
6910-
*varvalue;
6911-
int varsource;
6916+
*varvalue,
6917+
*varsourcefile;
6918+
int varsourceline;
6919+
GucSource varsource;
69126920

69136921
/*
69146922
* Open file
@@ -6933,16 +6941,26 @@ read_nondefault_variables(void)
69336941
break;
69346942

69356943
if ((record = find_option(varname, true, FATAL)) == NULL)
6936-
elog(FATAL, "failed to locate variable %s in exec config params file", varname);
6944+
elog(FATAL, "failed to locate variable \"%s\" in exec config params file", varname);
6945+
69376946
if ((varvalue = read_string_with_null(fp)) == NULL)
69386947
elog(FATAL, "invalid format of exec config params file");
6939-
if (fread(&varsource, sizeof(varsource), 1, fp) == 0)
6948+
if ((varsourcefile = read_string_with_null(fp)) == NULL)
69406949
elog(FATAL, "invalid format of exec config params file");
6950+
if (fread(&varsourceline, 1, sizeof(varsourceline), fp) != sizeof(varsourceline))
6951+
elog(FATAL, "invalid format of exec config params file");
6952+
if (fread(&varsource, 1, sizeof(varsource), fp) != sizeof(varsource))
6953+
elog(FATAL, "invalid format of exec config params file");
6954+
6955+
(void) set_config_option(varname, varvalue,
6956+
record->context, varsource,
6957+
GUC_ACTION_SET, true);
6958+
if (varsourcefile[0])
6959+
set_config_sourcefile(varname, varsourcefile, varsourceline);
69416960

6942-
(void) set_config_option(varname, varvalue, record->context,
6943-
varsource, GUC_ACTION_SET, true);
69446961
free(varname);
69456962
free(varvalue);
6963+
free(varsourcefile);
69466964
}
69476965

69486966
FreeFile(fp);

0 commit comments

Comments
 (0)
0