db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r615203 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ResultColumn.java testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
Date Fri, 25 Jan 2008 12:29:32 GMT
Author: dyre
Date: Fri Jan 25 04:29:31 2008
New Revision: 615203

URL: http://svn.apache.org/viewvc?rev=615203&view=rev
Log:
DERBY-3221: "java.sql.SQLException: The conglomerate (-5) requested does not exist."
from Derby 10.3.1.4 embedded within Eclipse 3.3 and RAD 7.0

Patch file: derby-3221.v3.diff

Modifies the logic in ResultColumn.getOrderableVariantType() so that it behaves
correctly even when a default column is explicitly mentioned in an insert statement.


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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?rev=615203&r1=615202&r2=615203&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Fri
Jan 25 04:29:31 2008
@@ -1435,14 +1435,16 @@
 		** return VARIANT.  Otherwise, we return
 		** CONSTANT. For result columns that are 
 		** generating autoincrement values, the result
-		** is variant-- note that there is no expression
-		** associated with an autoincrement column in 
-		** an insert statement.
+		** is variant.
 		*/
-		int expType = ((expression != null) ?
-					   expression.getOrderableVariantType() : 
-					   ((isAutoincrementGenerated()) ? 
-						Qualifier.VARIANT : Qualifier.CONSTANT));
+        int expType;
+        if (isAutoincrementGenerated()) {
+            expType = Qualifier.VARIANT;
+        } else if (expression != null) {
+            expType = expression.getOrderableVariantType();
+        } else {
+            expType = Qualifier.CONSTANT;
+        }
 
 		switch (expType)
 		{

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java?rev=615203&r1=615202&r2=615203&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
Fri Jan 25 04:29:31 2008
@@ -21,9 +21,6 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
-import java.util.HashMap;
-import java.util.Iterator;
-
 import java.sql.Connection;
 import java.sql.Statement;
 import java.sql.PreparedStatement;
@@ -2049,5 +2046,54 @@
             assertResultSet("R?="+i+" ?="+(i+1), empty, rs);
         }
         tst.close();
+    }
+
+
+    // Regression tests for DERBY-3343 (regression from the fix for DERBY-827)
+    /**
+     * Private helper method. Runs the same test for different
+     * generated identity columns.
+     * @param dataType SMALLINT, INT, or BIGINT
+     * @param generatedType BY DEFAULT or ALWAYS
+     * @throws Exception all errors passed on to JUnit
+     */
+    private void testGeneratedIdentity(String dataType, String generateType) 
+        throws Exception {
+        Statement s = createStatement();
+        s.execute("CREATE TABLE T(GI "+dataType+" PRIMARY KEY GENERATED "+
+                  generateType+
+                  " AS IDENTITY (START WITH 5, INCREMENT BY 10), "+
+                  "L VARCHAR(8))");
+        PreparedStatement implicit = 
+            prepareStatement("INSERT INTO T(L) VALUES('implicit')"); 
+        implicit.executeUpdate();
+        implicit.executeUpdate();
+        implicit.executeUpdate();
+        
+        PreparedStatement explicit = 
+            prepareStatement("INSERT INTO T(GI, L) "+
+                             "VALUES(DEFAULT, 'explicit')"); 
+        explicit.executeUpdate();
+        explicit.executeUpdate();
+        explicit.executeUpdate();
+    } 
+    public void testIntGeneratedByDefaultAsIdentity() throws Exception {
+        testGeneratedIdentity("INT","BY DEFAULT");
+    }
+    public void testSmallintGeneratedByDefaultAsIdentity() throws Exception {
+        testGeneratedIdentity("SMALLINT","BY DEFAULT");
+    }
+    public void testBigintGeneratedByDefaultAsIdentity() throws Exception {
+        testGeneratedIdentity("BIGINT","BY DEFAULT");
+    }
+
+    public void testIntGeneratedAlwaysAsIdentity() throws Exception {
+        testGeneratedIdentity("INT","ALWAYS");
+    }
+    public void testSmallintGeneratedAlwaysAsIdentity() throws Exception {
+        testGeneratedIdentity("SMALLINT","ALWAYS");
+    }
+    public void testBigintGeneratedAlwaysAsIdentity() throws Exception {
+        testGeneratedIdentity("BIGINT","ALWAYS");
     }
 }



Mime
View raw message