db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6284) Improve test coverage of org.apache.derby.iapi.db.ConnectionInfo
Date Wed, 03 Jul 2013 08:15:20 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13698733#comment-13698733

Knut Anders Hatlen commented on DERBY-6284:

I think it would be OK to remove lastAutoinccrementValue(). Its javadoc comment says that
applications should use java.sql.Statement.getGeneratedKeys() instead.

nextAutoincrementValue() won't work if it is called directly. It has to be called from inside
a stored procedure or function. So in order to test it, I think we'd need to create a table
with an auto-increment column, for example:

    create table t(x int generated always as identity)

Then create a stored function that calls nextAutoincrementValue() on the identity column:

    public static long nextValue() throws SQLException {
        return ConnectionInfo.nextAutoincrementValue("APP", "T", "X");

    create function next_value() returns bigint language java parameter style java external
name 'NameOfJavaClass.nextValue'

Then the method can be invoked from SQL like this:

    values next_value()

However, I tried this in my environment, and the call failed with a NullPointerException.
It looks like there are some data structures that need to be set up before the call in order
to make it succeed. Something similar to what AlterTableConstantAction.updateNewAutoincrementColumn()
does before it calls nextAutoincrementValue(). But I think it's probably more work than it's
worth to get this method tested separately. I'd recommend leaving it untested for now and
wait for DERBY-3888 to be fixed.
> Improve test coverage of org.apache.derby.iapi.db.ConnectionInfo
> ----------------------------------------------------------------
>                 Key: DERBY-6284
>                 URL: https://issues.apache.org/jira/browse/DERBY-6284
>             Project: Derby
>          Issue Type: Sub-task
>          Components: JDBC
>            Reporter: Bryan Pendleton
>            Assignee: ahsan shamsudeen
>            Priority: Minor
> According to code coverage analysis, org.apache.derby.iapi.db.ConnectionInfo is 
> not currently being exercised by any of our regression tests.
> This task is to investigate this class, and either remove the unused code, or add
> regression test that exercise the code, as appropriate.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message