aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-06-12 20:41:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-06-12 20:41:25 +0000
commitd9e223d53c5ca32ec6924e62b7b795a2fe08ab15 (patch)
treea4727437006eef4062ba6bd1d19e6a0d166da650 /src
parentaaf244247287b671db2d55098ed6aa774049a058 (diff)
downloadpostgresql-d9e223d53c5ca32ec6924e62b7b795a2fe08ab15.tar.gz
postgresql-d9e223d53c5ca32ec6924e62b7b795a2fe08ab15.zip
Fix critical error noticed by Massimo: copy.c used to have a
special hack to ensure it would close its output file even after failure due to elog(ERROR) partway through the copy. This is now unnecessary because fd.c takes care of cleaning up open files at transaction abort; worse, after fd.c closed the file copy.c would try to do so *again* at the start of the next COPY command. This would result in havoc in most implementations of stdio library.
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/copy.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index c450b20b26a..9d3dcfebfcd 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.79 1999/05/29 10:25:29 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.80 1999/06/12 20:41:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -239,24 +239,12 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
the class.
----------------------------------------------------------------------------*/
- static FILE *fp; /* static for cleanup */
- static bool file_opened = false; /* static for cleanup */
+ FILE *fp;
Relation rel;
extern char *UserName; /* defined in global.c */
const AclMode required_access = from ? ACL_WR : ACL_RD;
int result;
- /*
- * Close previous file opened for COPY but failed with elog(). There
- * should be a better way, but would not be modular. Prevents file
- * descriptor leak. bjm 1998/08/29
- */
- if (file_opened)
- {
- FreeFile(fp);
- file_opened = false;
- }
-
rel = heap_openr(relname);
if (rel == NULL)
elog(ERROR, "COPY command failed. Class %s "
@@ -299,7 +287,6 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
"effective uid %d, could not open file '%s' for "
"reading. Errno = %s (%d).",
geteuid(), filename, strerror(errno), errno);
- file_opened = true;
}
CopyFrom(rel, binary, oids, fp, delim);
}
@@ -332,14 +319,12 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
"effective uid %d, could not open file '%s' for "
"writing. Errno = %s (%d).",
geteuid(), filename, strerror(errno), errno);
- file_opened = true;
}
CopyTo(rel, binary, oids, fp, delim);
}
if (!pipe)
{
FreeFile(fp);
- file_opened = false;
}
else if (!from)
{