pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Kris Jurka <books@ejurka.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: patch: streaming of bytea parameter values
Date: Fri, 07 May 2004 19:50:17 +1200
Message-ID: <409B3FB9.6060607@opencloud.com> (raw)
In-Reply-To: <Pine.BSO.4.56.0405070113120.32656@leary.csoft.net>
References: <4085F25A.8060009@opencloud.com>
	<Pine.BSO.4.56.0405070113120.32656@leary.csoft.net>

Kris Jurka wrote:
> 
> On Wed, 21 Apr 2004, Oliver Jowett wrote:
> 
> 
>>This patch allows bytea parameters set via setBytes() / 
>>setBinaryStream() to be streamed to the backend. With the patch applied, 
>>the additional memory overhead for bytea parameters is small and 
>>independent of how large the parameter data is.
> 
> 
> Have you given any consideration to extending this to handle streaming
> large text fields via setAsciiStream(), setUnicodeStream(), or
> setObject(int, Object, Types.LONGVARCHAR) ?  Also updateable ResultSets 
> have similar updateXXX to PreparedStatement's setXXX methods that could 
> benefit from a streaming interface.

I think setObject() should use the changes when given a byte[], as it 
appears to delegate to setBytes() in that case.. although I find the 
setObject logic hard to follow at times (you are in a maze of twisty 
little case statements, all alike)

updateBytes() delegates to setObject(). updateBinaryStream() won't 
stream, at a glance, but should be easy to change so it delegates to 
setBinaryStream().

 From a quick look at the other streaming parameter types, it's not 
clear that we can stream them. setUnicodeStream and setCharacterStream 
can't be streamed under v3 as there's no simple relationship between the 
length parameter provided and the number of UTF8-encoded bytes we'd send 
to the backend. setAsciiStream could be streamed if we assume 7-bit 
ASCII (1:1 mapping to UTF8) but the JDBC javadoc doesn't say exactly 
what it means by "ASCII"..

> There is also the implied assumption that V3 protocol implies a unicode 
> client encoding which implies a seven bit safe streaming option which 
> would be better spelled out in a comment or called in a way that used the 
> encoding variable to derive this fact.

Fair comment.

In my local tree, this patch has been superceded by changes to use the 
v3 extended query protocol and stream the data directly as a binary 
parameter. I thought it might make a good interim solution for the 
official driver though.

-O



view thread (15+ messages)  latest in thread

Message-ID: <409B3FB9.6060607@opencloud.com>
Permalink:  ../409B3FB9.6060607@opencloud.com/
Also on:    postgresql.org/message-id/409B3FB9.6060607@opencloud.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: oliver@opencloud.com, books@ejurka.com
  Subject: Re: patch: streaming of bytea parameter values
  In-Reply-To: <409B3FB9.6060607@opencloud.com>
  References: <4085F25A.8060009@opencloud.com> <Pine.BSO.4.56.0405070113120.32656@leary.csoft.net> <409B3FB9.6060607@opencloud.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