Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 093281336018 for ; Mon, 20 Sep 2010 15:24:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 47418-01 for ; Mon, 20 Sep 2010 18:23:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fep11.mx.upcmail.net (fep11.mx.upcmail.net [62.179.121.31]) by mail.postgresql.org (Postfix) with ESMTP id 909FF1335BA8 for ; Mon, 20 Sep 2010 15:23:53 -0300 (ADT) Received: from edge05.upcmail.net ([192.168.13.212]) by viefep11-int.chello.at (InterMail vM.8.01.02.02 201-2260-120-106-20100312) with ESMTP id <20100920182351.PHHC4509.viefep11-int.chello.at@edge05.upcmail.net> for ; Mon, 20 Sep 2010 20:23:51 +0200 Received: from catv-86-101-163-116.catv.broadband.hu ([86.101.163.116]) by edge05.upcmail.net with edge id 96Po1f07G2WzZim056PqBn; Mon, 20 Sep 2010 20:23:51 +0200 X-SourceIP: 86.101.163.116 Date: Mon, 20 Sep 2010 20:23:48 +0200 From: Daniel Dekany Reply-To: Daniel Dekany X-Priority: 3 (Normal) Message-ID: <1359540791.20100920202348@freemail.hu> To: Daniel Dekany CC: pgsql-jdbc@postgresql.org Subject: Re: Bug? Reading items of array of composite a type In-Reply-To: <255315797.20100920125555@freemail.hu> References: <255315797.20100920125555@freemail.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Cloudmark-Analysis: v=1.1 cv=ZDt3ILgE3VX9xkJc7+9REBIC4hFTL6V7NAq0V56QRNQ= c=1 sm=0 a=z8IKmB3uo64A:10 a=-CRmgG0JhlAA:10 a=_So7fUQMAAAA:8 a=1oUQmlosR_8h64ijIPQA:9 a=ixc8a8d1_C14fZyqzfgA:7 a=dFZfDrgxzqVkAdFGTLzIP0Jer7gA:4 a=jiObf9B0YAUA:10 a=q-PRSMt6rt4A:10 a=RNDHIwyGQ1cA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.5 tagged_above=-10 required=5 tests=BAYES_05=-0.5, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201009/43 X-Sequence-Number: 20913 Nope... no bug here. Array items has two "columns": an index and the value, and the index happened to be the same as the first value which led to the misunderstanding here. Monday, September 20, 2010, 12:55:55 PM, Daniel Dekany wrote: > (Sorry for this is a duplicate of > http://pgfoundry.org/tracker/index.php?func=detail&aid=1010898&group_id=1000224&atid=854 > but now I guess it's unused and you expect reports here?) > > The items of an array of composite items are returned so that the > composite values will only have their first field returned correctly, > the second field will be a PGObject that represents the whole > composite value, and there will not be more fields. > > Example: > > ResultSet rs = con.createStatement().executeQuery( > "SELECT ARRAY[ROW(1,2,3)::some_composite_type]"); > while (rs.next()) { > ResultSet arrayRs = rs.getArray(1).getResultSet(); > while (arrayRs.next()) { > assert(arrayRs.getObject(1), 1); // Passes > assert(arrayRs.getObject(2), 2); // Fails, it's PGObject "(1,2,3)" > assert(arrayRs.getObject(3), 3); // Exception: there's only 2 columns > } > } > > This same issue doesn't appear if the composite value is not an item of an array. > > Versions: > postgresql-8.4-702.jdbc4.jar and postgresql-9.0dev-800.jdbc4.jar > PostgreSQL 8.3.11 (Win32) > Java 1.6.0_20-b02 > > Working demonstration code: > > http://pgfoundry.org/tracker/download.php/1000224/854/1010898/547/PgJDBCBugDemo.java > > -- > Best regards, > Daniel Dekany > > -- Best regards, Daniel Dekany