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 ka...@apache.org on 2011/11/07 11:43:27 UTC

svn commit: r1198695 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/compile/

Author: kahatlen
Date: Mon Nov  7 10:43:27 2011
New Revision: 1198695

URL: http://svn.apache.org/viewvc?rev=1198695&view=rev
Log:
DERBY-4845: Improve the dependency tracking for our build targets

Move getCreateAliasNode() and mapTableAsVTI() out of NodeFactory to
prevent that they expose impl classes to iapi code.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/NodeFactory.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/compile/MethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/NodeFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/NodeFactory.java?rev=1198695&r1=1198694&r2=1198695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/NodeFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/NodeFactory.java Mon Nov  7 10:43:27 2011
@@ -21,13 +21,8 @@
 
 package org.apache.derby.iapi.sql.compile;
 
-import java.util.Properties;
-
 import org.apache.derby.iapi.services.context.ContextManager;
 
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
 import org.apache.derby.iapi.error.StandardException;
 
 /* Strictly speaking we shouldn't import classes under the impl hierarchy here
@@ -35,8 +30,6 @@ import org.apache.derby.iapi.error.Stand
  * manish - Wed Mar 28 13:05:19 PST 2001
  */
 import	org.apache.derby.impl.sql.compile.QueryTreeNode;
-import org.apache.derby.impl.sql.compile.ResultColumnList;
-import org.apache.derby.impl.sql.compile.ResultSetNode;
 
 /**
 	This is an interface for NodeFactories.
@@ -573,53 +566,4 @@ public abstract class NodeFactory
 
 		return  retval;
 	}
-
-	/**
-	 * Get one of the several types of create alias nodes. Carved out of parser
-	 * so this could be used by ALTER PUBLICATION.
-	 *
-	 * @param aliasName				The name of the alias
-	 * @param targetName			The full path/method name
-	 * @param aliasSpecificInfo	The full path of the target method name,
-	 *								if any
-	 * @param aliasType	The type of alias to create
-	 * @param delimitedIdentifier	Whether or not to treat the class name
-	 *								as a delimited identifier if trying to
-	 *								resolve it as a class alias.
-	 * @param cm			A ContextManager
-	 *
-	 * @return	A CreateAliasNode matching the given parameters
-	 *
-	 * @exception StandardException		Thrown on error
-	 */
-	public abstract QueryTreeNode
-	getCreateAliasNode(
-		Object aliasName,
-		Object targetName,
-		Object aliasSpecificInfo,
-		char aliasType,
-		Boolean delimitedIdentifier,
-		ContextManager cm)
-		throws StandardException;
-
-	
-	/**
-	 * Return a correctly configured node that represents
-	 * a scan from a VTI dervied from the TableDesciptor.
-	 * Used to convert from system diagnostic tables
-	 * to VTI scans.
-	 * @param td Table that is really a vti
-	 * @param correlationName Correlation name of table clause
-	 * @param resultColumns Columns extracted from table.
-	 * @param tableProperties Properties being passed onto the table scan
-	 * @param cm Current context manager
-	 */
-	public abstract ResultSetNode mapTableAsVTI(
-			TableDescriptor td,
-			String correlationName,
-			ResultColumnList resultColumns,
-			Properties tableProperties,		
-			ContextManager cm) throws StandardException;
-
 }
-

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=1198695&r1=1198694&r2=1198695&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 Mon Nov  7 10:43:27 2011
@@ -21,6 +21,7 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import java.util.*;
 import org.apache.derby.catalog.IndexDescriptor;
 import org.apache.derby.iapi.util.StringUtil;
 
