db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1465110 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/sql/compile/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/junit/
Date Fri, 05 Apr 2013 20:11:18 GMT
Author: mikem
Date: Fri Apr  5 20:11:17 2013
New Revision: 1465110

URL: http://svn.apache.org/r1465110
Log:
DERBY-6131 select from view with "upper" and "in" list throws a ClassCastException 

backporting change #1464594 from trunk to 10.10 branch.

Prior to this fix the following query on a view would throw a ClassCastException    select
name from myView where upper(name) in ('AA', 'BB');
This query got in code that was trying to "push" predicates down, and
that code is only currently build to push constants and column references.
In this case it was mistakenly trying to push down the "upper" call, and
when it tried to cast it as a column reference it got the error.  The fix
was to check the type of the node and not push in this case.


Added:
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6131.java
      - copied unchanged from r1464594, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Derby6131.java
Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Reverse-merged /db/derby/code/trunk:r1464934
  Merged /db/derby/code/trunk:r1464594

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java?rev=1465110&r1=1465109&r2=1465110&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
Fri Apr  5 20:11:17 2013
@@ -1516,13 +1516,31 @@ public class PredicateList extends Query
 				else if (andNode.getLeftOperand() instanceof InListOperatorNode)
 				{
 					inNode = (InListOperatorNode) andNode.getLeftOperand();
-					if (! (inNode.getRightOperandList().isConstantExpression()))
+
+                    if (!(inNode.getLeftOperand() instanceof ColumnReference))
+                    {
+                        // A predicate can be pushed into an underlying select 
+                        // if the source of every ColumnReference in the 
+                        // predicate is itself a ColumnReference.
+                        // In this case the left operand is not a 
+                        // ColumnReference so do not push.
+
+                        continue;
+                    }
+                    else if (!(inNode.getRightOperandList().isConstantExpression()))
+                    {
+                        // only push down constant expressions, 
+                        // skipping this one that is not
+
 						continue;
+                    }
 
 					crNode = (ColumnReference) inNode.getLeftOperand();
 				}
 				else
+                {
 					continue;
+                }
 
 				// Remap this crNode to underlying column reference in the select, if possible.
 				ColumnReference newCRNode = select.findColumnReferenceInResult(crNode.columnName);

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1465110&r1=1465109&r2=1465110&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Fri Apr  5 20:11:17 2013
@@ -236,6 +236,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(Derby5652.suite());
         suite.addTest(TruncateTableAndOnlineBackupTest.suite()); 
         suite.addTest(QueryPlanTest.suite());
+        suite.addTest(Derby6131.suite());
         return suite;
 	}
 }

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=1465110&r1=1465109&r2=1465110&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
Fri Apr  5 20:11:17 2013
@@ -1053,6 +1053,42 @@ public abstract class BaseJDBCTestCase
     }
 
     /**
+     * Execute a DROP VIEW command using the passed in viewName as-is
+     * and the default connection.
+     * If the DROP VIEW fails because the view does not exist then
+     * the exception is ignored.
+     * @param viewName Table to be dropped.
+     * @throws SQLException
+     */
+    public final void dropView(String viewName) throws SQLException
+    {
+       dropView(getConnection(), viewName);
+    }
+    
+    /**
+     * Execute a DROP VIEW command using the passed in viewName as-is.
+     * If the DROP VIEW fails because the view does not exist then
+     * the exception is ignored.
+     * @param conn Connection to execute the DROP VIEW
+     * @param viewName Table to be dropped.
+     * @throws SQLException
+     */
+    public static void dropView(Connection conn, String viewName) throws SQLException
+    {
+        Statement statement = conn.createStatement();
+        String dropSQL = "DROP VIEW " + viewName;
+        try { 
+            
+            statement.executeUpdate(dropSQL); 
+        } catch (SQLException e) {
+            assertSQLState("42Y55", e);
+        }
+        finally {
+            statement.close();
+        }
+    }
+
+    /**
      * Assert that the query fails (either in compilation,
      * execution, or retrieval of results--doesn't matter)
      * and throws a SQLException with the expected states.



Mime
View raw message