Re: AbstractJdbc2Array - another patch

Lists: pgsql-jdbc
From: Marek Lewczuk <newsy(at)lewczuk(dot)com>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: AbstractJdbc2Array - another patch
Date: 2007-10-11 08:59:19
Message-ID: 470DE5E7.2090807@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hello all,
in the attachment you can find AbstractJdbc2Array with small patch
(empty array was wrongly interpreted). Please test it and if possible
add to cvs.

Regards,
Marek Lewczuk

Attachment Content-Type Size
AbstractJdbc2Array.java text/plain 18.3 KB

From: "Heikki Linnakangas" <heikki(at)enterprisedb(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-11 11:00:50
Message-ID: 470E0262.2050704@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Marek Lewczuk wrote:
> in the attachment you can find AbstractJdbc2Array with small patch
> (empty array was wrongly interpreted). Please test it and if possible
> add to cvs.

There seems to be a lot of unrelated stylistic changes, whitespace
changes, renaming of fields etc. in that new file. That makes it hard to
see what the problem is that it's fixing, and what was done to fix it.
Please make just the changes required to fix the problem, and if you
want to propose any other changes, send them as separate patches.

Also, please send patches in a "cvs diff -c" format, instead of sending
the whole file.

A small test case demonstrating the problem would also be very nice, to
help with the testing.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


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 08:12:40
Message-ID: Pine.BSO.4.64.0710180401490.16749@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Thu, 11 Oct 2007, Marek Lewczuk wrote:

> Hello all,
> in the attachment you can find AbstractJdbc2Array with small patch (empty
> array was wrongly interpreted). Please test it and if possible add to cvs.
>

I've finally found some time to test this and...

1) It causes six failures in the regression tests, these need to be fixed.

2) It would be good to have new tests for this new functionality.

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.

4) Shouldn't toString(PgArrayList) be PgArrayList.toString() ?

5) Your coding style is a little hard to read because you try to cram a
lot of code into a single line. Clarity is valued more than compactness.

Ex1 (line 214)

if (b != null && (b.length() > 0 || wasInsideString))
curArray.add(useObjects && !wasInsideString && b.equals("NULL") ? null :
b);

Ex2 (line 348)
oa[length++] = multi && v != null ? buildArray((PgArrayList) v, 0, -1) :
(v == null ? null : connection.getTimestampUtils().toTime(null, (String)
v));

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?

Kris Jurka

Attachment Content-Type Size
ArrayTest.java text/plain 980 bytes

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
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

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-10-26 11:49:02
Message-ID: 4721D42E.4060107@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
> 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.
I see the problem. I assume that we need to add support for array types,
which means that org.postgresql.core.Oid must have oid for every base
type array, e.g. _INT2 = 1005. It will be also required to add
appropriate data within org.postgresql.jdbc2.TypeInfoCache#types. Should
I do it ?

Regards,
Marek Lewczuk


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-26 16:13:06
Message-ID: Pine.BSO.4.64.0710261209350.18147@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Fri, 26 Oct 2007, Marek Lewczuk wrote:

> I see the problem. I assume that we need to add support for array types,
> which means that org.postgresql.core.Oid must have oid for every base type
> array, e.g. _INT2 = 1005. It will be also required to add appropriate data
> within org.postgresql.jdbc2.TypeInfoCache#types. Should I do it ?
>

That doesn't sound right to me because we won't be able to put every
possible type (think about user defined) into the Oid class. Perhaps
getResultSet should convert getBaseTypeName() to oid instead of
getBaseType? Then you just need to know if your output is an array or not
(by checking isMultiDimensional) to know whether you want the oid for type
or _type.

Kris Jurka


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-10-26 18:08:17
Message-ID: 47222D11.5010006@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
>
>
> That doesn't sound right to me because we won't be able to put every
> possible type (think about user defined) into the Oid class. Perhaps
I was thinking only about base types (they are already in Oid class),
because it will work much faster if they will be statically written in
Oid class.

