db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r557290 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute: BasicNoPutResultSetImpl.java MiscResultSet.java NoRowsResultSetImpl.java ScanResultSet.java
Date Wed, 18 Jul 2007 15:16:24 GMT
Author: djd
Date: Wed Jul 18 08:16:23 2007
New Revision: 557290

URL: http://svn.apache.org/viewvc?view=rev&rev=557290
Log:
Cleanup of some code in the language ResultSet implementations.
Don't store the LCC in each BasicNoPutResultSetImpl as it is available through
the activation. Re-write comments for NoRowsResultSetImpl and make its "rows" methods
final where possible to ensure sub-classes don't implement them, since they have no
meaning for a result set that does not return rows.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScanResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java?view=diff&rev=557290&r1=557289&r2=557290
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicNoPutResultSetImpl.java
Wed Jul 18 08:16:23 2007
@@ -74,7 +74,6 @@
     protected boolean finished;
 	protected ExecRow	  currentRow;
 	protected boolean isTopResultSet;
-	protected LanguageConnectionContext	lcc;
 	private SQLWarning	warnings;
 
 	/* Run time statistics variables */
@@ -98,12 +97,11 @@
 	ExecRow compactRow;
 
 	// Set in the constructor and not modified
-	protected Activation	    activation;
+	protected final Activation	    activation;
 	private boolean				statisticsTimingOn;
 
 	ResultDescription resultDescription;
 
-	private transient ExecutionFactory			exFactory;
 	private transient TransactionController	tc;
 
 	private int[] baseColumnMap;
@@ -127,7 +125,7 @@
 							double optimizerEstimatedCost)
 	{
 		this.activation = activation;
-		statisticsTimingOn = (activation != null && getLanguageConnectionContext().getStatisticsTiming());
+		statisticsTimingOn = getLanguageConnectionContext().getStatisticsTiming();
 		beginTime = startExecutionTime = getCurrentTimeMillis();
 		this.resultDescription = resultDescription;
 		this.optimizerEstimatedRowCount = optimizerEstimatedRowCount;
@@ -844,22 +842,7 @@
 	  */
 	protected	final LanguageConnectionContext	getLanguageConnectionContext()
 	{
-		if ( lcc == null )
-		{
-			/* We don't always have an activation.  Get the LCC
-			 * from the activation when we have one.
-			 */
-			if (activation != null)
-			{
-				lcc = activation.getLanguageConnectionContext();
-			}
-			else
-			{
-				lcc = (LanguageConnectionContext) ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);

-			}
-		}
-
-		return	lcc;
+        return getActivation().getLanguageConnectionContext();
 	}
 
 	/** @see NoPutResultSet#resultSetNumber() */
@@ -887,12 +870,7 @@
 	 */
 	final ExecutionFactory getExecutionFactory() 
 	{
-		if (exFactory == null) {
-			exFactory = activation.getExecutionFactory();
-		}
-		if (SanityManager.DEBUG)
-			SanityManager.ASSERT(exFactory!=null,"unable to get execution factory");
-		return exFactory;
+		return activation.getExecutionFactory();
 	}
 
 	/**
@@ -966,7 +944,7 @@
 
 			if (compactRow == null)
 			{
-				ExecutionFactory ex = lcc.getLanguageConnectionFactory().getExecutionFactory();
+				ExecutionFactory ex = getLanguageConnectionContext().getLanguageConnectionFactory().getExecutionFactory();
 
 				if (isKeyed)
 				{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java?view=diff&rev=557290&r1=557289&r2=557290
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java Wed
Jul 18 08:16:23 2007
@@ -62,7 +62,7 @@
 	{
 		setup();
 		activation.getConstantAction().executeConstantAction(activation);
-		super.close();
+		close();
 	}
 
 	// Does not override close() (no action required)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java?view=diff&rev=557290&r1=557289&r2=557290
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
Wed Jul 18 08:16:23 2007
@@ -46,21 +46,14 @@
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
 /**
- * This implementation of ResultSet
- * is meant to be overridden by subtypes
- * in the execution engine. Its primary users
- * will be DDL, which only need to define a
- * constructor to create the DDL object being
- * defined. All other ResultSet operations will
- * be handled by this superclass -- i.e., nothing
- * is allowed to be done to a DDL Result Set, since
- * it has no rows to provide.
- * <p>
- * This abstract class does not define the entire ResultSet
- * interface, but leaves the 'get' half of the interface
- * for subtypes to implement. It is package-visible only,
- * with its methods being public for exposure by its subtypes.
- * <p>
+ * Abstract ResultSet for implementations that do not return rows.
+ * Examples are DDL statements, CALL statements and DML.
+ * <P>
+ * An implementation must provide a ResultSet.open() method
+ * that performs the required action. 
+ * <P>
+ * ResultSet.returnsRows() returns false and any method
+ * that fetches a row will throw an exception.
  *
  */
 abstract class NoRowsResultSetImpl implements ResultSet
