db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4513) Forbid NEXT VALUE FOR clause in certain contexts
Date Sun, 07 Feb 2010 02:10:28 GMT

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

Rick Hillegas updated DERBY-4513:

    Attachment: derby-4513_01-aa-illegalContexts.diff

Attaching derby-4513_01-aa-illegalContexts.diff. This patch prevents you from using a NEXT
VALUE FOR clause in the following situations:


o Aggregates and GROUP BY expressions

o DISTINCT and ORDER BY expressions

o CASE expressions

o CHECK constraints and generation clauses

The limitations imposed by this patch are more restrictive than what the SQL Standard allows:

o Only one NEXT VALUE FOR expression is allowed per sequence per statement.

o NEXT VALUE FOR is not allowed in any statement which has a DISTINCT or ORDER BY expression.

When these limitations are checked in, I will create another JIRA to track the fact that Derby
is more restrictive than the Standard allows. We can consider relaxing limitations which users
find onerous.

Touches the following files


M      java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
M      java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java

The compiler context now tracks which sequences are mentioned in the statement.


M      java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj

Statements which have DISTINCT and ORDER BY expressions are marked so that the bind() logic
can reject NEXT VALUE FOR clauses.


M      java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
M      java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
M      java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
M      java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java
M      java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
M      java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
M      java/engine/org/apache/derby/impl/sql/compile/NextSequenceNode.java

Bind() logic to reject NEXT VALUE FOR in illegal situations.


M      java/engine/org/apache/derby/loc/messages.xml
M      java/shared/org/apache/derby/shared/common/reference/SQLState.java

New error messages.


M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequencePermsTest.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceTest.java

Regression tests.


> Forbid NEXT VALUE FOR clause in certain contexts
> ------------------------------------------------
>                 Key: DERBY-4513
>                 URL: https://issues.apache.org/jira/browse/DERBY-4513
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:
>            Reporter: Rick Hillegas
>            Assignee: Rick Hillegas
>         Attachments: derby-4513_01-aa-illegalContexts.diff
> This is part of the work needed to implement ANSI/ISO sequences. The functional spec
attached to DERBY-712 lists various situations in which the NEXT VALUE FOR clause is illegal.
These include:
>     * CASE expression
>     * WHERE clause
>     * ORDER BY clause
>     * AGGREGATE expression
>     * WINDOW function
>     * DISTINCT select list
> In addition, I propose that we make it illegal for a statement to have more than one
NEXT VALUE FOR clause on the same sequence generator. This is a tighter restriction than the
ANSI/ISO standard calls for. The standard requires that if two columns in a row are populated
by NEXT VALUE FOR clauses on the same sequence, then the values should be the same. I don't
feel confident that I could track down all of the cases which could give rise to this situation--so
I propose to limit the number of NEXT VALUE FOR clauses on a given sequence generator to just

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message