db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1071741 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Date Thu, 17 Feb 2011 18:34:35 GMT
Author: kmarsden
Date: Thu Feb 17 18:34:35 2011
New Revision: 1071741

URL: http://svn.apache.org/viewvc?rev=1071741&view=rev
Log:
DERBY-4798 NPE in nested outer join

merge 998170 from trunk. Moved test to JoinTest.java for 10.5
Contributed by Dag H Wanvik


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 17 18:34:35 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.6:942027,957000,957287,958621,962738,965351,987678,997790*,1031623,1055601,1068474,1071167
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,826263,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952237,952581,954748,955001,955634,956075,956445,956659,957260,958163,958618,959550,961892,962716,964039,964402,965647,96
 6393,967201,967304,980089,980684,986689,986834,987539,989099,997325*,999119,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,826263,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952237,952581,954748,955001,955634,956075,956445,956659,957260,958163,958618,959550,961892,962716,964039,964402,965647,96
 6393,967201,967304,980089,980684,986689,986834,987539,989099,997325*,998170,999119,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java?rev=1071741&r1=1071740&r2=1071741&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
Thu Feb 17 18:34:35 2011
@@ -1455,7 +1455,23 @@ public abstract class BaseActivation imp
 	protected final DataValueDescriptor getColumnFromRow(int rsNumber, int colId)
 		throws StandardException {
 
-		return row[rsNumber].getColumn(colId);
+        if (row[rsNumber] == null) {
+            /* This actually happens. NoPutResultSetImpl.clearOrderableCache
+             * attempts to prefetch invariant values into a cache. This fails
+             * in some deeply nested joins. See Beetle 4736 and 4880.*/
+
+            /*
+             * Update: DERBY-4798 shows a query for which we get an NPE unless
+             * this escape is in place (once removed by DERBY-3097, but
+             * reintroduced by DERBY-4798 until we understand how we can get
+             * rid of this anomaly). Thus, for now,
+             * OuterJoinTest#testDerby_4798_NPE will provoke an NPE if this
+             * code is removed.
+             */
+            return null;
+        }
+
+        return row[rsNumber].getColumn(colId);
 	}
 
     /**

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java?rev=1071741&r1=1071740&r2=1071741&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Thu Feb 17 18:34:35 2011
@@ -408,4 +408,123 @@ public class JoinTest extends BaseJDBCTe
         rollback();
     }
 
+    /**
+     * Test the queries reported in DERBY-4798 as giving null pointer
+     * exceptions. Should fail with NPE before the fix went in.
+     * In trunk and 10.6 this test is in OuterJoinTest but that test
+     * is not in 10.5 so put the test here in JoinTest
+     */
+    public void testDerby_4798_NPE() throws Exception
+    {
+        setAutoCommit(false);
+
+        Statement st = createStatement();
+        ResultSet rs = null;
+        String [][] expRS;
+
+        st.executeUpdate("create table t0(x0 int)");
+        st.executeUpdate("create table t1(x1 int)");
+        st.executeUpdate("create table t2(x2 int)");
+        st.executeUpdate("create table t3(x3 int)");
+        st.executeUpdate("create table t4(x4 int)");
+        st.executeUpdate("insert into t4 values(0)");
+        st.executeUpdate("insert into t4 values(1)");
+        st.executeUpdate("insert into t4 values(2)");
+        st.executeUpdate("insert into t4 values(3)");
+        st.executeUpdate("create table t5(x5 int)");
+        st.executeUpdate("insert into t5 values(0)");
+        st.executeUpdate("insert into t5 values(1)");
+        st.executeUpdate("insert into t5 values(2)");
+        st.executeUpdate("insert into t5 values(3)");
+        st.executeUpdate("insert into t5 values(4)");
+        st.executeUpdate("create table t6(x6 int)");
+        st.executeUpdate("insert into t6 values(0)");
+        st.executeUpdate("insert into t6 values(1)");
+        st.executeUpdate("insert into t6 values(2)");
+        st.executeUpdate("insert into t6 values(3)");
+        st.executeUpdate("insert into t6 values(4)");
+        st.executeUpdate("insert into t6 values(5)");
+        st.executeUpdate("create table t7(x7 int)");
+        st.executeUpdate("insert into t7 values(0)");
+        st.executeUpdate("insert into t7 values(1)");
+        st.executeUpdate("insert into t7 values(2)");
+        st.executeUpdate("insert into t7 values(3)");
+        st.executeUpdate("insert into t7 values(4)");
+        st.executeUpdate("insert into t7 values(5)");
+        st.executeUpdate("insert into t7 values(6)");
+        st.executeUpdate("insert into t0 values(1)");
+        st.executeUpdate("insert into t1 values(2)");
+        st.executeUpdate("insert into t0 values(3)");
+        st.executeUpdate("insert into t1 values(3)");
+        st.executeUpdate("insert into t2 values(4)");
+        st.executeUpdate("insert into t0 values(5)");
+        st.executeUpdate("insert into t2 values(5)");
+        st.executeUpdate("insert into t1 values(6)");
+        st.executeUpdate("insert into t2 values(6)");
+        st.executeUpdate("insert into t0 values(7)");
+        st.executeUpdate("insert into t1 values(7)");
+        st.executeUpdate("insert into t2 values(7)");
+        st.executeUpdate("insert into t3 values(8)");
+        st.executeUpdate("insert into t0 values(9)");
+        st.executeUpdate("insert into t3 values(9)");
+        st.executeUpdate("insert into t1 values(10)");
+        st.executeUpdate("insert into t3 values(10)");
+        st.executeUpdate("insert into t0 values(11)");
+        st.executeUpdate("insert into t1 values(11)");
+        st.executeUpdate("insert into t3 values(11)");
+        st.executeUpdate("insert into t2 values(12)");
+        st.executeUpdate("insert into t3 values(12)");
+        st.executeUpdate("insert into t0 values(13)");
+        st.executeUpdate("insert into t2 values(13)");
+        st.executeUpdate("insert into t3 values(13)");
+        st.executeUpdate("insert into t1 values(14)");
+        st.executeUpdate("insert into t2 values(14)");
+        st.executeUpdate("insert into t3 values(14)");
+        st.executeUpdate("insert into t0 values(15)");
+        st.executeUpdate("insert into t1 values(15)");
+        st.executeUpdate("insert into t2 values(15)");
+        st.executeUpdate("insert into t3 values(15)");
+
+        rs = st.executeQuery(
+        "SELECT t0.x0, " +
+        "       t1.x1," +
+        "       t2.x2," +
+        "       t3.x3," +
+        "       t4.x4," +
+        "       t5.x5," +
+        "       t6.x6," +
+        "       t7.x7 " +
+        "FROM         " +
+        " ((t0                                                               " +
+        "   LEFT OUTER JOIN ((t1                                             " +
+        "                     LEFT OUTER JOIN (t2                            " +
+        "                                      LEFT OUTER JOIN t3            " +
+        "                                        ON t2.x2 = t3.x3 )          " +
+        "                       ON t1.x1 = t2.x2 )                           " +
+        "                    LEFT OUTER JOIN (t4                             " +
+        "                                     INNER JOIN (t5                 " +
+        "                                                 LEFT OUTER JOIN t6 " +
+        "                                                   ON t5.x5 = t6.x6)" +
+        "                                       ON t4.x4 = t5.x5 )           " +
+        "                      ON t1.x1 = t5.x5 )                            " +
+        "     ON t0.x0 = t5.x5 )                                             " +
+        "  LEFT OUTER JOIN t7                                                " +
+        "    ON t3.x3 = t7.x7 )                                              ");
+
+        expRS = new String [][]
+        {
+            {"1", "1", null, null, null, null, null, null},
+            {"3", "3", "3", null, "3", "3", "3", null},
+            {"5", "5", null, null, null, null, null, null},
+            {"7", "7", null, null, null, null, null, null},
+            {"9", "9", null, null, null, null, null, null},
+            {"11", "11", null, null, null, null, null, null},
+            {"13", "13", null, null, null, null, null, null},
+            {"15", "15", null, null, null, null, null, null}
+        };
+
+        JDBC.assertFullResultSet(rs, expRS);
+    }
 }
+
+



Mime
View raw message