Skip to content

Commit 4bcb82a

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 9f5836d commit 4bcb82a

File tree

1 file changed

+20
-2
lines changed
  • src/backend/utils/misc

1 file changed

+20
-2
lines changed

src/backend/utils/misc/guc.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7264,6 +7264,8 @@ _ShowOption(struct config_generic * record, bool use_units)
72647264
*
72657265
* variable name, string, null terminated
72667266
* variable value, string, null terminated
7267+
* variable sourcefile, string, null terminated (empty if none)
7268+
* variable sourceline, integer
72677269
* variable source, integer
72687270
* variable scontext, integer
72697271
*/
@@ -7325,6 +7327,11 @@ write_one_nondefault_variable(FILE *fp, struct config_generic * gconf)
73257327

73267328
fputc(0, fp);
73277329

7330+
if (gconf->sourcefile)
7331+
fprintf(fp, "%s", gconf->sourcefile);
7332+
fputc(0, fp);
7333+
7334+
fwrite(&gconf->sourceline, 1, sizeof(gconf->sourceline), fp);
73287335
fwrite(&gconf->source, 1, sizeof(gconf->source), fp);
73297336
fwrite(&gconf->scontext, 1, sizeof(gconf->scontext), fp);
73307337
}
@@ -7417,7 +7424,9 @@ read_nondefault_variables(void)
74177424
{
74187425
FILE *fp;
74197426
char *varname,
7420-
*varvalue;
7427+
*varvalue,
7428+
*varsourcefile;
7429+
int varsourceline;
74217430
GucSource varsource;
74227431
GucContext varscontext;
74237432

@@ -7444,9 +7453,14 @@ read_nondefault_variables(void)
74447453
break;
74457454

74467455
if ((record = find_option(varname, true, FATAL)) == NULL)
7447-
elog(FATAL, "failed to locate variable %s in exec config params file", varname);
7456+
elog(FATAL, "failed to locate variable \"%s\" in exec config params file", varname);
7457+
74487458
if ((varvalue = read_string_with_null(fp)) == NULL)
74497459
elog(FATAL, "invalid format of exec config params file");
7460+
if ((varsourcefile = read_string_with_null(fp)) == NULL)
7461+
elog(FATAL, "invalid format of exec config params file");
7462+
if (fread(&varsourceline, 1, sizeof(varsourceline), fp) != sizeof(varsourceline))
7463+
elog(FATAL, "invalid format of exec config params file");
74507464
if (fread(&varsource, 1, sizeof(varsource), fp) != sizeof(varsource))
74517465
elog(FATAL, "invalid format of exec config params file");
74527466
if (fread(&varscontext, 1, sizeof(varscontext), fp) != sizeof(varscontext))
@@ -7455,8 +7469,12 @@ read_nondefault_variables(void)
74557469
(void) set_config_option(varname, varvalue,
74567470
varscontext, varsource,
74577471
GUC_ACTION_SET, true);
7472+
if (varsourcefile[0])
7473+
set_config_sourcefile(varname, varsourcefile, varsourceline);
7474+
74587475
free(varname);
74597476
free(varvalue);
7477+
free(varsourcefile);
74607478
}
74617479

74627480
FreeFile(fp);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy