Re: AbstractJdbc2Array - another patch

From: Kris Jurka <books(at)ejurka(dot)com>
To: Marek Lewczuk <newsy(at)lewczuk(dot)com>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: AbstractJdbc2Array - another patch
Date: 2007-10-18 18:05:40
Message-ID: 4717A074.4000109@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Marek Lewczuk wrote:
>
>> 3) When determing if NULL in an array string is a null value, you need
>> to check the server version. Prior to 8.2 an unadorned NULL is the
>> text "null", not an actual null value.
> See line 106 (of the attached AbstractJdbc2Array.java) - I'm checking,
> whether Object[] should be used instead of primitive arrays. It also
> used to check, whether NULL elements can be used. Now, see line 230/231
> - at this point, I'm checking, whether element is a text "NULL" or null
> element - it works just fine.

Perhaps that's OK. If you asked for primitive types on an int[] array
with a NULL value, you could want zero instead of an error trying to
convert the String "NULL" to an int, similar to rs.getInt() on a NULL
value. Let's leave this for now and work on fixing/writing new tests
and #6 and we can revisit this later.

>> 4) Shouldn't toString(PgArrayList) be PgArrayList.toString() ?
> It could be, but see line 598 (of the attached AbstractJdbc2Array.java)
> - I'm using escapeString, that throws SQLException and I cannot declare
> PgArrayList.toString() as throwing SQLException (super class declaration
> doesn't allow for that) - I could of course catch SQLException but it
> think it is better to stay with current implementation.

You're right, it's fine.

>> 6) I was unable to recursively retrieve multidimensional arrays as
>> ResultSets as I thought I should be able to do (in the attached test).
>> Shouldn't you retain an array as the base type for the top level of a
>> multi-dimensional array and expose a dimension at a time via each
>> ResultSet?
> You have made a mistake, please try attached ArrayTest.

Doh! OK, now it mostly works, but there's still an issue with setting
the basetype on a subarray to the base element type instead of an array
type, as attached. rs.getObject() (and metadata) are confused about
what the correct type is.

Attachment Content-Type Size
ArrayTest.java text/java 1.1 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mark Lewis 2007-10-18 18:10:14 Re: Fw: postgresql experts please help
Previous Message Kris Jurka 2007-10-18 18:03:23 Re: Fw: postgresql experts please help