db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r289298 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/ impl/sql/compile/ impl/sql/conn/
Date Thu, 15 Sep 2005 19:40:34 GMT
Author: djd
Date: Thu Sep 15 12:40:28 2005
New Revision: 289298

URL: http://svn.apache.org/viewcvs?rev=289298&view=rev
Log:
Cleanup of CompilerContext code.
Store a reference to the LanguageConnectionContext in the CompilerContext
to avoid re-fetching it from the stack on very use. A CompilerContext is
specific and private to a LanguageConnectionContext, added comments to that effect.
Remove unused code related to parameter modifications within the compiler context.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStorablePreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
Thu Sep 15 12:40:28 2005
@@ -51,6 +51,7 @@
  * the compiler.  Stack compiler contexts when a new, local parser is needed
  * (if calling the compiler recursively from within the compiler,
  * for example).
+ * CompilerContext objects are private to a LanguageConnectionContext.
  *
  * @author ames
  *
@@ -248,15 +249,6 @@
 	String getUniqueClassName();
 
 	/**
-	 * Get the current dependent from this CompilerContext.
-	 *
-	 * @return	The Dependent currently being compiled.
-	 *
-	 */
-
-	Dependent getCurrentDependent();
-
-	/**
 	 * Set the current dependent from this CompilerContext.
 	 * This should be called at the start of a compile to
 	 * register who has the dependencies needed for the compilation.
@@ -402,14 +394,12 @@
 	 *
 	 * @param conglomerateNumber	The conglomerate for which to get a
 	 *								StoreCostController.
-	 * @param lcc					Current LanguageConnectionContext.
 	 *
 	 * @return	The appropriate StoreCostController.
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public StoreCostController getStoreCostController(long conglomerateNumber,
-													  LanguageConnectionContext lcc)
+	public StoreCostController getStoreCostController(long conglomerateNumber)
 			throws StandardException;
 
 	/**
@@ -458,32 +448,6 @@
 	 */
 
 	public DataTypeDescriptor[] getParameterTypes();
-
-	/**
-	 * Get the next parameter number.
-	 * Useful when generating "associated" 
-	 * parameters.
-	 *
-	 * @return The next parameter number for the statement.
-	 */
-	public int getNextParameterNumber();
-
-	/**
-	 * Get the params stored vai setParams.
-	 * WARNING: nulls out the params value before
-	 * returning it, so a subsequent get will
-	 * get a null.
-	 *
-	 * @return the parameters
-	 */
-	public ParameterValueSet getParams();
-	
-	/**
-	 * Set params
-	 *
-	 * @param params the params
-	 */
-	public void setParams(ParameterValueSet params);
 
 	/**
 	 * Get the cursor info stored in the context.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
Thu Sep 15 12:40:28 2005
@@ -20,16 +20,12 @@
 
 package org.apache.derby.impl.sql;
 
-import org.apache.derby.iapi.reference.JDBC20Translation;
-
 import	org.apache.derby.catalog.Dependable;
 import	org.apache.derby.catalog.DependableFinder;
 
-import org.apache.derby.iapi.services.context.Context;
 import org.apache.derby.iapi.services.context.ContextService;
 import org.apache.derby.iapi.services.context.ContextManager;
 
-import org.apache.derby.iapi.services.monitor.ModuleFactory;
 import org.apache.derby.iapi.services.monitor.Monitor;
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
@@ -41,11 +37,7 @@
 import org.apache.derby.iapi.services.uuid.UUIDFactory;
 import org.apache.derby.iapi.util.ByteArray;
 
-import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
-import org.apache.derby.iapi.services.stream.InfoStreams;
-
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;
 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
 import org.apache.derby.iapi.sql.dictionary.SPSDescriptor;
 
@@ -59,12 +51,10 @@
 import org.apache.derby.iapi.sql.Activation;
 
 import org.apache.derby.iapi.sql.execute.ConstantAction;
-import org.apache.derby.iapi.sql.execute.ExecutionContext;
 import org.apache.derby.iapi.sql.execute.ExecCursorTableReference;
 import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
 
 import org.apache.derby.iapi.sql.depend.DependencyManager;
-import org.apache.derby.iapi.sql.depend.Dependent;
 import org.apache.derby.iapi.sql.depend.Provider;
 
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
@@ -75,14 +65,11 @@
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.Property;
 
 import org.apache.derby.iapi.services.loader.GeneratedClass;
-import org.apache.derby.iapi.services.loader.ClassFactory;
 
 import java.sql.Timestamp;
 import java.sql.SQLWarning;
-import java.util.Vector;
 
 /**
  * Basic implementation of prepared statement.
@@ -145,7 +132,6 @@
 	protected String UUIDString;
 	protected UUID   UUIDValue;
 
-	private ParameterValueSet params;
 	private boolean needsSavepoint;
 
 	private String execStmtName;
@@ -187,7 +173,7 @@
 	// constructors
 	//
 
-	protected GenericPreparedStatement() {
+	GenericPreparedStatement() {
 		/* Get the UUID for this prepared statement */
 		UUIDFactory uuidFactory = 
 			Monitor.getMonitor().getUUIDFactory();
@@ -247,11 +233,6 @@
 
 		Activation ac = new GenericActivationHolder(lcc, gc, this, scrollable);
 
-		if (params != null)
-		{
-			ac.setParameters(params, null);
-		}
-
 		inUseCount++;
 
 		return ac;
@@ -621,7 +602,7 @@
 	 *
 	 *	@param constantAction The big structure enclosing the Execution constants.
 	 */
-	public	final void	setConstantAction( ConstantAction constantAction )
+	final void	setConstantAction( ConstantAction constantAction )
 	{
 		executionConstants = constantAction;
 	}
@@ -642,7 +623,7 @@
 	 *
 	 *	@param	objects	The objects to save from compilation
 	 */
-	public	final void	setSavedObjects( Object[] objects )
+	final void	setSavedObjects( Object[] objects )
 	{
 		savedObjects = objects;
 	}
@@ -1065,22 +1046,6 @@
 	}
 
 	/**
-	 * Set parameters to be associated with this
-	 * statement.  Used to process EXECUTE STATMENT <name>
-	 * USING <resultSet> statements -- the <resultSet>
-	 * is evaluated and a parameter list is generated.
-	 * That list is saved using this call.  Parameters
-	 * are set in the activation when it is created
-	 * (see getActivation). 
-	 * 
-	 * @param params the parameters
-	 */
-	protected void setParams(ParameterValueSet params)
-	{
-		this.params = params;
-	}
-
-	/**
 	 * Does this statement need a savepoint?  
 	 * 
 	 * @return true if this statement needs a savepoint.
@@ -1165,7 +1130,6 @@
 		clone.targetColumns = targetColumns;
 		clone.updateColumns = updateColumns;
 		clone.updateMode = updateMode;	
-		clone.params = params;
 		clone.needsSavepoint = needsSavepoint;
 
 		return clone;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java Thu Sep
15 12:40:28 2005
@@ -460,7 +460,6 @@
 					preparedStmt.setConstantAction( qt.makeConstantAction() );
 					preparedStmt.setSavedObjects( cc.getSavedObjects() );
 					preparedStmt.setActivationClass(ac);
-					preparedStmt.setParams(cc.getParams());
 					preparedStmt.setNeedsSavepoint(qt.needsSavepoint());
 					preparedStmt.setCursorInfo((CursorInfo)cc.getCursorInfo());
 					preparedStmt.setIsAtomic(qt.isAtomic());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStorablePreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStorablePreparedStatement.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStorablePreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStorablePreparedStatement.java
Thu Sep 15 12:40:28 2005
@@ -125,7 +125,7 @@
 		return activationClass;
 	}
 
-	public void setActivationClass(GeneratedClass ac) {
+	void setActivationClass(GeneratedClass ac) {
 
 		super.setActivationClass(ac);
 		if (ac != null) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
Thu Sep 15 12:40:28 2005
@@ -65,9 +65,10 @@
 import java.util.Vector;
 import java.util.Properties;
 
-/*
+/**
  *
- * CompilerContextImpl
+ * CompilerContextImpl, implementation of CompilerContext.
+ * CompilerContext and hence CompilerContextImpl objects are private to a LanguageConnectionContext.
  *
  */
 public class CompilerContextImpl extends ContextImpl
@@ -98,11 +99,6 @@
 			{
 				if (currentDependent != null)
 				{
-					LanguageConnectionContext lcc;
-
-					/* Find the LanguageConnectionContext */
-					lcc = (LanguageConnectionContext)
-						getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
 					currentDependent.makeInvalid(DependencyManager.COMPILE_FAILED,
 												 lcc);
 				}
@@ -240,11 +236,6 @@
 		return lcf.getJavaFactory();
 	}
 
-
-	public Dependent getCurrentDependent() {
-		return currentDependent;
-	}
-
 	public void setCurrentDependent(Dependent d) {
 		currentDependent = d;
 	}
@@ -276,13 +267,12 @@
 
 	public void createDependency(Provider p) throws StandardException {
 		if (SanityManager.DEBUG)
-		SanityManager.ASSERT(getCurrentDependent() != null,
+		SanityManager.ASSERT(currentDependent != null,
 				"no current dependent for compilation");
 
-		LanguageConnectionContext	lcc = (LanguageConnectionContext)
-			getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
-		DependencyManager dm = lcc.getDataDictionary().getDependencyManager();
-		dm.addDependency(getCurrentDependent(), p, getContextManager());
+		if (dm == null)
+			dm = lcc.getDataDictionary().getDependencyManager();
+		dm.addDependency(currentDependent, p, getContextManager());
 		addProviderToAuxiliaryList(p);
 	}
 
@@ -296,9 +286,8 @@
 	 */
 	public	void createDependency(Dependent d, Provider p) throws StandardException
 	{
-		LanguageConnectionContext lcc = (LanguageConnectionContext)
-			getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
-		DependencyManager dm = lcc.getDataDictionary().getDependencyManager();
+		if (dm == null)
+			dm = lcc.getDataDictionary().getDependencyManager();
 
 		dm.addDependency(d, p, getContextManager());
 		addProviderToAuxiliaryList(p);
@@ -350,20 +339,6 @@
 		}		
 	}
 
