aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/copy.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1997-08-18 02:15:04 +0000
committerBruce Momjian <bruce@momjian.us>1997-08-18 02:15:04 +0000
commit022903f22e54cbc78b4acc1ef54f73d19a051630 (patch)
tree2a2d88e2f97a71233a4b61c1ebf549e663f3d3aa /src/backend/commands/copy.c
parenteaae21fb4d4b8423dbd26731d9fcd3b3cecf2724 (diff)
downloadpostgresql-022903f22e54cbc78b4acc1ef54f73d19a051630.tar.gz
postgresql-022903f22e54cbc78b4acc1ef54f73d19a051630.zip
Reduce open() calls. Replace fopen() calls with calls to fd.c functions.
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c10
1 files changed, 6 insertions, 4 deletions
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 <catalog/catname.h>
#include <catalog/pg_user.h>
#include <commands/copy.h>
+#include <storage/fd.h>
#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);