guc config_enum_entry add hidden field
"Alex Hunsaker" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.patches |
|---|---|
| Message-ID | <[email protected]> |
Tom Lane" <[email protected]> writes: > I am wondering if it's a good idea to hide the redundant entries > to reduce clutter in the pg_settings display. (We could do this > by adding a "hidden" boolean to struct config_enum_entry.) > Thoughts? The Attached patch does just that... -- Sent via pgsql-patches mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches
guc_config_enum_entry_hide.patch
(application/octet-stream, 7.9 KB)
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 198b227..dd55b30 100644
*** a/src/backend/utils/misc/guc.c
--- /bsrc/backend/utils/misc/guc.c
*************** static char *config_enum_get_options(str
*** 173,262 ****
* Options for enum values defined in this module.
*/
static const struct config_enum_entry message_level_options[] = {
! {"debug", DEBUG2},
! {"debug5", DEBUG5},
! {"debug4", DEBUG4},
! {"debug3", DEBUG3},
! {"debug2", DEBUG2},
! {"debug1", DEBUG1},
! {"log", LOG},
! {"info", INFO},
! {"notice", NOTICE},
! {"warning", WARNING},
! {"error", ERROR},
! {"fatal", FATAL},
! {"panic", PANIC},
! {NULL, 0}
};
static const struct config_enum_entry log_error_verbosity_options[] = {
! {"default", PGERROR_DEFAULT},
! {"terse", PGERROR_TERSE},
! {"verbose", PGERROR_VERBOSE},
! {NULL, 0}
};
static const struct config_enum_entry log_statement_options[] = {
! {"none", LOGSTMT_NONE},
! {"ddl", LOGSTMT_DDL},
! {"mod", LOGSTMT_MOD},
! {"all", LOGSTMT_ALL},
! {NULL, 0}
};
static const struct config_enum_entry regex_flavor_options[] = {
! {"advanced", REG_ADVANCED},
! {"extended", REG_EXTENDED},
! {"basic", REG_BASIC},
! {NULL, 0}
};
static const struct config_enum_entry isolation_level_options[] = {
! {"serializable", XACT_SERIALIZABLE},
! {"repeatable read", XACT_REPEATABLE_READ},
! {"read committed", XACT_READ_COMMITTED},
! {"read uncommitted", XACT_READ_UNCOMMITTED},
{NULL, 0}
};
static const struct config_enum_entry session_replication_role_options[] = {
! {"origin", SESSION_REPLICATION_ROLE_ORIGIN},
! {"replica", SESSION_REPLICATION_ROLE_REPLICA},
! {"local", SESSION_REPLICATION_ROLE_LOCAL},
! {NULL, 0}
};
#ifdef HAVE_SYSLOG
static const struct config_enum_entry syslog_facility_options[] = {
! {"local0", LOG_LOCAL0},
! {"local1", LOG_LOCAL1},
! {"local2", LOG_LOCAL2},
! {"local3", LOG_LOCAL3},
! {"local4", LOG_LOCAL4},
! {"local5", LOG_LOCAL5},
! {"local6", LOG_LOCAL6},
! {"local7", LOG_LOCAL7},
{NULL, 0}
};
#endif
static const struct config_enum_entry track_function_options[] = {
! {"none", TRACK_FUNC_OFF},
! {"pl", TRACK_FUNC_PL},
! {"all", TRACK_FUNC_ALL},
! {NULL, 0}
};
static const struct config_enum_entry xmlbinary_options[] = {
! {"base64", XMLBINARY_BASE64},
! {"hex", XMLBINARY_HEX},
! {NULL, 0}
};
static const struct config_enum_entry xmloption_options[] = {
! {"content", XMLOPTION_CONTENT},
! {"document", XMLOPTION_DOCUMENT},
! {NULL, 0}
};
/*
--- 173,262 ----
* Options for enum values defined in this module.
*/
static const struct config_enum_entry message_level_options[] = {
! {"debug", DEBUG2, false},
! {"debug5", DEBUG5, false},
! {"debug4", DEBUG4, false},
! {"debug3", DEBUG3, false},
! {"debug2", DEBUG2, false},
! {"debug1", DEBUG1, false},
! {"log", LOG, false},
! {"info", INFO, false},
! {"notice", NOTICE, false},
! {"warning", WARNING, false},
! {"error", ERROR, false},
! {"fatal", FATAL, false},
! {"panic", PANIC, false},
! {NULL, 0, false}
};
static const struct config_enum_entry log_error_verbosity_options[] = {
! {"default", PGERROR_DEFAULT, false},
! {"terse", PGERROR_TERSE, false},
! {"verbose", PGERROR_VERBOSE, false},
! {NULL, 0, false}
};
static const struct config_enum_entry log_statement_options[] = {
! {"none", LOGSTMT_NONE, false},
! {"ddl", LOGSTMT_DDL, false},
! {"mod", LOGSTMT_MOD, false},
! {"all", LOGSTMT_ALL, false},
! {NULL, 0, false}
};
static const struct config_enum_entry regex_flavor_options[] = {
! {"advanced", REG_ADVANCED, false},
! {"extended", REG_EXTENDED, false},
! {"basic", REG_BASIC, false},
! {NULL, 0, false}
};
static const struct config_enum_entry isolation_level_options[] = {
! {"serializable", XACT_SERIALIZABLE, false},
! {"repeatable read", XACT_REPEATABLE_READ, false},
! {"read committed", XACT_READ_COMMITTED, false},
! {"read uncommitted", XACT_READ_UNCOMMITTED, false},
{NULL, 0}
};
static const struct config_enum_entry session_replication_role_options[] = {
! {"origin", SESSION_REPLICATION_ROLE_ORIGIN, false},
! {"replica", SESSION_REPLICATION_ROLE_REPLICA, false},
! {"local", SESSION_REPLICATION_ROLE_LOCAL, false},
! {NULL, 0, false}
};
#ifdef HAVE_SYSLOG
static const struct config_enum_entry syslog_facility_options[] = {
! {"local0", LOG_LOCAL0, false},
! {"local1", LOG_LOCAL1, false},
! {"local2", LOG_LOCAL2, false},
! {"local3", LOG_LOCAL3, false},
! {"local4", LOG_LOCAL4, false},
! {"local5", LOG_LOCAL5, false},
! {"local6", LOG_LOCAL6, false},
! {"local7", LOG_LOCAL7, false},
{NULL, 0}
};
#endif
static const struct config_enum_entry track_function_options[] = {
! {"none", TRACK_FUNC_OFF, false},
! {"pl", TRACK_FUNC_PL, false},
! {"all", TRACK_FUNC_ALL, false},
! {NULL, 0, false}
};
static const struct config_enum_entry xmlbinary_options[] = {
! {"base64", XMLBINARY_BASE64, false},
! {"hex", XMLBINARY_HEX, false},
! {NULL, 0, false}
};
static const struct config_enum_entry xmloption_options[] = {
! {"content", XMLOPTION_CONTENT, false},
! {"document", XMLOPTION_DOCUMENT, false},
! {NULL, 0, false}
};
/*
*************** static const struct config_enum_entry xm
*** 264,279 ****
* accept all the likely variants of "on" and "off".
*/
static const struct config_enum_entry backslash_quote_options[] = {
! {"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING},
! {"on", BACKSLASH_QUOTE_ON},
! {"off", BACKSLASH_QUOTE_OFF},
! {"true", BACKSLASH_QUOTE_ON},
! {"false", BACKSLASH_QUOTE_OFF},
! {"yes", BACKSLASH_QUOTE_ON},
! {"no", BACKSLASH_QUOTE_OFF},
! {"1", BACKSLASH_QUOTE_ON},
! {"0", BACKSLASH_QUOTE_OFF},
! {NULL, 0}
};
/*
--- 264,279 ----
* accept all the likely variants of "on" and "off".
*/
static const struct config_enum_entry backslash_quote_options[] = {
! {"safe_encoding", BACKSLASH_QUOTE_SAFE_ENCODING, false},
! {"on", BACKSLASH_QUOTE_ON, false},
! {"off", BACKSLASH_QUOTE_OFF, false},
! {"true", BACKSLASH_QUOTE_ON, true},
! {"false", BACKSLASH_QUOTE_OFF, true},
! {"yes", BACKSLASH_QUOTE_ON, true},
! {"no", BACKSLASH_QUOTE_OFF, true},
! {"1", BACKSLASH_QUOTE_ON, true},
! {"0", BACKSLASH_QUOTE_OFF, true},
! {NULL, 0, false}
};
/*
*************** config_enum_get_options(struct config_en
*** 4353,4362 ****
if (!entry || !entry->name)
return NULL; /* Should not happen */
!
while (entry && entry->name)
{
! len += strlen(entry->name) + 2; /* string and ", " */
entry++;
}
--- 4353,4365 ----
if (!entry || !entry->name)
return NULL; /* Should not happen */
!
while (entry && entry->name)
{
! /* dont show hidden values */
! if (!entry->hidden)
! len += strlen(entry->name) + 2; /* string and ", " */
!
entry++;
}
*************** config_enum_get_options(struct config_en
*** 4367,4379 ****
entry = record->options;
while (entry && entry->name)
{
! strcat(hintmsg, entry->name);
! strcat(hintmsg, ", ");
entry++;
}
! /* Replace final comma/space */
! hintmsg[strlen(hintmsg)-2] = '\0';
strcat(hintmsg, suffix);
return hintmsg;
--- 4370,4394 ----
entry = record->options;
while (entry && entry->name)
{
! /* dont show hidden values */
! if (!entry->hidden)
! {
! strcat(hintmsg, entry->name);
! strcat(hintmsg, ", ");
! }
!
entry++;
}
! len = strlen(hintmsg);
!
! /* All the entries might have been hidden... */
! if (len && len > 1)
! /* Replace final comma/space */
! hintmsg[len-2] = '\0';
! else
! hintmsg[0] = '\0';
!
strcat(hintmsg, suffix);
return hintmsg;
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 3f58297..7649ffc 100644
*** a/src/include/utils/guc.h
--- /bsrc/include/utils/guc.h
*************** struct config_enum_entry
*** 100,105 ****
--- 100,106 ----
{
const char *name;
int val;
+ bool hidden;
};