Strip file names reported in error messages in vpath builds

In vpath builds, the __FILE__ macro that is used in verbose error
reports contains the full absolute file name, which makes the error
messages excessively verbose.  So keep only the base name, thus
matching the behavior of non-vpath builds.
REL8_2_STABLE
Peter Eisentraut 14 years ago
parent e53724fd5e
commit 1a44811775
  1. 18
      src/backend/utils/error/elog.c

@ -325,7 +325,14 @@ errstart(int elevel, const char *filename, int lineno,
edata->elevel = elevel;
edata->output_to_server = output_to_server;
edata->output_to_client = output_to_client;
edata->filename = filename;
if (filename)
{
const char *slash;
/* keep only base name, useful especially for vpath builds */
slash = strrchr(filename, '/');
edata->filename = slash ? slash + 1 : filename;
}
edata->lineno = lineno;
edata->funcname = funcname;
/* Select default errcode based on elevel */
@ -943,7 +950,14 @@ elog_start(const char *filename, int lineno, const char *funcname)
}
edata = &errordata[errordata_stack_depth];
edata->filename = filename;
if (filename)
{
const char *slash;
/* keep only base name, useful especially for vpath builds */
slash = strrchr(filename, '/');
edata->filename = slash ? slash + 1 : filename;
}
edata->lineno = lineno;
edata->funcname = funcname;
/* errno is saved now so that error parameter eval can't change it */

Loading…
Cancel
Save