> getResultSet should convert getBaseTypeName() to oid instead of
> getBaseType? Then you just need to know if your output is an array or
> not (by checking isMultiDimensional) to know whether you want the oid
> for type or _type.
I still think that we should add base type arrays into Oid class - it
will work much faster and will be appropriate cause Oid class already
contains base types, so it is logical to put there base type arrays too.
For user defined types I would provide a way to fetch oid from pg_type -
but for now user defined types are not supported. However, if you really
think that we should fetch oid for every array type then I'm able to do
it but in my opinion we should stick with Oid class for now (only for
base types).

Regards,
ML


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-28 19:12:45
Message-ID: Pine.BSO.4.64.0710281511210.31092@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Fri, 26 Oct 2007, Marek Lewczuk wrote:

> I still think that we should add base type arrays into Oid class - it will
> work much faster and will be appropriate cause Oid class already contains
> base types, so it is logical to put there base type arrays too. For user
> defined types I would provide a way to fetch oid from pg_type - but for now
> user defined types are not supported. However, if you really think that we
> should fetch oid for every array type then I'm able to do it but in my
> opinion we should stick with Oid class for now (only for base types).
>

This makes sense to me, static data for known types, dynamic for unknown.

Kris Jurka


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-10-28 19:28:59
Message-ID: 4724E2FB.3070309@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
>
> This makes sense to me, static data for known types, dynamic for unknown.
Great, I will prepare appropriate patches and send them tomorrow.


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-10-30 09:02:09
Message-ID: 4726F311.8090001@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
> This makes sense to me, static data for known types, dynamic for unknown.
>
Hi Kris,
in the attachment you can find jdbc.patch (that includes patches for a
few classes). You will see that I've added base types array types and
right now Array implementation works as should (your last test case is
working, which means that when using Array.getResultSet() returns
appropriate Array.getBaseType() and Array.getBaseTypeName()). However
those changes are not enough, there has to be more to be done in order
to provide support for user defined types, but I think that should be
done later. I also think that class TypeInfoCache must be absolutely
rewritten, cause it is not prepared for user defined types.

Regards,
ML

Attachment Content-Type Size
jdbc.zip application/x-zip-compressed 9.6 KB

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-10-30 13:47:45
Message-ID: 47273601.8060400@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
> This makes sense to me, static data for known types, dynamic for unknown.
In the attachment you can find the latest patch (in my previous post
I've attached wrong file).

Regards,
ML

Attachment Content-Type Size
jdbc.zip application/x-zip-compressed 9.6 KB

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-11-21 22:49:28
Message-ID: Pine.BSO.4.64.0711211452310.24674@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Tue, 30 Oct 2007, Marek Lewczuk wrote:

> in the attachment you can find jdbc.patch (that includes patches for a few
> classes). You will see that I've added base types array types and right now
> Array implementation works as should (your last test case is working, which
> means that when using Array.getResultSet() returns appropriate
> Array.getBaseType() and Array.getBaseTypeName()). However those changes are
> not enough, there has to be more to be done in order to provide support for
> user defined types, but I think that should be done later. I also think that
> class TypeInfoCache must be absolutely rewritten, cause it is not prepared
> for user defined types.
>

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.

2) Fixed driver code that was relying on the array return type in
AbstractJdbc2DatabaseMetaData.

3) Fixed the regression tests and added new ones to verify that array
handling works.

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.

5) Array.getResultSet didn't respect index or offset parameters.

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

7) Code did not correctly handle a string value of NULL in arrays for 8.1
and earlier server versions.

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.

Kris Jurka

Attachment Content-Type Size
array-v2.patch.gz application/octet-stream 11.2 KB

