Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1137 ArrayIndexOutOfBoundsException when querying PostGIS geometry columns

3.5.2
closed-fixed
nobody
postgis (1)
5
2014-03-20
2014-03-17
Jens Berke
No

SquirrelSQL 3.5.2, Ubuntu 12.10, Postgresql 9.1 and PostGIS 2.0.4.

The type of the geometry column in my database table is:

geometry(MultiPolygon,25832)

The new plugin for geometry column support doesn't work: the geometry column cells of the query results always contain "<ERROR>", and the log contains the following Exception:

2014-03-17 09:41:57,303 [Thread-5] ERROR net.sourceforge.squirrel_sql.fw.sql.ResultSetReader - Error reading column data, column index = 1
java.lang.ArrayIndexOutOfBoundsException: 2
at net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlGeometryTypeDataTypeComponent.createBriefInfo(Unknown Source)
at net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlGeometryTypeDataTypeComponent.readResultSet(Unknown Source)
at net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.CellComponentFactory.readResultSet(Unknown Source)
at net.sourceforge.squirrel_sql.fw.sql.ResultSetReader.doContentTabRead(Unknown Source)
at net.sourceforge.squirrel_sql.fw.sql.ResultSetReader.readRow(Unknown Source)
at net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet.createRow(Unknown Source)
at net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet._setResultSet(Unknown Source)
at net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet.setSqlExecutionTabResultSet(Unknown Source)
at net.sourceforge.squirrel_sql.client.session.mainpanel.SQLExecutionHandler.sqlResultSetAvailable(Unknown Source)
at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.processResultSet(Unknown Source)
at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.processQuery(Unknown Source)
at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.run(Unknown Source)
at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(Unknown Source)
at java.lang.Thread.run(Thread.java:744)

Discussion

1 2 > >> (Page 1 of 2)
  • Jjarmolowicz
    Jjarmolowicz
    2014-03-18

    Hi Jens!

    Can you share a column/table DDL?
    Also sample data (any geometry that is causing an error) would be usefull.

     
  • Jens Berke
    Jens Berke
    2014-03-19

    Hi,

    here's an example which reproduces the bug on my system when selecting the inserted values:

    CREATE TABLE SQUIRREL_BUG_1137 (
    ID BIGINT PRIMARY KEY
    );
    SELECT AddGeometryColumn('public', 'squirrel_bug_1137', 'geometry', 25832, 'multipolygon', 2);

    INSERT INTO SQUIRREL_BUG_1137 (ID, GEOMETRY)
    VALUES (1, ST_GeometryFromText('MULTIPOLYGON(((449273.647 6054547.602,449296.68 6054666.6652,449451.8874 6054651.7823,449395.1907 6054531.3017,449273.647 6054547.602)))', 25832));

    SELECT * FROM SQUIRREL_BUG_1137;

     
  • Jens Berke
    Jens Berke
    2014-03-19

    thanks for the patch. I copied the postgres.jar the the plugins folder of my installaton. However, I get two different class cast exceptions now. Moreover, the text in the query result for the geometry column is different now as well:

    "Cannot edit table because table cannot be foundor table name is not unique in DB."

    First kind of class cast exception:

    If I have a postgis-jdbc-2.0.jar for PostGIS 2.0 added to the "extra class path" of the PostgreSQL driver I get:

    2014-03-19 13:27:37,121 [Thread-3] ERROR net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlGeometryTypeDataTypeComponent - Unexpected exception while attempting to read PostgreSQL Geometry column
    java.lang.ClassCastException: org.postgis.PGgeometry cannot be cast to org.postgis.PGgeometry
    at net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlGeometryTypeDataTypeComponent.readResultSet(PostgreSqlGeometryTypeDataTypeComponent.java:175)
    at net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.CellComponentFactory.readResultSet(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.sql.ResultSetReader.doContentTabRead(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.sql.ResultSetReader.readRow(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet.createRow(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet._setResultSet(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.datasetviewer.ResultSetDataSet.setSqlExecutionTabResultSet(Unknown Source)
    at net.sourceforge.squirrel_sql.client.session.mainpanel.SQLExecutionHandler.sqlResultSetAvailable(Unknown Source)
    at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.processResultSet(Unknown Source)
    at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.processQuery(Unknown Source)
    at net.sourceforge.squirrel_sql.client.session.SQLExecuterTask.run(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:744)

    Second kind of class cast exception:

    If I don't have a postgis-jdbc-2.0.jar added to the "extra class path" of the PostgreSQL driver I get the same stack but the class cast is slightly different:

    2014-03-19 13:19:53,430 [Thread-4] ERROR net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlGeometryTypeDataTypeComponent - Unexpected exception while attempting to read PostgreSQL Geometry column
    java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to org.postgis.PGgeometry

     
  • Jjarmolowicz
    Jjarmolowicz
    2014-03-19

    Ok. The distribution seams to be acting differently than dev environment. Reproduced locally, trying to fix...

     
  • Jjarmolowicz
    Jjarmolowicz
    2014-03-19

    How about this one...

     
    Attachments
  • Jens Berke
    Jens Berke
    2014-03-19

    That fixed it, I don't get exceptions anymore. But the query result for the geometry column looks different, depending on the postgis-jdbc-jar:

    If I have a postgis-jdbc-2.0.jar for PostGIS 2.0 added to the "extra class path" of the PostgreSQL driver I get a correct result:

    SRID=25832;MULTIPOLYGON(((449273.647 6054547.602,449296.68 6054666.6652,449451.8874 6054651.7823,449395.1907 6054531.3017,449273.647 6054547.602)))

    If I don't have a postgis-jdbc-2.0.jar added to the "extra class path" of the PostgreSQL driver the result is a long hex value instead:

    0106000020E86400000100000001030000000100000005000000022B8796E66B1B41022B87E6A418574185EB51B8426C1B4105A392AAC2185741EA95B28CAF6E1B41053411F2BE1857415DDC46C3CC6D1B41840D4FD3A0185741022B8796E66B1B41022B87E6A4185741

    The hex value probably is the output created by the pretty old postgis-jdbc-1.3.3.jar in Squirrel's plugin directory. If that's the case and the hex value is not a parsing error by Squirrel I'd consider this bug fixed :)

    Thanks a lot for your work on this tool!

     
  • Jjarmolowicz
    Jjarmolowicz
    2014-03-19

    Well there is a mess with jars currently, but we will fix it. Actually the hex representation is native postges-jdbc, PgAdmin shows geometry as hex also. What I did is to detect if we got Geometry (means we got postgis on classpath), than call a method of PGgeometry to pretty print geometry as WKT.

     
  • Gerd Wagner
    Gerd Wagner
    2014-03-19

    • status: open --> closed-fixed
     
  • Gerd Wagner
    Gerd Wagner
    2014-03-19

    Patches #64 and #65 have been committed to our Git repository and will be available in future snapshots and versions.

    Thanks to Jaroslaw Jarmolowicz for the patches.

     
1 2 > >> (Page 1 of 2)