From 317975f40e8747b76108937f4ecbdd0bba3121a7 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Wed, 20 Dec 2023 11:41:18 +0100 Subject: [PATCH v5 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 | 6 ++++++ src/backend/utils/error/elog.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 254b75382f8..cb195ffb553 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11314,6 +11314,12 @@ 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 errors 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