@@ -35,6 +36,7 @@ import org.apache.derby.iapi.util.ReuseF
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.property.PropertyUtil;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
@@ -78,12 +80,6 @@ import org.apache.derby.iapi.store.acces
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
 
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Vector;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
 
 /**
  * A FromBaseTable represents a table in the FROM list of a DML statement,
@@ -2192,7 +2188,7 @@ public class FromBaseTable extends FromT
 		TableDescriptor tableDescriptor = bindTableDescriptor();
 
 		if (tableDescriptor.getTableType() == TableDescriptor.VTI_TYPE) {
-			ResultSetNode vtiNode = getNodeFactory().mapTableAsVTI(
+			ResultSetNode vtiNode = mapTableAsVTI(
 					tableDescriptor,
 					getCorrelationName(),
 					resultColumns,
@@ -2388,6 +2384,64 @@ public class FromBaseTable extends FromT
 		return this;
 	}
 
+    /**
+     * Return a node that represents invocation of the virtual table for the
+     * given table descriptor. The mapping of the table descriptor to a specific
+     * VTI class name will occur as part of the "init" phase for the
+     * NewInvocationNode that we create here.
+     *
+     * Currently only handles no argument VTIs corresponding to a subset of the
+     * diagnostic tables. (e.g. lock_table). The node returned is a FROM_VTI
+     * node with a passed in NEW_INVOCATION_NODE representing the class, with no
+     * arguments. Other attributes of the original FROM_TABLE node (such as
+     * resultColumns) are passed into the FROM_VTI node.
+     */
+    private ResultSetNode mapTableAsVTI(
+            TableDescriptor td,
+            String correlationName,
+            ResultColumnList resultColumns,
+            Properties tableProperties,
+            ContextManager cm)
+        throws StandardException {
+
+
+        // The fact that we pass a non-null table descriptor to the following
+        // call is an indication that we are mapping to a no-argument VTI. Since
+        // we have the table descriptor we do not need to pass in a TableName.
+        // See NewInvocationNode for more.
+        QueryTreeNode newNode =
+                getNodeFactory().getNode(C_NodeTypes.NEW_INVOCATION_NODE,
+                null, // TableName
+                td, // TableDescriptor
+                Collections.EMPTY_LIST,
+                Boolean.FALSE,
+                cm);
+
+        QueryTreeNode vtiNode;
+
+        if (correlationName != null) {
+            vtiNode = getNodeFactory().getNode(C_NodeTypes.FROM_VTI,
+                    newNode,
+                    correlationName,
+                    resultColumns,
+                    tableProperties,
+                    cm);
+        } else {
+            TableName exposedName = newNode.makeTableName(td.getSchemaName(),
+                    td.getDescriptorName());
+
+            vtiNode = getNodeFactory().getNode(C_NodeTypes.FROM_VTI,
+                    newNode,
+                    correlationName,
+                    resultColumns,
+                    tableProperties,
+                    exposedName,
+                    cm);
+        }
+
+        return (ResultSetNode) vtiNode;
+    }
+
 	/** 
 	 * Determine whether or not the specified name is an exposed name in
 	 * the current query block.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?rev=1198695&r1=1198694&r2=1198695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java Mon Nov  7 10:43:27 2011
@@ -29,13 +29,9 @@ import org.apache.derby.iapi.services.sa
 
 import org.apache.derby.iapi.error.StandardException;
 
-import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.types.JSQLType;
 
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.iapi.sql.compile.Visitable;
 import org.apache.derby.iapi.sql.compile.Visitor;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
@@ -55,14 +51,13 @@ import org.apache.derby.iapi.store.acces
 
 import org.apache.derby.iapi.util.JBitSet;
 
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
 import org.apache.derby.catalog.types.RoutineAliasInfo;
 
-import java.lang.reflect.Modifier;
 import java.lang.reflect.Member;
 
 import java.sql.ResultSet;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
@@ -163,11 +158,11 @@ abstract class MethodCallNode extends Ja
 	/**
 	 * Add the parameter list
 	 *
-	 * @param parameterList		A Vector of the parameters
+	 * @param parameterList		A list of the parameters
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void addParms(Vector parameterList) throws StandardException
+	public void addParms(List parameterList) throws StandardException
 	{
 		methodParms = new JavaValueNode[parameterList.size()];
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java?rev=1198695&r1=1198694&r2=1198695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java Mon Nov  7 10:43:27 2011
@@ -54,6 +54,7 @@ import java.lang.reflect.Modifier;
 
 import java.util.Vector;
 import java.util.Enumeration;
+import java.util.List;
 
 /**
  * A NewInvocationNode represents a new object() invocation.
@@ -85,7 +86,7 @@ public class NewInvocationNode extends M
 		throws StandardException
 	{
 		super.init("<init>");
-		addParms((Vector) params);
+		addParms((List) params);
 
 		this.javaClassName = (String) javaClassName;
 		this.delimitedIdentifier =
@@ -132,7 +133,7 @@ public class NewInvocationNode extends M
 		throws StandardException
 	{
 		super.init("<init>");
-		addParms((Vector) params);
+		addParms((List) params);
 
 		if (SanityManager.DEBUG)
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java?rev=1198695&r1=1198694&r2=1198695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java Mon Nov  7 10:43:27 2011
@@ -22,7 +22,6 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.Properties;
-import java.util.Vector;
 
 import org.apache.derby.iapi.services.context.ContextManager;
 
@@ -34,7 +33,6 @@ import org.apache.derby.iapi.sql.compile
 
 import org.apache.derby.iapi.sql.compile.NodeFactory;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.property.PropertyUtil;
@@ -43,9 +41,7 @@ import org.apache.derby.iapi.error.Stand
 import org.apache.derby.iapi.reference.EngineType;
 import org.apache.derby.iapi.reference.SQLState;
 
-import org.apache.derby.catalog.AliasInfo;
 import org.apache.derby.iapi.services.loader.ClassInfo;
-import org.apache.derby.iapi.util.StringUtil;
 
 /**
  * This class is a factory for QueryTreeNode nodes.  It exists to provide
@@ -75,8 +71,6 @@ public class NodeFactoryImpl extends Nod
 	private final ClassInfo[]	nodeCi =
 		new ClassInfo[C_NodeTypes.FINAL_VALUE+1];
 	
-	private static final Vector emptyVector = new Vector(0);
-
 	//////////////////////////////////////////////////////////////////////
 	//
 	// ModuleControl interface
@@ -651,141 +645,4 @@ public class NodeFactoryImpl extends Nod
 			throw StandardException.newException(SQLState.NOT_IMPLEMENTED);
 		}
 	}
-
-
-	/**
-	 * Get one of the several types of create alias nodes. Carved out of parser
-	 * so this could be used by ALTER PUBLICATION.
-	 *
-	 * @param aliasName	The name of the alias
-	 * @param targetName	The full path/method name
-	 * @param aliasSpecificInfo	The full path of the target method name,
-	 *								if any
-	 * @param aliasType	The type of alias to create
-	 * @param delimitedIdentifier	Whether or not to treat the class name
-	 *								as a delimited identifier if trying to
-	 *								resolve it as a class alias.
-	 * @param cm			A ContextManager
-	 *
-	 * @return	A CreateAliasNode matching the given parameters
-	 *
-	 * @exception StandardException		Thrown on error
-	 */
-	public	QueryTreeNode
-	getCreateAliasNode(
-		Object aliasName,
-		Object targetName,
-		Object aliasSpecificInfo,
-		char aliasType,
-		Boolean delimitedIdentifier,
-		ContextManager cm)
-		throws StandardException
-	{
-		int nodeType;
-		String methodName = null;
-		String targetMethodName = null;
-		String targetClassName = null;
-
-		nodeType = C_NodeTypes.CREATE_ALIAS_NODE;
-
-		if (
-            (aliasType != AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR) &&
-            (aliasType != AliasInfo.ALIAS_TYPE_UDT_AS_CHAR)
-            )
-		{
-        	int lastPeriod;
-        	String fullStaticMethodName = (String) targetName;
-        	int paren = fullStaticMethodName.indexOf('(');
-        	if (paren == -1) {
-            	// not a Java signature - split based on last period
-            	lastPeriod = fullStaticMethodName.lastIndexOf('.');
-        	} else {
-            	// a Java signature - split on last period before the '('
-            	lastPeriod = fullStaticMethodName.substring(0, paren).lastIndexOf('.');
-        	}
-        	if (lastPeriod == -1 || lastPeriod == fullStaticMethodName.length()-1) {
-            	throw StandardException.newException(SQLState.LANG_INVALID_FULL_STATIC_METHOD_NAME, fullStaticMethodName);
-        	}
-        	String javaClassName = fullStaticMethodName.substring(0, lastPeriod);
-        	methodName = fullStaticMethodName.substring(lastPeriod + 1);
-			targetName = javaClassName;
-		}
-
-		return getNode(
-			nodeType,
-			aliasName,
-			targetName,
-			methodName,
-			aliasSpecificInfo,
-			new Character(aliasType),
-			delimitedIdentifier,
-			cm );
-	}
-
-	/**
-	 * Return a node that represents invocation of the virtual table
-	 * for the given table descriptor.  The mapping of the table descriptor
-	 * to a specific VTI class name will occur as part of the "init"
-	 * phase for the NewInvocationNode that we create here.
-	 * <P>
-	 * Currently only handles no argument vtis corresponding to a subset
-	 * of the diagnostic tables. (e.g. lock_table).
-	 * The node returned is a FROM_VTI node with a passed in NEW_INVOCATION_NODE
-	 * representing the class, with no arguments.
-	 * Other attributes of the original FROM_TABLE node (such as resultColumns)
-	 * are passed into the FROM_VTI node.
-	 * 
-	 */
-	public ResultSetNode mapTableAsVTI(
-			TableDescriptor td,
-			String correlationName,
-			ResultColumnList resultColumns,
-			Properties tableProperties,		
-			ContextManager cm)
-		throws StandardException {
-		
-	
-		/* The fact that we pass a non-null table descriptor to the
-		 * following call is an indication that we are mapping to a
-		 * no-argument VTI.  Since we have the table descriptor we
-		 * do not need to pass in a TableName. See NewInvocationNode
-		 * for more.
-		 */
-		QueryTreeNode newNode =
-			getNode(C_NodeTypes.NEW_INVOCATION_NODE, 
-				null,	// TableName
-				td,     // TableDescriptor
-				emptyVector,
-				Boolean.FALSE,
-				cm);
-		
-		 QueryTreeNode vtiNode;
-		 
-		 if (correlationName != null)
-		 {
-			 vtiNode = getNode(C_NodeTypes.FROM_VTI,
-						newNode,
-						correlationName,
-						resultColumns,
-						tableProperties,
-						cm);
-		 }
-		 else
-		 {
-			 TableName exposedName = newNode.makeTableName(td.getSchemaName(),
-						td.getDescriptorName());
-			 
-			vtiNode = getNode(C_NodeTypes.FROM_VTI,
-						newNode,
-						correlationName,
-						resultColumns,
-						tableProperties,
-						exposedName,
-						cm);
-		}
-		 
-		return (ResultSetNode) vtiNode;
-	}
 }
