From dacb18f62e7794d8165de80b811c994d384dc060 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Wed, 20 Dec 2023 11:41:18 +0100 Subject: [PATCH v1] 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 | 5 +++++ src/backend/utils/error/elog.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 44cada2b403..9b352109a3e 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11015,6 +11015,11 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' be used to debug specific areas of the source code. + + A single * character 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 6ea575a53b1..840fbe42ac5 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -840,6 +840,8 @@ matches_backtrace_functions(const char *funcname) if (*p == '\0') /* end of backtrace_symbol_list */ break; + if (strcmp("*", p) == 0) + return true; if (strcmp(funcname, p) == 0) return true; p += strlen(p) + 1; @@ -2128,14 +2130,14 @@ check_backtrace_functions(char **newval, void **extra, GucSource source) int j; /* - * Allow characters that can be C identifiers and commas as separators, as - * well as some whitespace for readability. + * Allow characters that can be C identifiers, commas as separators, the + * wildcard symbol, as well as some whitespace for readability. */ validlen = strspn(*newval, "0123456789_" "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ", \n\t"); + ",* \n\t"); if (validlen != newvallen) { GUC_check_errdetail("invalid character"); base-commit: 00498b718564cee3530b76d860b328718aed672b -- 2.34.1