Quote filenames in error messages
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Thu, 14 Sep 2023 09:17:33 +0000 (11:17 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Thu, 14 Sep 2023 09:17:33 +0000 (11:17 +0200)
The majority of all filenames are quoted in user facing error and
log messages, but a few were still printed without quotes.  While
these filenames do not risk causing any ambiguity as their format
is strict, quote them anyways to be consistent across all logs.

Also concatenate a message to keep it one line to make it easier
to grep for in the code.

Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/080EEABE-6645-4A46-AB20-6285ADAC44FE@yesql.se

src/backend/access/transam/xlog.c
src/bin/pg_waldump/pg_waldump.c

index f26c8d18a6159b4a7d392c9bb5a2138850d618fd..725a308debb79e96a3f92eb6bb1301b661f90981 100644 (file)
@@ -2248,8 +2248,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
                    errno = save_errno;
                    ereport(PANIC,
                            (errcode_for_file_access(),
-                            errmsg("could not write to log file %s "
-                                   "at offset %u, length %zu: %m",
+                            errmsg("could not write to log file \"%s\" at offset %u, length %zu: %m",
                                    xlogfname, startoffset, nleft)));
                }
                nleft -= written;
index b9acfed3b7af02c170ec7e3bb52aba5e70a27213..a3535bdfa9c708fe983e156b3d2f48422e884a52 100644 (file)
@@ -418,11 +418,11 @@ WALDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen,
        if (errinfo.wre_errno != 0)
        {
            errno = errinfo.wre_errno;
-           pg_fatal("could not read from file %s, offset %d: %m",
+           pg_fatal("could not read from file \"%s\", offset %d: %m",
                     fname, errinfo.wre_off);
        }
        else
-           pg_fatal("could not read from file %s, offset %d: read %d of %d",
+           pg_fatal("could not read from file \"%s\", offset %d: read %d of %d",
                     fname, errinfo.wre_off, errinfo.wre_read,
                     errinfo.wre_req);
    }