Hi, I'd like your opinion on the following bug/RFE for H2 1.3.171:
1. Given this table: CREATE TABLE connections (id IDENTITY, call_id BIGINT NOT NULL, from_participant_id BIGINT NOT NULL, to_participant_id BIGINT NOT NULL, creation_time TIMESTAMP NOT NULL, messages_md5 VARCHAR(32) NOT NULL, messages_last_modified TIMESTAMP NOT NULL, expired BOOLEAN NOT NULL, UNIQUE (from_participant_id, to_participant_id), FOREIGN KEY (call_id) REFERENCES calls(id) ON DELETE CASCADE, FOREIGN KEY (from_participant_id) REFERENCES participants(id) ON DELETE CASCADE, FOREIGN KEY (to_participant_id) REFERENCES participants(id) ON DELETE CASCADE, CHECK (SELECT participants.call_id FROM calls, participants WHERE participants.id IN (from_participant_id, to_participant_id)) = call_id); 2. When I insert into this table, it fails with the following stack-trace: com.mysema.query.QueryException: Caught JdbcSQLException for insert into CONNECTIONS (CALL_ID, FROM_PARTICIPANT_ID, TO_PARTICIPANT_ID, CREATION_TIME, MESSAGES_MD5, MESSAGES_LAST_MODIFIED, EXPIRED) values (?, ?, ?, ?, ?, ?, ?) at com.mysema.query.sql.dml.SQLInsertClause.executeWithKeys(SQLInsertClause.java:294) ~[querydsl-sql-3.2.0.jar:na] at com.mysema.query.sql.dml.SQLInsertClause.executeWithKey(SQLInsertClause.java:171) ~[querydsl-sql-3.2.0.jar:na] at com.mysema.query.sql.dml.SQLInsertClause.executeWithKey(SQLInsertClause.java:163) ~[querydsl-sql-3.2.0.jar:na] at com.mycompany.sql.row.Connection.insert(Connection.java:56) ~[server.service-1.0-SNAPSHOT.jar:na] at com.mycompany.web.resource.CallResource.createConnection(CallResource.java:332) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_21] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_21] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_21] at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_21] at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) ~[jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511) [jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442) [jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391) [jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381) [jersey-server-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) [jersey-servlet-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538) [jersey-servlet-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:910) [jersey-servlet-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:858) [jersey-servlet-1.17.1.jar:1.17.1] at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:812) [jersey-servlet-1.17.1.jar:1.17.1] at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na] at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na] at com.mycompany.web.SessionFilter.doFilter(SessionFilter.java:58) [classes/:na] at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na] at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na] at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118) [guice-servlet-3.0.jar:na] at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113) [guice-servlet-3.0.jar:na] at org.glassfish.grizzly.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:137) [grizzly-http-servlet-2.2.16.jar:2.2.16] at org.glassfish.grizzly.servlet.FilterChainImpl.invokeFilterChain(FilterChainImpl.java:106) [grizzly-http-servlet-2.2.16.jar:2.2.16] at org.glassfish.grizzly.servlet.ServletHandler.doServletService(ServletHandler.java:252) [grizzly-http-servlet-2.2.16.jar:2.2.16] at org.glassfish.grizzly.servlet.ServletHandler.service(ServletHandler.java:188) [grizzly-http-servlet-2.2.16.jar:2.2.16] at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164) [grizzly-http-server-2.2.16.jar:2.2.16] at org.glassfish.grizzly.http.server.HttpHandlerChain.service(HttpHandlerChain.java:196) [grizzly-http-server-2.2.16.jar:2.2.16] at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164) [grizzly-http-server-2.2.16.jar:2.2.16] at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:175) [grizzly-http-server-2.2.16.jar:2.2.16] at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:815) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567) [grizzly-framework-2.2.16.jar:2.2.16] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547) [grizzly-framework-2.2.16.jar:2.2.16] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_21] Caused by: org.h2.jdbc.JdbcSQLException: Scalar subquery contains more than one row; SQL statement: insert into CONNECTIONS (CALL_ID, FROM_PARTICIPANT_ID, TO_PARTICIPANT_ID, CREATION_TIME, MESSAGES_MD5, MESSAGES_LAST_MODIFIED, EXPIRED) values (?, ?, ?, ?, ?, ?, ?) [90053-171] at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.171.jar:1.3.171] at org.h2.message.DbException.get(DbException.java:169) ~[h2-1.3.171.jar:1.3.171] at org.h2.message.DbException.get(DbException.java:146) ~[h2-1.3.171.jar:1.3.171] at org.h2.message.DbException.get(DbException.java:135) ~[h2-1.3.171.jar:1.3.171] at org.h2.expression.Subquery.getValue(Subquery.java:40) ~[h2-1.3.171.jar:1.3.171] at org.h2.expression.Comparison.getValue(Comparison.java:206) ~[h2-1.3.171.jar:1.3.171] at org.h2.constraint.ConstraintCheck.checkRow(ConstraintCheck.java:91) ~[h2-1.3.171.jar:1.3.171] at org.h2.table.Table.fireConstraints(Table.java:873) ~[h2-1.3.171.jar:1.3.171] at org.h2.table.Table.fireBeforeRow(Table.java:863) ~[h2-1.3.171.jar:1.3.171] at org.h2.command.dml.Insert.insertRows(Insert.java:121) ~[h2-1.3.171.jar:1.3.171] at org.h2.command.dml.Insert.update(Insert.java:84) ~[h2-1.3.171.jar:1.3.171] at org.h2.command.CommandContainer.update(CommandContainer.java:75) ~[h2-1.3.171.jar:1.3.171] at org.h2.command.Command.executeUpdate(Command.java:230) ~[h2-1.3.171.jar:1.3.171] at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:156) ~[h2-1.3.171.jar:1.3.171] at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:142) ~[h2-1.3.171.jar:1.3.171] at com.mysema.query.sql.dml.SQLInsertClause.executeWithKeys(SQLInsertClause.java:278) ~[querydsl-sql-3.2.0.jar:na] ... 63 common frames omitted 3. As you can see, the error message points to the INSERT statement but in fact the error is in the CHECK constraint. 4. Expected behavior: stack-trace should reference CHECK constraint, not INSERT statement. Can I file a bug report for this? Thanks, Gili -- 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 http://groups.google.com/group/h2-database?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
