patch: support user implementations of Array in setArray() - Mailing list pgsql-jdbc

From Oliver Jowett
Subject patch: support user implementations of Array in setArray()
Date
Msg-id 20030722141709.GF11354@opencloud.com
Whole thread Raw
Responses Re: patch: support user implementations of Array in setArray()
List pgsql-jdbc
This patch modifies setArray() to handle implementations of Array other than
the driver's own (which you can only get from getArray(), anyway, making
setArray() not very useful currently).

The "right way" of implementing this requires a lot of restructuring of the
setXXX code, so I've taken the easy way out and implemented it by calling
setObject() for each element and stealing the resulting m_bind[] value. This
requires some extra escaping of string literals so we can easily turn a
string literal into an array value by replacing the enclosing '' with "".

This version also uses reflection to get at the array elements regardless of
the type of the array (Object[] vs primitive-type[]). It's easy enough to
expand this out to explicitly deal with the different array types and avoid
reflection, if there's interest. I haven't benchmarked the two approaches --
reflection's got a lot faster recently so I suspect there's not much between
them.

Also attached is a testcase for getArray() and setArray(). The tests that
use server-side prepare will fail without my earlier patch that corrects the
types generated by setObject().

Should we provide a simple implementation of Array with the driver? e.g.
something like the WrappedArray used in the testcase.

-O

Attachment

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Detecting 'socket errors' - closing the Connection object
Next
From: Dmitry Tkach
Date:
Subject: Re: the IN clause saga