You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2014/11/13 18:26:08 UTC
svn commit: r1639402 - in /db/derby/code/branches/10.10: ./
java/engine/org/apache/derby/impl/sql/compile/
java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Author: mamta
Date: Thu Nov 13 17:26:07 2014
New Revision: 1639402
URL: http://svn.apache.org/r1639402
Log:
DERBY-6577(Quantified comparison returns wrong result in CASE, COALESCE, IN and BETWEEN)
Back porting to 10.10
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InbetweenTest.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1594816,1595121
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java Thu Nov 13 17:26:07 2014
@@ -1070,7 +1070,7 @@ public class JoinNode extends TableOpera
* to joinClause.preprocess() because we know that no
* flattening will take place. (Bug #1206)
*/
- joinClause.preprocess(
+ joinClause = joinClause.preprocess(
numTables,
(FromList) getNodeFactory().getNode(
C_NodeTypes.FROM_LIST,
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java Thu Nov 13 17:26:07 2014
@@ -271,7 +271,7 @@ public class SQLToJavaValueNode extends
PredicateList outerPredicateList)
throws StandardException
{
- value.preprocess(numTables,
+ value = value.preprocess(numTables,
outerFromList, outerSubqueryList,
outerPredicateList);
}
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Thu Nov 13 17:26:07 2014
@@ -1106,7 +1106,7 @@ public class SelectNode extends ResultSe
if (whereSubquerys != null){
whereSubquerys.markWhereSubqueries();
}
- whereClause.preprocess(numTables,
+ whereClause = whereClause.preprocess(numTables,
fromList, whereSubquerys,
wherePredicates);
}
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java Thu Nov 13 17:26:07 2014
@@ -550,14 +550,13 @@ public class ValueNodeList extends Query
throws StandardException
{
int size = size();
- ValueNode valueNode;
for (int index = 0; index < size; index++)
{
- valueNode = (ValueNode) elementAt(index);
- valueNode.preprocess(numTables,
+ ValueNode vn = ((ValueNode)elementAt(index)).preprocess(numTables,
outerFromList, outerSubqueryList,
outerPredicateList);
+ setElementAt(vn, index);
}
}
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java Thu Nov 13 17:26:07 2014
@@ -529,4 +529,13 @@ public class CaseExpressionTest extends
JDBC.assertSingleValueResultSet(ps.executeQuery(), "0");
}
+
+ /** Regression test case for DERBY-6577. */
+ public void testQuantifiedComparison() throws SQLException {
+ // This query used to return wrong results.
+ JDBC.assertUnorderedResultSet(createStatement().executeQuery(
+ "select c, case when c = all (values 'Y') then true end "
+ + "from (values 'Y', 'N') v(c)"),
+ new String[][] { { "N", null }, { "Y", "true" }});
+ }
}
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java Thu Nov 13 17:26:07 2014
@@ -1085,6 +1085,15 @@ public class CoalesceTest extends BaseJD
vetThreeArgCoalesce("values coalesce(?, ?, cast(? as char(1)))");
}
+ /** Regression test case for DERBY-6577. */
+ public void testQuantifiedComparison() throws SQLException {
+ // This query used to return wrong results.
+ JDBC.assertUnorderedResultSet(createStatement().executeQuery(
+ "select c, coalesce((c = all (values 'Y')), false) "
+ + "from (values 'Y', 'N') v(c)"),
+ new String[][] { { "N", "false" }, { "Y", "true" }});
+ }
+
private void vetThreeArgCoalesce(String sql) throws SQLException {
// First three values in each row are arguments to COALESCE. The
// last value is the expected return value.
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InbetweenTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InbetweenTest.java?rev=1639402&r1=1639401&r2=1639402&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InbetweenTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/InbetweenTest.java Thu Nov 13 17:26:07 2014
@@ -4467,4 +4467,25 @@ public final class InbetweenTest extends
"on a=b where b not between 1 and 5"),
new String[][]{{"0", "0"}});
}
+
+ /** Regression test case for DERBY-6577. */
+ public void testInBetweenQuantifiedComparison() throws SQLException {
+ Statement s = createStatement();
+ String[][] expectedRows = {
+ { "Y", "true" },
+ { "N", "false" },
+ };
+
+ // This query used to return wrong results.
+ JDBC.assertUnorderedResultSet(s.executeQuery(
+ "select c, true in ((c = all (values 'Y'))) "
+ + "from (values 'Y', 'N') v(c)"),
+ expectedRows);
+
+ // This query used to return wrong results.
+ JDBC.assertUnorderedResultSet(s.executeQuery(
+ "select c, true between false and (c = all (values 'Y')) "
+ + "from (values 'Y', 'N') v(c)"),
+ expectedRows);
+ }
}