-
-

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1198695&r1=1198694&r2=1198695&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Mon Nov  7 10:43:27 2011
@@ -1671,7 +1671,7 @@ public class SQLParser
 	 * Get one of the several types of create alias nodes.
 	 *
 	 * @param aliasName	The name of the alias
-	 * @param fullStaticMethodName	The full path/method name
+	 * @param targetName TableName for target, or the full path/method name
 	 * @param aliasSpecificInfo	 Information specific to the type of alias being created.
 	 * @param aliasType	The type of alias to create
 	 * @param delimitedIdentifier	Whether or not to treat the class name
@@ -1685,24 +1685,47 @@ public class SQLParser
 	StatementNode
 	getCreateAliasNode(
 		Object aliasName,
-		String fullStaticMethodName,
+		Object targetName,
 		Object aliasSpecificInfo,
 		char aliasType,
 		Boolean delimitedIdentifier)
 		throws StandardException
 	{
+        int nodeType = C_NodeTypes.CREATE_ALIAS_NODE;
+        String methodName = null;
 
-		StatementNode aliasNode = (StatementNode) getNodeFactory().getCreateAliasNode
-			(
-				aliasName,
-				fullStaticMethodName,
-				aliasSpecificInfo,
-				aliasType,
-				delimitedIdentifier,
-				getContextManager()
-			);
+        if (
+            (aliasType != AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR) &&
+            (aliasType != AliasInfo.ALIAS_TYPE_UDT_AS_CHAR)
+            )
+        {
+            int lastPeriod;
+            String fullStaticMethodName = (String) targetName;
+            int paren = fullStaticMethodName.indexOf('(');
+            if (paren == -1) {
+                // not a Java signature - split based on last period
+                lastPeriod = fullStaticMethodName.lastIndexOf('.');
+            } else {
+                // a Java signature - split on last period before the '('
+                lastPeriod = fullStaticMethodName.substring(0, paren).lastIndexOf('.');
+            }
+            if (lastPeriod == -1 || lastPeriod == fullStaticMethodName.length()-1) {
+                throw StandardException.newException(SQLState.LANG_INVALID_FULL_STATIC_METHOD_NAME, fullStaticMethodName);
+            }
+            String javaClassName = fullStaticMethodName.substring(0, lastPeriod);
+            methodName = fullStaticMethodName.substring(lastPeriod + 1);
+            targetName = javaClassName;
+        }
 
-		return aliasNode;
+        return (StatementNode) getNodeFactory().getNode(
+            nodeType,
+            aliasName,
+            targetName,
+            methodName,
+            aliasSpecificInfo,
+            new Character(aliasType),
+            delimitedIdentifier,
+            cm );
 	}
 
 	/**
@@ -11085,14 +11108,13 @@ synonymDefinition() throws StandardExcep
 		checkVersion(DataDictionary.DD_VERSION_DERBY_10_1,
 			     "CREATE SYNONYM");
 
-		return  (StatementNode) getNodeFactory().getCreateAliasNode
+		return getCreateAliasNode
 			(
 				synonymName,
 				targetName,
 				null,
 				AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR,
-				Boolean.FALSE,
-				getContextManager()
+				Boolean.FALSE
 			);
 	}
 }