From 2dcea42f5583e773864fe7f84c0c218cdea68d76 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Wed, 20 Dec 2023 11:41:18 +0100 Subject: [PATCH v6 2/2] Add wildcard support to backtrace_functions GUC With this change setting backtrace_functions to '*' will start logging backtraces for all errors (or more precisely all logs). --- doc/src/sgml/config.sgml | 8 ++++++++ src/backend/utils/error/elog.c | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index c76e97d2d33..1fddc0fce04 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11314,6 +11314,14 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' code. + + A single * character can be used instead of a list + of C functions. This * is interpreted as a wildcard + and will cause all log entries equal to or higher than + in the log to + contain backtraces. + + Backtrace support is not available on all platforms, and the quality of the backtraces depends on compilation options. diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index b214747500c..ca621ea3fff 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -836,6 +836,9 @@ matches_backtrace_functions(const char *funcname) if (!backtrace_function_list || funcname == NULL || funcname[0] == '\0') return false; + if (strcmp(backtrace_function_list, "*") == 0) + return true; + p = backtrace_function_list; for (;;) { @@ -2131,6 +2134,12 @@ check_backtrace_functions(char **newval, void **extra, GucSource source) int i; int j; + if (strcmp(*newval, "*") == 0) + { + *extra = guc_strdup(ERROR, "*"); + return true; + } + /* * Allow characters that can be C identifiers and commas as separators, as * well as some whitespace for readability. -- 2.34.1