@@ -109,10 +102,7 @@
 		sc.setTopResultSet(this, (NoPutResultSet[]) null);
 
 		// Pick up any materialized subqueries
-		if (subqueryTrackingArray == null)
-		{
-			subqueryTrackingArray = sc.getSubqueryTrackingArray();
-		}
+		subqueryTrackingArray = sc.getSubqueryTrackingArray();
 	}
 
 	/**
@@ -163,7 +153,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	getAbsoluteRow(int row) throws StandardException
+	public final ExecRow	getAbsoluteRow(int row) throws StandardException
 	{
 		/*
 			The JDBC use of this class will never call here.
@@ -189,7 +179,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	getRelativeRow(int row) throws StandardException
+	public final ExecRow	getRelativeRow(int row) throws StandardException
 	{
 		/*
 			The JDBC use of this class will never call here.
@@ -207,7 +197,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	setBeforeFirstRow() 
+	public final ExecRow	setBeforeFirstRow() 
 		throws StandardException
 	{
 		/*
@@ -226,7 +216,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	getFirstRow() 
+	public final ExecRow	getFirstRow() 
 		throws StandardException
 	{
 		/*
@@ -244,7 +234,7 @@
 	 *									that this method is not intended to
 	 *									be used.
 	 */
-	public ExecRow	getNextRow() throws StandardException
+	public final ExecRow	getNextRow() throws StandardException
 	{
 		/*
 			The JDBC use of this class will never call here.
@@ -262,7 +252,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	getPreviousRow() 
+	public final ExecRow	getPreviousRow() 
 		throws StandardException
 	{
 		/*
@@ -281,7 +271,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	getLastRow()
+	public final ExecRow	getLastRow()
 		throws StandardException
 	{
 		/*
@@ -300,7 +290,7 @@
 	 * @exception StandardException		Thrown on failure
 	 * @see Row
 	 */
-	public ExecRow	setAfterLastRow() 
+	public final ExecRow	setAfterLastRow() 
 		throws StandardException
 	{
 		/*
@@ -327,7 +317,7 @@
      * @return true if before the first row, false otherwise. Returns
      * false when the result set contains no rows.
      */
-    public boolean checkRowPosition(int isType)
+    public final boolean checkRowPosition(int isType)
 	{
 		return false;
 	}
@@ -341,7 +331,7 @@
 	 * @return	the row number, or 0 if not on a row
 	 *
 	 */
-	public int getRowNumber()
+	public final int getRowNumber()
 	{
 		return 0;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScanResultSet.java?view=diff&rev=557290&r1=557289&r2=557290
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScanResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScanResultSet.java Wed
Jul 18 08:16:23 2007
@@ -77,7 +77,7 @@
 
         if (isolationLevel == ExecutionContext.UNSPECIFIED_ISOLATION_LEVEL) {
             unspecifiedIsolationLevel = true;
-            isolationLevel = lcc.getCurrentIsolationLevel();
+            isolationLevel = getLanguageConnectionContext().getCurrentIsolationLevel();
         } else {
             unspecifiedIsolationLevel = false;
         }
@@ -98,7 +98,7 @@
      */
     void initIsolationLevel() {
         if (isolationLevelNeedsUpdate) {
-            int languageLevel = lcc.getCurrentIsolationLevel();
+            int languageLevel = getLanguageConnectionContext().getCurrentIsolationLevel();
             lockMode = getLockMode(languageLevel);
             isolationLevel = translateLanguageIsolationLevel(languageLevel);
             isolationLevelNeedsUpdate = false;



Mime
View raw message