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 ka...@apache.org on 2009/09/28 16:20:44 UTC
svn commit: r819547 - in /db/derby/code/branches/10.5: ./
java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Author: kahatlen
Date: Mon Sep 28 14:20:43 2009
New Revision: 819547
URL: http://svn.apache.org/viewvc?rev=819547&view=rev
Log:
DERBY-4342: SQLSTATE 38000 (NullPointerException) at inner self join and value(x1, x2...)
Merged fix from trunk (revision 819006).
Modified:
db/derby/code/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 28 14:20:43 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=819547&r1=819546&r2=819547&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java Mon Sep 28 14:20:43 2009
@@ -428,4 +428,20 @@
}
}
+ /**
+ * Remap all the {@code ColumnReference}s in this tree to be clones of
+ * the underlying expression.
+ *
+ * @return the remapped tree
+ * @throws StandardException if an error occurs
+ */
+ public ValueNode remapColumnReferencesToExpressions()
+ throws StandardException
+ {
+ for (int i = 0; i < argumentsList.size(); i++) {
+ ValueNode vn = (ValueNode) argumentsList.elementAt(i);
+ vn.remapColumnReferencesToExpressions();
+ }
+ return this;
+ }
}
Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java?rev=819547&r1=819546&r2=819547&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CoalesceTest.java Mon Sep 28 14:20:43 2009
@@ -30,10 +30,10 @@
import java.io.UnsupportedEncodingException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.TestConfiguration;
import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.JDBC;
/**
@@ -1170,6 +1170,19 @@
expectedValues[index++]);
}
+ /**
+ * Regression test for DERBY-4342. A self-join with COALESCE in the WHERE
+ * clause used to fail with a NullPointerException because
+ * CoalesceFunctionNode didn't remap column references correctly.
+ */
+ public void testColumnRemappingDerby4342() throws SQLException {
+ JDBC.assertSingleValueResultSet(s.executeQuery(
+ "select t1.smallintcol from " +
+ "AllDataTypesTable t1 join AllDataTypesTable t2 " +
+ "on t1.smallintcol=t2.smallintcol where " +
+ "coalesce(t1.smallintcol, t1.integercol) = 1"),
+ "1");
+ }
/**************supporting methods *******************/
private void dumpRS(ResultSet rs, String expectedValue) throws SQLException