From 022903f22e54cbc78b4acc1ef54f73d19a051630 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 18 Aug 1997 02:15:04 +0000 Subject: Reduce open() calls. Replace fopen() calls with calls to fd.c functions. --- src/backend/commands/copy.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/backend/commands/copy.c') diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 429725d85e4..b44414000b2 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.24 1997/06/12 15:39:44 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.25 1997/08/18 02:14:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,7 @@ #include #include #include +#include #define ISOCTAL(c) (((c) >= '0') && ((c) <= '7')) #define VALUE(c) ((c) - '0') @@ -127,7 +128,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, fp = Pfin; } else fp = stdin; } else { - fp = fopen(filename, "r"); + fp = AllocateFile(filename, "r"); if (fp == NULL) elog(WARN, "COPY command, running in backend with " "effective uid %d, could not open file '%s' for " @@ -145,7 +146,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, } else { mode_t oumask; /* Pre-existing umask value */ oumask = umask((mode_t) 0); - fp = fopen(filename, "w"); + fp = AllocateFile(filename, "w"); umask(oumask); if (fp == NULL) elog(WARN, "COPY command, running in backend with " @@ -156,7 +157,8 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, } CopyTo(rel, binary, oids, fp, delim); } - if (!pipe) fclose(fp); + if (!pipe) + FreeFile(fp); else if (!from && !binary) { fputs("\\.\n", fp); if (IsUnderPostmaster) fflush(Pfout); -- cgit v1.2.3