db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r763230 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ResultColumnList.java testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Date Wed, 08 Apr 2009 13:00:38 GMT
Author: rhillegas
Date: Wed Apr  8 13:00:38 2009
New Revision: 763230

URL: http://svn.apache.org/viewvc?rev=763230&view=rev
Log:
DERBY-4146: Bind a column descriptor to a generated result column for INSERTs without target
lists.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=763230&r1=763229&r2=763230&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Wed Apr  8 13:00:38 2009
@@ -4096,6 +4096,8 @@
                 {
                     throw StandardException.newException(SQLState.LANG_CANT_OVERRIDE_GENERATION_CLAUSE,
rc.getName());
                 }
+
+                if ( sourceRC != null ) { sourceRC.setColumnDescriptor(cd.getTableDescriptor(),
cd); }
             }
 			
 			if ((cd != null) && (cd.isAutoincrement()))

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java?rev=763230&r1=763229&r2=763230&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Wed Apr  8 13:00:38 2009
@@ -5117,6 +5117,148 @@
              );
     }
     
+    /**
+     * <p>
+     * Test that a generated column can refer to an identity column.
+     * </p>
+     */
+    public  void    test_030_derby_4146()
+        throws Exception
+    {
+        Connection  conn = getConnection();
+
+        //
+        // Schema
+        //
+        goodStatement
+            (
+             conn,
+             "create table t_4146 (c1 int generated always as identity, c2 generated always
as (c1+100))"
+             );
+        goodStatement
+            (
+             conn,
+             "create table t_4146_2 (c1 int generated always as identity, c2 generated always
as (c1+100), c3 int default 1000)"
+             );
+
+        goodStatement
+            (
+             conn,
+             "insert into t_4146 values ( default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_MODIFY_IDENTITY,
+             "insert into t_4146 values ( -1, default )"
+             );
+        expectCompilationError
+            (
+             CANT_OVERRIDE_GENERATION_CLAUSE,
+             "insert into t_4146 values ( default, -1 )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t_4146 (c1, c2) values ( default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_MODIFY_IDENTITY,
+             "insert into t_4146 (c1, c2) values ( -1, default )"
+             );
+        expectCompilationError
+            (
+             CANT_OVERRIDE_GENERATION_CLAUSE,
+             "insert into t_4146 (c1, c2) values ( default, -1 )"
+             );
+        assertResults
+            (
+             conn,
+             "select * from t_4146 order by c1",
+             new String[][]
+             {
+                 { "1", "101", },
+                 { "2", "102", },
+             },
+             false
+             );
+
+        goodStatement
+            (
+             conn,
+             "insert into t_4146_2 values ( default, default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_MODIFY_IDENTITY,
+             "insert into t_4146_2 values ( -1, default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_OVERRIDE_GENERATION_CLAUSE,
+             "insert into t_4146_2 values ( default, -1, default )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t_4146_2 (c1, c2) values ( default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_MODIFY_IDENTITY,
+             "insert into t_4146_2 (c1, c2) values ( -1, default )"
+             );
+        expectCompilationError
+            (
+             CANT_OVERRIDE_GENERATION_CLAUSE,
+             "insert into t_4146_2 (c1, c2) values ( default, -1 )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t_4146_2 (c1, c2, c3) values ( default, default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_MODIFY_IDENTITY,
+             "insert into t_4146_2 (c1, c2, c3) values ( -1, default, default )"
+             );
+        expectCompilationError
+            (
+             CANT_OVERRIDE_GENERATION_CLAUSE,
+             "insert into t_4146_2 (c1, c2, c3) values ( default, -1, default )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t_4146_2 (c1, c2, c3) values ( default, default, 2000 )"
+             );
+        expectCompilationError
+            (
+             CANT_MODIFY_IDENTITY,
+             "insert into t_4146_2 (c1, c2, c3) values ( -1, default, 3000 )"
+             );
+        expectCompilationError
+            (
+             CANT_OVERRIDE_GENERATION_CLAUSE,
+             "insert into t_4146_2 (c1, c2, c3) values ( default, -1, 4000 )"
+             );
+        assertResults
+            (
+             conn,
+             "select * from t_4146_2 order by c1",
+             new String[][]
+             {
+                 { "1", "101", "1000", },
+                 { "2", "102", "1000", },
+                 { "3", "103", "1000", },
+                 { "4", "104", "2000", },
+             },
+             false
+             );
+
+    }
+    
 
     ///////////////////////////////////////////////////////////////////////////////////
     //



Mime
View raw message