db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r962731 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
Date Sat, 10 Jul 2010 00:29:39 GMT
Author: kmarsden
Date: Sat Jul 10 00:29:38 2010
New Revision: 962731

URL: http://svn.apache.org/viewvc?rev=962731&view=rev
Log:
DERBY-4449 ArrayIndexOutOfBoundsException when inserting DEFAULT into unspecified column

merged svn version 951366
Contributed by Knut Anders Hatlen.
Ported version tested by Lily Wei


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jul 10 00:29:38 2010
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.6:957000
-/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792434,793089,793588,794106,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,829410,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,903108,905224,908418,908586,909176,911315,915733,916075,916897,918359,921028,927430,928065,936215,942286,942476,942480,942587,946794,948045,948069,951346,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550
+/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792434,793089,793588,794106,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,829410,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,903108,905224,908418,908586,909176,911315,915733,916075,916897,918359,921028,927430,928065,936215,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=962731&r1=962730&r2=962731&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Sat Jul 10 00:29:38 2010
@@ -3890,12 +3890,12 @@ public class ResultColumnList extends Qu
 			{
 				//				DefaultNode defaultNode = (DefaultNode) rc.getExpression();
 				// Get ColumnDescriptor by name or by position?
-				ColumnDescriptor cd;
+				ColumnDescriptor cd = null;
 				if (tcl == null)
 				{
 					cd = ttd.getColumnDescriptor(index + 1);
 				}
-				else
+				else if (index < tcl.size())
 				{
 					ResultColumn trc = (ResultColumn) tcl.elementAt(index);
 					cd = ttd.getColumnDescriptor(trc.getName());

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java?rev=962731&r1=962730&r2=962731&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InsertTest.java
Sat Jul 10 00:29:38 2010
@@ -35,6 +35,7 @@ import org.apache.derbyTesting.junit.Tes
 public class InsertTest extends BaseJDBCTestCase {
 
     private static final String PARAMETER_IN_SELECT_LIST = "42X34";
+    private static final String TOO_MANY_RESULT_COLUMNS = "42X06";
 
     public InsertTest(String name) {
         super(name);
@@ -187,4 +188,23 @@ public class InsertTest extends BaseJDBC
                 "insert into derby4671 select ? from derby4671 "
                 + "intersect select ? from derby4671");
     }
+
+    /**
+     * Regression test case for DERBY-4449. INSERT statements with an explicit
+     * target column list used to fail with ArrayIndexOutOfBoundsException if
+     * the table constructor had more columns than the target column list and
+     * one of the extra columns was specified as DEFAULT.
+     */
+    public void testInsertTooManyDefaultColumns() throws SQLException {
+        createStatement().execute("create table derby4449(x int)");
+        // This statement has always failed gracefully (no explicit target
+        // column list)
+        assertCompileError(
+                TOO_MANY_RESULT_COLUMNS,
+                "insert into derby4449 values (default, default)");
+        // This statement used to fail with ArrayIndexOutOfBoundsException
+        assertCompileError(
+                TOO_MANY_RESULT_COLUMNS,
+                "insert into derby4449 (x) values (default, default)");
+    }
 }



Mime
View raw message