mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Add GUC backtrace_on_internal_error
When enabled (default off), this logs a backtrace anytime elog() or an equivalent ereport() for internal errors is called. This is not well covered by the existing backtrace_functions, because there are many equally-worded low-level errors in many functions. And if you find out where the error is, then you need to manually rewrite the elog() to ereport() to attach the errbacktrace(), which is annoying. Having a backtrace automatically on every elog() call could be very helpful during development for various kinds of common errors from palloc, syscache, node support, etc. Discussion: https://www.postgresql.org/message-id/flat/ba76c6bc-f03f-4285-bf16-47759cfcab9e@eisentraut.org
This commit is contained in:
@@ -498,9 +498,11 @@ errfinish(const char *filename, int lineno, const char *funcname)
|
||||
|
||||
/* Collect backtrace, if enabled and we didn't already */
|
||||
if (!edata->backtrace &&
|
||||
edata->funcname &&
|
||||
backtrace_functions &&
|
||||
matches_backtrace_functions(edata->funcname))
|
||||
((edata->funcname &&
|
||||
backtrace_functions &&
|
||||
matches_backtrace_functions(edata->funcname)) ||
|
||||
(edata->sqlerrcode == ERRCODE_INTERNAL_ERROR &&
|
||||
backtrace_on_internal_error)))
|
||||
set_backtrace(edata, 2);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user