jOOQ / jOOQ

jOOQ is the best way to write SQL in Java
https://www.jooq.org
Other
6.15k stars 1.21k forks source link

Logged exception in initLongIndexes with Oracle ojdbc8 and returning #12711

Closed hesselink closed 2 years ago

hesselink commented 2 years ago

Expected behavior

An Oracle insert query with a returning clause works and doesn't log an exception.

Actual behavior

The query still seems to work, but logs an exception.

Steps to reproduce the problem

We had a query like this:

dsl.insertInto(TABLE)
                    .set(BLAH, value)
...
                    .onConflict(THING)
                    .doNothing()
                    .returning(SOMETHING)
                    .fetchOptional();

On Oracle (using ojdbc8) we found that, while the code seemed to function, it was logging an exception at INFO level:

java.sql.SQLException: Unsupported feature: getMetaData
    at oracle.jdbc.driver.ArrayDataResultSet.getMetaData(ArrayDataResultSet.java:1098)
    at com.zaxxer.hikari.pool.HikariProxyResultSet.getMetaData(HikariProxyResultSet.java)
    at org.jooq.tools.jdbc.DefaultResultSet.getMetaData(DefaultResultSet.java:293)
    at org.jooq.impl.CursorImpl$CursorResultSet.getMetaData(CursorImpl.java:527)
    at org.jooq.impl.CursorImpl.initLongIndexes(CursorImpl.java:167)
    at org.jooq.impl.CursorImpl.<init>(CursorImpl.java:142)
    at org.jooq.impl.CursorImpl.<init>(CursorImpl.java:126)
    at org.jooq.impl.AbstractDMLQuery.execute(AbstractDMLQuery.java:839)
    at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:350)
    at org.jooq.impl.InsertImpl.fetchOne(InsertImpl.java:1061)
    at org.jooq.impl.InsertImpl.fetchOptional(InsertImpl.java:1068)

It looks like jooq tries to work around an Oracle issue for LONGVARCHAR and LONGVARBINARY columns in initLongIndexes, where it calls getMetaData, but that is implemented to throw in the Oracle driver for ArrayDataResultSet.

The issue looks like it might be related to or a duplicate of #5543, but I wasn't sure so decided to file.

Versions

lukaseder commented 2 years ago

Thanks a lot for your report.

To help try reproducing this, can you please provide your DDL (CREATE TABLE) for TABLE, BLAH, THING, SOMETHING, and all the TABLE / VARRAY / OBJECT types that may be involved here?

Note: A lot of things have improved with the INSERT .. RETURNING implementation since jOOQ 3.11, can you confirm this particular issue is still present in 3.15.5?

The issue looks like it might be related to or a duplicate of #5543, but I wasn't sure so decided to file.

I don't think these are related. The other issue is about an ojdbc bug. This one looks like an unsupported feature in ojdbc.

lukaseder commented 2 years ago

Duplicate of https://github.com/jOOQ/jOOQ/issues/13473, which was fixed in jOOQ 3.17.0, 3.16.7 (https://github.com/jOOQ/jOOQ/issues/13474), and 3.15.11 (https://github.com/jOOQ/jOOQ/issues/13475)