[ 
https://issues.apache.org/jira/browse/DERBY-6378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13797933#comment-13797933
 ] 

Dag H. Wanvik edited comment on DERBY-6378 at 10/17/13 2:22 PM:
----------------------------------------------------------------

The following code failed with an assert failure. It's a similar unexpected 
push down for
ORDER BY:

{code}
(select * from t1 order by a,b fetch first 1 rows only) order by a,b desc
{code}

{code:title=AssertFailure|borderStyle=solid}
testDerby6378(org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest)java.sql.SQLException:
 Java exception: 'ASSERT FAILED: 
org.apache.derby.shared.common.sanity.AssertFailure'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:103)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:137)
        at org.apache.derby.impl.jdbc.Util.javaException(Util.java:331)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:436)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2395)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:691)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:147)
        at 
org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest.testDerby6378(OffsetFetchNextTest.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at 
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:117)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:440)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:457)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at 
singlederbyjunittest.SingleDerbyJunitTest.main(SingleDerbyJunitTest.java:22)
Caused by: java.sql.SQLException: Java exception: 'ASSERT FAILED: 
org.apache.derby.shared.common.sanity.AssertFailure'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:141)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
        ... 34 more
Caused by: org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED
        at 
org.apache.derby.shared.common.sanity.SanityManager.ASSERT(SanityManager.java:98)
        at 
org.apache.derby.impl.sql.compile.SelectNode.pushOrderByList(SelectNode.java:986)
        at 
org.apache.derby.impl.sql.compile.CursorNode.optimizeStatement(CursorNode.java:591)
        at 
org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:459)
        at 
org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
        at 
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1109)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:683)
        ... 27 more
2) 
testDerby6378(org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest)java.sql.SQLException:
 DERBY SQL error: ERRORCODE: 0, SQLSTATE: XJ001, SQLERRMC: 
org.apache.derby.shared.common.sanity.AssertFailureASSERT FAILEDXJ001.U
        at 
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:112)
        at 
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:321)
        at 
org.apache.derby.client.am.ClientStatement.executeQuery(ClientStatement.java:515)
        at 
org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest.testDerby6378(OffsetFetchNextTest.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at 
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:117)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:440)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:457)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
singlederbyjunittest.SingleDerbyJunitTest.main(SingleDerbyJunitTest.java:22)
Caused by: org.apache.derby.client.am.SqlException: DERBY SQL error: ERRORCODE: 
0, SQLSTATE: XJ001, SQLERRMC: 
org.apache.derby.shared.common.sanity.AssertFailureASSERT FAILEDXJ001.U
        at 
org.apache.derby.client.am.ClientStatement.completeSqlca(ClientStatement.java:2119)
        at 
org.apache.derby.client.net.NetStatementReply.parsePrepareError(NetStatementReply.java:579)
        at 
org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(NetStatementReply.java:145)
        at 
org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(NetStatementReply.java:54)
        at 
org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(StatementReply.java:41)
        at 
org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(NetStatement.java:156)
        at 
org.apache.derby.client.am.ClientStatement.readPrepareDescribeOutput(ClientStatement.java:1703)
        at 
org.apache.derby.client.am.ClientStatement.flowExecute(ClientStatement.java:2392)
        at 
org.apache.derby.client.am.ClientStatement.executeQueryX(ClientStatement.java:521)
        at 
org.apache.derby.client.am.ClientStatement.executeQuery(ClientStatement.java:506)
        ... 35 more
{code}



was (Author: dagw):
{code:title=AssertFailure|borderStyle=solid}
testDerby6378(org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest)java.sql.SQLException:
 Java exception: 'ASSERT FAILED: 
org.apache.derby.shared.common.sanity.AssertFailure'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:103)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:137)
        at org.apache.derby.impl.jdbc.Util.javaException(Util.java:331)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:436)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2395)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:691)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:147)
        at 
org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest.testDerby6378(OffsetFetchNextTest.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at 
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:117)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:440)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:457)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at 
singlederbyjunittest.SingleDerbyJunitTest.main(SingleDerbyJunitTest.java:22)
Caused by: java.sql.SQLException: Java exception: 'ASSERT FAILED: 
org.apache.derby.shared.common.sanity.AssertFailure'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:141)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:73)
        ... 34 more
Caused by: org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED
        at 
org.apache.derby.shared.common.sanity.SanityManager.ASSERT(SanityManager.java:98)
        at 
org.apache.derby.impl.sql.compile.SelectNode.pushOrderByList(SelectNode.java:986)
        at 
org.apache.derby.impl.sql.compile.CursorNode.optimizeStatement(CursorNode.java:591)
        at 
org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:459)
        at 
org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
        at 
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1109)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:683)
        ... 27 more
2) 
testDerby6378(org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest)java.sql.SQLException:
 DERBY SQL error: ERRORCODE: 0, SQLSTATE: XJ001, SQLERRMC: 
org.apache.derby.shared.common.sanity.AssertFailureASSERT FAILEDXJ001.U
        at 
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:112)
        at 
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:321)
        at 
org.apache.derby.client.am.ClientStatement.executeQuery(ClientStatement.java:515)
        at 
org.apache.derbyTesting.functionTests.tests.lang.OffsetFetchNextTest.testDerby6378(OffsetFetchNextTest.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at 
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:117)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBareOverridable(BaseJDBCTestCase.java:440)
        at 
org.apache.derbyTesting.junit.BaseJDBCTestCase.runBare(BaseJDBCTestCase.java:457)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
singlederbyjunittest.SingleDerbyJunitTest.main(SingleDerbyJunitTest.java:22)
Caused by: org.apache.derby.client.am.SqlException: DERBY SQL error: ERRORCODE: 
0, SQLSTATE: XJ001, SQLERRMC: 
org.apache.derby.shared.common.sanity.AssertFailureASSERT FAILEDXJ001.U
        at 
org.apache.derby.client.am.ClientStatement.completeSqlca(ClientStatement.java:2119)
        at 
org.apache.derby.client.net.NetStatementReply.parsePrepareError(NetStatementReply.java:579)
        at 
org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(NetStatementReply.java:145)
        at 
org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(NetStatementReply.java:54)
        at 
org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(StatementReply.java:41)
        at 
org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(NetStatement.java:156)
        at 
org.apache.derby.client.am.ClientStatement.readPrepareDescribeOutput(ClientStatement.java:1703)
        at 
org.apache.derby.client.am.ClientStatement.flowExecute(ClientStatement.java:2392)
        at 
org.apache.derby.client.am.ClientStatement.executeQueryX(ClientStatement.java:521)
        at 
org.apache.derby.client.am.ClientStatement.executeQuery(ClientStatement.java:506)
        ... 35 more
{code}


> OFFSET/FETCH NEXT ignored when query is enclosed in parentheses
> ---------------------------------------------------------------
>
>                 Key: DERBY-6378
>                 URL: https://issues.apache.org/jira/browse/DERBY-6378
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.10.1.1
>            Reporter: Knut Anders Hatlen
>            Assignee: Dag H. Wanvik
>         Attachments: derby-6378-1.diff
>
>
> ij version 10.10
> ij> connect 'jdbc:derby:memory:db;create=true';
> ij> create table t(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t values 1,2,3;
> 3 rows inserted/updated/deleted
> ij> select * from t offset 1 row fetch first 1 row only;
> X          
> -----------
> 2          
> 1 row selected
> ij> (select * from t offset 1 row fetch first 1 row only);
> X          
> -----------
> 1          
> 2          
> 3          
> 3 rows selected
> I would have expected that both of the queries had returned a single row.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to