db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r479886 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: ./ compile/ depend/
Date Tue, 28 Nov 2006 04:12:15 GMT
Author: djd
Date: Mon Nov 27 20:12:14 2006
New Revision: 479886

URL: http://svn.apache.org/viewvc?view=rev&rev=479886
Log:
DERBY-2096 (partial) Move needsSavepoint() to StatementNode, remove QueryTreeNode.bind and
optimize.
Have GenericStatement use StatementNode for the head of the statement's query tree.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.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/DefaultNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- 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 Mon Nov
27 20:12:14 2006
@@ -44,10 +44,9 @@
 import org.apache.derby.iapi.sql.depend.Dependent;
 
 import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.NodeFactory;
 import org.apache.derby.iapi.sql.compile.Parser;
 
-import org.apache.derby.impl.sql.compile.QueryTreeNode;
+import org.apache.derby.impl.sql.compile.StatementNode;
 import org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext;
 
 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
@@ -308,7 +307,7 @@
 
 				//Only top level statements go through here, nested statement
 				//will invoke this method from other places
-				QueryTreeNode qt = p.parseStatement(statementText, paramDefaults);
+				StatementNode qt = p.parseStatement(statementText, paramDefaults);
 
 				parseTime = getCurrentTimeMillis(lcc);
 
@@ -342,7 +341,7 @@
 					// transaction.
 					lcc.beginNestedTransaction(true);
 
-					qt = qt.bind();
+					qt.bindStatement();
 					bindTime = getCurrentTimeMillis(lcc);
 
 					if (SanityManager.DEBUG) 
@@ -393,7 +392,7 @@
 							((GenericLanguageConnectionContext)lcc).removeStatement(this);
 					}
 					
-					qt = qt.optimize();
+					qt.optimizeStatement();
 
 					optimizeTime = getCurrentTimeMillis(lcc);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
Mon Nov 27 20:12:14 2006
@@ -78,7 +78,7 @@
 	private	boolean				isRow;
 	private	boolean				isEnabled;
 	private	Vector				refClause;
-	private	QueryTreeNode		whenClause;
+	private	ValueNode		    whenClause;
 	private	String				whenText;
 	private	int					whenOffset;
 	private	StatementNode		actionNode;
@@ -157,7 +157,7 @@
 		this.isRow = ((Boolean) isRow).booleanValue();
 		this.isEnabled = ((Boolean) isEnabled).booleanValue();
 		this.refClause = (Vector) refClause;	
-		this.whenClause = (QueryTreeNode) whenClause;
+		this.whenClause = (ValueNode) whenClause;
 		this.whenText = (whenText == null) ? null : ((String) whenText).trim();
 		this.whenOffset = ((Integer) whenOffset).intValue();
 		this.actionNode = (StatementNode) actionNode;
@@ -279,12 +279,14 @@
 			if(isBefore)
 				compilerContext.setReliability(CompilerContext.MODIFIES_SQL_DATA_PROCEDURE_ILLEGAL);
 					
-			actionNode.bind();
+			actionNode.bindStatement();
 
+			/* when clause is always null
 			if (whenClause != null)
 			{
 				whenClause.bind();
 			}
+			*/
 		}
 		finally
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- 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
Mon Nov 27 20:12:14 2006
@@ -1220,7 +1220,7 @@
 		/* Finally, we can call the parser */
 		// Since this is always nested inside another SQL statement, so topLevel flag
 		// should be false
