ilovejs / h2database

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

Quoting of columns not parsed correctly #596

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using subqueries and quoting the column names, I face a problem with the 
parser:

org.h2.jdbc.JdbcSQLException: Duplicate column name "ID_ACCOUNTING_SCOPE"; SQL 
statement:
SELECT /* + parallel */ 
     "ID_ACCOUNTING_SCOPE"  "ID_ACCOUNTING_SCOPE"
FROM (SELECT a.ID_ACCOUNTING_SCOPE "ID_ACCOUNTING_SCOPE"
FROM   cfe.accounting_scope a
       INNER JOIN cfe.sys_accounting_scope_code b
               ON a.id_accounting_scope_code = b.id_accounting_scope_code 
)  [42121-184]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.table.Table.setColumns(Table.java:410)
    at org.h2.table.TableView.initColumnsAndTables(TableView.java:211)
    at org.h2.table.TableView.init(TableView.java:102)
    at org.h2.table.TableView.<init>(TableView.java:67)
    at org.h2.table.TableView.createTempView(TableView.java:512)
    at org.h2.command.Parser.readTableFilter(Parser.java:1170)
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1866)
    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)
    at java.lang.Thread.run(Thread.java:745)

    at org.h2.engine.SessionRemote.done(SessionRemote.java:622)
    at org.h2.command.CommandRemote.prepare(CommandRemote.java:68)
    at org.h2.command.CommandRemote.<init>(CommandRemote.java:45)
    at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:492)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1189)
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:72)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:277)

Additional explanation on the given sample: It is generated automatically by a 
report designer, which is fed with the subquery only. This subquery may use 
labels, which needs quotes and also are case sensitive, e.g. "My First 
ColumnName".
The given example works well with Oracle at least (which is technically a poor 
argument, but market share wise ...).

Original issue reported on code.google.com by andreas....@gmail.com on 6 Jan 2015 at 5:49

GoogleCodeExporter commented 9 years ago
Apologies, the mistake is on my side as the same column name exists in a and b 
tables.
Please discard this issue.

Original comment by andreas....@gmail.com on 6 Jan 2015 at 5:56

GoogleCodeExporter commented 9 years ago

Original comment by noelgrandin on 6 Jan 2015 at 7:53