db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1495) Attempt to modify an identity column error after resetting identity column
Date Wed, 20 Sep 2006 15:58:25 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1495?page=comments#action_12436264 ] 
            
Kristian Waagan commented on DERBY-1495:
----------------------------------------

Thanks Bryan.

I have been able to determine what seems to be causing the problem, but have not yet understood
how to fix it. This is my first venture into the this area of the code, so things are very
unclear to me.

First, after studying the various variables describing an identity column, I noticed that
if the DefaultInfo assoiciated with an identity column is null, the column is said to be "generated
always as identity". In effect, the column definition is changed after the restart/increment
operation, because the defaultInfo is set to null. This can be observed with the new describe
command in ij.

Bryan's guess seems to be valid, but if I add the old DefaultInfoImpl instance to the new
one, I get a NPE when doing a drop on the table the next time I boot the database. It happens
for 'BasicDependencyManager.clearDependencies'. It also happens if I create a new instance
(new DefaultInfoImpl(true,null,null)) and add it to the newly created ColumnDescriptor. This
piece of the code is in AlterTableConstantAction.modifyColumnDefault, as Bryan mentioned.

Is the error in this method, or does it happen earlier so the input is not as expected?
What step have I forgotten to do?

I'll keep looking into this, but any piece of further advice is appreciated!

> Attempt to modify an identity column error after resetting identity column
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1495
>                 URL: http://issues.apache.org/jira/browse/DERBY-1495
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.2.1.0
>         Environment: Java 1.5.0_06-b05 on Linux Ubuntu 5.10. Derby version 10.2.0.3-412239
>            Reporter: Lars Gråmark
>            Priority: Minor
>
> When an identity counter is altered using the ALTER TABLE statement below, it seems as
if the GENERATED BY DEFAULT behavior is lost.
> The following statements will reproduce the error.
> CREATE TABLE MYTABLE (
>   id   INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL
>  ,col2 INT NOT NULL
> )
> -- Insert using an explicit value on the ID-field
> INSERT INTO MYTABLE(ID, COL2) VALUES(2, 2)
> -- Reset the identity field
> ALTER TABLE mytable ALTER COLUMN id RESTART WITH 3
> -- Try inserting another explicit value and the error below is thrown.
> INSERT INTO MYTABLE(ID, COL2) VALUES(4, 4)
> Error: SQL Exception: Attempt to modify an identity column 'ID'. , SQL State: 42Z23,
Error Code: 30000
> -- Although, this works fine
> INSERT INTO MYTABLE(COL2) VALUES(4)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message