pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bug? Reading items of array of composite a type
2+ messages / 1 participants
[nested] [flat]

* Bug? Reading items of array of composite a type
@ 2010-09-20 10:55 Daniel Dekany <ddekany@freemail.hu>
  2010-09-20 18:23 ` Re: Bug? Reading items of array of composite a type Daniel Dekany <ddekany@freemail.hu>
  0 siblings, 1 reply; 2+ messages in thread

From: Daniel Dekany @ 2010-09-20 10:55 UTC (permalink / raw)
  To: pgsql-jdbc

(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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Bug? Reading items of array of composite a type
  2010-09-20 10:55 Bug? Reading items of array of composite a type Daniel Dekany <ddekany@freemail.hu>
@ 2010-09-20 18:23 ` Daniel Dekany <ddekany@freemail.hu>
  0 siblings, 0 replies; 2+ messages in thread

From: Daniel Dekany @ 2010-09-20 18:23 UTC (permalink / raw)
  To: pgsql-jdbc; +Cc: pgsql-jdbc

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-09-20 18:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-09-20 10:55 Bug? Reading items of array of composite a type Daniel Dekany <ddekany@freemail.hu>
2010-09-20 18:23 ` Daniel Dekany <ddekany@freemail.hu>

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