mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.215 2004/01/18 02:15:29 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.216 2004/01/26 22:35:31 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -921,7 +921,14 @@ DoCopy(const CopyStmt *stmt)
|
||||
}
|
||||
|
||||
if (!pipe)
|
||||
FreeFile(copy_file);
|
||||
{
|
||||
/* we assume only the write case could fail here */
|
||||
if (FreeFile(copy_file))
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
filename)));
|
||||
}
|
||||
else if (IsUnderPostmaster && !is_from)
|
||||
SendCopyEnd(binary);
|
||||
pfree(attribute_buf.data);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.132 2004/01/07 18:56:25 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.133 2004/01/26 22:35:32 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -241,12 +241,11 @@ write_group_file(Relation grel)
|
||||
}
|
||||
heap_endscan(scan);
|
||||
|
||||
fflush(fp);
|
||||
if (ferror(fp))
|
||||
if (FreeFile(fp))
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to temporary file \"%s\": %m", tempname)));
|
||||
FreeFile(fp);
|
||||
errmsg("could not write to temporary file \"%s\": %m",
|
||||
tempname)));
|
||||
|
||||
/*
|
||||
* Rename the temp file to its final name, deleting the old pg_pwd. We
|
||||
@@ -372,12 +371,11 @@ write_user_file(Relation urel)
|
||||
}
|
||||
heap_endscan(scan);
|
||||
|
||||
fflush(fp);
|
||||
if (ferror(fp))
|
||||
if (FreeFile(fp))
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to temporary file \"%s\": %m", tempname)));
|
||||
FreeFile(fp);
|
||||
errmsg("could not write to temporary file \"%s\": %m",
|
||||
tempname)));
|
||||
|
||||
/*
|
||||
* Rename the temp file to its final name, deleting the old pg_pwd. We
|
||||
|
||||
Reference in New Issue
Block a user