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 rh...@apache.org on 2019/04/02 13:28:40 UTC

svn commit: r1856824 - in /db/derby/code/branches/10.15: ./ java/org.apache.derby.engine/org/apache/derby/impl/sql/compile/AggregateNode.java java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/lang/AggBuiltinTest.java

Author: rhillegas
Date: Tue Apr  2 13:28:40 2019
New Revision: 1856824

URL: http://svn.apache.org/viewvc?rev=1856824&view=rev
Log:
DERBY-7041: Port 1856730 from trunk to the 10.15 branch.

Modified:
    db/derby/code/branches/10.15/   (props changed)
    db/derby/code/branches/10.15/java/org.apache.derby.engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/branches/10.15/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/lang/AggBuiltinTest.java

Propchange: db/derby/code/branches/10.15/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr  2 13:28:40 2019
@@ -2,4 +2,4 @@
 /db/derby/code/branches/10.7:1061570,1061578,1082235
 /db/derby/code/branches/10.8:1177474,1234973,1464951
 /db/derby/code/branches/10.9:1373148
-/db/derby/code/trunk:1063809,1851719-1851720,1854928,1854986,1855177,1855325-1855326,1855360,1855362,1855520,1856701
+/db/derby/code/trunk:1063809,1851719-1851720,1854928,1854986,1855177,1855325-1855326,1855360,1855362,1855520,1856701,1856730

Modified: db/derby/code/branches/10.15/java/org.apache.derby.engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.15/java/org.apache.derby.engine/org/apache/derby/impl/sql/compile/AggregateNode.java?rev=1856824&r1=1856823&r2=1856824&view=diff
==============================================================================
--- db/derby/code/branches/10.15/java/org.apache.derby.engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/branches/10.15/java/org.apache.derby.engine/org/apache/derby/impl/sql/compile/AggregateNode.java Tue Apr  2 13:28:40 2019
@@ -398,8 +398,12 @@ class AggregateNode extends UnaryOperato
             }
 
             // set up dependency on the user-defined aggregate and compile a check for USAGE
-            // priv if needed
-            getCompilerContext().createDependency( ad );
+            // priv if needed. no need for a dependency if this is a builtin, system-supplied
+            // aggregate
+            if ( !isModernBuiltinAggregate )
+            {
+                getCompilerContext().createDependency( ad );
+            }
 
             if ( isPrivilegeCollectionRequired() )
             {

Modified: db/derby/code/branches/10.15/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/lang/AggBuiltinTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.15/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/lang/AggBuiltinTest.java?rev=1856824&r1=1856823&r2=1856824&view=diff
==============================================================================
--- db/derby/code/branches/10.15/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/lang/AggBuiltinTest.java (original)
+++ db/derby/code/branches/10.15/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/lang/AggBuiltinTest.java Tue Apr  2 13:28:40 2019
@@ -80,6 +80,9 @@ public final class AggBuiltinTest extend
             stddev_pop();
             // Standard deviation sample (n - 1)
         	stddev_samp();
+
+            // bugs
+            derby7041();
         	
         } finally {
             try {
@@ -94,6 +97,71 @@ public final class AggBuiltinTest extend
         }
     }
 
+    /**
+     * Bug 7041 was an NPE raised when trying to record a persistent dependency
+     * from a view to a builtin aggregate which had been created with the user-defined
+     * aggregate machinery.
+     */
+    private void derby7041() throws SQLException
+    {
+        x
+            (
+             "CREATE TABLE T1_7041\n" +
+             "(\n" +
+             "	T1_7041_KEY INTEGER,\n" +
+             "	T1_7041_TAG INTEGER\n" +
+             ")\n"
+             );
+        x
+            (
+             "CREATE TABLE T2_7041\n" +
+             "(\n" +
+             "	T2_7041_KEY INTEGER\n" +
+             ")\n"
+             );
+        x
+            (
+             "CREATE TABLE T3_7041\n" +
+             "(\n" +
+             "	T3_7041_KEY1 INTEGER,\n" +
+             "	T3_7041_KEY2 INTEGER,\n" +
+             "	T3_7041_VAL INTEGER\n" +
+             ")\n"
+             );
+        x
+            (
+             "CREATE VIEW V1_7041 (T1_7041_TAG, VALUE) AS\n" +
+             "(\n" +
+             "  SELECT T1_7041_TAG, T3_7041_VAL AS VALUE\n" +
+             "  FROM T1_7041, T2_7041, T3_7041\n" +
+             "  WHERE\n" +
+             "    T1_7041_KEY = T3_7041_KEY2\n" +
+             "    AND T2_7041_KEY = T3_7041_KEY1\n" +
+             ")\n"
+             );
+        x
+            (
+             "CREATE VIEW V2_7041 AS\n" +
+             "(\n" +
+             "  SELECT\n" +
+             "    A.T1_7041_TAG AS A_T1_7041_TAG,\n" +
+             "    A.VALUE AS A_VALUE\n" +
+             "  FROM V1_7041 AS A, V1_7041 AS B\n" +
+             ")\n"
+             );
+        x
+            (
+             "CREATE VIEW V3_7041 (A_T1_7041_TAG, STD_DEV_A_VALUE) AS\n" +
+             "(\n" +
+             "  SELECT\n" +
+             "    A_T1_7041_TAG,\n" +
+             "    STDDEV_SAMP(A_VALUE) AS STD_DEV_A_VALUE\n" +
+             "  FROM V2_7041\n" +
+             "  GROUP BY A_T1_7041_TAG\n" +
+             ")\n"
+             );
+    }
+
 
     private void avg() throws SQLException {
         x("create table t (i int, s smallint, l bigint,"