aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/copy.c')
-rw-r--r--src/bin/psql/copy.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index eee628ccdf1..f1b7e12531b 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -424,7 +424,10 @@ do_copy(const char *args)
*
* conn should be a database connection that you just issued COPY TO on
* and got back a PGRES_COPY_OUT result.
+ *
* copystream is the file stream for the data to go to.
+ * copystream can be NULL to eat the data without writing it anywhere.
+ *
* The final status for the COPY is returned into *res (but note
* we already reported the error, if it's not a success result).
*
@@ -446,7 +449,7 @@ handleCopyOut(PGconn *conn, FILE *copystream, PGresult **res)
if (buf)
{
- if (OK && fwrite(buf, 1, ret, copystream) != ret)
+ if (OK && copystream && fwrite(buf, 1, ret, copystream) != ret)
{
psql_error("could not write COPY data: %s\n",
strerror(errno));
@@ -457,7 +460,7 @@ handleCopyOut(PGconn *conn, FILE *copystream, PGresult **res)
}
}
- if (OK && fflush(copystream))
+ if (OK && copystream && fflush(copystream))
{
psql_error("could not write COPY data: %s\n",
strerror(errno));