pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Altaf Malik <mmalik_altaf@yahoo.com>
To: Kris Jurka <books@ejurka.com>
Cc: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JDBC causing the connection to close after executing a COPY command
Date: Thu, 13 Dec 2007 11:09:49 -0800 (PST)
Message-ID: <35579.58043.qm@web39104.mail.mud.yahoo.com> (raw)
In-Reply-To: <Pine.BSO.4.64.0712131126070.28251@leary.csoft.net>

I debugged little more and found that this is not because of incomplete copy support. When a response to any of the copy operations is received, JDBC reads next few bytes to ignore the response. But unfortunately driver reads extra four bytes which is the RFQ message so the RFQ message gets corrupted and IOException is thrown considering it as an unknown packet.

I am attaching a patch that fixes this issue and driver works smoothly even after giving the error on copy response.

Regards,
Altaf Malik
EnterpriseDB
http://www.enterprisedb.com/

Kris Jurka <books@ejurka.com> wrote: 

On Thu, 13 Dec 2007, Altaf Malik wrote:

> Also if i enable logging in JDBC, and only execute the COPY statement, 
> log shows that FrontEnd sent a Terminate message.
>

What's happening is that after receiving the server's message that it 
wants to do a COPY, the driver doesn't understand the protocol and dies 
with an "java.io.IOException: Unexpected packet type: " error.  Once this 
happens the driver can't do anything but close the connection.  As part of 
the connection closing process it issues a Terminate message to the 
server, in case it's still listening and the protocol is in a good enough 
state that the server might receive it.  The driver is not explicitly 
terminating the connection upon receiving a copy request, that's just what 
happens when it gets confused.

Kris Jurka


       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Attachments:

pg_copy.diff (text/x-patch, 972B) download *** org/postgresql/core/v3/QueryExecutorImpl.java 2007-10-15 13:06:24.000000000 +0500 --- org/postgresql/core/v3/QueryExecutorImpl.java 2007-12-13 20:37:28.000000000 +0500 *************** *** 1439,1445 **** int l_len = pgStream.ReceiveInteger4(); /* discard */ ! pgStream.Receive(l_len); handler.handleError(new PSQLException(GT.tr("The driver currently does not support COPY operations."), PSQLState.NOT_IMPLEMENTED)); } --- 1439,1446 ---- int l_len = pgStream.ReceiveInteger4(); /* discard */ ! // read l_len-4 (length includes the 4 bytes for message length itself ! pgStream.Receive(l_len - 4); handler.handleError(new PSQLException(GT.tr("The driver currently does not support COPY operations."), PSQLState.NOT_IMPLEMENTED)); }

view thread (9+ messages)  latest in thread

Message-ID: <35579.58043.qm@web39104.mail.mud.yahoo.com>
Permalink:  ../35579.58043.qm@web39104.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/35579.58043.qm@web39104.mail.mud.yahoo.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mmalik_altaf@yahoo.com, books@ejurka.com, pg@fastcrypt.com
  Subject: Re: JDBC causing the connection to close after executing a COPY command
  In-Reply-To: <35579.58043.qm@web39104.mail.mud.yahoo.com>
  References: <Pine.BSO.4.64.0712131126070.28251@leary.csoft.net> <35579.58043.qm@web39104.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox