Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 6A1609FB675 for ; Thu, 5 Jul 2007 12:05:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 99131-07 for ; Thu, 5 Jul 2007 12:05:46 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id 642109FB30E for ; Thu, 5 Jul 2007 12:05:45 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so557055ugf for ; Thu, 05 Jul 2007 08:05:44 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:user-agent:mime-version:to:subject:content-type:from; b=Fk/VlQzhHrQfmrQLGblJF7x8OIXqS/k9nmOFqyYxb+YDtsP2HWT7RF8NTrKSWRBz0HsRa3uz/cgrzHLMzrgJYsdBt91+QqasuuVhJb5iXqD0ZB2RCg2D4Dw7wki6YIQyNg7g7+70EpMA7S5BclBZin3sHMURSdARctp7JBLgTjY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:user-agent:mime-version:to:subject:content-type:from; b=FRzIzUJSUep8vqPOmKJYV3vxf0C6vPoS2fa38pmmy+QJK6CyOZttPm+svHxfQKTt/9wlldzre+P/R7t2kyICaOBZz5JWOqw7doqJ8BEV5aV7qIokmkE3lJtbRnvpgZBYirRuJFbg3hyjH6RdQmi8wTkanGqDXDvIBLPWXSObhHM= Received: by 10.82.111.8 with SMTP id j8mr20401734buc.1183647943927; Thu, 05 Jul 2007 08:05:43 -0700 (PDT) Received: from ?10.44.16.231? ( [62.77.174.157]) by mx.google.com with ESMTP id z40sm22205167ikz.2007.07.05.08.05.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 05 Jul 2007 08:05:42 -0700 (PDT) Message-ID: <468D08BB.701@google.com> Date: Thu, 05 Jul 2007 16:05:31 +0100 User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Bug in org.postgresql.jdbc2.AbstractJdbc2Array Content-Type: multipart/mixed; boundary="------------020609070205000800000104" From: Alessandro Di Bella X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/21 X-Sequence-Number: 17195 This is a multi-part message in MIME format. --------------020609070205000800000104 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I found a bug in the org.postgresql.jdbc2.AbstractJdbc2Array class that causes the following exception when an array contains a null value: Caused by: org.postgresql.util.PSQLException: Bad value for type date : NULL at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:246) at org.postgresql.jdbc2.TimestampUtils.toDate(TimestampUtils.java:402) at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:210) I attached a patch that fixes the problem. If you are happy with it, please merge it with the HEAD stream. Thanks Alessandro --------------020609070205000800000104 Content-Type: text/plain; name="pgjdbc-sqlarray-patch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pgjdbc-sqlarray-patch.patch" Index: org/postgresql/jdbc2/AbstractJdbc2Array.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Array.java,v retrieving revision 1.18 diff -u -p -r1.18 AbstractJdbc2Array.java --- org/postgresql/jdbc2/AbstractJdbc2Array.java 4 Dec 2005 21:40:33 -0000 1.18 +++ org/postgresql/jdbc2/AbstractJdbc2Array.java 5 Jul 2007 14:56:50 -0000 @@ -185,8 +185,10 @@ public class AbstractJdbc2Array break; case Types.NUMERIC: retVal = new BigDecimal[ count ]; - for ( ; count > 0; count-- ) - ((BigDecimal[])retVal)[i++] = AbstractJdbc2ResultSet.toBigDecimal( arrayContents[(int)index++], -1 ); + for ( ; count > 0; count-- ){ + String content = arrayContents[(int)index++]; + ((BigDecimal[])retVal)[i++] = ("NULL".equals(content)) ? null : AbstractJdbc2ResultSet.toBigDecimal( content, -1 ); + } break; case Types.REAL: retVal = new float[ count ]; @@ -201,23 +203,31 @@ public class AbstractJdbc2Array case Types.CHAR: case Types.VARCHAR: retVal = new String[ count ]; - for ( ; count > 0; count-- ) - ((String[])retVal)[i++] = arrayContents[(int)index++]; + for ( ; count > 0; count-- ){ + String content = arrayContents[(int)index++]; + ((String[])retVal)[i++] = ("NULL".equals(content)) ? null : content; + } break; case Types.DATE: retVal = new java.sql.Date[ count ]; - for ( ; count > 0; count-- ) - ((java.sql.Date[])retVal)[i++] = conn.getTimestampUtils().toDate(null, arrayContents[(int)index++] ); + for ( ; count > 0; count-- ){ + String content = arrayContents[(int)index++]; + ((java.sql.Date[])retVal)[i++] = ("NULL".equals(content)) ? null : conn.getTimestampUtils().toDate(null, content ); + } break; case Types.TIME: retVal = new java.sql.Time[ count ]; - for ( ; count > 0; count-- ) - ((java.sql.Time[])retVal)[i++] = conn.getTimestampUtils().toTime(null, arrayContents[(int)index++] ); + for ( ; count > 0; count-- ){ + String content = arrayContents[(int)index++]; + ((java.sql.Time[])retVal)[i++] = ("NULL".equals(content)) ? null : conn.getTimestampUtils().toTime(null, content ); + } break; case Types.TIMESTAMP: retVal = new Timestamp[ count ]; - for ( ; count > 0; count-- ) - ((java.sql.Timestamp[])retVal)[i++] = conn.getTimestampUtils().toTimestamp(null, arrayContents[(int)index++] ); + for ( ; count > 0; count-- ){ + String content = arrayContents[(int)index++]; + ((java.sql.Timestamp[])retVal)[i++] = ("NULL".equals(content)) ? null : conn.getTimestampUtils().toTimestamp(null, content ); + } break; // Other datatypes not currently supported. If you are really using other types ask --------------020609070205000800000104--