pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Marek Lewczuk <newsy@lewczuk.com>
Cc: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Re: AbstractJdbc2Array - another patch
Date: Thu, 18 Oct 2007 04:12:40 -0400 (EDT)
Message-ID: <Pine.BSO.4.64.0710180401490.16749@leary.csoft.net> (raw)
In-Reply-To: <470DE5E7.2090807@lewczuk.com>
References: <470DE5E7.2090807@lewczuk.com>



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

Attachments:

ArrayTest.java (text/plain, 980B) download import java.sql.*; public class ArrayTest { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5830/jurka","jurka",""); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT '{{1,2,3},{4,5,6}}'::int[]"); rs.next(); Array arr = rs.getArray(1); ResultSet arrRS = arr.getResultSet(); arrRS.next(); System.out.println(arrRS.getString(1)); Array a1 = arrRS.getArray(1); ResultSet rs1 = a1.getResultSet(); while (rs1.next()) { System.out.println(rs1.getInt(1)); } rs1.close(); arrRS.next(); System.out.println(arrRS.getString(1)); Array a2 = arrRS.getArray(1); ResultSet rs2 = a2.getResultSet(); while (rs2.next()) { System.out.println(rs2.getInt(1)); } rs2.close(); arrRS.close(); rs.close(); stmt.close(); conn.close(); } }

view thread (20+ messages)  latest in thread

Message-ID: <Pine.BSO.4.64.0710180401490.16749@leary.csoft.net>
Permalink:  ../Pine.BSO.4.64.0710180401490.16749@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.64.0710180401490.16749@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, newsy@lewczuk.com
  Subject: Re: AbstractJdbc2Array - another patch
  In-Reply-To: <Pine.BSO.4.64.0710180401490.16749@leary.csoft.net>
  References: <470DE5E7.2090807@lewczuk.com> <Pine.BSO.4.64.0710180401490.16749@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox