Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 98216632BE7 for ; Thu, 22 Jul 2010 18:34:22 -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 93241-04; Thu, 22 Jul 2010 21:34:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 73153632857; Thu, 22 Jul 2010 18:34:12 -0300 (ADT) Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 61D602840F; Thu, 22 Jul 2010 17:34:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=1cI5AHHMT4d478js9yaq/rPIqYo=; b=JbjljK w0qSsZ6qu9USkNFMJ0utxQHqyAC3Wt7yTwtQqF/2aCLv9Rzx9ZEB/LE/t/LtXqoX Iyt9myLqEbFtssKXFd9gUp7JllRkpUpt4RBTjlCNBpjLAgPGfls2aTQrcI5jdTGa L8YCMYVKSeXFXsmvunIR65c2egUooi+JWxjT8= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 9FA8A28404; Thu, 22 Jul 2010 17:34:09 -0400 (EDT) Received: by leary.csoft.net (Postfix, from userid 1112) id 4941AA200; Thu, 22 Jul 2010 17:34:09 -0400 (EDT) Date: Thu, 22 Jul 2010 17:34:08 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: pgsql-hackers@postgresql.org, Matthew Wakeling cc: Kevin Grittner , Maciek Sakrejda , Samuel Gendler , pgsql-jdbc@postgresql.org Subject: Re: Trouble with COPY IN In-Reply-To: Message-ID: References: <4C4562C50200002500033951@gw.wicourts.gov> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1783210526-1279834448=:16703" 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/84 X-Sequence-Number: 20749 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-1783210526-1279834448=:16703 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Per discussion and investigation on the -jdbc list, the server appears to violate the frontend/backend protocol when binary copy data is sent to the server. Upon receiving the binary copy end of data marker (a -1 field count), the server immediately responds with CommandComplete and ReadyForQuery without waiting for the frontend to issue CopyDone or CopyFail. This confuses the JDBC driver as it doesn't think the command sequence should have finished yet. Attached is a patch to make the server continue to consume protocol data until instructed to stop by the client in the same way as copying text data to the server currently works. http://www.postgresql.org/docs/8.4/static/protocol-flow.html#PROTOCOL-COPY http://www.postgresql.org/docs/8.4/static/sql-copy.html Kris Jurka --0-1783210526-1279834448=:16703 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=binary-copy-end.patch Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=binary-copy-end.patch KioqIGEvc3JjL2JhY2tlbmQvY29tbWFuZHMvY29weS5jDQotLS0gYi9zcmMv YmFja2VuZC9jb21tYW5kcy9jb3B5LmMNCioqKioqKioqKioqKioqKg0KKioq IDIwNTgsMjA2OSAqKioqIENvcHlGcm9tKENvcHlTdGF0ZSBjc3RhdGUpDQog IAkJCWludDE2CQlmbGRfY291bnQ7DQogIAkJCUxpc3RDZWxsICAgKmN1cjsN CiAgDQohIAkJCWlmICghQ29weUdldEludDE2KGNzdGF0ZSwgJmZsZF9jb3Vu dCkgfHwNCiEgCQkJCWZsZF9jb3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