From 71e2c1f1fa903ecfce4a79ff5981d0d754d134a2 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Wed, 20 Dec 2023 11:41:18 +0100 Subject: [PATCH v3 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 ba5dbf9f096..a59d8e1b263 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11136,6 +11136,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 8364125f44a..923e00e766e 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; @@ -2135,14 +2137,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