agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v25 4/9] change ConcatRTEPermissionInfoLists API 172+ messages / 2 participants [nested] [flat]
* [PATCH v25 4/9] change ConcatRTEPermissionInfoLists API @ 2022-11-15 18:22 Alvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Alvaro Herrera @ 2022-11-15 18:22 UTC (permalink / raw) --- src/backend/optimizer/plan/subselect.c | 5 +++-- src/backend/optimizer/prep/prepjointree.c | 10 ++++++---- src/backend/rewrite/rewriteHandler.c | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index a61082d27c..cbeb0191fb 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -1500,8 +1500,9 @@ convert_EXISTS_sublink_to_join(PlannerInfo *root, SubLink *sublink, * Add subquery's RTEPermissionInfos into the upper query. This also * updates the subquery's RTEs' perminfoindex. */ - ConcatRTEPermissionInfoLists(&parse->rtepermlist, subselect->rtepermlist, - subselect->rtable); + parse->rtepermlist = ConcatRTEPermissionInfoLists(parse->rtepermlist, + subselect->rtepermlist, + subselect->rtable); /* Now we can attach the modified subquery rtable to the parent */ parse->rtable = list_concat(parse->rtable, subselect->rtable); diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index b2ab2c14a4..8d7b243b21 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -1201,8 +1201,9 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, * Add subquery's RTEPermissionInfos into the upper query. This also * updates the subquery's RTEs' perminfoindex. */ - ConcatRTEPermissionInfoLists(&parse->rtepermlist, subquery->rtepermlist, - subquery->rtable); + parse->rtepermlist = ConcatRTEPermissionInfoLists(parse->rtepermlist, + subquery->rtepermlist, + subquery->rtable); /* * Now append the adjusted rtable entries to upper query. (We hold off @@ -1348,8 +1349,9 @@ pull_up_simple_union_all(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte) * Add subquery's RTEPermissionInfos into the upper query. This also * updates the subquery's RTEs' perminfoindex. */ - ConcatRTEPermissionInfoLists(&root->parse->rtepermlist, - subquery->rtepermlist, rtable); + root->parse->rtepermlist = ConcatRTEPermissionInfoLists(root->parse->rtepermlist, + subquery->rtepermlist, + rtable); /* * Append child RTEs to parent rtable. */ diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index fda0eacf79..656a27ea22 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -420,10 +420,11 @@ rewriteRuleAction(Query *parsetree, * for both. Copy rtable before calling ConcatRTEPermissionInfoLists(), * because perminfoindex of those RTEs will be updated there. */ - sub_action->rtepermlist = copyObject(sub_action->rtepermlist); query_rtable = copyObject(parsetree->rtable); - ConcatRTEPermissionInfoLists(&sub_action->rtepermlist, - parsetree->rtepermlist, query_rtable); + sub_action->rtepermlist = + ConcatRTEPermissionInfoLists(copyObject(sub_action->rtepermlist), + parsetree->rtepermlist, + query_rtable); sub_action->rtable = list_concat(query_rtable, sub_action->rtable); /* -- 2.30.2 --3sqhherzatux5zde Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v25-0005-lfirst-lfirst_node.patch" ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
* [PATCH 1/2] simplify coding in check_log_min_messages @ 2026-02-17 15:33 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 172+ messages in thread From: Álvaro Herrera @ 2026-02-17 15:33 UTC (permalink / raw) --- src/backend/utils/error/elog.c | 47 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b9d2c96b97a..80d4eef755a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -193,6 +193,7 @@ static pg_noinline void set_backtrace(ErrorData *edata, int num_skip); static void backtrace_cleanup(int code, Datum arg); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void FreeErrorDataContents(ErrorData *edata); +static int parse_message_level(const char *level); static int log_min_messages_cmp(const ListCell *a, const ListCell *b); static void write_console(const char *line, int len); static const char *process_log_prefix_padding(const char *p, int *ppadding); @@ -2403,9 +2404,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) */ if (sep == NULL) { - const struct config_enum_entry *entry; - bool found; - /* Reject duplicates for default log level. */ if (defaultlevel != -1) { @@ -2414,18 +2412,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) } /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, elem) == 0) - { - defaultlevel = entry->val; - found = true; - break; - } - } - - if (!found) + if ((defaultlevel = parse_message_level(elem)) == 0) { GUC_check_errdetail("Unrecognized log level: \"%s\".", elem); goto lmm_fail; @@ -2437,7 +2424,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) char *ptype = elem; bool found; int level; - const struct config_enum_entry *entry; /* * Temporarily clobber the ':' with a string terminator, so that @@ -2446,18 +2432,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source) *sep = '\0'; /* Validate the log level */ - found = false; - for (entry = server_message_level_options; entry && entry->name; entry++) - { - if (pg_strcasecmp(entry->name, loglevel) == 0) - { - level = entry->val; - found = true; - break; - } - } - - if (!found) + if ((level = parse_message_level(loglevel)) == 0) { GUC_check_errdetail("Unrecognized log level for process type \"%s\": \"%s\".", ptype, loglevel); @@ -2566,6 +2541,22 @@ lmm_fail: return true; } +/* + * Recognize the given string as a message level (for log_min_messages), and + * return its value if successful. Otherwise, return 0. + */ +static int +parse_message_level(const char *level) +{ + const struct config_enum_entry *entry; + + for (entry = server_message_level_options; entry && entry->name; entry++) + if (pg_strcasecmp(entry->name, level) == 0) + return entry->val; + + return 0; +} + /* * list_sort() callback for check_log_min_messages. The default element * goes first; the rest are ordered by strcmp() of the process type. -- 2.47.3 --dnohjpfxulhc3bo3 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0002-memory-free-simplify.patch ^ permalink raw reply [nested|flat] 172+ messages in thread
end of thread, other threads:[~2026-02-17 15:33 UTC | newest] Thread overview: 172+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-11-15 18:22 [PATCH v25 4/9] change ConcatRTEPermissionInfoLists API Alvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]> 2026-02-17 15:33 [PATCH 1/2] simplify coding in check_log_min_messages Álvaro Herrera <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox