Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd88cd7d

Browse files
committed
Add a field to guc enums to allow hiding of values from display while
still accepting them as input, used to allow alternate syntax for thesame setting.Alex Hunsaker
1 parenta8f98c0 commitd88cd7d

File tree

2 files changed

+91
-73
lines changed

2 files changed

+91
-73
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 89 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* 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 $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -173,107 +173,107 @@ static char *config_enum_get_options(struct config_enum *record,
173173
* Options for enum values defined in this module.
174174
*/
175175
staticconststructconfig_enum_entrymessage_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}
190190
};
191191

192192
staticconststructconfig_enum_entrylog_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}
197197
};
198198

199199
staticconststructconfig_enum_entrylog_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}
205205
};
206206

207207
staticconststructconfig_enum_entryregex_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}
212212
};
213213

214214
staticconststructconfig_enum_entryisolation_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},
219219
{NULL,0}
220220
};
221221

222222
staticconststructconfig_enum_entrysession_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}
227227
};
228228

229229
#ifdefHAVE_SYSLOG
230230
staticconststructconfig_enum_entrysyslog_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},
239239
{NULL,0}
240240
};
241241
#endif
242242

243243
staticconststructconfig_enum_entrytrack_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}
248248
};
249249

250250
staticconststructconfig_enum_entryxmlbinary_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}
254254
};
255255

256256
staticconststructconfig_enum_entryxmloption_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}
260260
};
261261

262262
/*
263263
* Although only "on", "off", and "safe_encoding" are documented, we
264264
* accept all the likely variants of "on" and "off".
265265
*/
266266
staticconststructconfig_enum_entrybackslash_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}
277277
};
278278

279279
/*
@@ -4339,8 +4339,8 @@ config_enum_lookup_by_name(struct config_enum *record, const char *value, int *r
43394339

43404340

43414341
/*
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, separatedby ", " (comma-space).
43444344
* If prefix is non-NULL, it is added before the first enum value.
43454345
* If suffix is non-NULL, it is added to the end of the string.
43464346
*/
@@ -4353,10 +4353,12 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
43534353

43544354
if (!entry|| !entry->name)
43554355
returnNULL;/* Should not happen */
4356-
4356+
43574357
while (entry&&entry->name)
43584358
{
4359-
len+=strlen(entry->name)+2;/* string and ", " */
4359+
if (!entry->hidden)
4360+
len+=strlen(entry->name)+2;/* string and ", " */
4361+
43604362
entry++;
43614363
}
43624364

@@ -4367,13 +4369,28 @@ config_enum_get_options(struct config_enum *record, const char *prefix, const ch
43674369
entry=record->options;
43684370
while (entry&&entry->name)
43694371
{
4370-
strcat(hintmsg,entry->name);
4371-
strcat(hintmsg,", ");
4372+
if (!entry->hidden)
4373+
{
4374+
strcat(hintmsg,entry->name);
4375+
strcat(hintmsg,", ");
4376+
}
4377+
43724378
entry++;
43734379
}
43744380

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+
43774394
strcat(hintmsg,suffix);
43784395

43794396
returnhintmsg;

‎src/include/utils/guc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
88
* Written by Peter Eisentraut <peter_e@gmx.net>.
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.95 2008/05/12 08:35:05 mha Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.96 2008/05/28 09:04:06 mha Exp $
1111
*--------------------------------------------------------------------
1212
*/
1313
#ifndefGUC_H
@@ -100,6 +100,7 @@ struct config_enum_entry
100100
{
101101
constchar*name;
102102
intval;
103+
boolhidden;
103104
};
104105

105106

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp