Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 980BFB5DBCA; Mon, 4 Jul 2011 13:02:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 00853-02; Mon, 4 Jul 2011 16:02:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 4253FB5DBBE; Mon, 4 Jul 2011 13:02:17 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p64G2DEl002823; Mon, 4 Jul 2011 12:02:13 -0400 (EDT) To: "Steve Haslam" cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: BUG #6083: psql script line numbers incorrectly count \copy data In-reply-to: <201106291338.p5TDcPTZ012367@wwwmaster.postgresql.org> References: <201106291338.p5TDcPTZ012367@wwwmaster.postgresql.org> Comments: In-reply-to "Steve Haslam" message dated "Wed, 29 Jun 2011 13:38:25 +0000" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <911.1309795226.0@sss.pgh.pa.us> Date: Mon, 04 Jul 2011 12:02:12 -0400 Message-ID: <2822.1309795332@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/19 X-Sequence-Number: 30631 ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <911.1309795226.1@sss.pgh.pa.us> "Steve Haslam" writes: > ... Apparently, the data read from \copy > is incrementing the script line number counter? Yeah, so it is. That is correct behavior for COPY FROM STDIN, but not so much for copying from a separate file. The attached patch seems like an appropriate fix. However, I'm unsure whether to apply it to released branches ... does anyone think this might break somebody's application? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-patch; charset="us-ascii" Content-ID: <911.1309795226.2@sss.pgh.pa.us> Content-Description: copy-lineno.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 5e69d29b6cbeab56aa0c85e85c3edce46d06efac..ebe5ee9ea551b858a4ad611932= 2405109d3212d8 100644 *** a/src/bin/psql/copy.c --- b/src/bin/psql/copy.c *************** handleCopyIn(PGconn *conn, FILE *copystr *** 586,592 **** } } = ! pset.lineno++; } } = --- 586,593 ---- } } = ! if (copystream =3D=3D pset.cur_cmd_source) ! pset.lineno++; } } = ------- =_aaaaaaaaaa0--