From: Eric Lenio <eric(at)lenio(dot)net>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Marek Lewczuk <newsy(at)lewczuk(dot)com>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: AbstractJdbc2Array - another patch
Date: 2007-11-22 06:09:06
Message-ID: 20071122060905.GB25875@lenio.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Wed, Nov 21, 2007 at 05:49:28PM -0500, Kris Jurka wrote:
>
>
> On Tue, 30 Oct 2007, Marek Lewczuk wrote:
>
> >in the attachment you can find jdbc.patch (that includes patches for a few
> >classes). You will see that I've added base types array types and right
> >now Array implementation works as should (your last test case is working,
> >which means that when using Array.getResultSet() returns appropriate
> >Array.getBaseType() and Array.getBaseTypeName()). However those changes
> >are not enough, there has to be more to be done in order to provide
> >support for user defined types, but I think that should be done later. I
> >also think that class TypeInfoCache must be absolutely rewritten, cause it
> >is not prepared for user defined types.
> >
>
> 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.
>
> 2) Fixed driver code that was relying on the array return type in
> AbstractJdbc2DatabaseMetaData.
>
> 3) Fixed the regression tests and added new ones to verify that array
> handling works.
>
> 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.
>
> 5) Array.getResultSet didn't respect index or offset parameters.
>
> 6) For TypeInfoCache I've added a new column to link the base and array
> types instead of duplicating the whole rows.
>
> 7) Code did not correctly handle a string value of NULL in arrays for 8.1
> and earlier server versions.
>
> 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.
>
> Kris Jurka

Kris/Marek: I've attached a very small followup patch which addresses a
need I had: I was using java.sql.DatabaseMetaData's getColumns method to
attempt to get the COLUMN_SIZE attribute for a column of type "character
varying(255) []". Without my patch (applied after Kris's patches) the
COLUMN_SIZE would be 2147483647, with the patch it would be 255. I am
by no means a JDBC or Postgresql expert, so maybe I am way off base.
What do you think?

Eric.

Attachment Content-Type Size
TypeInfoCache.patch text/plain 517 bytes

From: Kris Jurka <books(at)ejurka(dot)com>
To: Eric Lenio <eric(at)lenio(dot)net>
Cc: Marek Lewczuk <newsy(at)lewczuk(dot)com>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: AbstractJdbc2Array - another patch
Date: 2007-11-22 06:26:56
Message-ID: Pine.BSO.4.64.0711220119340.30460@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Thu, 22 Nov 2007, Eric Lenio wrote:

> Kris/Marek: I've attached a very small followup patch which addresses a
> need I had: I was using java.sql.DatabaseMetaData's getColumns method to
> attempt to get the COLUMN_SIZE attribute for a column of type "character
> varying(255) []". Without my patch (applied after Kris's patches) the
> COLUMN_SIZE would be 2147483647, with the patch it would be 255. I am
> by no means a JDBC or Postgresql expert, so maybe I am way off base.
> What do you think?
>

Looks reasonable, but way too specific. We don't want to do that for each
array type. At the top of each of the methods that have the switch
statements we should have something that checks to see if it is an array
type and converts the oid to the oid of the base type.

Kris Jurka


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
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

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 14:29:42
Message-ID: 47459256.9000700@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Marek Lewczuk pisze:
> Kris Jurka pisze:
Argh... sorry for English mistakes. I type to fast and sometimes I don't
pay attention to typos and grammar mistakes. Sorry...

> I was concentrate on make it working for >= 8.2 - again my mistake, sorry.
I was concentrated on doing it for...

> Well, I aware that java.lang.reflect.Array#newInstance can be used
I'm aware...

> I one to discuss one more thing - see below lines in the AbstractJdb2Array:
I want to discuss one...

Best wishes,
Marek


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-11-24 06:07:14
Message-ID: Pine.BSO.4.64.0711240055520.505@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Thu, 22 Nov 2007, Marek Lewczuk wrote:

> 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.

Doesn't seem to work. The attached case fails in two different ways
depending on whether compatible is set or not. The JDK methods you can
use depends on where the code you are adding goes. In this case you're
adding code to a JDBC2 class, so you are restricted to JDK1.2 code. JDBC3
-> 1.4, JDBC3g -> 1.5, JDBC4 -> 1.6.

> 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 ?
>

Right now you use objects if either dims > 1 or useObjects. I'm
suggesting that we should only use objects if useObjects. That way people
who want to get int[][] returned can get that via setting compatible=8.2.

Kris Jurka