-	/** @see CompilerContext#setParams */
-	public void setParams(ParameterValueSet params)
-	{
-		this.params = params;
-	}
-
-	/** @see CompilerContext#getParams */
-	public ParameterValueSet getParams()
-	{
-		ParameterValueSet tmpParams = this.params;
-		this.params = null;
-		return tmpParams;
-	}
-
 	/** @see CompilerContext#setCursorInfo */
 	public void setCursorInfo(Object cursorInfo)
 	{
@@ -446,8 +421,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public StoreCostController getStoreCostController(long conglomerateNumber,
-													  LanguageConnectionContext lcc)
+	public StoreCostController getStoreCostController(long conglomerateNumber)
 			throws StandardException
 	{
 		/*
@@ -513,11 +487,6 @@
 			/*
 			** Get a StoreCostController from the store.
 			*/
-			LanguageConnectionContext lcc;
-
-			/* Find the LanguageConnectionContext */
-			lcc = (LanguageConnectionContext)
-				getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
 
 			sortCostController =
 				lcc.getTransactionCompile().openSortCostController((Properties) null);
@@ -614,21 +583,6 @@
 	}
 
 	/**
-	 * @see CompilerContext#getNextParameterNumber
-	 */
-	public int getNextParameterNumber()
-	{
-		if (SanityManager.DEBUG)
-		{
-			SanityManager.ASSERT(parameterList != null,
-				"parameterList is expected to be non-null");
-		}
-		
-		// Parameter #s are 0-based
-		return parameterList.size();
-	}
-
-	/**
 	 * @see CompilerContext#setScanIsolationLevel
 	 */
 	public void setScanIsolationLevel(int isolationLevel)
@@ -696,13 +650,15 @@
 	//
 	/////////////////////////////////////////////////////////////////////////////////////
 
-	public CompilerContextImpl(ContextManager cm, LanguageConnectionFactory lcf,
+	public CompilerContextImpl(ContextManager cm,
+			LanguageConnectionContext lcc,
 		TypeCompilerFactory typeCompilerFactory )
 	{
 		super(cm, CompilerContext.CONTEXT_ID);
 
+		this.lcc = lcc;
+		lcf = lcc.getLanguageConnectionFactory();
 		this.parser = lcf.newParser(this);
-		this.lcf = lcf;
 		this.typeCompilerFactory = typeCompilerFactory;
 
 		// the prefix for classes in this connection
@@ -714,10 +670,11 @@
 	*/
 
 	private final Parser 		parser;
-	private LanguageConnectionFactory lcf;
+	private final LanguageConnectionContext lcc;
+	private final LanguageConnectionFactory lcf;
 	private TypeCompilerFactory	typeCompilerFactory;
 	private Dependent			currentDependent;
-	private DependencyManager	dmgr;
+	private DependencyManager	dm;
 	private boolean				firstOnStack;
 	private boolean				inUse;
 	private int					reliability = CompilerContext.SQL_LEGAL;
@@ -731,7 +688,6 @@
 	private long				nextClassName;
 	private Vector				savedObjects;
 	private String				classPrefix;
-	private ParameterValueSet	params;
 	private SchemaDescriptor	compilationSchema;
 	private ProviderList		currentAPL;
 	private boolean returnParameterFlag;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
Thu Sep 15 12:40:28 2005
@@ -61,7 +61,6 @@
 
 public class CreateViewNode extends CreateStatementNode
 {
-	Dependent			currentDependent;
 	ResultColumnList	resultColumns;
 	ResultSetNode		queryExpression;
 	String				qeText;
@@ -212,13 +211,6 @@
 		{
 			throw StandardException.newException(SQLState.LANG_DUPLICATE_COLUMN_NAME_CREATE_VIEW,
duplicateColName);
 		}
-
-		/* Remember the current Dependent (the statement) here (since we
-		 * already have the CompilerContext).  We will use this info
-		 * during generate() to create the dependencies for the view.
-		 */
-		currentDependent = cc.getCurrentDependent();
-
 
 		/* Only 5000 columns allowed per view */
 		if (queryExpression.getResultColumns().size() > Limits.DB2_MAX_COLUMNS_IN_VIEW)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
Thu Sep 15 12:40:28 2005
@@ -1477,26 +1477,7 @@
 			indexNames[ictr] = 
 				((cd.isConstraint()) ? null : cd.getConglomerateName());
 
-			/*
-			** This is a nasty hack to deal with the fact that
-			** some testing wind up calling this method w/o
-			** going through the normal setup -- so there is
-			** no connection context.  So, in the debug codeline,
-			** we'll skip setting the dependency if isn't on
-			** in the compilation context.
-			*/
-			if (SanityManager.DEBUG)
-			{
-				if (cc.getCurrentDependent() != null)
-				{
-					cc.createDependency(cd);
-				}
-			}
-			else
-			{
-				cc.createDependency(cd);
-			}
-
+			cc.createDependency(cd);
 		}
 
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Thu
Sep 15 12:40:28 2005
@@ -4339,8 +4339,7 @@
 										ConglomerateDescriptor cd)
 			throws StandardException
 	{
-		return getCompilerContext().getStoreCostController(cd.getConglomerateNumber(), 
-														   getLanguageConnectionContext());
+		return getCompilerContext().getStoreCostController(cd.getConglomerateNumber());
 	}
 
 	private StoreCostController getBaseCostController()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=289298&r1=289297&r2=289298&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Thu Sep 15 12:40:28 2005
@@ -1825,7 +1825,7 @@
 
 		if (cc == null || cc.getInUse())
 		{
-			cc = new CompilerContextImpl(getContextManager(), connFactory, tcf);
+			cc = new CompilerContextImpl(getContextManager(), this, tcf);
 			if (firstCompilerContext) { cc.firstOnStack(); }
 		}
 		else



Mime
View raw message