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

Suran Jayathilaka updated DERBY-712:
------------------------------------

    Attachment: create_drop_sequence_a.patch

Hi Rick, 

The call to initAndCheck(null) in CreateSequenceNode.init() was a line left in 
the code by mistake.

In this patch I added basic implementation of DROP SEQUENCE.

When running the SequenceTest, while the CREATE statement seems to execute ok, 
I get the following exception for DROP.

1) 
testDropSequence(org.apache.derbyTesting.functionTests.tests.lang.SequenceTest)java.sql.SQLException:
 Java exception: 'org.apache.derby.catalog.types.TypeDescriptorImpl cannot b
e cast to org.apache.derby.iapi.types.DataTypeDescriptor: 
java.lang.ClassCastException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
        at org.apache.derby.impl.jdbc.Util.javaException(Util.java:244)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2201)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:175)
        at 
org.apache.derbyTesting.functionTests.tests.lang.SequenceTest.testDropSequence(SequenceTest.java:118)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
Caused by: java.sql.SQLException: Java exception: 
'org.apache.derby.catalog.types.TypeDescriptorImpl cannot be cast to 
org.apache.derby.iapi.types.DataTypeDescriptor: java.lang.Cla
ssCastException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70)
        ... 34 more
Caused by: java.lang.ClassCastException: 
org.apache.derby.catalog.types.TypeDescriptorImpl cannot be cast to 
org.apache.derby.iapi.types.DataTypeDescriptor
        at 
org.apache.derby.impl.sql.catalog.SYSSEQUENCESRowFactory.buildDescriptor(SYSSEQUENCESRowFactory.java:235)
        at 
org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndexMinion(DataDictionaryImpl.java:8673)
        at 
org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndex(DataDictionaryImpl.java:8388)
        at 
org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSequenceDescriptor(DataDictionaryImpl.java:12747)
        at 
org.apache.derby.impl.sql.compile.DropSequenceNode.bindStatement(DropSequenceNode.java:81)
        at 
org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:316)
        at 
org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
        at 
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:822)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
        ... 27 more

I don't get where the datatype, which is a DataTypeDescriptor object at the 
time of creation,  turned into a TypeDescriptorImpl instance.

Also, in the executeConstantAction() method of DropSequenceConstantAction, 
what's the SQLState code that I should use for the exception when the 
sequenceDescriptor is null?


> Support for sequences
> ---------------------
>
>                 Key: DERBY-712
>                 URL: https://issues.apache.org/jira/browse/DERBY-712
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>         Environment: feature request 
>            Reporter: Tony Dahbura
>            Assignee: Suran Jayathilaka
>             Fix For: 10.6.0.0
>
>         Attachments: altertable.diff, catalogs_a.patch, catalogs_b.patch, 
> catalogs_c.patch, catalogs_d.patch, catalogs_e.patch, catalogs_f.patch, 
> catalogs_f_2.patch, catalogs_g.diff, catalogs_h.diff, 
> create_drop_sequence_a.patch, create_sequence_a.patch, SequenceGenerator.html
>
>
> Would like to see support added for sequences.  This would permit a select 
> against the sequence to always obtain a ever increasing/decreasing value.  
> The identity column works fine but there are times for applications where the 
> application needs to obtain the sequence number and use it prior to the 
> database write.  Subsequent calls to the table/column would result in a new 
> number on each call.
> SQL such as the following:
> SELECT NEXT VALUE FOR sequence_name FROM sometable ; would result in a next 
> value.

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

Reply via email to