Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 6D6896332C3 for ; Fri, 23 Jul 2010 11:11:52 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 36079-01 for ; Fri, 23 Jul 2010 14:11:45 +0000 (UTC) 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 C1398632459 for ; Fri, 23 Jul 2010 11:11:44 -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 o6NEBao7009654; Fri, 23 Jul 2010 10:11:36 -0400 (EDT) To: Kris Jurka cc: pgsql-hackers@postgresql.org, Matthew Wakeling , Kevin Grittner , Maciek Sakrejda , Samuel Gendler , pgsql-jdbc@postgresql.org Subject: Re: [HACKERS] Trouble with COPY IN In-reply-to: <4C499E26.4060307@ejurka.com> References: <4C4562C50200002500033951@gw.wicourts.gov> <9143.1279892435@sss.pgh.pa.us> <4C499E26.4060307@ejurka.com> Comments: In-reply-to Kris Jurka message dated "Fri, 23 Jul 2010 06:50:30 -0700" Date: Fri, 23 Jul 2010 10:11:36 -0400 Message-ID: <9653.1279894296@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/94 X-Sequence-Number: 20759 Kris Jurka writes: > On 7/23/2010 6:40 AM, Tom Lane wrote: >> I believe this is a misunderstanding of the protocol spec. The spec is >> (intended to say that) we'll continue to accept data after reporting an >> error, not that we will silently swallow an incorrect data stream and >> not complain about it. Which is what this patch will do. > All this does is make binary mode match text mode. The fact that text mode eats data after \. is a backwards-compatibility kluge to match the behavior of pre-7.4 COPY. It could very legitimately be argued to be a bug in itself. I don't think that we should make binary mode match it. The main concrete reason why not is that binary mode has almost no redundancy. It would be really easy for the code change you suggest to result in data being silently discarded with no hint of what went wrong. After some reflection, I think the real issue here is that the JDBC driver is depending on a behavior not stated in the protocol, which is the relative timing of FE-to-BE and BE-to-FE messages. Once you've sent the EOF marker, the only correct follow-on for a spec-compliant frontend is a CopyEnd message. So the backend is just sending its response a bit sooner. There's nothing in the protocol spec forbidding that. I would be willing to accept a patch that avoided sending CopyEnd immediately after receiving EOF, so long as it still threw an error for extra data; but this is not that patch. The larger issue though is whether it wouldn't be better to change the driver behavior instead. I can't help thinking that the JDBC driver must be being overly cute if this breaks it ... and you're never going to get everybody to upgrade their server version, even if we were willing to back-patch the change. regards, tom lane