Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JavaTableFunction is not closing underlying ResultSet when reading column list #3434

@Axinet

Description

@Axinet

Hello,

I have recently discovered issue with function org.h2.schema.FunctionAlias.JavaMethod#resultSetToResult which leaves ResultSet rs passed in argument unclosed, when int maxrows =0 (we are reading only column metadata, not full data).

When we read all rows, after the last row (next() == null) result set is closed, but we only read metadata result set is kept hanging open. It is an issue, when for custom JavaTableFunction we use a file based result set, as we end up with lots of open file handlers.

For now based on https://github.com/h2database/h2database/blob/45b609dec0e45125e6a93f85c9018d34551332a1/h2/src/test/org/h2/samples/Function.java getMatrix example, we were able to inject Connection in our function and in case of when conn.getMetaData().getURL().equals("jdbc:columnlist:connection") we return a new SimpleResultSet with only column metadata set, and only otherwise File based result set, but in our opinion that result sets used in resultSetToResult should be closed by library, not by us.

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