db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1476021 - in /db/derby/code/branches/10.8: ./ java/engine/org/apache/derby/impl/sql/compile/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 26 Apr 2013 01:59:09 GMT
Author: mamta
Date: Fri Apr 26 01:59:08 2013
New Revision: 1476021

URL: http://svn.apache.org/r1476021
Log:
DERBY-6185 (Query against view  with "where name LIKE 'Col1' ESCAPE '\' " failed)

backporting changes to 10.8 codeline


Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1471022

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
Fri Apr 26 01:59:08 2013
@@ -123,6 +123,7 @@ public class BetweenOperatorNode extends
 									C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE,
 									leftOperand, 
 								 	rightOperandList.elementAt(0),
+								 	Boolean.FALSE,
 									cm);
 		/* Set type info for the operator node */
 		leftBCO.bindComparisonOperator();
@@ -139,6 +140,7 @@ public class BetweenOperatorNode extends
 								C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE,
 								leftClone,
 								rightOperandList.elementAt(1),
+							 	Boolean.FALSE,
 								cm);
 		/* Set type info for the operator node */
 		rightBCO.bindComparisonOperator();
@@ -224,6 +226,7 @@ public class BetweenOperatorNode extends
 						C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
 						leftClone1, 
 						rightOperandList.elementAt(1),
+					 	Boolean.FALSE,
 						cm);
 
 		/* Set type info for the operator node */
@@ -243,6 +246,7 @@ public class BetweenOperatorNode extends
 					C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
 					leftOperand, 
 					rightOperandList.elementAt(0),
+				 	Boolean.FALSE,
 					cm);
 
 		/* Set type info for the operator node */
@@ -302,6 +306,7 @@ public class BetweenOperatorNode extends
 							C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
 							leftOperand, 
 							rightOperandList.elementAt(0),
+						 	Boolean.FALSE,
 							cm);
 		/* Set type info for the operator node */
 		leftBCO.bindComparisonOperator();
@@ -312,6 +317,7 @@ public class BetweenOperatorNode extends
 						C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
 						leftOperand, 
 						rightOperandList.elementAt(1),
+					 	Boolean.FALSE,
 						cm);
 		/* Set type info for the operator node */
 		rightBCO.bindComparisonOperator();

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java
Fri Apr 26 01:59:08 2013
@@ -58,14 +58,28 @@ public abstract class BinaryComparisonOp
 	 * @param operator		The name of the operator
 	 * @param methodName	The name of the method to call in the generated
 	 *						class
+	 * @param forQueryRewrite Can be true only if if this node has been 
+	 *                      added by an internal rewrite of the query. This
+	 *                      allows binding to be more liberal when checking 
+	 *                      it against allowed syntax.
+	 *                      This parameter will be passed FALSE when a new 
+	 *                      instance of the node is being created(which is 
+	 *                      the majority of the cases). But when an  
+	 *                      existing node is getting cloned, the value of
+	 *                      this parameter should be passed as the 
+	 *                      originalNode.getForQueryRewrite(). Examples of
+	 *                      this can be found in Predicate.Java and 
+	 *                      PredicateList.java
 	 */
 
 	public void init(
 				Object	leftOperand,
 				Object	rightOperand,
 				Object		operator,
-				Object		methodName)
+				Object		methodName,
+                Object      forQueryRewrite)
 	{
+        this.forQueryRewrite = ((Boolean)forQueryRewrite).booleanValue();
 		super.init(leftOperand, rightOperand, operator, methodName,
 				ClassName.DataValueDescriptor, ClassName.DataValueDescriptor);
 	}

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
Fri Apr 26 01:59:08 2013
@@ -86,7 +86,18 @@ public class BinaryRelationalOperatorNod
 	 */
 	private InListOperatorNode inListProbeSource = null;
 
-	public void init(Object leftOperand, Object rightOperand)
+	//DERBY-6185 (Query against view  with "where name LIKE 
+	// 'Col1' ESCAPE '\' " failed)
+	//4th argument forQueryRewrite can be true only if this node has been 
+	//  added by an internal rewrite of the query. This allows binding to 
+	//  be more liberal when checking it against allowed syntax.
+	//  This parameter will be passed FALSE when a new instance of the node
+	//  is being created(which is the majority of the cases). But when an 
+	//  existing node is getting cloned, the value of this parameter should 
+	//  be passed as the originalNode.getForQueryRewrite(). Examples of this
+	//  can be found in Predicate.Java and PredicateList.java
+	public void init(Object leftOperand, Object rightOperand,
+        Object forQueryRewrite)
 	{
 		String methodName = "";
 		String operatorName = "";
@@ -135,7 +146,7 @@ public class BinaryRelationalOperatorNod
 				}
 			    break;
 		}
-		super.init(leftOperand, rightOperand, operatorName, methodName);
+		super.init(leftOperand, rightOperand, operatorName, methodName, forQueryRewrite);
 		btnVis = null;
 	}
 
@@ -144,10 +155,21 @@ public class BinaryRelationalOperatorNod
 	 * an InListOperatorNode.  This version is used during IN-list
 	 * preprocessing to create a "probe predicate" for the IN-list.
 	 * See InListOperatorNode.preprocess() for more.
+	 * DERBY-6185 (Query against view  with "where name LIKE 
+	 *  'Col1' ESCAPE '\' " failed)
+	 * 4th argument forQueryRewrite can be true only if this node has been
+	 *  added by an internal rewrite of the query. This allows binding to
+	 *  be more liberal when checking it against allowed syntax.
+	 *  This parameter will be passed FALSE when a new instance of the node
+	 *  is being created(which is the majority of the cases). But when an 
+	 *  existing node is getting cloned, the value of this parameter should
+	 *  be passed as the originalNode.getForQueryRewrite(). Examples of this
+	 *  can be found in Predicate.Java and PredicateList.java
 	 */
-	public void init(Object leftOperand, Object rightOperand, Object inListOp)
+	public void init(Object leftOperand, Object rightOperand,
+			 Object inListOp, Object forQueryRewrite)
 	{
-		init(leftOperand, rightOperand);
+		init(leftOperand, rightOperand, forQueryRewrite);
 		this.inListProbeSource = (InListOperatorNode)inListOp;
 	}
 
@@ -1047,6 +1069,7 @@ public class BinaryRelationalOperatorNod
 		negation = (BinaryOperatorNode)
 			getNodeFactory().getNode(getNegationNode(),
 									 leftOperand, rightOperand,
+									 Boolean.FALSE,
 									 getContextManager());
 		negation.setType(getTypeServices());
 		return negation;
@@ -1092,6 +1115,7 @@ public class BinaryRelationalOperatorNod
     BinaryOperatorNode getSwappedEquivalent() throws StandardException {
         BinaryOperatorNode newNode = (BinaryOperatorNode) getNodeFactory().getNode(getNodeTypeForSwap(),
                 rightOperand, leftOperand,
+                Boolean.FALSE,
                 getContextManager());
         newNode.setType(getTypeServices());
         return newNode;
@@ -1319,6 +1343,7 @@ public class BinaryRelationalOperatorNod
 		return (RelationalOperator)getNodeFactory().getNode(getNodeType(),
 														  otherCR,
 														  rightOperand,
+														  Boolean.FALSE,
 														  getContextManager());
 	}
 	

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
Fri Apr 26 01:59:08 2013
@@ -605,6 +605,7 @@ public class ColumnReference extends Val
 										C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 										this,
 										trueNode,
+										Boolean.FALSE,
 										getContextManager());
 		/* Set type info for the operator node */
 		equalsNode.bindComparisonOperator();

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
Fri Apr 26 01:59:08 2013
@@ -145,6 +145,7 @@ public final class InListOperatorNode ex
 						C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 						leftOperand, 
 						(ValueNode) rightOperandList.elementAt(0),
+						Boolean.FALSE,
 						getContextManager());
 			/* Set type info for the operator node */
 			equal.bindComparisonOperator();
@@ -284,6 +285,7 @@ public final class InListOperatorNode ex
 							C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 							leftOperand, 
 							minValue,
+							Boolean.FALSE,
 							getContextManager());
 					/* Set type info for the operator node */
 					equal.bindComparisonOperator();
@@ -353,6 +355,7 @@ public final class InListOperatorNode ex
 					leftOperand, 
 					pNode,
 					this,
+					Boolean.FALSE,
 					getContextManager());
 
 			/* Set type info for the operator node */
@@ -422,6 +425,7 @@ public final class InListOperatorNode ex
 						C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
 						leftClone,
 						(ValueNode) rightOperandList.elementAt(0),
+						Boolean.FALSE,
 						getContextManager());
 		/* Set type info for the operator node */
 		leftBCO.bindComparisonOperator();
@@ -438,6 +442,7 @@ public final class InListOperatorNode ex
 							C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
 							leftClone,
 							(ValueNode) rightOperandList.elementAt(elemsDone),
+							Boolean.FALSE,
 							getContextManager());
 			/* Set type info for the operator node */
 			rightBCO.bindComparisonOperator();

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
Fri Apr 26 01:59:08 2013
@@ -914,6 +914,7 @@ public class JoinNode extends TableOpera
 										C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 										leftCR,
 										rightCR,
+										Boolean.FALSE,
 										getContextManager());
 				equalsNode.bindComparisonOperator();
 

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
Fri Apr 26 01:59:08 2013
@@ -405,6 +405,7 @@ public final class LikeEscapeOperatorNod
                                 C_NodeTypes.CHAR_CONSTANT_NODE,
                                 newPattern,
                                 getContextManager()),
+                                Boolean.FALSE,
                             getContextManager());
 
                     // Set forQueryRewrite to bypass comparability checks
@@ -684,7 +685,8 @@ public final class LikeEscapeOperatorNod
                     C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE,
                     receiver.getClone(), 
                     likeLTopt,
-                    getContextManager());
+                    Boolean.FALSE,
+                   getContextManager());
 
             // Disable comparability checks
             lessThan.setForQueryRewrite(true);
@@ -743,6 +745,7 @@ public final class LikeEscapeOperatorNod
                 C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
                 receiver.getClone(), 
                 likeGEopt,
+                Boolean.FALSE,
                 getContextManager());
 
 

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/Predicate.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
Fri Apr 26 01:59:08 2013
@@ -1015,6 +1015,7 @@ public final class Predicate extends Que
 					parentRSNsTables,
 					childRSN,
 					whichRC),
+					Boolean.valueOf(opNode.getForQueryRewrite()),
 				getContextManager());
 
 		// Bind the new op node.

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
Fri Apr 26 01:59:08 2013
@@ -1584,6 +1584,7 @@ public class PredicateList extends Query
 										newCRNode,
 										opNode.getRightOperand(),
 										inNode,
+										Boolean.valueOf(opNode.getForQueryRewrite()),
 										getContextManager());
 					newRelop.bindComparisonOperator();
 					leftOperand = newRelop;
@@ -2172,6 +2173,7 @@ public class PredicateList extends Query
 										C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 										outerCR.getClone(),
 										innerCR.getClone(),
+										Boolean.FALSE,
 										getContextManager());
 					newEquals.bindComparisonOperator();
 					/* Create the AND */

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
Fri Apr 26 01:59:08 2013
@@ -1615,6 +1615,7 @@ public class SubqueryNode extends ValueN
 							nodeType,
 							leftOperand,
 							rightOperand,
+							Boolean.FALSE,
 							getContextManager());
 
 		bcoNode.bindComparisonOperator();
@@ -2379,6 +2380,7 @@ public class SubqueryNode extends ValueN
   									C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
   									leftOperand,
   									this,
+  									Boolean.FALSE,
   									getContextManager());
   				break;
 
@@ -2387,6 +2389,7 @@ public class SubqueryNode extends ValueN
   								C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
   								leftOperand,
   								this,
+  								Boolean.FALSE,
   								getContextManager());
   				break;
 
@@ -2395,6 +2398,7 @@ public class SubqueryNode extends ValueN
   								C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
   								leftOperand,
   								this,
+  								Boolean.FALSE,
   								getContextManager());
   				break;
 
@@ -2403,6 +2407,7 @@ public class SubqueryNode extends ValueN
   							C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE,
   							leftOperand,
   							this,
+  							Boolean.FALSE,
   							getContextManager());
   				break;
 
@@ -2411,6 +2416,7 @@ public class SubqueryNode extends ValueN
   							C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
   							leftOperand,
   							this,
+  							Boolean.FALSE,
   							getContextManager());
   				break;
 
@@ -2419,6 +2425,7 @@ public class SubqueryNode extends ValueN
   								C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE,
   								leftOperand,
   								this,
