Issue Details (XML | Word | Printable)

Key: DERBY-1495
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Bryan Pendleton
Reporter: Lars Gråmark
Votes: 3
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Derby

Attempt to modify an identity column error after resetting identity column

Created: 11/Jul/06 04:50 AM   Updated: 13/Dec/07 09:05 AM
Return to search
Component/s: SQL
Affects Version/s: 10.2.1.6
Fix Version/s: 10.2.2.0, 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works preserveColDefault_v1.diff 2006-11-12 12:36 AM Bryan Pendleton 9 kB
Environment: Java 1.5.0_06-b05 on Linux Ubuntu 5.10. Derby version 10.2.0.3-412239
Issue Links:
Duplicate
 

Resolution Date: 13/Nov/06 08:38 PM


 Description  « Hide
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)

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kristian Waagan made changes - 19/Oct/06 09:54 AM
Field Original Value New Value
Link This issue is duplicated by DERBY-1645 [ DERBY-1645 ]
Bryan Pendleton made changes - 09/Nov/06 10:48 PM
Assignee Bryan Pendleton [ bryanpendleton ]
Bryan Pendleton made changes - 12/Nov/06 12:36 AM
Attachment preserveColDefault_v1.diff [ 12344819 ]
Bryan Pendleton made changes - 12/Nov/06 12:36 AM
Derby Info [Patch Available]
Bryan Pendleton made changes - 13/Nov/06 08:38 PM
Fix Version/s 10.3.0.0 [ 12310800 ]
Derby Info [Patch Available]
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Bryan Pendleton made changes - 15/Nov/06 03:20 PM
Fix Version/s 10.2.1.8 [ 12312096 ]
Andrew McIntyre made changes - 13/Dec/07 09:05 AM
Status Resolved [ 5 ] Closed [ 6 ]