Tom Lane wrote:
> Brent Verner <brent@rcfile.org> writes:
> > | This coding is WRONG. You do not use fclose() to release a file
> > | opened with AllocateFile.
>
> > s/fclose/FreeFile/
>
> Actually, my recommendation is to remove it altogether. The mechanisms
> are in place to close allocated files after elog(), so why waste thought
> and code space to release them manually?
Fix applied. There is a FileFree() just below this in the code:
if (!pipe)
FreeFile(fp);
We don't need the if (!pipe) because this code is in an else of
if(pipe). For clarity, it seems the FreeFile call makes sense.
The psql/copy.c file is fine because it isn't backend code.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Index: src/backend/commands/copy.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/copy.c,v
retrieving revision 1.146
diff -c -r1.146 copy.c
*** src/backend/commands/copy.c 23 Feb 2002 21:46:02 -0000 1.146
--- src/backend/commands/copy.c 24 Feb 2002 02:28:07 -0000
***************
*** 337,343 ****
fstat(fileno(fp),&st);
if( S_ISDIR(st.st_mode) ){
! fclose(fp);
elog(ERROR,"COPY: %s is a directory.",filename);
}
}
--- 337,343 ----
fstat(fileno(fp),&st);
if( S_ISDIR(st.st_mode) ){
! FreeFile(fp);
elog(ERROR,"COPY: %s is a directory.",filename);
}
}
***************
*** 389,395 ****
(int) geteuid(), filename, strerror(errno), errno);
fstat(fileno(fp),&st);
if( S_ISDIR(st.st_mode) ){
! fclose(fp);
elog(ERROR,"COPY: %s is a directory.",filename);
}
}
--- 389,395 ----
(int) geteuid(), filename, strerror(errno), errno);
fstat(fileno(fp),&st);
if( S_ISDIR(st.st_mode) ){
! FreeFile(fp);
elog(ERROR,"COPY: %s is a directory.",filename);
}
}