10
10
* Written by Peter Eisentraut <peter_e@gmx.net>.
11
11
*
12
12
* IDENTIFICATION
13
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.455 2008/05/26 18:54:29 tgl Exp $
13
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.456 2008/05/28 09:04:06 mha Exp $
14
14
*
15
15
*--------------------------------------------------------------------
16
16
*/
@@ -173,107 +173,107 @@ static char *config_enum_get_options(struct config_enum *record,
173
173
* Options for enum values defined in this module.
174
174
*/
175
175
static const struct config_enum_entry message_level_options []= {
176
- {"debug" ,DEBUG2 },
177
- {"debug5" ,DEBUG5 },
178
- {"debug4" ,DEBUG4 },
179
- {"debug3" ,DEBUG3 },
180
- {"debug2" ,DEBUG2 },
181
- {"debug1" ,DEBUG1 },
182
- {"log" ,LOG },
183
- {"info" ,INFO },
184
- {"notice" ,NOTICE },
185
- {"warning" ,WARNING },
186
- {"error" ,ERROR },
187
- {"fatal" ,FATAL },
188
- {"panic" ,PANIC },
189
- {NULL ,0 }
176
+ {"debug" ,DEBUG2 , false },
177
+ {"debug5" ,DEBUG5 , false },
178
+ {"debug4" ,DEBUG4 , false },
179
+ {"debug3" ,DEBUG3 , false },
180
+ {"debug2" ,DEBUG2 , false },
181
+ {"debug1" ,DEBUG1 , false },
182
+ {"log" ,LOG , false },
183
+ {"info" ,INFO , false },
184
+ {"notice" ,NOTICE , false },
185
+ {"warning" ,WARNING , false },
186
+ {"error" ,ERROR , false },
187
+ {"fatal" ,FATAL , false },
188
+ {"panic" ,PANIC , false },
189
+ {NULL ,0 , false }
190
190
};
191
191
192
192
static const struct config_enum_entry log_error_verbosity_options []= {
193
- {"default" ,PGERROR_DEFAULT },
194
- {"terse" ,PGERROR_TERSE },
195
- {"verbose" ,PGERROR_VERBOSE },
196
- {NULL ,0 }
193
+ {"default" ,PGERROR_DEFAULT , false },
194
+ {"terse" ,PGERROR_TERSE , false },
195
+ {"verbose" ,PGERROR_VERBOSE , false },
196
+ {NULL ,0 , false }
197
197
};
198
198
199
199
static const struct config_enum_entry log_statement_options []= {
200
- {"none" ,LOGSTMT_NONE },
201
- {"ddl" ,LOGSTMT_DDL },
202
- {"mod" ,LOGSTMT_MOD },
203
- {"all" ,LOGSTMT_ALL },
204
- {NULL ,0 }
200
+ {"none" ,LOGSTMT_NONE , false },
201
+ {"ddl" ,LOGSTMT_DDL , false },
202
+ {"mod" ,LOGSTMT_MOD , false },
203
+ {"all" ,LOGSTMT_ALL , false },
204
+ {NULL ,0 , false }
205
205
};
206
206
207
207
static const struct config_enum_entry regex_flavor_options []= {
208
- {"advanced" ,REG_ADVANCED },
209
- {"extended" ,REG_EXTENDED },
210
- {"basic" ,REG_BASIC },
211
- {NULL ,0 }
208
+ {"advanced" ,REG_ADVANCED , false },
209
+ {"extended" ,REG_EXTENDED , false },
210
+ {"basic" ,REG_BASIC , false },
211
+ {NULL ,0 , false }
212
212
};
213
213
214
214
static const struct config_enum_entry isolation_level_options []= {
215
- {"serializable" ,XACT_SERIALIZABLE },
216
- {"repeatable read" ,XACT_REPEATABLE_READ },
217
- {"read committed" ,XACT_READ_COMMITTED },
218
- {"read uncommitted" ,XACT_READ_UNCOMMITTED },
215
+ {"serializable" ,XACT_SERIALIZABLE , false },
216
+ {"repeatable read" ,XACT_REPEATABLE_READ , false },
217
+ {"read committed" ,XACT_READ_COMMITTED , false },
218
+ {"read uncommitted" ,XACT_READ_UNCOMMITTED , false },
219
219
{NULL ,0 }
220
220
};
221
221
222
222
static const struct config_enum_entry session_replication_role_options []= {
223
- {"origin" ,SESSION_REPLICATION_ROLE_ORIGIN },
224
- {"replica" ,SESSION_REPLICATION_ROLE_REPLICA },
225
- {"local" ,SESSION_REPLICATION_ROLE_LOCAL },
226
- {NULL ,0 }
223
+ {"origin" ,SESSION_REPLICATION_ROLE_ORIGIN , false },
224
+ {"replica" ,SESSION_REPLICATION_ROLE_REPLICA , false },
225
+ {"local" ,SESSION_REPLICATION_ROLE_LOCAL , false },
226
+ {NULL ,0 , false }
227
227
};
228
228
229
229
#ifdef HAVE_SYSLOG
230
230
static const struct config_enum_entry syslog_facility_options []= {
231
- {"local0" ,LOG_LOCAL0 },
232
- {"local1" ,LOG_LOCAL1 },
233
- {"local2" ,LOG_LOCAL2 },
234
- {"local3" ,LOG_LOCAL3 },
235
- {"local4" ,LOG_LOCAL4 },
236
- {"local5" ,LOG_LOCAL5 },
237
- {"local6" ,LOG_LOCAL6 },
238
- {"local7" ,LOG_LOCAL7 },
231
+ {"local0" ,LOG_LOCAL0 , false },
232
+ {"local1" ,LOG_LOCAL1 , false },
233
+ {"local2" ,LOG_LOCAL2 , false },
234
+ {"local3" ,LOG_LOCAL3 , false },
235
+ {"local4" ,LOG_LOCAL4 , false },
236
+ {"local5" ,LOG_LOCAL5 , false },
237
+ {"local6" ,LOG_LOCAL6 , false },
238
+ {"local7" ,LOG_LOCAL7 , false },
239
239
{NULL ,0 }
240
240
};
241
241
#endif
242
242
243
243
static const struct config_enum_entry track_function_options []= {
244
- {"none" ,TRACK_FUNC_OFF },
245
- {"pl" ,TRACK_FUNC_PL },
246
- {"all" ,TRACK_FUNC_ALL },
247
- {NULL ,0 }
244
+ {"none" ,TRACK_FUNC_OFF , false },
245
+ {"pl" ,TRACK_FUNC_PL , false },
246
+ {"all" ,TRACK_FUNC_ALL , false },
247
+ {NULL ,0 , false }
248
248
};
249
249
250
250
static const struct config_enum_entry xmlbinary_options []= {
251
- {"base64" ,XMLBINARY_BASE64 },
252
- {"hex" ,XMLBINARY_HEX },
253
- {NULL ,0 }
251
+ {"base64" ,XMLBINARY_BASE64 , false },
252
+ {"hex" ,XMLBINARY_HEX , false },
253
+ {NULL ,0 , false }
254
254
};
255
255
256
256
static const struct config_enum_entry xmloption_options []= {
257
- {"content" ,XMLOPTION_CONTENT },
258
- {"document" ,XMLOPTION_DOCUMENT },
259
- {NULL ,0 }
257
+ {"content" ,XMLOPTION_CONTENT , false },
258
+ {"document" ,XMLOPTION_DOCUMENT , false },
259
+ {NULL ,0 , false }
260
260
};
261
261
262
262
/*
263
263
* Although only "on", "off", and "safe_encoding" are documented, we
264
264
* accept all the likely variants of "on" and "off".
265
265
*/
266
266
static const struct config_enum_entry backslash_quote_options []= {
267
- {"safe_encoding" ,BACKSLASH_QUOTE_SAFE_ENCODING },
268
- {"on" ,BACKSLASH_QUOTE_ON },
269
- {"off" ,BACKSLASH_QUOTE_OFF },
270
- {"true" ,BACKSLASH_QUOTE_ON },
271
- {"false" ,BACKSLASH_QUOTE_OFF },
272
- {"yes" ,BACKSLASH_QUOTE_ON },
273
- {"no" ,BACKSLASH_QUOTE_OFF },
274
- {"1" ,BACKSLASH_QUOTE_ON },
275
- {"0" ,BACKSLASH_QUOTE_OFF },
276
- {NULL ,0 }
267
+ {"safe_encoding" ,BACKSLASH_QUOTE_SAFE_ENCODING , false },
268
+ {"on" ,BACKSLASH_QUOTE_ON , false },
269
+ {"off" ,BACKSLASH_QUOTE_OFF , false },
270
+ {"true" ,BACKSLASH_QUOTE_ON , true },
271
+ {"false" ,BACKSLASH_QUOTE_OFF , true },
272
+ {"yes" ,BACKSLASH_QUOTE_ON , true },
273
+ {"no" ,BACKSLASH_QUOTE_OFF , true },
274
+ {"1" ,BACKSLASH_QUOTE_ON , true },
275
+ {"0" ,BACKSLASH_QUOTE_OFF , true },
276
+ {NULL ,0 , false }
277
277
};
278
278
279
279
/*
@@ -4339,8 +4339,8 @@ config_enum_lookup_by_name(struct config_enum *record, const char *value, int *r
4339
4339
4340
4340
4341
4341
/*
4342
- * Return a list of all available options for an enum,separated
4343
- * by ", " (comma-space).
4342
+ * Return a list of all available options for an enum,excluding
4343
+ *hidden ones, separated by ", " (comma-space).
4344
4344
* If prefix is non-NULL, it is added before the first enum value.
4345
4345
* If suffix is non-NULL, it is added to the end of the string.
4346
4346
*/
@@ -4353,10 +4353,12 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
4353
4353
4354
4354
if (!entry || !entry -> name )
4355
4355
return NULL ;/* Should not happen */
4356
-
4356
+
4357
4357
while (entry && entry -> name )
4358
4358
{
4359
- len += strlen (entry -> name )+ 2 ;/* string and ", " */
4359
+ if (!entry -> hidden )
4360
+ len += strlen (entry -> name )+ 2 ;/* string and ", " */
4361
+
4360
4362
entry ++ ;
4361
4363
}
4362
4364
@@ -4367,13 +4369,28 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
4367
4369
entry = record -> options ;
4368
4370
while (entry && entry -> name )
4369
4371
{
4370
- strcat (hintmsg ,entry -> name );
4371
- strcat (hintmsg ,", " );
4372
+ if (!entry -> hidden )
4373
+ {
4374
+ strcat (hintmsg ,entry -> name );
4375
+ strcat (hintmsg ,", " );
4376
+ }
4377
+
4372
4378
entry ++ ;
4373
4379
}
4374
4380
4375
- /* Replace final comma/space */
4376
- hintmsg [strlen (hintmsg )- 2 ]= '\0' ;
4381
+ len = strlen (hintmsg );
4382
+
4383
+ /*
4384
+ * All the entries may have been hidden, leaving the string empty
4385
+ * if no prefix was given. This indicates a broken GUC setup, since
4386
+ * there is no use for an enum without any values, so we just check
4387
+ * to make sure we don't write to invalid memory instead of actually
4388
+ * trying to do something smart with it.
4389
+ */
4390
+ if (len > 1 )
4391
+ /* Replace final comma/space */
4392
+ hintmsg [len - 2 ]= '\0' ;
4393
+
4377
4394
strcat (hintmsg ,suffix );
4378
4395
4379
4396
return hintmsg ;