-		QueryTreeNode qt = p.parseStatement(select);
+		StatementNode qt = p.parseStatement(select);
 		if (SanityManager.DEBUG)
 		{
 			if (! (qt instanceof CursorNode))

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java Mon
Nov 27 20:12:14 2006
@@ -236,7 +236,7 @@
 		/* Finally, we can call the parser */
 		// Since this is always nested inside another SQL statement, so topLevel flag
 		// should be false
-		QueryTreeNode qt = p.parseStatement(values);
+		StatementNode qt = p.parseStatement(values);
 		if (SanityManager.DEBUG)
 		{
 			if (! (qt instanceof CursorNode))

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java Mon
Nov 27 20:12:14 2006
@@ -106,7 +106,7 @@
 
 	private ConstantAction[] dependentConstantActions;
 	private boolean cascadeDelete;
-	private QueryTreeNode[] dependentNodes;
+	private StatementNode[] dependentNodes;
 
 	/**
 	 * Initializer for a DeleteNode.
@@ -369,14 +369,14 @@
 				{
 					cascadeDelete = true;
 					int noDependents = fkTableNames.length;
-					dependentNodes = new QueryTreeNode[noDependents];
+					dependentNodes = new StatementNode[noDependents];
 					graphHashTable.put(currentTargetTableName, new Integer(noDependents));
 					for(int i =0 ; i < noDependents ; i ++)
 					{
 						dependentNodes[i] = getDependentTableNode(fkTableNames[i],
 															  fkRefActions[i],
 															  fkColDescriptors[i]);
-						dependentNodes[i].bind();
+						dependentNodes[i].bindStatement();
 					}
 				}
 			}
@@ -726,10 +726,10 @@
 	 * DML (UPDATE or DELETE) on the dependent tables. 
 	 * Following function returns the DML Node for the dependent table.
 	 */
-	private QueryTreeNode getDependentTableNode(String tableName, int refAction,
+	private StatementNode getDependentTableNode(String tableName, int refAction,
 												ColumnDescriptorList cdl) throws StandardException
 	{
-		QueryTreeNode node=null;
+		StatementNode node=null;
 
 		int index = tableName.indexOf('.');
 		String schemaName = tableName.substring(0 , index);
@@ -752,22 +752,18 @@
 	}
 
 
-    private QueryTreeNode getEmptyDeleteNode(String schemaName, String targetTableName)
+    private StatementNode getEmptyDeleteNode(String schemaName, String targetTableName)
         throws StandardException
     {
 
         ValueNode whereClause = null;
-        TableName tableName = null;
-        FromTable fromTable = null;
-        QueryTreeNode retval;
-        SelectNode resultSet;
 
-        tableName = new TableName();
+        TableName tableName = new TableName();
         tableName.init(schemaName , targetTableName);
 
         NodeFactory nodeFactory = getNodeFactory();
         FromList   fromList = (FromList) nodeFactory.getNode(C_NodeTypes.FROM_LIST, getContextManager());
-        fromTable = (FromTable) nodeFactory.getNode(
+        FromTable fromTable = (FromTable) nodeFactory.getNode(
                                                     C_NodeTypes.FROM_BASE_TABLE,
                                                     tableName,
                                                     null,
@@ -782,7 +778,7 @@
 		((FromBaseTable) fromTable).setTableProperties(targetProperties);
 
         fromList.addFromTable(fromTable);
-        resultSet = (SelectNode) nodeFactory.getNode(
+        SelectNode resultSet = (SelectNode) nodeFactory.getNode(
                                                      C_NodeTypes.SELECT_NODE,
                                                      null,
                                                      null,   /* AGGREGATE list */
@@ -791,35 +787,30 @@
                                                      null, /* GROUP BY list */
                                                      getContextManager());
 
-        retval =(QueryTreeNode) nodeFactory.getNode(
+        return (StatementNode) nodeFactory.getNode(
                                                     C_NodeTypes.DELETE_NODE,
                                                     tableName,
                                                     resultSet,
                                                     getContextManager());
 
-        return retval;
     }
 
 
 	
-    private QueryTreeNode getEmptyUpdateNode(String schemaName, 
+    private StatementNode getEmptyUpdateNode(String schemaName, 
 											 String targetTableName,
 											 ColumnDescriptorList cdl)
         throws StandardException
     {
 
         ValueNode whereClause = null;
-        TableName tableName = null;
-        FromTable fromTable = null;
-        QueryTreeNode retval;
-        SelectNode resultSet;
 
-        tableName = new TableName();
+        TableName tableName = new TableName();
         tableName.init(schemaName , targetTableName);
 
         NodeFactory nodeFactory = getNodeFactory();
         FromList   fromList = (FromList) nodeFactory.getNode(C_NodeTypes.FROM_LIST, getContextManager());
-        fromTable = (FromTable) nodeFactory.getNode(
+        FromTable fromTable = (FromTable) nodeFactory.getNode(
                                                     C_NodeTypes.FROM_BASE_TABLE,
                                                     tableName,
                                                     null,
@@ -836,7 +827,7 @@
 
         fromList.addFromTable(fromTable);
 
-		resultSet = (SelectNode) nodeFactory.getNode(
+        SelectNode resultSet = (SelectNode) nodeFactory.getNode(
                                                      C_NodeTypes.SELECT_NODE,
                                                      getSetClause(tableName, cdl),
                                                      null,   /* AGGREGATE list */
@@ -845,13 +836,12 @@
                                                      null, /* GROUP BY list */
                                                      getContextManager());
 
-        retval =(QueryTreeNode) nodeFactory.getNode(
+        return (StatementNode) nodeFactory.getNode(
                                                     C_NodeTypes.UPDATE_NODE,
                                                     tableName,
                                                     resultSet,
                                                     getContextManager());
 
-        return retval;
     }
 
 
@@ -896,7 +886,7 @@
 		{
 			for(int index=0 ; index < dependentNodes.length ; index++)
 			{
-				dependentNodes[index] =  dependentNodes[index].optimize();
+				dependentNodes[index].optimizeStatement();
 			}
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Mon
Nov 27 20:12:14 2006
@@ -468,26 +468,6 @@
 	}
 
 	/**
-	 * Perform the binding operation on a query tree.  Binding consists of
-	 * permissions checking, view resolution, datatype resolution, and
-	 * creation of a dependency list (for determining whether a tree or
-	 * plan is still up to date).
-	 *
-	 * This bind() method does nothing.  Each node type that can appear
-	 * at the top of a tree can override this method with its own bind()
-	 * method that does "something".
-	 *
-	 * @return	The bound query tree
-	 *
-	 * @exception StandardException		Thrown on error
-	 */
-
-	public QueryTreeNode bind() throws StandardException
-	{
-		return this;
-	}
-
-	/**
 	 * Return true if the node references SESSION schema tables (temporary or permanent)
 	 *
 	 * @return	true if references SESSION schema tables, else false
@@ -575,29 +555,6 @@
 	}
 
 	/**
-	 * Generates an optimized QueryTree from a bound QueryTree.  Actually,
-	 * it annotates the tree in place rather than generating a new tree,
-	 * but this interface allows the root node of the optmized QueryTree
-	 * to be different from the root node of the bound QueryTree.
-	 *
-	 * For non-optimizable statements (for example, CREATE TABLE),
-	 * return the bound tree without doing anything.  For optimizable
-	 * statements, this method will be over-ridden in the statement's
-	 * root node (DMLStatementNode in all cases we know about so far).
-	 *
-	 * Throws an exception if the tree is not bound, or if the binding
-	 * is out of date.
-	 *
-	 * @return	An optimized QueryTree
-	 *
-	 * @exception StandardException		Thrown on error
-	 */
-	public QueryTreeNode optimize() throws StandardException
-	{
-		return this;
-	}
-
-	/**
 	 * this implementation of generate() is
 	 * a place-holder until all of the nodes that need to,
 	 * implement it. Only the root, statement nodes
@@ -680,20 +637,7 @@
 		return	null;
 	}
 
-	/**
-	 * Returns whether or not this Statement requires a set/clear savepoint
-	 * around its execution.  The following statement "types" do not require them:
-	 *		Cursor	- unnecessary and won't work in a read only environment
-	 *		Xact	- savepoint will get blown away underneath us during commit/rollback
-	 * <p>
-	 * ONLY CALLABLE AFTER GENERATION
-	 *
-	 * @return boolean	Whether or not this Statement requires a set/clear savepoint
-	 */
-	public boolean needsSavepoint()
-	{
-		return true;
-	}
+
 
 	/**
 	 * Returns the name of statement in EXECUTE STATEMENT command.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Mon
Nov 27 20:12:14 2006
@@ -1243,7 +1243,7 @@
 		/* Finally, we can call the parser */
 		// Since this is always nested inside another SQL statement, so topLevel flag
 		// should be false
-		QueryTreeNode qt = p.parseStatement(values);
+		StatementNode qt = p.parseStatement(values);
 		if (SanityManager.DEBUG)
 		{
 			if (! (qt instanceof CursorNode))

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StatementNode.java Mon
Nov 27 20:12:14 2006
@@ -78,6 +78,24 @@
 	{
 		return true;
 	}
+	
+	/**
+	 * Returns whether or not this Statement requires a set/clear savepoint
+	 * around its execution.  The following statement "types" do not require them:
+	 *		Cursor	- unnecessary and won't work in a read only environment
+	 *		Xact	- savepoint will get blown away underneath us during commit/rollback
+	 * <p>
+	 * ONLY CALLABLE AFTER GENERATION
+	 * <P>
+	 * This implementation returns true, sub-classes can override the
+	 * method to not require a savepoint.
+	 *
+	 * @return boolean	Whether or not this Statement requires a set/clear savepoint
+	 */
+	public boolean needsSavepoint()
+	{
+		return true;
+	}
 
 	/**
 	 * Convert this object to a String.  See comments in QueryTreeNode.java
@@ -119,15 +137,6 @@
 	{
 	}
 	
-	// TEMP map QueryTreeNode.bind() onto bindStatement()
-	// for StatementNode. Part of incremental development
-	// in switching the api for a compiled statement to
-	// be StatementNode.
-	public final QueryTreeNode bind() throws StandardException {
-		bindStatement();
-		return this;
-	}
-	
 	/**
 	 * Generates an optimized statement from a bound StatementNode.  Actually,
 	 * it annotates the tree in place rather than generating a new tree.
@@ -147,13 +156,7 @@
 	{
 		
 	}
-	// TEMP -RE_WORK for switching to StatementNode.
-	public final QueryTreeNode optimize() throws StandardException
-	{
-		optimizeStatement();
-		return this;
-	}
-	
+
 	/**
 	 * create the outer shell class builder for the class we will
 	 * be generating, generate the expression to stuff in it,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java?view=diff&rev=479886&r1=479885&r2=479886
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
Mon Nov 27 20:12:14 2006
@@ -305,7 +305,6 @@
 							compSchema = dd.getSchemaDescriptor(vd.getCompSchemaId(), null);
 							CompilerContext newCC = lcc.pushCompilerContext(compSchema);
 							Parser	pa = newCC.getParser();
-							LanguageConnectionFactory	lcf = lcc.getLanguageConnectionFactory();
 
 							// Since this is always nested inside another SQL
 							// statement, so topLevel flag should be false
@@ -314,7 +313,7 @@
 
 							// need a current dependent for bind
 							newCC.setCurrentDependent(dep);
-							cvn = (CreateViewNode) cvn.bind();
+							cvn.bindStatement();
 							ProviderInfo[] providerInfos = cvn.getProviderInfo();
 							lcc.popCompilerContext(newCC);
 



Mime
View raw message