Skip to content

Wrong WKB produced by jdbc driver when reading geometry type #486

@lukaseder

Description

@lukaseder

Try this:

try (Statement s = connection.createStatement()) {
    s.executeUpdate("install spatial");
    s.executeUpdate("load spatial");

    try (ResultSet rs = s.executeQuery("select cast('point (1 1)' as geometry)")) {
        rs.next();
        println(HexFormat.of().formatHex(rs.getBytes(1)));
    }
}

This prints:

00000000000000000000000001000000000000000000f03f000000000000f03f

Which is an invalid WKB representation of point(1 1). The correct representation is:

0101000000000000000000f03f000000000000f03f

This can be validated with this query:

select st_ashexwkb(cast ('POINT(1 1)' as geometry));

Or also with PostgreSQL:

select encode(st_asbinary(cast('point (1 1)' as geometry)), 'hex')`

I'm not sure if this is a duckdb_jdbc problem or a duckdb problem. Feel free to move the issue if it's not a JDBC problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions