From 3a8cdf33aa4a492f58d60c859c11a2c0e199023d Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 11 Jun 2004 03:54:54 +0000 Subject: [PATCH] >> It certainly doesn't. There still was a bug with the locale stuff, >> though - the GUC variable was not set in the child >processes. So "show >> lc_collate" would *always* return "C", for example. attached >patch fixes >> this. > >Hm. Why were these vars not propagated by the regular >mechanism for GUC >variables (write_nondefault_variables or whatever it's called)? If the >problem is that it's not accepting PGC_INTERNAL values, then we need to >fix it there not here, because otherwise we'll have to pass all the >PGC_INTERNAL variables through the backend_variables file, which seems >like a recipe for more of the same sort of bug. Good point :-( I think the problem is not only that it specifically does not deal with PGC_INTERNAL variables. The problem is in the fact that write_nondefault_variables is called *before* the locale is read (because the locale is read from pg_control and not from any of the "usual" ways to read it). Attached patch is another stab at fixing it. It makes postmaster dump a new copy of the file once it has started the database (before it accepts any connections), which is when it will know about these parameters. Also updates the reading code to set the context to the one where the variable was originally set (PGC_POSTMASTER won't work for PGC_INTERNAL, and the other way around). We still pass lc_collate through the special file, because set_config_option on lc_collate will speficially *not* call setlocale(), and we need that call. But we no longer call set_config_option from there. Magnus Hagander --- src/backend/postmaster/postmaster.c | 6 +++++- src/backend/utils/misc/guc.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 85ba8309d4..2081eb3650 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.402 2004/06/03 02:08:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.403 2004/06/11 03:54:43 momjian Exp $ * * NOTES * @@ -830,6 +830,10 @@ PostmasterMain(int argc, char *argv[]) */ StartupPID = StartupDataBase(); +#ifdef EXEC_BACKEND + write_nondefault_variables(PGC_POSTMASTER); +#endif + status = ServerLoop(); /* diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8f1e7084c5..f050e201e2 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.210 2004/05/30 23:40:38 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.211 2004/06/11 03:54:54 momjian Exp $ * *-------------------------------------------------------------------- */ @@ -4454,15 +4454,19 @@ read_nondefault_variables(void) for (;;) { + struct config_generic *record; + if ((varname = read_string_with_null(fp)) == NULL) break; + if ((record = find_option(varname)) == NULL) + elog(FATAL, "failed to locate variable %s in exec config params file",varname); if ((varvalue = read_string_with_null(fp)) == NULL) elog(FATAL, "invalid format of exec config params file"); if (fread(&varsource, sizeof(varsource), 1, fp) == 0) elog(FATAL, "invalid format of exec config params file"); - (void) set_config_option(varname, varvalue, PGC_POSTMASTER, + (void) set_config_option(varname, varvalue, record->context, varsource, false, true); free(varname); free(varvalue); -- 2.40.0