pg_dump: Fix weird error message composition
authorPeter Eisentraut <[email protected]>
Thu, 20 Jun 2024 09:36:38 +0000 (11:36 +0200)
committerPeter Eisentraut <[email protected]>
Thu, 20 Jun 2024 09:36:38 +0000 (11:36 +0200)
The previous way could make it look like "stdin" was the actual input
file name.  Write it as two separate messages instead.

src/bin/pg_dump/filter.c

index 3fb93c5f155f1d39aaeadf403a90dc12475101ed..5815cd237483f5968663e9db0bc25ae867db6060 100644 (file)
@@ -161,10 +161,12 @@ pg_log_filter_error(FilterStateData *fstate, const char *fmt,...)
    vsnprintf(buf, sizeof(buf), fmt, argp);
    va_end(argp);
 
-   pg_log_error("invalid format in filter read from \"%s\" on line %d: %s",
-                (fstate->fp == stdin ? "stdin" : fstate->filename),
-                fstate->lineno,
-                buf);
+   if (fstate->fp == stdin)
+       pg_log_error("invalid format in filter read from standard input on line %d: %s",
+                    fstate->lineno, buf);
+   else
+       pg_log_error("invalid format in filter read from file \"%s\" on line %d: %s",
+                    fstate->filename, fstate->lineno, buf);
 }
 
 /*