Hi,
I have a simple test case, where it cannot run but throws an NPE. I have
tested in 1.4.196 and in the head revision.

There seems to be a second issue whereby this cannot be rerun (in the
console at least) since you  get this error, as if the WITH condition has
created a persistent view.

Hope this helps!

regards,

Mike

Cannot drop "B" because "BB, BB" depends on it; SQL statement:
<http://192.168.0.15:49741/query.do?jsessionid=6cdf827bc58d664086f36b8ae0985c48#>
----------------------------------------

DROP TABLE IF EXISTS A;
DROP TABLE IF EXISTS B;
DROP TABLE IF EXISTS C;
CREATE TABLE A(VAL VARCHAR(255));
CREATE TABLE B(A VARCHAR(255), VAL VARCHAR(255));
CREATE TABLE C(B VARCHAR(255), VAL VARCHAR(255));

INSERT INTO A VALUES('fruit');
INSERT INTO B VALUES('fruit','apple');
INSERT INTO B VALUES('fruit','banana');
INSERT INTO C VALUES('apple', 'golden delicious');
INSERT INTO C VALUES('apple', 'granny smith');
INSERT INTO C VALUES('apple', 'pippin');
INSERT INTO A VALUES('veg');
INSERT INTO B VALUES('veg', 'carrot');
INSERT INTO C VALUES('carrot', 'nantes');
INSERT INTO C VALUES('carrot', 'imperator');
INSERT INTO C VALUES(null, 'banapple');
INSERT INTO A VALUES('meat');

WITH BB as (SELECT
        sum(1) as X,
        a
    FROM B
    JOIN C ON B.val=C.b
    GROUP BY a)
SELECT
    A.val,
    sum(SELECT X FROM BB WHERE BB.a IS A.val)
FROM A
GROUP BY A.val;;


-----------------------------------
This is the NullPointerExeption trying to run the select.

General error: "java.lang.NullPointerException" [50000-196]
<http://192.168.0.15:49741/query.do?jsessionid=6cdf827bc58d664086f36b8ae0985c48#>
HY000/50000 (Help)
<http://h2database.com/javadoc/org/h2/api/ErrorCode.html#c50000>
org.h2.jdbc.JdbcSQLException: General error:
"java.lang.NullPointerException" [50000-196]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345
<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=345&build=196>)

    at org.h2.message.DbException.get(DbException.java:168
<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=168&build=196>)

    at org.h2.message.DbException.convert(DbException.java:295
<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=295&build=196>)

    at org.h2.message.DbException.toSQLException(DbException.java:268
<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=268&build=196>)

    at org.h2.message.TraceObject.logAndConvert(TraceObject.java:358
<http://h2database.com/html/source.html?file=org/h2/message/TraceObject.java&line=358&build=196>)

    at
org.h2.jdbc.JdbcResultSetMetaData.getColumnLabel(JdbcResultSetMetaData.java:70
<http://h2database.com/html/source.html?file=org/h2/jdbc/JdbcResultSetMetaData.java&line=70&build=196>)

    at org.h2.server.web.WebApp.getResultSet(WebApp.java:1646
<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1646&build=196>)

    at org.h2.server.web.WebApp.getResult(WebApp.java:1397
<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1397&build=196>)

    at org.h2.server.web.WebApp.query(WebApp.java:1053
<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1053&build=196>)

    at org.h2.server.web.WebApp$1.next(WebApp.java:1015
<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1015&build=196>)

    at org.h2.server.web.WebApp$1.next(WebApp.java:1
<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1&build=196>)

    at org.h2.server.web.WebThread.process(WebThread.java:164
<http://h2database.com/html/source.html?file=org/h2/server/web/WebThread.java&line=164&build=196>)

    at org.h2.server.web.WebThread.run(WebThread.java:89
<http://h2database.com/html/source.html?file=org/h2/server/web/WebThread.java&line=89&build=196>)

    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at org.h2.util.StringUtils.indent(StringUtils.java:594
<http://h2database.com/html/source.html?file=org/h2/util/StringUtils.java&line=594&build=196>)

    at org.h2.util.StringUtils.indent(StringUtils.java:582
<http://h2database.com/html/source.html?file=org/h2/util/StringUtils.java&line=582&build=196>)

    at org.h2.table.TableView.getSQL(TableView.java:442
<http://h2database.com/html/source.html?file=org/h2/table/TableView.java&line=442&build=196>)

    at org.h2.table.TableFilter.getPlanSQL(TableFilter.java:824
<http://h2database.com/html/source.html?file=org/h2/table/TableFilter.java&line=824&build=196>)

    at org.h2.command.dml.Select.getPlanSQL(Select.java:1103
<http://h2database.com/html/source.html?file=org/h2/command/dml/Select.java&line=1103&build=196>)

    at org.h2.expression.Subquery.getSQL(Subquery.java:93
<http://h2database.com/html/source.html?file=org/h2/expression/Subquery.java&line=93&build=196>)

    at org.h2.expression.Aggregate.getSQL(Aggregate.java:574
<http://h2database.com/html/source.html?file=org/h2/expression/Aggregate.java&line=574&build=196>)

    at org.h2.expression.Expression.getAlias(Expression.java:245
<http://h2database.com/html/source.html?file=org/h2/expression/Expression.java&line=245&build=196>)

    at org.h2.result.LocalResult.getAlias(LocalResult.java:439
<http://h2database.com/html/source.html?file=org/h2/result/LocalResult.java&line=439&build=196>)

    at
org.h2.jdbc.JdbcResultSetMetaData.getColumnLabel(JdbcResultSetMetaData.java:68
<http://h2database.com/html/source.html?file=org/h2/jdbc/JdbcResultSetMetaData.java&line=68&build=196>)

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to