Attachment Content-Type Size
ArrayTest4.java text/plain 929 bytes

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-27 09:02:07
Message-ID: 474BDD0F.6050609@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
> Doesn't seem to work. The attached case fails in two different ways
> depending on whether compatible is set or not. The JDK methods you can
> use depends on where the code you are adding goes. In this case you're
> adding code to a JDBC2 class, so you are restricted to JDK1.2 code.
> JDBC3 -> 1.4, JDBC3g -> 1.5, JDBC4 -> 1.6.
It should work right now (I've tested it using your examples). As for
java.lang.reflect package it was added in JDK1.1, so it should work for
all supported Java versions.

> Right now you use objects if either dims > 1 or useObjects. I'm
> suggesting that we should only use objects if useObjects. That way
> people who want to get int[][] returned can get that via setting
> compatible=8.2.
Well, my implementation works as you described, have a look at
Boolean/boolean:
if (dims > 1 || useObjects) // if more than one dimension or objects
{
// here I check if more than one dimension and if so
// I check for useObjects - if true, then Boolean[] if false then
boolean[]
ret = oa = (dims > 1 ? (Object[])
java.lang.reflect.Array.newInstance(useObjects ? Boolean.class :
boolean.class, dimsLength) : new Boolean[count]);
}

else // if one dimension primitive array
{
ret = pa = new boolean[count];
}

In the attachment you can find appropriate patch. Please review it
again. Btw, you didn't answer about
ResultSetMetaData.getColumnTypeName() - does it mean, that we won't do
anything with that in near future ?

Best wishes,
Marek

Attachment Content-Type Size
AbstractJdbc2Array.patch.zip application/x-zip-compressed 8.6 KB

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-12-01 08:29:52
Message-ID: Pine.BSO.4.64.0712010316190.12362@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Tue, 27 Nov 2007, Marek Lewczuk wrote:

> [one more patch for multi-dimensional arrays]
>

Applied with one last minor fix. Array elements are escaped differently
than literals or identifiers, so I've added a new escapeArrayElement
method instead of trying to use connection.escapeString.

> Btw, you didn't answer about ResultSetMetaData.getColumnTypeName() - does it
> mean, that we won't do anything with that in near future ?
>

I don't have any immediate plans to work on this issue. The 8.3 release
is coming fast and there are two more large patches that I need to have
another look at (copy + binary transfer). Schema qualifying all types has
been a problem since the 7.3 release and we haven't heard a whole lot of
complaints about it, so I'm not hugely concerned. That's not to say I
don't think we should fix it, just that it's low on my priority list. If
you want to work on it, I'd be happy to look at whatever you come up with.

Kris Jurka


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-12-01 19:01:35
Message-ID: 4751AF8F.2030504@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka pisze:
> Applied with one last minor fix. Array elements are escaped differently
> than literals or identifiers, so I've added a new escapeArrayElement
> method instead of trying to use connection.escapeString.
Great, thanks.

> I don't have any immediate plans to work on this issue. The 8.3 release
> is coming fast and there are two more large patches that I need to have
> another look at (copy + binary transfer). Schema qualifying all types
> has been a problem since the 7.3 release and we haven't heard a whole
> lot of complaints about it, so I'm not hugely concerned. That's not to
> say I don't think we should fix it, just that it's low on my priority
> list. If you want to work on it, I'd be happy to look at whatever you
> come up with.
Ok, I will try to prepare my proposal. If there will be other things,
that I could help please write me an email.

Best wishes,
ML


From: Kris Jurka <books(at)ejurka(dot)com>
To: Eric Lenio <eric(at)lenio(dot)net>
Cc: Marek Lewczuk <newsy(at)lewczuk(dot)com>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>, danap(at)ttc-cmc(dot)net
Subject: Re: AbstractJdbc2Array - another patch
Date: 2008-04-15 05:21:44
Message-ID: Pine.BSO.4.64.0804150117200.8211@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Thu, 22 Nov 2007, Eric Lenio wrote:

> Kris/Marek: I've attached a very small followup patch which addresses a
> need I had: I was using java.sql.DatabaseMetaData's getColumns method to
> attempt to get the COLUMN_SIZE attribute for a column of type "character
> varying(255) []". Without my patch (applied after Kris's patches) the
> COLUMN_SIZE would be 2147483647, with the patch it would be 255. I am
> by no means a JDBC or Postgresql expert, so maybe I am way off base.
> What do you think?
>

I've applied a patch to CVS to do this along the lines I suggested in the
thread.

Kris Jurka