Max size for bytea type

From: "Do, Leon \(Leon\)" <leondo(at)alcatel-lucent(dot)com>
To: "PostgreSQL JDBC" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Max size for bytea type
Date: 2007-01-19 20:32:46
Message-ID: D1EE06BA46B1E4449AF9A4F2FBEE18616FB822@ILEXC2U01.ndc.lucent.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

Can someone explain why I cann't get bytea data of more than 1998 bytes?
Below 1998 size is ok but I got exception if the size is at and above
1998. I used jdbc-8.1-407.jdbc3.jar.

//setting bytea value. Work fine
byte[] bdata = new byte[1998];
for (int b = 0; b < bdata.length; b++) {
bdata[b] = (byte) (b % Byte.MAX_VALUE);
}

ByteArrayInputStream is = new
ByteArrayInputStream(bdata);

prepstmt.setBinaryStream(1, is, bdata.length);

//getting bytea value. Got error
ByteArrayInputStream s = (ByteArrayInputStream) rs
.getBinaryStream(1);

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
1998
at org.postgresql.util.PGbytea.toBytes(PGbytea.java:39)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBytes(AbstractJdbc2Result
Set.java:2048)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBinaryStream(AbstractJdbc
2ResultSet.java:2168)

Thanks

Leon Do
> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Dave Cramer
> Sent: Friday, January 19, 2007 2:13 PM
> To: Guillaume Smet
> Cc: PostgreSQL JDBC; Tom Lane
> Subject: Re: [JDBC] Memory leaks using refcursors
>
>
> On 19-Jan-07, at 11:07 AM, Guillaume Smet wrote:
>
> > On 1/19/07, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
> >> I believe the problem is in the server's XA code somehow
> not closing
> >> unnamed parameters properly.
> >>
> >> If you could run the code I sent you and tell me if it
> causes a leak,
> >> then that will confirm it.
> >
> > Sorry, I did not understand what you've asked me. I just
> run the test
> > without the XA code and it has the memory leak with the old 408
> > driver.
> > IMHO, it's quite logical as this memory leak has nothing to do with
> > the transaction management as all the operations are in a big
> > transaction.
> > When I close the transaction, XA or not XA, the backend used by the
> > connection returns to a normal memory usage.
>
> So I've sent Guillaume a driver which closes the refcursor
> directly after reading the contents for testing.
>
> So far so good.
>
> Dave
> >
> > --
> > Guillaume
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 5: don't forget to increase your free space map settings
> >
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ken Johanson 2007-01-20 05:43:53 Re: Synthesize support for Statement.getGeneratedKeys()?
Previous Message Dave Cramer 2007-01-19 19:12:34 Re: Memory leaks using refcursors