Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f058451

Browse files
committed
Revert (again) GUC patch to return commented fields to their default
values, due to concern about the patch.
1 parent 3648147 commit f058451

File tree

4 files changed

+291
-562
lines changed

4 files changed

+291
-562
lines changed

src/backend/utils/misc/guc-file.l

Lines changed: 17 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.44 2006/08/13 02:22:24 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.45 2006/08/14 02:27:26 momjian Exp $
88
*/
99

1010
%{
@@ -50,8 +50,7 @@ int GUC_yylex(void);
5050
static bool ParseConfigFile(const char *config_file, const char *calling_file,
5151
int depth, GucContext context, int elevel,
5252
struct name_value_pair **head_p,
53-
struct name_value_pair **tail_p,
54-
int *varcount);
53+
struct name_value_pair **tail_p);
5554
static void free_name_value_list(struct name_value_pair * list);
5655
static char *GUC_scanstr(const char *s);
5756

@@ -115,11 +114,8 @@ STRING \'([^'\\\n]|\\.|\'\')*\'
115114
void
116115
ProcessConfigFile(GucContext context)
117116
{
118-
int elevel, i;
117+
int elevel;
119118
struct name_value_pair *item, *head, *tail;
120-
char *env;
121-
bool *apply_list = NULL;
122-
int varcount = 0;
123119
124120
Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
125121
@@ -138,109 +134,25 @@ ProcessConfigFile(GucContext context)
138134
139135
if (!ParseConfigFile(ConfigFileName, NULL,
140136
0, context, elevel,
141-
&head, &tail, &varcount))
137+
&head, &tail))
142138
goto cleanup_list;
143139
144-
/* Can we allocate memory here, what about leaving here prematurely? */
145-
apply_list = (bool *) palloc(sizeof(bool) * varcount);
146-
147140
/* Check if all options are valid */
148-
for (item = head, i = 0; item; item = item->next, i++)
141+
for (item = head; item; item = item->next)
149142
{
150-
bool isEqual, isContextOk;
151-
152-
if (!verify_config_option(item->name, item->value, context,
153-
PGC_S_FILE, &isEqual, &isContextOk))
154-
{
155-
ereport(elevel,
156-
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
157-
errmsg("configuration file is invalid")));
143+
if (!set_config_option(item->name, item->value, context,
144+
PGC_S_FILE, false, false))
158145
goto cleanup_list;
159-
}
160-
161-
if (isContextOk == false)
162-
{
163-
apply_list[i] = false;
164-
if (context == PGC_SIGHUP)
165-
{
166-
if (isEqual == false)
167-
ereport(elevel,
168-
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
169-
errmsg("parameter \"%s\" cannot be changed after server start; configuration file change ignored",
170-
item->name)));
171-
}
172-
else
173-
/* if it is boot phase, context must be valid for all
174-
* configuration item. */
175-
goto cleanup_list;
176-
}
177-
else
178-
apply_list[i] = true;
179146
}
180147
181148
/* If we got here all the options checked out okay, so apply them. */
182-
for (item = head, i = 0; item; item = item->next, i++)
183-
if (apply_list[i])
184-
set_config_option(item->name, item->value, context,
185-
PGC_S_FILE, false, true);
186-
187-
if (context == PGC_SIGHUP)
149+
for (item = head; item; item = item->next)
188150
{
189-
/*
190-
* Revert all "untouched" options with reset source PGC_S_FILE to
191-
* default/boot value.
192-
*/
193-
for (i = 0; i < num_guc_variables; i++)
194-
{
195-
struct config_generic *gconf = guc_variables[i];
196-
197-
if (gconf->reset_source == PGC_S_FILE &&
198-
!(gconf->status & GUC_IN_CONFFILE))
199-
{
200-
if (gconf->context == PGC_BACKEND && IsUnderPostmaster)
201-
; /* Be silent. Does any body want message from each session? */
202-
else if (gconf->context == PGC_POSTMASTER)
203-
ereport(elevel,
204-
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
205-
errmsg("parameter \"%s\" cannot be changed (commented) after server start; configuration file change ignored",
206-
gconf->name)));
207-
else if (set_config_option(gconf->name, NULL, context,
208-
PGC_S_FILE, false, true))
209-
{
210-
GucStack *stack;
211-
212-
gconf->reset_source = PGC_S_DEFAULT;
213-
214-
for (stack = gconf->stack; stack; stack = stack->prev)
215-
if (stack->source == PGC_S_FILE)
216-
stack->source = PGC_S_DEFAULT;
217-
218-
ereport(elevel,
219-
(errcode(ERRCODE_SUCCESSFUL_COMPLETION),
220-
errmsg("configuration option %s returned to default value", gconf->name)));
221-
}
222-
}
223-
gconf->status &= ~GUC_IN_CONFFILE;
224-
}
225-
226-
/*
227-
* Revert to environment variable. PGPORT is ignored, because it cannot be
228-
* set in running state.
229-
*/
230-
env = getenv("PGDATESTYLE");
231-
if (env != NULL)
232-
set_config_option("datestyle", env, context,
233-
PGC_S_ENV_VAR, false, true);
234-
235-
env = getenv("PGCLIENTENCODING");
236-
if (env != NULL)
237-
set_config_option("client_encoding", env, context,
238-
PGC_S_ENV_VAR, false, true);
151+
set_config_option(item->name, item->value, context,
152+
PGC_S_FILE, false, true);
239153
}
240154
241-
cleanup_list:
242-
if (apply_list)
243-
pfree(apply_list);
155+
cleanup_list:
244156
free_name_value_list(head);
245157
}
246158
@@ -277,14 +189,13 @@ static bool
277189
ParseConfigFile(const char *config_file, const char *calling_file,
278190
int depth, GucContext context, int elevel,
279191
struct name_value_pair **head_p,
280-
struct name_value_pair **tail_p,
281-
int *varcount)
192+
struct name_value_pair **tail_p)
282193
{
283-
bool OK = true;
284-
char abs_path[MAXPGPATH];
285-
FILE *fp;
194+
bool OK = true;
195+
char abs_path[MAXPGPATH];
196+
FILE *fp;
286197
YY_BUFFER_STATE lex_buffer;
287-
int token;
198+
int token;
288199

289200
/*
290201
* Reject too-deep include nesting depth. This is just a safety check
@@ -378,7 +289,7 @@ ParseConfigFile(const char *config_file, const char *calling_file,
378289

379290
if (!ParseConfigFile(opt_value, config_file,
380291
depth + 1, context, elevel,
381-
head_p, tail_p, varcount))
292+
head_p, tail_p))
382293
{
383294
pfree(opt_name);
384295
pfree(opt_value);
@@ -422,7 +333,6 @@ ParseConfigFile(const char *config_file, const char *calling_file,
422333
else
423334
(*tail_p)->next = item;
424335
*tail_p = item;
425-
(*varcount)++;
426336
}
427337

428338
/* break out of loop if read EOF, else loop for next line */

0 commit comments

Comments
 (0)