From c77f363384c3f4a6bbc73f501d2459e94382a30b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 26 Jan 2004 22:35:32 +0000 Subject: 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. --- src/interfaces/libpq/fe-lobj.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/interfaces') diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 822ccfe11d6..16d4970d9eb 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.46 2004/01/07 18:56:29 neilc Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.47 2004/01/26 22:35:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -491,7 +491,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) } /* - * read in from the Unix file and write to the inversion file + * read in from the inversion file and write to the Unix file */ while ((nbytes = lo_read(conn, lobj, buf, LO_BUFSIZE)) > 0) { @@ -508,7 +508,14 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) } (void) lo_close(conn, lobj); - (void) close(fd); + + if (close(fd)) + { + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext("error while writing to file \"%s\"\n"), + filename); + return -1; + } return 1; } -- cgit v1.2.3