db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r427899 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/ engine/org/apache/derby/loc/ shared/org/apache/derby/shared/common/reference/ testing/org/apache/derbyTesting/functionTests/harness/ testing/org/apache/derbyT...
Date Wed, 02 Aug 2006 05:30:11 GMT
Author: davidvc
Date: Tue Aug  1 22:30:11 2006
New Revision: 427899

URL: http://svn.apache.org/viewvc?rev=427899&view=rev
Log:
DERBY-939: NullPointerException at ResultSet.close() time for simple 
query using UNION and INTERSECT.  Contributed by Yip Ng.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RealResultSetStatisticsFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RealResultSetStatisticsFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RealResultSetStatisticsFactory.java?rev=427899&r1=427898&r2=427899&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RealResultSetStatisticsFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RealResultSetStatisticsFactory.java
Tue Aug  1 22:30:11 2006
@@ -62,6 +62,7 @@
 import org.apache.derby.impl.sql.execute.RowResultSet;
 import org.apache.derby.impl.sql.execute.ScalarAggregateResultSet;
 import org.apache.derby.impl.sql.execute.ScrollInsensitiveResultSet;
+import org.apache.derby.impl.sql.execute.SetOpResultSet;
 import org.apache.derby.impl.sql.execute.SortResultSet;
 import org.apache.derby.impl.sql.execute.TableScanResultSet;
 import org.apache.derby.impl.sql.execute.UnionResultSet;
@@ -96,6 +97,7 @@
 import org.apache.derby.impl.sql.execute.rts.RealRowResultSetStatistics;
 import org.apache.derby.impl.sql.execute.rts.RealScalarAggregateStatistics;
 import org.apache.derby.impl.sql.execute.rts.RealScrollInsensitiveResultSetStatistics;
+import org.apache.derby.impl.sql.execute.rts.RealSetOpResultSetStatistics;
 import org.apache.derby.impl.sql.execute.rts.RealSortStatistics;
 import org.apache.derby.impl.sql.execute.rts.RealTableScanStatistics;
 import org.apache.derby.impl.sql.execute.rts.RealUnionResultSetStatistics;
@@ -816,9 +818,32 @@
 											rrs.optimizerEstimatedRowCount,
 											rrs.optimizerEstimatedCost);
 		}
