Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd9e223d

Browse files
committed
Fix critical error noticed by Massimo: copy.c used to have a
special hack to ensure it would close its output file even after failuredue to elog(ERROR) partway through the copy. This is now unnecessarybecause 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* atthe start of the next COPY command. This would result in havoc in mostimplementations of stdio library.
1 parentaaf2442 commitd9e223d

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

‎src/backend/commands/copy.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.79 1999/05/29 10:25:29 vadim Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.80 1999/06/12 20:41:25 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -239,24 +239,12 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
239239
the class.
240240
----------------------------------------------------------------------------*/
241241

242-
staticFILE*fp;/* static for cleanup */
243-
staticboolfile_opened= false;/* static for cleanup */
242+
FILE*fp;
244243
Relationrel;
245244
externchar*UserName;/* defined in global.c */
246245
constAclModerequired_access=from ?ACL_WR :ACL_RD;
247246
intresult;
248247

249-
/*
250-
* Close previous file opened for COPY but failed with elog(). There
251-
* should be a better way, but would not be modular. Prevents file
252-
* descriptor leak. bjm 1998/08/29
253-
*/
254-
if (file_opened)
255-
{
256-
FreeFile(fp);
257-
file_opened= false;
258-
}
259-
260248
rel=heap_openr(relname);
261249
if (rel==NULL)
262250
elog(ERROR,"COPY command failed. Class %s "
@@ -299,7 +287,6 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
299287
"effective uid %d, could not open file '%s' for "
300288
"reading. Errno = %s (%d).",
301289
geteuid(),filename,strerror(errno),errno);
302-
file_opened= true;
303290
}
304291
CopyFrom(rel,binary,oids,fp,delim);
305292
}
@@ -332,14 +319,12 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
332319
"effective uid %d, could not open file '%s' for "
333320
"writing. Errno = %s (%d).",
334321
geteuid(),filename,strerror(errno),errno);
335-
file_opened= true;
336322
}
337323
CopyTo(rel,binary,oids,fp,delim);
338324
}
339325
if (!pipe)
340326
{
341327
FreeFile(fp);
342-
file_opened= false;
343328
}
344329
elseif (!from)
345330
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp