[ 
https://issues.apache.org/jira/browse/DERBY-6378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dag H. Wanvik updated DERBY-6378:
---------------------------------

    Attachment: derby-6378-2.diff
                derby-6378-2.status

Uploading a second patch for this issue, which introduced a stack mechanism for 
order by and offset/fetch clauses, factored out into 
ResultSetNode#QueryExpressionClause (nested class). From the javadoc for that 
class
{panel}
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
{noformat}
            obl[0] = "order by a",
            offset[0] = null,
            fetchFirst[0] = "next 5 rows"
{noformat} 
and
{noformat}
            obl[0} = "order by b",
            offset[1] = null
            fetchFirst[1] = null
{noformat}
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).
{panel}

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
>
>
> 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