Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id D8B182E0043 for ; Tue, 20 Nov 2007 14:57:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 46717-03 for ; Tue, 20 Nov 2007 14:57:32 -0400 (AST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by postgresql.org (Postfix) with ESMTP id 8B0E92E0036 for ; Tue, 20 Nov 2007 14:57:33 -0400 (AST) Received: from [127.0.0.1] (ip-90-186-165-42.web.vodafone.de [90.186.165.42]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1IuYHq2b1a-0003b1; Tue, 20 Nov 2007 19:57:32 +0100 Message-ID: <47432E13.4080707@deriva.de> Date: Tue, 20 Nov 2007 19:57:23 +0100 From: =?ISO-8859-1?Q?Christian_Schr=F6der?= Organization: Deriva GmbH User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: NULL values in arrays Content-Type: multipart/mixed; boundary="------------080002040207090203080603" X-Provags-ID: V01U2FsdGVkX1/1b8vczdjxAPpRPF0iYAwUrZ63ASe+P2GjTfh TVyqSS4YhQJRlgGqHgle/4RNo/1SAgSfOcFdVHLVtiBVeS1NGz ex2RJ/bjad9TY45dcoW6g== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/62 X-Sequence-Number: 17817 This is a multi-part message in MIME format. --------------080002040207090203080603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Hi list, since PostgreSQL version 8.2 arrays can contain null values. This doesn't seem to be correctly handled by the driver. (I had a look at the latest CVS version.) I have found in the archive a mail from Marek Lewczuk (sent on 2007-10-11) who adressed this issue, but the thread seems to be dead. Moreover, he did not supply a patch, so I tried to do it myself. Could you please have a look at the attached file and decide if it should be applied to the sources? Thanks a lot! Christian -- Deriva GmbH Tel.: +49 551 489500-42 Financial IT and Consulting Fax: +49 551 489500-91 Hans-Böckler-Straße 2 http://www.deriva.de D-37079 Göttingen Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer --------------080002040207090203080603 Content-Type: text/plain; name="AbstractJdbc2Array.java.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="AbstractJdbc2Array.java.patch" Index: AbstractJdbc2Array.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Array.java,v retrieving revision 1.19 diff -c -r1.19 AbstractJdbc2Array.java *** AbstractJdbc2Array.java 10 Sep 2007 08:34:31 -0000 1.19 --- AbstractJdbc2Array.java 20 Nov 2007 18:29:45 -0000 *************** *** 103,108 **** --- 103,110 ---- StringBuffer sbuf = new StringBuffer(); boolean foundOpen = false; boolean insideString = false; + boolean isQuoted = false; + boolean haveMinServerVersion82 = conn.haveMinimumServerVersion("8.2"); /** * Starting with 8.0 non-standard (beginning index *************** *** 142,147 **** --- 144,150 ---- else if (chars[i] == '"') { insideString = !insideString; + isQuoted = true; continue; } else if (!insideString && (chars[i] == ',' || chars[i] == '}') || *************** *** 149,156 **** { if ( chars[i] != '"' && chars[i] != '}' && chars[i] != ',' ) sbuf.append(chars[i]); ! array.add( sbuf.toString() ); sbuf = new StringBuffer(); continue; } sbuf.append( chars[i] ); --- 152,160 ---- { if ( chars[i] != '"' && chars[i] != '}' && chars[i] != ',' ) sbuf.append(chars[i]); ! array.add( sbuf.toString().equals("NULL") && !isQuoted && haveMinServerVersion82 ? null : sbuf.toString() ); sbuf = new StringBuffer(); + isQuoted = false; continue; } sbuf.append( chars[i] ); --------------080002040207090203080603--