]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Strip file names reported in error messages in vpath builds
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 29 Nov 2011 20:04:59 +0000 (22:04 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 30 Nov 2011 04:46:52 +0000 (06:46 +0200)
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.

src/backend/utils/error/elog.c

index 7bba9445abcb28856a702f7f5a0367eff0cfa009..9a388f0f3b191085e9d46a7f541c1a4b0b31e50e 100644 (file)
@@ -313,7 +313,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 */
@@ -950,7 +957,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 */