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-4449) ArrayIndexOutOfBoundsException when inserting DEFAULT into unspecified column
Date Thu, 03 Jun 2010 08:43:59 GMT

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

Knut Anders Hatlen commented on DERBY-4449:

Here's the failing code:

				// Get ColumnDescriptor by name or by position?
				ColumnDescriptor cd;
				if (tcl == null)
					cd = ttd.getColumnDescriptor(index + 1);
					ResultColumn trc = (ResultColumn) tcl.elementAt(index);
					cd = ttd.getColumnDescriptor(trc.getName());

				// Too many RCs if no ColumnDescriptor
				if (cd == null)
					throw StandardException.newException(SQLState.LANG_TOO_MANY_RESULT_COLUMNS, 

The call to tcl.elementAt(index) is the one that raises the AIOOBE. Note that the code expects
that there may be too many columns, and then getColumnDescriptor() should return null. But
in the case where we have a target column list, we fail before we get to the point where getColumnDescriptor()
is called.

I think it would be sufficient to check that the index is within range before calling elementAt()
and set cd to null if it's not.

> ArrayIndexOutOfBoundsException when inserting DEFAULT into unspecified column
> -----------------------------------------------------------------------------
>                 Key: DERBY-4449
>                 URL: https://issues.apache.org/jira/browse/DERBY-4449
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:,
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
> When inserting rows into a table, with just a subset of the table's columns in the target
column list, an ArrayIndexOutOfBoundsException is raised if the table constructor contains
the same number of columns as the target table, and the extra columns are specified as DEFAULT:
> ij> create table t (a int, b int);
> 0 rows inserted/updated/deleted
> ij> insert into t(a) values (1,default);
> ERROR XJ001: Java exception: '1 >= 1: java.lang.ArrayIndexOutOfBoundsException'.
> The insert statement should have failed with this error:
> ERROR 42802: The number of values assigned is not the same as the number of specified
or implied columns.

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

View raw message