Re: AbstractJdbc2Array - another patch

From: Marek Lewczuk <newsy(at)lewczuk(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: AbstractJdbc2Array - another patch
Date: 2007-11-22 11:07:07
Message-ID: 474562DB.6090802@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Kris Jurka pisze:
> Attached is a revised version of your patch after I worked on it a bit.
> Things I've changed:
>
> 1) Looking up the array type for a base type by using typelem doesn't
> work because typelem is not unique. Since no code was calling
> getPGTypeArray, I just removed this code.
Agree.

>
> 3) Fixed the regression tests and added new ones to verify that array
> handling works.
I wanted to do it, but I was waiting for you comments about my code.
Thanks for that.

> 4) Changed Array.getResultSet to use generic coding rather than
> hardcoding type oids for each java.sql.Types value. This allows
> getResultSet to be used on types that aren't known to the driver, like
> aclitem[]. You still can't call getArray on this type, but we're
> getting closer.
Agree.

>
> 5) Array.getResultSet didn't respect index or offset parameters.
Sorry, my mistake.

>
> 6) For TypeInfoCache I've added a new column to link the base and array
> types instead of duplicating the whole rows.
Agree.

>
> 7) Code did not correctly handle a string value of NULL in arrays for
> 8.1 and earlier server versions.
I was concentrate on make it working for >= 8.2 - again my mistake, sorry.

> So with these changes, I think the code is pretty much ready to go, with
> the exception of how multidimensional results are returned. The way you
> wrap the arrays in Object[] makes it impossible to cast to things like
> Integer[][]. Also I think we should be able to return multidimensional
> arrays of primitive type if the "compatible" option is set to 8.2. I
> think you should be using java.lang.reflect.Array#newInstance to create
> the arrays you are returning to get the correct type instead of building
> them up incrementally.
Well, I aware that java.lang.reflect.Array#newInstance can be used
however I didn't know for what versions of JDK reflect package can be
used - if you have mentioned about it so I guess that I can - in the
attachment you can find AbstractJdbc2Array patch - please review it.

I one to discuss one more thing - see below lines in the AbstractJdb2Array:
this.useObjects = connection.haveMinimumCompatibleVersion("8.3");
this.haveMinServer82 = connection.haveMinimumServerVersion("8.2");

We must clarify, when to use objects instead of primitive types ? Can
you describe it ?

Regards,
Marek

Attachment Content-Type Size
array-patch.zip application/x-zip-compressed 8.5 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Marek Lewczuk 2007-11-22 14:29:42 Re: AbstractJdbc2Array - another patch
Previous Message Kris Jurka 2007-11-22 06:26:56 Re: AbstractJdbc2Array - another patch