Fix errorhandling for reading from a pipe
authorDaniel Gustafsson <[email protected]>
Fri, 8 Mar 2024 21:53:06 +0000 (22:53 +0100)
committerDaniel Gustafsson <[email protected]>
Fri, 8 Mar 2024 21:53:06 +0000 (22:53 +0100)
When reading a line from a pipe failed on no data being read, the
errorhandling was erroneously logging with %m even thoug no error
description is available for %m to print.  This flaw accidentally
introduced in 5c7038d70bb.

Reported-by: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/baa34329-f431-46af-bf74-1a78fdc90e4f@eisentraut.org

src/common/exec.c

index bcd5b71101ed0d59dd70ddb192e7800081f3a487..0bee19c1e539fea1186fe9847568caf6c96bbfba 100644 (file)
@@ -393,8 +393,8 @@ pipe_read_line(char *cmd)
            log_error(errcode_for_file_access(),
                      _("could not read from command \"%s\": %m"), cmd);
        else
-           log_error(errcode_for_file_access(),
-                     _("no data was returned by command \"%s\": %m"), cmd);
+           log_error(errcode(ERRCODE_NO_DATA),
+                     _("no data was returned by command \"%s\""), cmd);
    }
 
    (void) pclose_check(pipe_cmd);