From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | patch: support user implementations of Array in setArray() |
Date: | 2003-07-22 14:17:09 |
Message-ID: | 20030722141709.GF11354@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
ArrayTest.java | text/x-java | 5.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitry Tkach | 2003-07-22 14:18:28 | Re: Detecting 'socket errors' - closing the Connection object |
Previous Message | Oliver Jowett | 2003-07-22 13:54:53 | patch: tiny patch to correct stringbuffer size estimate |