pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <ringerc@ringerc.id.au>
To: Werner Donné <werner.donne@pincette.biz>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Streaming bytea implementation offered
Date: Sat, 01 Sep 2012 09:04:11 +0800
Message-ID: <50415F0B.9020504@ringerc.id.au> (raw)
In-Reply-To: <6EA298B8-34D9-4832-A722-161911A22AB6@pincette.biz>
References: <6EA298B8-34D9-4832-A722-161911A22AB6@pincette.biz>

On 09/01/2012 12:49 AM, Werner Donné wrote:
> Hello,
>
> I have modified version 9.1-902 of the driver in order for it to stream bytea values when calling ResultSet.getBinaryStream(). The implementation is here:
>
> http://www.pincette.biz/home/werner/postgresql-jdbc-9.1-902-patched.src.zip
>
> When a bytea value is larger than 1MB it is streamed to a temporary file instead of being copied in the "answer" array. When the stream is later accessed, either with "getBinaryInputStream" or "getBytes", the bytes are fetched from the temporary file, which is subsequently deleted. The "getBytes" method copies the bytes in the result array, while "getBinaryInputStream" returns a FileInputStream with an overridden "close" method that deletes the temporary file

Sounds potentially good, but what happens if it's run inside the 
SecurityManager, or in an environment with no ability to create 
temporary files?

What about out-of-disk causing failures that wouldn't occur with OOM?

Do you propose to make this always-on, or configurable?

How (if at all) does this interact with JDBC-standard BLOB support, and 
with large objects?


If you'd like this change considered, it'd be great if you could create 
a patch against the current PgJDBC sources, rather than just publishing 
patched sources. I'd recommend that you clone PgJDBC 
(https://github.com/pgjdbc/pgjdbc):

     git://github.com/pgjdbc/pgjdbc.git

then copy your changes into that working tree and use `git diff`. 
Alternately, you can , `git add` them, `git commit`, then use `git 
format-patch` to get a diff; see

     http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html

Make sure not to include any generated files, and please add some unit 
tests demonstrating the functionality if possible.

--
Craig Ringer





view thread (5+ messages)  latest in thread

Message-ID: <50415F0B.9020504@ringerc.id.au>
Permalink:  ../50415F0B.9020504@ringerc.id.au/
Also on:    postgresql.org/message-id/50415F0B.9020504@ringerc.id.au

 · 

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: ringerc@ringerc.id.au, werner.donne@pincette.biz
  Subject: Re: Streaming bytea implementation offered
  In-Reply-To: <50415F0B.9020504@ringerc.id.au>
  References: <6EA298B8-34D9-4832-A722-161911A22AB6@pincette.biz> <50415F0B.9020504@ringerc.id.au>

* 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