Removing useless \. at the end of copy in pgbench - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Removing useless \. at the end of copy in pgbench
Date
Msg-id 20180728.102312.512546427263024232.t-ishii@sraoss.co.jp
Whole thread Raw
Responses Re: Removing useless \. at the end of copy in pgbench  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Removing useless \. at the end of copy in pgbench  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
While populating pgbench_account table by using COPY FROM STDIN,
pgbench sends out "\." at the end of the copy data. However this is
only necessary in the version 2 of frontend/backend protocol (i.e. the
version 3 protocol does not need it). I think we can safely remove the
code to save a few CPU cycle since we only support back to PostgreSQL
9.3 and the version 3 protocol has been supported since 7.4.

If we want to support pre 7.4 backend (which only supports the version
2 protocol), we could test the current protocol version and decide
whether we should send out "\." or not, but I doubt it's necessary.

Comments?

(patch to remove the unneccessary code attached)
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 41b756c..54b7182 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -3686,11 +3686,6 @@ initGenerateData(PGconn *con)
         }
 
     }
-    if (PQputline(con, "\\.\n"))
-    {
-        fprintf(stderr, "very last PQputline failed\n");
-        exit(1);
-    }
     if (PQendcopy(con))
     {
         fprintf(stderr, "PQendcopy failed\n");

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15182: Canceling authentication due to timeout aka Denialof Service Attack
Next
From: Tom Lane
Date:
Subject: Re: Removing useless \. at the end of copy in pgbench