[ https://issues.apache.org/jira/browse/DERBY-6378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13807192#comment-13807192 ]
ASF subversion and git services commented on DERBY-6378: -------------------------------------------------------- Commit 1536507 from [~dagw] in branch 'code/trunk' [ https://svn.apache.org/r1536507 ] DERBY-6378 OFFSET/FETCH NEXT ignored when query is enclosed in parentheses Patch derby-6378-4. To address the required generality of several layers of nested multiple clauses allowed by SQL, this patch introduces a stack mechanism for order by and offset/fetch clauses, factored out into ResultSetNode#QueryExpressionClause (nested class). From the javadoc for that class: For ease of handling order by clause, offset clause and fetch first/next clauses in subclasses. Clauses on the same nesting level have the same index in the lists, so at any level, any of the lists' elements may be empty. For example, (select * from t order by a fetch next 5 rows only) order by b would have obl[0] = "order by a", offset[0] = null, fetchFirst[0] = "next 5 rows" and obl[1] = "order by b", offset[1] = null fetchFirst[1] = null When starting a new level, always remember to do a push() before adding clauses via setOffset(org.apache.derby.impl.sql.compile.ValueNode), setFetchFirst(org.apache.derby.impl.sql.compile.ValueNode), setOrderByList(org.apache.derby.impl.sql.compile.OrderByList) and setHasJDBCLimitClause(java.lang.Boolean). Added tests to OrderByAndOffsetFetchInSubqueries in #testDerby6378, running regressions. > 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, derby-6378-2.diff, > derby-6378-2.status, derby-6378-3.diff, derby-6378-3.status, > derby-6378-4.diff, derby-6378-4.status > > > 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)