From 5ab507155a1cb60e490209d28a092fc2d7c0f6be Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Wed, 20 Dec 2023 11:41:18 +0100 Subject: [PATCH v4 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 | 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 bc066284334..2a6d015d6d4 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11275,6 +11275,11 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' 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 699d9d0a241..553e4785520 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -843,6 +843,8 @@ matches_backtrace_functions(const char *funcname) if (*p == '\0') /* end of backtrace_function_list */ break; + if (strcmp("*", p) == 0) + return true; if (strcmp(funcname, p) == 0) return true; p += strlen(p) + 1; @@ -2133,14 +2135,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"); -- 2.34.1