4
4
*
5
5
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
6
6
*
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 $
8
8
*/
9
9
10
10
%{
@@ -50,8 +50,7 @@ int GUC_yylex(void);
50
50
static bool ParseConfigFile (const char *config_file, const char *calling_file,
51
51
int depth, GucContext context, int elevel,
52
52
struct name_value_pair **head_p,
53
- struct name_value_pair **tail_p,
54
- int *varcount);
53
+ struct name_value_pair **tail_p);
55
54
static void free_name_value_list (struct name_value_pair * list);
56
55
static char *GUC_scanstr (const char *s);
57
56
@@ -115,11 +114,8 @@ STRING \'([^'\\\n]|\\.|\'\')*\'
115
114
void
116
115
ProcessConfigFile(GucContext context)
117
116
{
118
- int elevel, i ;
117
+ int elevel;
119
118
struct name_value_pair *item, *head, *tail;
120
- char *env;
121
- bool *apply_list = NULL;
122
- int varcount = 0;
123
119
124
120
Assert(context == PGC_POSTMASTER || context == PGC_SIGHUP);
125
121
@@ -138,109 +134,25 @@ ProcessConfigFile(GucContext context)
138
134
139
135
if (!ParseConfigFile(ConfigFileName, NULL,
140
136
0, context, elevel,
141
- &head, &tail, &varcount ))
137
+ &head, &tail))
142
138
goto cleanup_list;
143
139
144
- /* Can we allocate memory here, what about leaving here prematurely? */
145
- apply_list = (bool *) palloc(sizeof(bool) * varcount);
146
-
147
140
/* 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)
149
142
{
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))
158
145
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;
179
146
}
180
147
181
148
/* 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)
188
150
{
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);
239
153
}
240
154
241
- cleanup_list:
242
- if (apply_list)
243
- pfree(apply_list);
155
+ cleanup_list:
244
156
free_name_value_list(head);
245
157
}
246
158
@@ -277,14 +189,13 @@ static bool
277
189
ParseConfigFile (const char *config_file, const char *calling_file,
278
190
int depth, GucContext context, int elevel,
279
191
struct name_value_pair **head_p,
280
- struct name_value_pair **tail_p,
281
- int *varcount)
192
+ struct name_value_pair **tail_p)
282
193
{
283
- bool OK = true ;
284
- char abs_path[MAXPGPATH];
285
- FILE *fp;
194
+ bool OK = true ;
195
+ char abs_path[MAXPGPATH];
196
+ FILE *fp;
286
197
YY_BUFFER_STATE lex_buffer;
287
- int token;
198
+ int token;
288
199
289
200
/*
290
201
* 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,
378
289
379
290
if (!ParseConfigFile (opt_value, config_file,
380
291
depth + 1 , context, elevel,
381
- head_p, tail_p, varcount ))
292
+ head_p, tail_p))
382
293
{
383
294
pfree (opt_name);
384
295
pfree (opt_value);
@@ -422,7 +333,6 @@ ParseConfigFile(const char *config_file, const char *calling_file,
422
333
else
423
334
(*tail_p)->next = item;
424
335
*tail_p = item;
425
- (*varcount)++;
426
336
}
427
337
428
338
/* break out of loop if read EOF, else loop for next line */
0 commit comments