setBinaryStream can abandon connection

From: Kris Jurka <books(at)ejurka(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: setBinaryStream can abandon connection
Date: 2004-10-17 12:58:39
Message-ID: Pine.BSO.4.56.0410170735120.16087@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


Currently using setBinaryStream over a v3 protocol connection can
completely break your connection if you happen to get the length wrong or
your InputStream throws an Exception the driver will simply close your
connection giving you no chance to rollback. This patch fixes that by
continuing to pump fake data into the Bind message and simply not issuing
the Execute message.

This isn't ideal because it doesn't actually force a backend error so it
is possible to issue a commit later that will succeed instead of failing,
but I still think it's better than the current behavior. I suppose we
could deliberately introduce a syntax error or something if in not in
autocommit mode.

Finally do we need a special -1 length argument to tell the driver we
don't know the length. This will force a copy of the stream instead of
the current direct streaming to the backend, but a memory hog is better
than not working at all.

Kris Jurka

Attachment Content-Type Size
v3.stream.failure.patch text/plain 9.8 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Németh György 2004-10-17 18:27:33 Problem with PostgreSQL JDBC driver
Previous Message Kris Jurka 2004-10-17 12:07:37 Re: A solution to the SSL customizing problem