feristhia / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Select WILDCARD --> Unexpected code path Exception #601

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
With 1.4 branch he following query fails:

select a1.*
from
    risk.instrument a1
    inner join (
        select a.*
        from risk.INSTRUMENT a
            inner join risk.counterparty b
                on b.id_counterparty=a.id_counterparty
                    and b.id_status='C'
            left join risk.EXECUTION_INSTRUMENT ex 
                on a.ID_INSTRUMENT_REF=ex.ID_INSTRUMENT_REF 
        where
            a.id_status='C'
            and a.fair_value<0
            and ex.ID_EXECUTION_REF is null
    ) b 
        on a1.id_counterparty=b.id_counterparty
            and a1.id_status='C'

--> rg.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: 
Unexpected code path" [50000-185]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:168)
    at org.h2.message.DbException.convert(DbException.java:295)
    at org.h2.server.TcpServerThread.sendError(TcpServerThread.java:221)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:161)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Unexpected code path
    at org.h2.message.DbException.throwInternalError(DbException.java:242)
    at org.h2.message.DbException.throwInternalError(DbException.java:255)
    at org.h2.expression.Wildcard.isEverything(Wildcard.java:100)
    at org.h2.command.dml.Select.isEverything(Select.java:1313)
    at org.h2.table.TableView.isQueryComparable(TableView.java:268)
    at org.h2.expression.Comparison.createIndexConditions(Comparison.java:366)
    at org.h2.expression.ConditionAndOr.createIndexConditions(ConditionAndOr.java:63)
    at org.h2.table.TableFilter.mapAndAddFilter(TableFilter.java:598)
    at org.h2.table.TableFilter.addJoin(TableFilter.java:582)
    at org.h2.command.Parser.readJoin(Parser.java:1526)
    at org.h2.command.Parser.parseJoinTableFilter(Parser.java:1872)
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1867)
    at org.h2.command.Parser.parseSelectSimple(Parser.java:1975)
    at org.h2.command.Parser.parseSelectSub(Parser.java:1860)
    at org.h2.command.Parser.parseSelectUnion(Parser.java:1681)
    at org.h2.command.Parser.parseSelect(Parser.java:1669)
    at org.h2.command.Parser.parsePrepared(Parser.java:433)
    at org.h2.command.Parser.parse(Parser.java:305)
    at org.h2.command.Parser.parse(Parser.java:277)
    at org.h2.command.Parser.prepareCommand(Parser.java:242)
    at org.h2.engine.Session.prepareLocal(Session.java:446)
    at org.h2.server.TcpServerThread.process(TcpServerThread.java:264)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:159)
    ... 1 more

                    General error: "java.lang.RuntimeException: Unexpected code path" [50000-185]

However, when defining certain fields instead of using the wildcard, it works:

select a1.id_instrument
from
    risk.instrument a1
    inner join (
        select a.*
        from risk.INSTRUMENT a
            inner join risk.counterparty b
                on b.id_counterparty=a.id_counterparty
                    and b.id_status='C'
            left join risk.EXECUTION_INSTRUMENT ex 
                on a.ID_INSTRUMENT_REF=ex.ID_INSTRUMENT_REF 
        where
            a.id_status='C'
            and a.fair_value<0
            and ex.ID_EXECUTION_REF is null
    ) b 
        on a1.id_counterparty=b.id_counterparty
            and a1.id_status='C'
--> 23 rows selected

Please note, that the same query worked well with 1.3 branch.

Original issue reported on code.google.com by andreas....@gmail.com on 16 Feb 2015 at 5:12

GoogleCodeExporter commented 9 years ago
Fixed in Revision r6016

Log message

In version 1.4.184, a bug was introduced that broke queries that have both joins
and wildcards, for example: select * from dual join(select x from dual) on 1=1

Original comment by andreas....@gmail.com on 17 Feb 2015 at 3:59

GoogleCodeExporter commented 9 years ago
Should be fixed with version 1.4.186

Original comment by thomas.t...@gmail.com on 2 Mar 2015 at 10:02