aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-26 22:35:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-26 22:35:32 +0000
commitc77f363384c3f4a6bbc73f501d2459e94382a30b (patch)
treec722b460526c687c1ec9c546aed71b52fbcb3cc4 /src/bin/psql/command.c
parente0707cbae9cb5360cd044231fda921fffe8095c5 (diff)
downloadpostgresql-c77f363384c3f4a6bbc73f501d2459e94382a30b.tar.gz
postgresql-c77f363384c3f4a6bbc73f501d2459e94382a30b.zip
Ensure that close() and fclose() are checked for errors, at least in
cases involving writes. Per recent discussion about the possibility of close-time failures on some filesystems. There is a TODO item for this, too.
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a8e956530b2..2b8fcb9dcde 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.111 2004/01/25 03:07:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.112 2004/01/26 22:35:32 tgl Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -1601,8 +1601,12 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
remove(fname);
error = true;
}
- else
- fclose(stream);
+ else if (fclose(stream) != 0)
+ {
+ psql_error("%s: %s\n", fname, strerror(errno));
+ remove(fname);
+ error = true;
+ }
}
}