Re: TypeInfoCache.getPGArrayElement - determine if array

Lists: pgsql-jdbc
From: Radosław Smogura <rsmogura(at)softperience(dot)eu>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: TypeInfoCache.getPGArrayElement - determine if array
Date: 2010-11-22 09:45:43
Message-ID: b4061baf630d6ebb766e790c1910b248@smogura-softworks.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

In TypeInfo.getPGArrayElement it is written "Returns: the base type's OID,
or 0 if unknown", but if given oid isn't array exception is thrown (empty
result set), if unknown doesn't means unspecified then following patch

ResultSet rs = _getArrayElementOidStatement.getResultSet();
if (!rs.next()) {
pgType = Integer.valueOf(0);
_pgArrayToPgType.put(new Integer(oid), pgType);
}else {
pgType = Integer.valueOf((int)rs.getLong(1));
_pgArrayToPgType.put(new Integer(oid), pgType);
_pgNameToOid.put(rs.getString(2), pgType);
_oidToPgName.put(pgType, rs.getString(2));
}

--
----------
Radosław Smogura
http://www.softperience.eu


From: Kris Jurka <books(at)ejurka(dot)com>
To: Radosław Smogura <rsmogura(at)softperience(dot)eu>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: TypeInfoCache.getPGArrayElement - determine if array
Date: 2010-11-23 07:28:02
Message-ID: alpine.BSO.2.00.1011230225550.26635@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 22 Nov 2010, Rados?aw Smogura wrote:

>
> In TypeInfo.getPGArrayElement it is written "Returns: the base type's OID,
> or 0 if unknown", but if given oid isn't array exception is thrown (empty
> result set), if unknown doesn't means unspecified then following patch

Yes, it does have the assumption that the oid passes is an array type, but
I'm not sure that's a problem. Is there a case that you want to use this
for a type that may or may not be an array and don't want an exception
thrown? If not, I think updating the documentation is the way to go.

Kris Jurka


From: Radosław Smogura <rsmogura(at)softperience(dot)eu>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: TypeInfoCache.getPGArrayElement - determine if array
Date: 2010-11-23 14:31:03
Message-ID: 7a27153d09f87cba150ba2b47bbfafda@smogura-softworks.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

Yes, I works on binary read/write (more read) and I search simple way to
determine if given type is array type. But I think I've found good solution
getSQLType() == Java.ARRAY, is it OK?

By the way I've passed almost 85% of JDBC test in binary mode, arrays,
unknown types and few procedure meta data test left. Few fails are for
discussion, as binary PG doesn't give information available in text mode.

Kind regards,
Radek

On Tue, 23 Nov 2010 02:28:02 -0500 (EST), Kris Jurka <books(at)ejurka(dot)com>
wrote:
> On Mon, 22 Nov 2010, Rados?aw Smogura wrote:
>
>>
>> In TypeInfo.getPGArrayElement it is written "Returns: the base type's
>> OID,
>> or 0 if unknown", but if given oid isn't array exception is thrown
(empty
>> result set), if unknown doesn't means unspecified then following patch
>
> Yes, it does have the assumption that the oid passes is an array type,
but
> I'm not sure that's a problem. Is there a case that you want to use
this
> for a type that may or may not be an array and don't want an exception
> thrown? If not, I think updating the documentation is the way to go.
>
> Kris Jurka

--
----------
Radosław Smogura
http://www.softperience.eu