Skip to content

Commit 75b6183

Browse files
committed
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.
1 parent d16ebde commit 75b6183

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/backend/utils/error/elog.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,14 @@ errstart(int elevel, const char *filename, int lineno,
335335
edata->elevel = elevel;
336336
edata->output_to_server = output_to_server;
337337
edata->output_to_client = output_to_client;
338-
edata->filename = filename;
338+
if (filename)
339+
{
340+
const char *slash;
341+
342+
/* keep only base name, useful especially for vpath builds */
343+
slash = strrchr(filename, '/');
344+
edata->filename = slash ? slash + 1 : filename;
345+
}
339346
edata->lineno = lineno;
340347
edata->funcname = funcname;
341348
/* the default text domain is the backend's */
@@ -1103,7 +1110,14 @@ elog_start(const char *filename, int lineno, const char *funcname)
11031110
}
11041111

11051112
edata = &errordata[errordata_stack_depth];
1106-
edata->filename = filename;
1113+
if (filename)
1114+
{
1115+
const char *slash;
1116+
1117+
/* keep only base name, useful especially for vpath builds */
1118+
slash = strrchr(filename, '/');
1119+
edata->filename = slash ? slash + 1 : filename;
1120+
}
11071121
edata->lineno = lineno;
11081122
edata->funcname = funcname;
11091123
/* errno is saved now so that error parameter eval can't change it */

0 commit comments

Comments
 (0)