aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/copy.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-12-04 19:40:17 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-12-04 19:40:17 +0000
commitf4bd04bb67c5da67b4fc35aa4da4ac47cff4cd66 (patch)
tree60021bf58981f978795048a26038ab07702a9940 /src/backend/commands/copy.c
parentdae887abfe54b10820e03f0de82542306d825b00 (diff)
downloadpostgresql-f4bd04bb67c5da67b4fc35aa4da4ac47cff4cd66.tar.gz
postgresql-f4bd04bb67c5da67b4fc35aa4da4ac47cff4cd66.zip
Replace pq_getbytes(&ch, 1) calls with pq_getbyte(), which is easier
to use and significantly faster. This tweak saves 25% (!) of the runtime of COPY IN in a test with 8000-character lines. I wouldn't normally commit a performance improvement this late in the cycle, but 25% got my attention...
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 7f1e288fab9..726ae39324f 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.142 2001/10/25 05:49:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.143 2001/12/04 19:40:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -157,13 +157,10 @@ CopyGetChar(FILE *fp)
{
if (!fp)
{
- unsigned char ch;
+ int ch = pq_getbyte();
- if (pq_getbytes((char *) &ch, 1))
- {
+ if (ch == EOF)
fe_eof = true;
- return EOF;
- }
return ch;
}
else
@@ -209,12 +206,9 @@ CopyDonePeek(FILE *fp, int c, int pickup)
if (pickup)
{
/*
- * We want to pick it up - just receive again into dummy
- * buffer
+ * We want to pick it up
*/
- char c;
-
- pq_getbytes(&c, 1);
+ (void) pq_getbyte();
}
/* If we didn't want to pick it up, just leave it where it sits */
}