+		else if (rs instanceof SetOpResultSet)
+		{
+			SetOpResultSet srs = (SetOpResultSet) rs;
+
+			return new RealSetOpResultSetStatistics(
+											srs.getOpType(),
+											srs.numOpens,
+											srs.rowsSeen,
+											srs.rowsFiltered,
+											srs.constructorTime,
+											srs.openTime,
+											srs.nextTime,
+											srs.closeTime,
+											srs.getResultSetNumber(),
+											srs.getRowsSeenLeft(),
+											srs.getRowsSeenRight(),
+											srs.getRowsReturned(),
+											srs.optimizerEstimatedRowCount,
+											srs.optimizerEstimatedCost,
+											getResultSetStatistics(srs.getLeftSourceInput()),
+											getResultSetStatistics(srs.getRightSourceInput())
+											);
+		}
 		else if (rs instanceof UnionResultSet)
 		{
-			UnionResultSet urs = (UnionResultSet) rs;
+			UnionResultSet urs = (UnionResultSet)rs;
 
 			return new RealUnionResultSetStatistics(
 											urs.numOpens,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java?rev=427899&r1=427898&r2=427899&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SetOpResultSet.java
Tue Aug  1 22:30:11 2006
@@ -2,7 +2,7 @@
 
    Derby - Class org.apache.derby.impl.sql.execute.SetOpResultSet
 
-   Copyright 2004 The Apache Software Foundation or its licensors, as applicable.
+   Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -64,6 +64,11 @@
     private final int[] intermediateOrderByColumns;
     private final int[] intermediateOrderByDirection;
 
+    /* Run time statistics variables */
+    private int rowsSeenLeft;
+    private int rowsSeenRight;
+    private int rowsReturned;
+
     SetOpResultSet( NoPutResultSet leftSource,
                     NoPutResultSet rightSource,
                     Activation activation, 
@@ -99,12 +104,17 @@
 	{
 		beginTime = getCurrentTimeMillis();
 		if (SanityManager.DEBUG)
-	    	SanityManager.ASSERT( ! isOpen, "SetOpProjectRestrictResultSet already open");
+	    	SanityManager.ASSERT( ! isOpen, "SetOpResultSet already open");
 
         isOpen = true;
         leftSource.openCore();
         rightSource.openCore();
         rightInputRow = rightSource.getNextRowCore();
+        if (rightInputRow != null)
+        {
+            rowsSeenRight++;
+        }
+
 		numOpens++;
 
 		openTime += getElapsedMillis(beginTime);
@@ -121,6 +131,8 @@
         {
             while( (leftInputRow = leftSource.getNextRowCore()) != null)
             {
+                rowsSeenLeft++;
+
                 DataValueDescriptor[] leftColumns = leftInputRow.getRowArray();
                 if( !all)
                 {
@@ -130,9 +142,15 @@
                 }
                 int compare = 0;
                 // Advance the right until there are no more right rows or leftRow <=
rightRow
-                while( rightInputRow != null && (compare = compare( leftColumns,
rightInputRow.getRowArray())) > 0)
+                while ( rightInputRow != null && (compare = compare(leftColumns,
rightInputRow.getRowArray())) > 0)
+                {
                     rightInputRow = rightSource.getNextRowCore();
-                
+                    if (rightInputRow != null)
+                    {
+                        rowsSeenRight++;
+                    }
+                }
+
                 if( rightInputRow == null || compare < 0)
                 {
                     // The left row is not in the right source.
@@ -145,10 +163,17 @@
                     // The left and right rows are the same
                     if( SanityManager.DEBUG)
                         SanityManager.ASSERT( rightInputRow != null && compare ==
0,
-                                              "Insert/Except execution has gotten confused.");
-                    if( all)
+                                              "Intersect/Except execution has gotten confused.");
+                    if ( all)
+                    {
                         // Just advance the right input by one row.
                         rightInputRow = rightSource.getNextRowCore();
+                        if (rightInputRow != null)
+                        {
+                            rowsSeenRight++;
+                        }
+                    }
+
                     // If !all then we will skip past duplicates on the left at the top of
this loop,
                     // which will then force us to skip past any right duplicates.
                     if( opType == IntersectOrExceptNode.INTERSECT_OP)
@@ -160,7 +185,12 @@
             }
         }
         currentRow = leftInputRow;
-        setCurrentRow( currentRow);
+        setCurrentRow( currentRow );
+
+        if (currentRow != null) {
+           rowsReturned++;
+        }
+
         nextTime += getElapsedMillis(beginTime);
         return currentRow;
     } // end of getNextRowCore
@@ -168,9 +198,13 @@
     private void advanceRightPastDuplicates( DataValueDescriptor[] leftColumns)
         throws StandardException
     {
-        while((rightInputRow = rightSource.getNextRowCore()) != null
-              && compare( leftColumns, rightInputRow.getRowArray()) == 0)
-            ;
+        while ((rightInputRow = rightSource.getNextRowCore()) != null)
+        {
+            rowsSeenRight++;
+
+            if (compare(leftColumns, rightInputRow.getRowArray()) == 0) 
+                continue;
+        }
     } // end of advanceRightPastDuplicates
         
     private int compare( DataValueDescriptor[] leftCols, DataValueDescriptor[] rightCols)
@@ -237,7 +271,7 @@
         }
 		else
 			if (SanityManager.DEBUG)
-				SanityManager.DEBUG("CloseRepeatInfo","Close of UnionResultSet repeated");
+				SanityManager.DEBUG("CloseRepeatInfo","Close of SetOpResultSet repeated");
 
 		closeTime += getElapsedMillis(beginTime);
 	} // end of close
@@ -283,5 +317,82 @@
         // RESOLVE: What is the row location of an INTERSECT supposed to be: the location
from the
         // left side, the right side, or null?
         return ((CursorResultSet)leftSource).getRowLocation();
+    }
+
+    /**
+     * Return the set operation of this <code>SetOpResultSet</code>
+     *
+     * @return the set operation of this ResultSet, the value is either 
+     *         <code>IntersectOrExceptNode.INTERSECT_OP</code> for 
+     *         Intersect operation or <code>IntersectOrExceptNode.EXCEPT_OP
+     *         </code> for Except operation
+     *         
+     * @see    org.apache.derby.impl.sql.compile.IntersectOrExceptNode
+     */
+    public int getOpType()
+    {
+        return opType;
+    }
+
+    /**
+     * Return the result set number
+     *
+     * @return the result set number
+     */
+    public int getResultSetNumber()
+    {
+        return resultSetNumber;
+    }
+
+    /**
+     * Return the left source input of this <code>SetOpResultSet</code>
+     *
+     * @return the left source input of this <code>SetOpResultSet</code>
+     * @see org.apache.derby.iapi.sql.execute.NoPutResultSet
+     */
+    public NoPutResultSet getLeftSourceInput()
+    {
+        return leftSource;
+    }
+
+    /**
+     * Return the right source input of this <code>SetOpResultSet</code>
+     *
+     * @return the right source input of this <code>SetOpResultSet</code>
+     * @see org.apache.derby.iapi.sql.execute.NoPutResultSet
+     */
+    public NoPutResultSet getRightSourceInput()
+    {
+        return rightSource;
+    }
+
+    /**
+     * Return the number of rows seen on the left source input
+     *
+     * @return the number of rows seen on the left source input
+     */
+    public int getRowsSeenLeft()
+    {
+        return rowsSeenLeft;
+    }
+
+    /**
+     * Return the number of rows seen on the right source input
+     *
+     * @return the number of rows seen on the right source input
+     */
+    public int getRowsSeenRight()
+    {
+        return rowsSeenRight;
+    }
+
+    /**
+     * Return the number of rows returned from the result set
+     *
+     * @return the number of rows returned from the result set
+     */
+    public int getRowsReturned()
+    {
+        return rowsReturned;
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=427899&r1=427898&r2=427899&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Tue Aug  1
22:30:11 2006
@@ -973,7 +973,11 @@
 43Y55.U=End Referential Action On Dependent Table Number
 43Y56.U=User supplied optimizer overrides on {0} are {1}
 43Y57.U=User supplied optimizer overrides for join are {0}
-
+43Y58.U=Intersect ResultSet
+43Y59.U=Intersect
+43Y60.U=Except ResultSet
+43Y61.U=Except
+	
 54004=SELECT statement has too many items in GROUP BY, ORDER BY or select list.
 54008=The CREATE INDEX statement specifies too many columns (16 is the maximum).
 54023=The limit for the number of parameters for a procedure has been exceeded. Limit is
{0} and number of parameters for procedure {1} are {2}.

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=427899&r1=427898&r2=427899&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Tue Aug  1 22:30:11 2006
@@ -1153,7 +1153,11 @@
 	String RTS_BEGIN_DEPENDENT_NUMBER								   = "43Y54.U";	
 	String RTS_END_DEPENDENT_NUMBER									   = "43Y55.U";	
 	String RTS_USER_SUPPLIED_OPTIMIZER_OVERRIDES_FOR_TABLE			   = "43Y56.U";	
-	String RTS_USER_SUPPLIED_OPTIMIZER_OVERRIDES_FOR_JOIN			   = "43Y57.U";	
+	String RTS_USER_SUPPLIED_OPTIMIZER_OVERRIDES_FOR_JOIN			   = "43Y57.U";
+	String RTS_INTERSECT_RS                                            = "43Y58.U";
+	String RTS_INTERSECT                                               = "43Y59.U";
+	String RTS_EXCEPT_RS                                               = "43Y60.U";
+	String RTS_EXCEPT                                                  = "43Y61.U";
 
 	// org.apache.derby.catalog.types
 	String TI_SQL_TYPE_NAME			= "44X00.U";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java?rev=427899&r1=427898&r2=427899&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
Tue Aug  1 22:30:11 2006
@@ -39,7 +39,8 @@
 
 public class Sed
 {
-	private	static	final	String	SQL_EXCEPTION_FILTERED_SUBSTITUTION = "SQL Exception:";
+	private	static	final	String	SQL_EXCEPTION_FILTERED_SUBSTITUTION = 
+        "java.sql.SQLException:";
 
     public Sed()
     {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall?rev=427899&r1=427898&r2=427899&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
Tue Aug  1 22:30:11 2006
@@ -117,6 +117,7 @@
 lang/repeat.java
 lang/schemas.sql
 lang/select.sql
+lang/setOpPlan.sql
 lang/simpleThreadWrapper.java
 lang/specjPlans.sql
 lang/SpillHash.java



Mime
View raw message