DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Developer Options

backtrace_functions

Log backtrace for errors in these functions.

  • Default: '' (empty)
  • Type: string
  • Applies: Session (superuser)

In plain words

When PostgreSQL raises an error, the log tells you the message, but not which path through the C code led there. If you list the name of the C function that raises the error, PostgreSQL adds a backtrace (the chain of function calls) to the log entry.

It is mainly for developers and for support cases where a mysterious error needs to be traced inside the server.

For DBAs and operators

The value is a comma-separated list of C function names (the function that calls ereport/elog, not an SQL function). Find it with \set VERBOSITY verbose in psql or log_error_verbosity = verbose: the LOCATION: line names it. Captured on 18.6 with SET backtrace_functions = 'int4div' and SELECT 1/0:

ERROR: division by zeroBACKTRACE: postgres: postgres postgres [local] SELECT(+0x157e49) [0x55f700d72e49] postgres: postgres postgres [local] SELECT(evaluate_expr+0x8d) [0x55f7010dc2fd] postgres: postgres postgres [local] SELECT(expression_tree_mutator_impl+0x9e7) …

The backtrace goes to the server log only, not to the client. Its quality depends on the platform (glibc backtrace()) and on symbols: stripped package binaries show mostly offsets, which you can resolve with addr2line and the matching debug-symbol package (postgresql-18-dbgsym, postgresql18-debuginfo). Despite the wording "error", any message level raised in a listed function gets a backtrace (verified on 18.6 with a NOTICE). For an assertion failure or crash, a core dump is still the better tool.

Developer option: meant for debugging and testing PostgreSQL itself. Leave it at the default on production servers unless a specific diagnosis calls for it.

How to change it

A superuser (or a role granted SET) can change it per session with SET.

See it in context

Logger (logging collector) Client backend

Related parameters

log_error_verbosity log_min_error_statement send_abort_for_crash

All Developer Options parameters