+  								Boolean.FALSE,
   								getContextManager());
   				break;
   		}

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
Fri Apr 26 01:59:08 2013
@@ -547,6 +547,7 @@ public abstract class ValueNode extends 
 								C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 								this,
 								falseNode,
+								Boolean.FALSE,
 								getContextManager());
 		nullableResult = getTypeServices().isNullable();
 		equalsNode.setType(new DataTypeDescriptor(

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
Fri Apr 26 01:59:08 2013
@@ -5679,6 +5679,7 @@ additiveExpression(ValueNode farLeftOper
 							nodeType,
 							farLeftOperand,
 							leftOperand,
+							Boolean.FALSE,
 							getContextManager());
 	}
 }
@@ -12433,6 +12434,7 @@ valueSpecification() throws StandardExce
 														C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 														leftExpression,
 														rightExpression,
+														Boolean.FALSE,
 														cm),
 											thenElseList,
 											Boolean.TRUE,//this node is for nullif 

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java?rev=1476021&r1=1476020&r2=1476021&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java
Fri Apr 26 01:59:08 2013
@@ -52,6 +52,88 @@ public final class ViewsTest extends Bas
         return new CleanDatabaseTestSetup(suite);
     }
 
+    //DERBY-6185(Query against view  with 
+    // "where name LIKE 'Col1' ESCAPE '\' " failed)
+    //Problem was that we clone binary comparison operator node during the
+    // optimize phase but we did not copy the entire state of the original
+    // node
+    public void test_DERBY6185() throws Exception
+    {
+        ResultSet rs = null;
+        
+        Statement st = createStatement();
+        PreparedStatement ps;
+
+        // create 2 tables and a view
+        st.executeUpdate(
+            "create table mytbl1 (name clob(10K))");
+        st.executeUpdate("insert into mytbl1 "+
+            "values ('Col1'),('Col2')");
+        st.executeUpdate(
+            "create table mytbl2 (name clob(10K))");
+        st.executeUpdate("insert into mytbl2 "+
+                "values ('Col1'),('Col2')");
+        st.executeUpdate(
+            "create view myview (name) as select t1.name from " +
+            "mytbl1 t1 union all select t2.name from mytbl2 t2");
+
+        //test base table's CLOB and LIKE clause with Statement
+        rs = st.executeQuery("select name from mytbl1 " +
+                "where name LIKE 'Col1'");
+        JDBC.assertFullResultSet(rs, new String[][]{
+                {"Col1"}
+        });
+
+        //test base table's CLOB and LIKE clause with PreparedStatement
+        ps = prepareStatement("select name from mytbl1 " +
+                "where name LIKE ?");
+        ps.setString(1, "Col1");
+        rs = ps.executeQuery();
+        JDBC.assertFullResultSet(rs, new String[][]{
+                {"Col1"}
+        });
+
+        //test view's CLOB and LIKE clause with Statement
+        rs = st.executeQuery("select name from myview " +
+            "where name LIKE 'Col1'");
+        JDBC.assertFullResultSet(rs, new String[][]{
+                {"Col1"},
+                {"Col1"}
+        });
+
+        //test view's CLOB and LIKE clause with PreparedStatement
+        ps = prepareStatement("select name from myview " +
+                "where name LIKE ?");
+        ps.setString(1, "Col1");
+        rs = ps.executeQuery();
+        JDBC.assertFullResultSet(rs, new String[][]{
+                {"Col1"},
+                {"Col1"}
+        });
+
+        //test UNION's CLOB and LIKE clause with Statement
+        rs = st.executeQuery("select name from " +
+             "(select name from mytbl1 t1 union all " +
+             "select t2.name from mytbl2 t2) " +
+             "as s where name like 'Col1'");
+        JDBC.assertFullResultSet(rs, new String[][]{
+                {"Col1"},
+                {"Col1"}
+        });
+
+        //test UNION's CLOB and LIKE clause with PreparedStatement
+        ps = prepareStatement("select name from " +
+             "(select name from mytbl1 t1 union all " +
+             "select t2.name from mytbl2 t2) " +
+             "as s where name like ?");
+        ps.setString(1, "Col1");
+        rs = ps.executeQuery();
+        JDBC.assertFullResultSet(rs, new String[][]{
+                {"Col1"},
+                {"Col1"}
+        });
+    }
+
     public void test_views() throws Exception
     {
         ResultSet rs = null;



Mime
View raw message