pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Array support in 8.1 JDBC driver
2+ messages / 2 participants
[nested] [flat]

* Array support in 8.1 JDBC driver
@ 2006-03-28 17:09  jao@geophile.com
  0 siblings, 1 reply; 2+ messages in thread

From: jao@geophile.com @ 2006-03-28 17:09 UTC (permalink / raw)
  To: pgsql-jdbc

I am using postgres 7.4 with an 8.1 JDBC driver. I am considering
whether I should use postgres arrays, and a key issue is JDBC support.
I found this comment about the 7.4 driver from Oliver Jowett
(http://archives.postgresql.org/pgsql-jdbc/2004-11/msg00141.php):

    The driver does not really support setArray() / updateArray() for
    arbitary Array implementations. I had a patch to fix this ages ago but
    it has rotted since then, and was never really the right way to do it
    anyway.

The 8.1 release notes for dev307 say this, which seems to imply
better support:

    Fix setArray when using the v3 protocol. We can't bind arrays as text,
    we need the correct type. This gets the array type from the
    Array.getBaseType method. This is a fragile means that depends on a
    specific Array implementation, but we already depend on a very
    specific implementation (toString() returning a correctly formatted pg
    array) that we can live with this. (oliver)

I'm not sure I understand this. It sounds like the array is converted
to a string. Is the string then just pasted into the query?  What does
this to to the use of server-side prepared statements? I'd like to
avoid parsing the "same" statement repeatedly due to the use of
arrays.

Or is the string then somehow used to bind an array to the prepared
statement?

I don't have to use postgres array, and if the driver will introduce
lots of string manipulation, I'll probably do something else.

Jack Orenstein





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Array support in 8.1 JDBC driver
@ 2006-03-28 20:56  Kris Jurka <books@ejurka.com>
  parent: jao@geophile.com
  0 siblings, 0 replies; 2+ messages in thread

From: Kris Jurka @ 2006-03-28 20:56 UTC (permalink / raw)
  To: jao@geophile.com; +Cc: pgsql-jdbc



On Tue, 28 Mar 2006, jao@geophile.com wrote:

> I'm not sure I understand this. It sounds like the array is converted
> to a string. Is the string then just pasted into the query?  What does
> this to to the use of server-side prepared statements? I'd like to
> avoid parsing the "same" statement repeatedly due to the use of
> arrays.
>
> Or is the string then somehow used to bind an array to the prepared
> statement?

Yes.  The conversion to string is for the bind parameter.  Basically 
setArray takes a java.sql.Array not something like int[].  We also require 
a very specific implementation of the java.sql.Array interface to be 
passed to the setArray function.  The requirements are that getBaseType 
return the correct type value and that calling toString returns the data 
in the format that the postgresql server expects for a bind variable.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-03-28 20:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-03-28 17:09 Array support in 8.1 JDBC driver jao@geophile.com
2006-03-28 20:56 ` Kris Jurka <books@ejurka.com>

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