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-481) implement SQL generated columns
Date Tue, 04 Nov 2008 21:06:44 GMT

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

Rick Hillegas updated DERBY-481:

    Attachment: derby-481-11-aa-notNull.diff

Attaching derby-481-11-aa-notNull.diff. Running tests now. This patch adds support for NOT
NULL constraints on generated columns. Makes the following changes:

A) Exposes the "normalization" logic in NormalizeResultSet and applies this logic to generated
columns. This logic is what enforces NOT NULL constraints. This logic was already being called
by the INSERT and UPDATE execution-time logic after populating the target row. Using the terms
introduced above with the summary of patch derby-481-04-aa-insert.diff: the normalization
logic was being called immediately after (1') executed but it wasn't being called after (2')
was executed. Now this logic is also called on generated columns after they are populated--that
is, after (2') runs.

B) Loosens a condition which prevents ALTER TABLE from adding new columns which don't have
DEFAULT clauses. Now it's ok to add these clauses with NOT NULL if they are generated columns.

C) Adds some tests to verify (A) and (B).

Touches the following files:

M      java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java

Exposes the "normalization" logic which is called after (1') runs.

M      java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
M      java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java

Adds a new method to ResultColumnDescriptors so that they can be asked whether they represent
generated columns. This is useful so that we only call the normalization logic on generated
columns rather than all columns in the target row.

M      java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java

Calls the normalization logic on generated columns just after (2') runs. Slightly changes
the signature of evaluateGenerationClauses().

M      java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
M      java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java

Reworks calls to evaluateGenerationClauses().

M      java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java

Changes the ALTER TABLE logic for (B).

M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java

Adds new tests.

> implement SQL generated columns
> -------------------------------
>                 Key: DERBY-481
>                 URL: https://issues.apache.org/jira/browse/DERBY-481
>             Project: Derby
>          Issue Type: New Feature
>          Components: SQL
>    Affects Versions:
>            Reporter: Rick Hillegas
>            Assignee: Rick Hillegas
>         Attachments: derby-481-00-aa-prototype.diff, derby-481-01-aa-catalog.diff, derby-481-02-aa-utilities.diff,
derby-481-03-aa-grammar.diff, derby-481-04-aa-insert.diff, derby-481-05-aa-update.diff, derby-481-06-aa-genreferences.diff,
derby-481-07-aa-noSQLinRoutines.diff, derby-481-07-ab-noSQLinRoutines.diff, derby-481-08-aa-castToDeclaredType.diff,
derby-481-09-aa-dummyDefaults.diff, derby-481-10-aa-foreignKeyActions.diff, derby-481-11-aa-notNull.diff,
> Satheesh has pointed out that generated columns, a SQL 2003 feature, would satisfy the
performance requirements of Expression Indexes (bug 455). Generated columns may not be as
elegant as Expression Indexes, but they are easier to implement. We would allow the following
new kind of column definition in CREATE TABLE and ALTER TABLE statements:
>     columnName GENERATED ALWAYS AS ( expression )
> If expression were an indexableExpression (as defined in bug 455), then we could create
indexes on it. There is no work for the optimizer to do here. The Language merely has to compute
the generated column at INSERT/UPDATE time.

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

View raw message