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 da...@apache.org on 2013/06/21 09:47:52 UTC
svn commit: r1495305 [16/21] - in /db/derby/code/trunk:
java/engine/org/apache/derby/ java/engine/org/apache/derby/catalog/types/
java/engine/org/apache/derby/iapi/services/io/
java/engine/org/apache/derby/iapi/sql/
java/engine/org/apache/derby/iapi/sq...
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java Fri Jun 21 07:47:47 2013
@@ -22,25 +22,20 @@
package org.apache.derby.impl.sql.compile;
import java.util.List;
-
+import java.util.Properties;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.AccessPath;
import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Optimizable;
import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.Visitor;
import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
+import org.apache.derby.iapi.sql.compile.Visitor;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
import org.apache.derby.iapi.util.JBitSet;
-
/**
* A SingleChildResultSetNode represents a result set with a single child.
*
@@ -56,29 +51,23 @@ abstract class SingleChildResultSetNode
// Does this node have the truly... for the underlying tree
protected boolean hasTrulyTheBestAccessPath;
-
- /**
- * Initialilzer for a SingleChildResultSetNode.
- *
- * @param childResult The child ResultSetNode
- * @param tableProperties Properties list associated with the table
- */
-
- public void init(Object childResult, Object tableProperties)
- {
- /* correlationName is always null */
- super.init(null, tableProperties);
- this.childResult = (ResultSetNode) childResult;
-
- /* Propagate the child's referenced table map, if one exists */
- if (this.childResult.getReferencedTableMap() != null)
- {
- referencedTableMap =
- (JBitSet) this.childResult.getReferencedTableMap().clone();
- }
- }
+ SingleChildResultSetNode(
+ ResultSetNode childResult,
+ Properties tableProperties,
+ ContextManager cm) {
+
+ super(null /* correlationName */, tableProperties, cm);
+ this.childResult = childResult;
+
+ /* Propagate the child's referenced table map, if one exists */
+ if (childResult.getReferencedTableMap() != null) {
+ referencedTableMap =
+ (JBitSet)childResult.getReferencedTableMap().clone();
+ }
+ }
/** @see Optimizable#getTrulyTheBestAccessPath */
+ @Override
public AccessPath getTrulyTheBestAccessPath()
{
if (hasTrulyTheBestAccessPath)
@@ -97,7 +86,7 @@ abstract class SingleChildResultSetNode
*
* @return ResultSetNode The childResult from this node.
*/
- public ResultSetNode getChildResult()
+ ResultSetNode getChildResult()
{
return childResult;
}
@@ -117,6 +106,7 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
+ @Override
public void pullOptPredicates(
OptimizablePredicateList optimizablePredicates)
throws StandardException
@@ -128,6 +118,7 @@ abstract class SingleChildResultSetNode
}
/** @see Optimizable#forUpdate */
+ @Override
public boolean forUpdate()
{
if (childResult instanceof Optimizable)
@@ -143,6 +134,7 @@ abstract class SingleChildResultSetNode
/**
* @see Optimizable#initAccessPaths
*/
+ @Override
public void initAccessPaths(Optimizer optimizer)
{
super.initAccessPaths(optimizer);
@@ -160,6 +152,7 @@ abstract class SingleChildResultSetNode
* child, in order to ensure that we've handled the full plan
* all the way down this node's subtree.
*/
+ @Override
public void updateBestPlanMap(short action,
Object planKey) throws StandardException
{
@@ -189,8 +182,8 @@ abstract class SingleChildResultSetNode
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -214,7 +207,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
- public boolean referencesTarget(String name, boolean baseTable)
+ @Override
+ boolean referencesTarget(String name, boolean baseTable)
throws StandardException
{
return childResult.referencesTarget(name, baseTable);
@@ -227,6 +221,7 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -238,7 +233,8 @@ abstract class SingleChildResultSetNode
*
* @param level The query block level for this FromTable.
*/
- public void setLevel(int level)
+ @Override
+ void setLevel(int level)
{
super.setLevel(level);
if (childResult instanceof FromTable)
@@ -258,6 +254,7 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
+ @Override
boolean subqueryReferencesTarget(String name, boolean baseTable)
throws StandardException
{
@@ -288,8 +285,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
-
- public ResultSetNode preprocess(int numTables,
+ @Override
+ ResultSetNode preprocess(int numTables,
GroupByList gbl,
FromList fromList)
throws StandardException
@@ -313,7 +310,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode addNewPredicate(Predicate predicate)
+ @Override
+ ResultSetNode addNewPredicate(Predicate predicate)
throws StandardException
{
childResult = childResult.addNewPredicate(predicate);
@@ -331,7 +329,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
- public void pushExpressions(PredicateList predicateList)
+ @Override
+ void pushExpressions(PredicateList predicateList)
throws StandardException
{
if (childResult instanceof FromTable)
@@ -352,7 +351,8 @@ abstract class SingleChildResultSetNode
*
* @return boolean Whether or not the FromSubquery is flattenable.
*/
- public boolean flattenableInFromSubquery(FromList fromList)
+ @Override
+ boolean flattenableInFromSubquery(FromList fromList)
{
/* Flattening currently involves merging predicates and FromLists.
* We don't have a FromList, so we can't flatten for now.
@@ -369,7 +369,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode ensurePredicateList(int numTables)
+ @Override
+ ResultSetNode ensurePredicateList(int numTables)
throws StandardException
{
return this;
@@ -387,8 +388,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
-
- public ResultSetNode optimize(DataDictionary dataDictionary,
+ @Override
+ ResultSetNode optimize(DataDictionary dataDictionary,
PredicateList predicates,
double outerRows)
throws StandardException
@@ -401,16 +402,14 @@ abstract class SingleChildResultSetNode
predicates,
outerRows);
- Optimizer optimizer =
- getOptimizer(
- (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager()),
- predicates,
- dataDictionary,
- (RequiredRowOrdering) null);
- costEstimate = optimizer.newCostEstimate();
+ Optimizer opt = getOptimizer(
+ new FromList(getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager()),
+ predicates,
+ dataDictionary,
+ (RequiredRowOrdering) null);
+
+ costEstimate = opt.newCostEstimate();
costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
childResult.getCostEstimate().rowCount(),
childResult.getCostEstimate().singleScanRowCount());
@@ -423,7 +422,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode modifyAccessPaths() throws StandardException
+ @Override
+ ResultSetNode modifyAccessPaths() throws StandardException
{
childResult = childResult.modifyAccessPaths();
@@ -435,7 +435,8 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode changeAccessPath() throws StandardException
+ @Override
+ ResultSetNode changeAccessPath() throws StandardException
{
childResult = childResult.changeAccessPath();
return this;
@@ -454,6 +455,7 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
+ @Override
FromTable getFromTableByName(String name, String schemaName, boolean exactMatch)
throws StandardException
{
@@ -466,6 +468,7 @@ abstract class SingleChildResultSetNode
*
* @param decrement The amount to decrement by.
*/
+ @Override
void decrementLevel(int decrement)
{
super.decrementLevel(decrement);
@@ -479,7 +482,8 @@ abstract class SingleChildResultSetNode
*
* @return The lock mode
*/
- public int updateTargetLockMode()
+ @Override
+ int updateTargetLockMode()
{
return childResult.updateTargetLockMode();
}
@@ -499,6 +503,7 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException Thrown on error
*/
+ @Override
boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder)
throws StandardException
{
@@ -514,7 +519,8 @@ abstract class SingleChildResultSetNode
* @return Whether or not the underlying ResultSet tree will return a single row.
* @exception StandardException Thrown on error
*/
- public boolean isOneRowResultSet() throws StandardException
+ @Override
+ boolean isOneRowResultSet() throws StandardException
{
// Default is false
return childResult.isOneRowResultSet();
@@ -525,7 +531,8 @@ abstract class SingleChildResultSetNode
*
* @return Whether or not the underlying ResultSet tree is for a NOT EXISTS.
*/
- public boolean isNotExists()
+ @Override
+ boolean isNotExists()
{
return childResult.isNotExists();
}
@@ -546,6 +553,7 @@ abstract class SingleChildResultSetNode
/**
* @see ResultSetNode#adjustForSortElimination
*/
+ @Override
void adjustForSortElimination()
{
childResult.adjustForSortElimination();
@@ -554,6 +562,7 @@ abstract class SingleChildResultSetNode
/**
* @see ResultSetNode#adjustForSortElimination
*/
+ @Override
void adjustForSortElimination(RequiredRowOrdering rowOrdering)
throws StandardException
{
@@ -566,7 +575,8 @@ abstract class SingleChildResultSetNode
* @return The final CostEstimate for this node, which is
* the final cost estimate for the child node.
*/
- public CostEstimate getFinalCostEstimate()
+ @Override
+ CostEstimate getFinalCostEstimate()
throws StandardException
{
/*
@@ -590,6 +600,7 @@ abstract class SingleChildResultSetNode
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java Fri Jun 21 07:47:47 2013
@@ -21,29 +21,21 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.sql.compile.CompilerContext;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.store.access.Qualifier;
-
-
import java.lang.reflect.Modifier;
-
+import java.sql.Types;
+import java.util.List;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.ClassName;
import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-
-import java.sql.Types;
-
-import java.util.List;
+import org.apache.derby.iapi.store.access.Qualifier;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
/**
SpecialFunctionNode handles system SQL functions.
@@ -72,12 +64,12 @@ import java.util.List;
This node is used rather than some use of MethodCallNode for
runtime performance. MethodCallNode does not provide a fast access
- to the current language connection or activatation, since it is geared
+ to the current language connection or activation, since it is geared
towards user defined routines.
*/
-public class SpecialFunctionNode extends ValueNode
+class SpecialFunctionNode extends ValueNode
{
/**
Name of SQL function
@@ -94,9 +86,11 @@ public class SpecialFunctionNode extends
*/
private String methodType;
- /**
- */
- //private boolean isActivationCall;
+ SpecialFunctionNode(int nodeType, ContextManager cm) {
+ super(cm);
+ setNodeType(nodeType); // valid nodeType checked below in bindExpression
+ }
+
/**
* Binding this special function means setting the result DataTypeServices.
@@ -113,9 +107,13 @@ public class SpecialFunctionNode extends
*
* @exception StandardException Thrown on error
*/
- ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List aggregates)
- throws StandardException
- { DataTypeDescriptor dtd;
+ @Override
+ ValueNode bindExpression(FromList fromList,
+ SubqueryList subqueryList,
+ List<AggregateNode> aggregates)
+ throws StandardException
+ {
+ DataTypeDescriptor dtd;
int nodeType = getNodeType();
switch (nodeType)
{
@@ -212,6 +210,7 @@ public class SpecialFunctionNode extends
*
* @return The variant type for the underlying expression.
*/
+ @Override
protected int getOrderableVariantType()
{
return Qualifier.QUERY_INVARIANT;
@@ -227,6 +226,7 @@ public class SpecialFunctionNode extends
*
* @exception StandardException Thrown on error
*/
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -256,6 +256,7 @@ public class SpecialFunctionNode extends
/*
print the non-node subfields
*/
+ @Override
public String toString() {
if (SanityManager.DEBUG)
{
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?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- 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 Fri Jun 21 07:47:47 2013
@@ -21,28 +21,20 @@
package org.apache.derby.impl.sql.compile;
+import java.lang.reflect.Modifier;
import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.loader.GeneratedClass;
+import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.ResultDescription;
-
-import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.store.access.ConglomerateController;
import org.apache.derby.iapi.store.access.TransactionController;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.ClassName;
-import org.apache.derby.iapi.services.loader.GeneratedClass;
-
import org.apache.derby.iapi.util.ByteArray;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import java.lang.reflect.Modifier;
/**
* A StatementNode represents a single statement in the language. It is
@@ -59,10 +51,13 @@ import java.lang.reflect.Modifier;
public abstract class StatementNode extends QueryTreeNode
{
-
/** Cached empty list object. */
static final TableDescriptor[] EMPTY_TD_LIST = new TableDescriptor[0];
+ StatementNode(ContextManager cm) {
+ super(cm);
+ }
+
/**
* By default, assume StatementNodes are atomic.
* The rare statements that aren't atomic (e.g.
@@ -72,6 +67,7 @@ public abstract class StatementNode exte
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean isAtomic() throws StandardException
{
return true;
@@ -149,7 +145,7 @@ public abstract class StatementNode exte
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -163,7 +159,7 @@ public abstract class StatementNode exte
}
}
- public abstract String statementToString();
+ abstract String statementToString();
/**
* Perform the binding operation statement. Binding consists of
@@ -198,7 +194,7 @@ public abstract class StatementNode exte
*
* @exception StandardException Thrown on error
*/
- public void optimizeStatement() throws StandardException
+ public void optimizeStatement() throws StandardException
{
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java Fri Jun 21 07:47:47 2013
@@ -21,28 +21,20 @@
package org.apache.derby.impl.sql.compile;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
+import java.util.List;
import org.apache.derby.iapi.error.StandardException;
-
import org.apache.derby.iapi.reference.SQLState;
-
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.loader.ClassInspector;
-
-import org.apache.derby.iapi.store.access.Qualifier;
-
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CompilerContext;
-
+import org.apache.derby.iapi.store.access.Qualifier;
import org.apache.derby.iapi.util.JBitSet;
-import java.lang.reflect.Member;
-import java.lang.reflect.Modifier;
-
-import java.util.List;
-
/**
* A StaticClassFieldReferenceNode represents a Java static field reference from
* a Class (as opposed to an Object). Field references can be
@@ -67,16 +59,23 @@ public final class StaticClassFieldRefer
private Member field;
/**
- * Initializer for a StaticClassFieldReferenceNode
+ * Constructor for a StaticClassFieldReferenceNode
*
* @param javaClassName The class name
* @param fieldName The field name
+ * @param cm The context manager
*/
- public void init(Object javaClassName, Object fieldName, Object classNameDelimitedIdentifier)
- {
- this.fieldName = (String) fieldName;
- this.javaClassName = (String) javaClassName;
- this.classNameDelimitedIdentifier = ((Boolean) classNameDelimitedIdentifier).booleanValue();
+ StaticClassFieldReferenceNode(
+ String javaClassName,
+ String fieldName,
+ boolean classNameDelimitedIdentifier,
+ ContextManager cm)
+ {
+ super(cm);
+ setNodeType(C_NodeTypes.STATIC_CLASS_FIELD_REFERENCE_NODE);
+ this.fieldName = fieldName;
+ this.javaClassName = javaClassName;
+ this.classNameDelimitedIdentifier = classNameDelimitedIdentifier;
}
/**
@@ -92,7 +91,9 @@ public final class StaticClassFieldRefer
*
* @exception StandardException Thrown on error
*/
- JavaValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List aggregates)
+ JavaValueNode bindExpression(FromList fromList,
+ SubqueryList subqueryList,
+ List<AggregateNode> aggregates)
throws StandardException
{
ClassInspector classInspector = getClassFactory().getClassInspector();
@@ -195,6 +196,7 @@ public final class StaticClassFieldRefer
*
* @return The variant type for the underlying expression.
*/
+ @Override
int getOrderableVariantType()
{
if (SanityManager.DEBUG)
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java Fri Jun 21 07:47:47 2013
@@ -21,40 +21,30 @@
package org.apache.derby.impl.sql.compile;
+import java.lang.reflect.Modifier;
+import java.sql.ParameterMetaData;
+import java.util.List;
+import org.apache.derby.catalog.AliasInfo;
+import org.apache.derby.catalog.TypeDescriptor;
+import org.apache.derby.catalog.types.RoutineAliasInfo;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.LocalField;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
import org.apache.derby.iapi.services.context.ContextManager;
-
import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.sql.compile.NodeFactory;
-import org.apache.derby.iapi.types.JSQLType;
+import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.conn.Authorizer;
+import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
+import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.JSQLType;
import org.apache.derby.iapi.types.StringDataValue;
import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
-import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
-
-import org.apache.derby.iapi.reference.ClassName;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.compiler.LocalField;
-
import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import org.apache.derby.iapi.sql.conn.Authorizer;
-
-import org.apache.derby.catalog.AliasInfo;
-import org.apache.derby.catalog.TypeDescriptor;
-import org.apache.derby.catalog.types.RoutineAliasInfo;
-
-import java.lang.reflect.Modifier;
-import java.sql.ParameterMetaData;
-import java.util.List;
/**
* A StaticMethodCallNode represents a static method call from a Class
@@ -92,8 +82,10 @@ import java.util.List;
- the parameter is passed directly to the method call (no casts or expressions).
- the method's parameter type is a Java array type.
- Since this is a dynmaic decision we compile in code to take both paths, based upon a boolean isINOUT which is dervied from the
- ParameterValueSet. Code is logically (only single parameter String[] shown here). Note, no casts can exist here.
+ Since this is a dynamic decision we compile in code to take both paths,
+ based upon a boolean is INOUT which is derived from the
+ ParameterValueSet. Code is logically (only single parameter String[] shown
+ here). Note, no casts can exist here.
boolean isINOUT = getParameterValueSet().getParameterMode(0) == PARAMETER_IN_OUT;
if (isINOUT) {
@@ -105,7 +97,7 @@ import java.util.List;
*
*/
-public class StaticMethodCallNode extends MethodCallNode
+class StaticMethodCallNode extends MethodCallNode
{
private TableName procedureName;
@@ -137,22 +129,39 @@ public class StaticMethodCallNode extend
/**
- * Intializer for a NonStaticMethodCallNode
+ * Constructor for a NonStaticMethodCallNode
*
* @param methodName The name of the method to call
- * @param javaClassName The name of the java class that the static method belongs to.
+ * @param javaClassName The name of the java class that the static
+ * method belongs to.
+ * @param cm The context manager
*/
- public void init(Object methodName, Object javaClassName)
- {
- if (methodName instanceof String)
- init(methodName);
- else {
- procedureName = (TableName) methodName;
- init(procedureName.getTableName());
- }
+ StaticMethodCallNode(
+ String methodName,
+ String javaClassName,
+ ContextManager cm) {
+ super(methodName, cm);
+ setNodeType(C_NodeTypes.STATIC_METHOD_CALL_NODE);
+ this.javaClassName = javaClassName;
+ }
- this.javaClassName = (String) javaClassName;
- }
+ /**
+ * Constructor for a StaticMethodCallNode
+ *
+ * @param methodName The name of the method to call
+ * @param javaClassName The name of the java class that the static
+ * method belongs to.
+ * @param cm The context manager
+ */
+ StaticMethodCallNode(
+ TableName methodName,
+ String javaClassName,
+ ContextManager cm) {
+ super(methodName.getTableName(), cm);
+ procedureName = methodName;
+ setNodeType(C_NodeTypes.STATIC_METHOD_CALL_NODE);
+ this.javaClassName = javaClassName;
+ }
/**
* Get the aggregate, if any, which this method call resolves to.
@@ -209,12 +218,10 @@ public class StaticMethodCallNode extend
if ( (ad != null) && (ad.getAliasType() == AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR) )
{
- resolvedAggregate = (AggregateNode) getNodeFactory().getNode
- (
- C_NodeTypes.AGGREGATE_NODE,
+ resolvedAggregate = new AggregateNode(
((SQLToJavaValueNode) methodParms[ 0 ]).getSQLValueNode(),
new UserAggregateDefinition( ad ),
- Boolean.FALSE,
+ false,
ad.getJavaClassName(),
getContextManager()
);
@@ -376,13 +383,10 @@ public class StaticMethodCallNode extend
);
- ValueNode returnValueToSQL = (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.JAVA_TO_SQL_VALUE_NODE,
- this,
- getContextManager());
+ ValueNode returnValueToSQL =
+ new JavaToSQLValueNode(this, getContextManager());
- ValueNode returnValueCastNode = (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.CAST_NODE,
+ ValueNode returnValueCastNode = new CastNode(
returnValueToSQL,
returnValueDtd,
getContextManager());
@@ -392,11 +396,8 @@ public class StaticMethodCallNode extend
returnType.getCollationType(),
StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-
- JavaValueNode returnValueToJava = (JavaValueNode) getNodeFactory().getNode(
- C_NodeTypes.SQL_TO_JAVA_VALUE_NODE,
- returnValueCastNode,
- getContextManager());
+ JavaValueNode returnValueToJava = new SQLToJavaValueNode(
+ returnValueCastNode, getContextManager());
returnValueToJava.setCollationType(returnType.getCollationType());
return returnValueToJava.bindExpression(fromList, subqueryList, aggregates);
}
@@ -498,14 +499,16 @@ public class StaticMethodCallNode extend
throws StandardException {
if (sd.getUUID() != null) {
- java.util.List list = getDataDictionary().getRoutineList(
- sd.getUUID().toString(), methodName,
- forCallStatement ? AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR : AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR
- );
+ List<AliasDescriptor> list = getDataDictionary().getRoutineList(
+ sd.getUUID().toString(),
+ methodName,
+ forCallStatement ?
+ AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR :
+ AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR);
for (int i = list.size() - 1; i >= 0; i--) {
- AliasDescriptor proc = (AliasDescriptor) list.get(i);
+ AliasDescriptor proc = list.get(i);
RoutineAliasInfo rai = (RoutineAliasInfo) proc.getAliasInfo();
int parameterCount = rai.getParameterCount();
@@ -794,28 +797,19 @@ public class StaticMethodCallNode extend
if (sqlParamNode == null)
{
- sqlParamNode = (ValueNode) getNodeFactory().getNode
- (
- C_NodeTypes.JAVA_TO_SQL_VALUE_NODE,
- methodParms[p],
- getContextManager()
- );
+ sqlParamNode =
+ new JavaToSQLValueNode(methodParms[p], getContextManager());
}
ValueNode castNode = makeCast
(
sqlParamNode,
paramdtd,
- getNodeFactory(),
getContextManager()
);
- methodParms[p] = (JavaValueNode) getNodeFactory().getNode
- (
- C_NodeTypes.SQL_TO_JAVA_VALUE_NODE,
- castNode,
- getContextManager()
- );
+ methodParms[p] =
+ new SQLToJavaValueNode(castNode, getContextManager());
methodParms[p] = methodParms[p].bindExpression(
fromList, subqueryList, aggregates);
@@ -829,17 +823,12 @@ public class StaticMethodCallNode extend
/**
* Wrap a parameter in a CAST node.
*/
- public static ValueNode makeCast
- ( ValueNode parameterNode, DataTypeDescriptor targetType, NodeFactory nodeFactory, ContextManager cm )
+ public static ValueNode makeCast (ValueNode parameterNode,
+ DataTypeDescriptor targetType,
+ ContextManager cm)
throws StandardException
{
- ValueNode castNode = (ValueNode) nodeFactory.getNode
- (
- C_NodeTypes.CAST_NODE,
- parameterNode,
- targetType,
- cm
- );
+ ValueNode castNode = new CastNode(parameterNode, targetType, cm);
// Argument type has the same semantics as assignment:
// Section 9.2 (Store assignment). There, General Rule
@@ -889,6 +878,7 @@ public class StaticMethodCallNode extend
Push extra code to generate the casts within the
arrays for the parameters passed as arrays.
*/
+ @Override
void generateOneParameter(ExpressionClassBuilder acb,
MethodBuilder mb,
int parameterNumber )
@@ -1026,6 +1016,7 @@ public class StaticMethodCallNode extend
*
* @exception StandardException Thrown on error
*/
+ @Override
boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
throws StandardException
{
@@ -1051,7 +1042,7 @@ public class StaticMethodCallNode extend
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java Fri Jun 21 07:47:47 2013
@@ -21,20 +21,24 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-
import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
/**
- * A SubqueryList represents a list of subquerys within a specific clause
+ * A SubqueryList represents a list of subqueries within a specific clause
* (select, where or having) in a DML statement. It extends QueryTreeNodeVector.
*
*/
-public class SubqueryList extends QueryTreeNodeVector
+class SubqueryList extends QueryTreeNodeVector
{
+ SubqueryList(ContextManager cm) {
+ super(cm);
+ setNodeType(C_NodeTypes.SUBQUERY_LIST);
+ }
+
/**
* Add a subquery to the list.
*
@@ -42,7 +46,7 @@ public class SubqueryList extends QueryT
*
*/
- public void addSubqueryNode(SubqueryNode subqueryNode) throws StandardException
+ void addSubqueryNode(SubqueryNode subqueryNode) throws StandardException
{
addElement(subqueryNode);
}
@@ -58,7 +62,7 @@ public class SubqueryList extends QueryT
*
* @exception StandardException Thrown on error
*/
- public void preprocess(int numTables,
+ void preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
@@ -86,7 +90,7 @@ public class SubqueryList extends QueryT
* @exception StandardException Thrown on error
*/
- public void optimize(DataDictionary dataDictionary, double outerRows)
+ void optimize(DataDictionary dataDictionary, double outerRows)
throws StandardException
{
int size = size();
@@ -105,7 +109,7 @@ public class SubqueryList extends QueryT
*
* @exception StandardException Thrown on error
*/
- public void modifyAccessPaths()
+ void modifyAccessPaths()
throws StandardException
{
int size = size();
@@ -127,7 +131,7 @@ public class SubqueryList extends QueryT
*
* @exception StandardException Thrown on error
*/
- public boolean referencesTarget(String name, boolean baseTable)
+ boolean referencesTarget(String name, boolean baseTable)
throws StandardException
{
int size = size();
@@ -157,6 +161,7 @@ public class SubqueryList extends QueryT
*
* @exception StandardException Thrown on error
*/
+ @Override
public boolean referencesSessionSchema()
throws StandardException
{
@@ -183,7 +188,7 @@ public class SubqueryList extends QueryT
*
* @exception StandardException Thrown on error
*/
- public void setPointOfAttachment(int pointOfAttachment)
+ void setPointOfAttachment(int pointOfAttachment)
throws StandardException
{
int size = size();
@@ -220,7 +225,7 @@ public class SubqueryList extends QueryT
* so we can avoid flattenning later.
*
*/
- public void markHavingSubqueries() {
+ void markHavingSubqueries() {
int size = size();
for (int index = 0; index < size; index++)
@@ -236,7 +241,7 @@ public class SubqueryList extends QueryT
* Mark all of the subqueries in this list as being part of a where clause
* so we can avoid flattening later if needed.
*/
- public void markWhereSubqueries() {
+ void markWhereSubqueries() {
int size = size();
for (int index = 0; index < size; index++)
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Fri Jun 21 07:47:47 2013
@@ -21,35 +21,26 @@
package org.apache.derby.impl.sql.compile;
+import java.lang.reflect.Modifier;
+import java.util.List;
import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.classfile.VMOpcode;
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.sql.conn.Authorizer;
-
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
import org.apache.derby.iapi.store.access.Qualifier;
-
-import java.lang.reflect.Modifier;
-
-import java.util.List;
-import org.apache.derby.impl.sql.execute.OnceResultSet;
-
+import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
+import org.apache.derby.impl.sql.execute.OnceResultSet;
/**
* A SubqueryNode represents a subquery. Subqueries return values to their
@@ -81,7 +72,7 @@ import org.apache.derby.iapi.services.cl
*
*/
-public class SubqueryNode extends ValueNode
+class SubqueryNode extends ValueNode
{
/*
** This must be a single-column result set. If the subquery is
@@ -176,29 +167,29 @@ public class SubqueryNode extends ValueN
* NotNode above the SubqueryNode in the tree.
*
*/
- public final static int NOTIMPLEMENTED_SUBQUERY = -1;
- public final static int FROM_SUBQUERY = 0;
- public final static int IN_SUBQUERY = 1;
- public final static int NOT_IN_SUBQUERY = 2;
- public final static int EQ_ANY_SUBQUERY = 3;
- public final static int EQ_ALL_SUBQUERY = 4;
- public final static int NE_ANY_SUBQUERY = 5;
- public final static int NE_ALL_SUBQUERY = 6;
- public final static int GT_ANY_SUBQUERY = 7;
- public final static int GT_ALL_SUBQUERY = 8;
- public final static int GE_ANY_SUBQUERY = 9;
- public final static int GE_ALL_SUBQUERY = 10;
- public final static int LT_ANY_SUBQUERY = 11;
- public final static int LT_ALL_SUBQUERY = 12;
- public final static int LE_ANY_SUBQUERY = 13;
- public final static int LE_ALL_SUBQUERY = 14;
- public final static int EXISTS_SUBQUERY = 15;
- public final static int NOT_EXISTS_SUBQUERY = 16;
- public final static int EXPRESSION_SUBQUERY = 17;
+ final static int NOTIMPLEMENTED_SUBQUERY = -1;
+ final static int FROM_SUBQUERY = 0;
+ final static int IN_SUBQUERY = 1;
+ final static int NOT_IN_SUBQUERY = 2;
+ final static int EQ_ANY_SUBQUERY = 3;
+ final static int EQ_ALL_SUBQUERY = 4;
+ final static int NE_ANY_SUBQUERY = 5;
+ final static int NE_ALL_SUBQUERY = 6;
+ final static int GT_ANY_SUBQUERY = 7;
+ final static int GT_ALL_SUBQUERY = 8;
+ final static int GE_ANY_SUBQUERY = 9;
+ final static int GE_ALL_SUBQUERY = 10;
+ final static int LT_ANY_SUBQUERY = 11;
+ final static int LT_ALL_SUBQUERY = 12;
+ final static int LE_ANY_SUBQUERY = 13;
+ final static int LE_ALL_SUBQUERY = 14;
+ final static int EXISTS_SUBQUERY = 15;
+ final static int NOT_EXISTS_SUBQUERY = 16;
+ final static int EXPRESSION_SUBQUERY = 17;
/**
- * Initializer.
+ * Constructor.
*
* @param resultSet The ResultSetNode for the subquery
* @param subqueryType The type of the subquery
@@ -207,23 +198,26 @@ public class SubqueryNode extends ValueN
* @param offset OFFSET n ROWS
* @param fetchFirst FETCH FIRST n ROWS ONLY
* @param hasJDBClimitClause True if the offset/fetchFirst clauses come from JDBC limit/offset escape syntax
+ * @param cm Context Manager
*/
- public void init(
- Object resultSet,
- Object subqueryType,
- Object leftOperand,
- Object orderCols,
- Object offset,
- Object fetchFirst,
- Object hasJDBClimitClause)
- {
- this.resultSet = (ResultSetNode) resultSet;
- this.subqueryType = ((Integer) subqueryType).intValue();
- this.orderByList = (OrderByList)orderCols;
- this.offset = (ValueNode)offset;
- this.fetchFirst = (ValueNode)fetchFirst;
- this.hasJDBClimitClause = (hasJDBClimitClause == null) ? false : ((Boolean) hasJDBClimitClause).booleanValue();
+ SubqueryNode(ResultSetNode resultSet,
+ int subqueryType,
+ ValueNode leftOperand,
+ OrderByList orderCols,
+ ValueNode offset,
+ ValueNode fetchFirst,
+ boolean hasJDBClimitClause,
+ ContextManager cm)
+ {
+ super(cm);
+ setNodeType(C_NodeTypes.SUBQUERY_NODE);
+ this.resultSet = resultSet;
+ this.subqueryType = subqueryType;
+ this.orderByList = orderCols;
+ this.offset = offset;
+ this.fetchFirst = fetchFirst;
+ this.hasJDBClimitClause = hasJDBClimitClause;
/* Subqueries are presumed not to be under a top level AndNode by
* default. This is because expression normalization only recurses
@@ -231,7 +225,7 @@ public class SubqueryNode extends ValueN
* built-in functions, etc.
*/
underTopAndNode = false;
- this.leftOperand = (ValueNode) leftOperand;
+ this.leftOperand = leftOperand;
}
/**
@@ -240,7 +234,7 @@ public class SubqueryNode extends ValueN
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -265,8 +259,8 @@ public class SubqueryNode extends ValueN
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -309,7 +303,7 @@ public class SubqueryNode extends ValueN
*
* @return ResultSetNode underlying this SubqueryNode.
*/
- public ResultSetNode getResultSet()
+ ResultSetNode getResultSet()
{
return resultSet;
}
@@ -319,7 +313,7 @@ public class SubqueryNode extends ValueN
*
* @return int Type of this subquery.
*/
- public int getSubqueryType()
+ int getSubqueryType()
{
return subqueryType;
}
@@ -329,7 +323,7 @@ public class SubqueryNode extends ValueN
*
* @param subqueryType of this subquery.
*/
- public void setSubqueryType(int subqueryType)
+ void setSubqueryType(int subqueryType)
{
this.subqueryType = subqueryType;
}
@@ -341,7 +335,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
- public void setPointOfAttachment(int pointOfAttachment)
+ void setPointOfAttachment(int pointOfAttachment)
throws StandardException
{
/* Materialized subqueries always keep their point of
@@ -360,7 +354,7 @@ public class SubqueryNode extends ValueN
* @return boolean Whether or not this subquery is immediately under a
* top level AndNode.
*/
- public boolean getUnderTopAndNode()
+ boolean getUnderTopAndNode()
{
return underTopAndNode;
}
@@ -370,7 +364,7 @@ public class SubqueryNode extends ValueN
*
* @return int The ResultSet # for the point of attachment
*/
- public int getPointOfAttachment()
+ int getPointOfAttachment()
{
if (SanityManager.DEBUG)
{
@@ -411,7 +405,8 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
- public ValueNode remapColumnReferencesToExpressions()
+ @Override
+ ValueNode remapColumnReferencesToExpressions()
throws StandardException
{
/* We need to remap both the SELECT and Predicate lists
@@ -449,6 +444,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
+ @Override
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
throws StandardException
{
@@ -605,7 +601,8 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
- public ValueNode preprocess(int numTables,
+ @Override
+ ValueNode preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
@@ -701,7 +698,7 @@ public class SubqueryNode extends ValueN
leftOperand = parentComparisonOperator.getLeftOperand();
// Flatten the subquery
RowResultSetNode rrsn = (RowResultSetNode) resultSet;
- FromList fl = new FromList();
+ FromList fl = new FromList(getContextManager());
// Remove ourselves from the outer subquery list
outerSubqueryList.removeElement(this);
@@ -1109,10 +1106,7 @@ public class SubqueryNode extends ValueN
*/
if (leftOperand == null)
{
- return (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.BOOLEAN_CONSTANT_NODE,
- Boolean.TRUE,
- getContextManager());
+ return new BooleanConstantNode(true, getContextManager());
}
else
{
@@ -1237,7 +1231,7 @@ public class SubqueryNode extends ValueN
* references.
* @exception StandardException Thrown on error
*/
- public boolean hasCorrelatedCRs() throws StandardException
+ boolean hasCorrelatedCRs() throws StandardException
{
if (doneCorrelationCheck)
{
@@ -1268,7 +1262,8 @@ public class SubqueryNode extends ValueN
*/
if (oldRCL.size() > 1)
{
- ResultColumnList newRCL = new ResultColumnList();
+ ResultColumnList
+ newRCL = new ResultColumnList(getContextManager());
newRCL.addResultColumn(oldRCL.getResultColumn(1));
realSubquery.setResultColumns(newRCL);
}
@@ -1288,7 +1283,7 @@ public class SubqueryNode extends ValueN
/**
* Transform:
- * expresion QuantifiedOperator (select x from ...)
+ * expression QuantifiedOperator (select x from ...)
* into
* (select true from .. where expression <BinaryComparisonOperator> x ...)
* IS [NOT] NULL
@@ -1329,14 +1324,13 @@ public class SubqueryNode extends ValueN
throws StandardException
{
AndNode andNode;
- BinaryComparisonOperatorNode bcoNode = null;
JBitSet tableMap;
Predicate predicate;
ResultColumn firstRC;
ResultColumnList resultColumns;
UnaryComparisonOperatorNode ucoNode = null;
- ValueNode oldWhereClause;
ValueNode rightOperand;
+ ContextManager cm = getContextManager();
/* We have to ensure that the resultSet immediately under us has
* a PredicateList, otherwise we can't push the predicate down.
@@ -1355,8 +1349,7 @@ public class SubqueryNode extends ValueN
*/
ResultColumnList newRCL = resultColumns.copyListAndObjects();
newRCL.genVirtualColumnNodes(resultSet, resultColumns);
- resultSet = (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.PROJECT_RESTRICT_NODE,
+ resultSet = new ProjectRestrictNode(
resultSet, // child
newRCL, // result columns
null, // restriction
@@ -1364,13 +1357,14 @@ public class SubqueryNode extends ValueN
null, // project subqueries
null, // restrict subqueries
null,
- getContextManager());
+ cm);
resultColumns = newRCL;
firstRC = (ResultColumn) resultColumns.elementAt(0);
rightOperand = firstRC.getExpression();
- bcoNode = getNewJoinCondition(leftOperand, rightOperand);
+ BinaryComparisonOperatorNode bcoNode =
+ getNewJoinCondition(leftOperand, rightOperand);
ValueNode andLeft = bcoNode;
@@ -1391,47 +1385,33 @@ public class SubqueryNode extends ValueN
{
/* Create a normalized structure.
*/
- BooleanConstantNode falseNode = (BooleanConstantNode) getNodeFactory().getNode(
- C_NodeTypes.BOOLEAN_CONSTANT_NODE,
- Boolean.FALSE,
- getContextManager());
- OrNode newOr = (OrNode) getNodeFactory().getNode(
- C_NodeTypes.OR_NODE,
- bcoNode,
- falseNode,
- getContextManager());
+ BooleanConstantNode
+ falseNode = new BooleanConstantNode(false, cm);
+ OrNode newOr =
+ new OrNode(bcoNode, falseNode, cm);
+
newOr.postBindFixup();
andLeft = newOr;
if (leftNullable)
{
- UnaryComparisonOperatorNode leftIsNull = (UnaryComparisonOperatorNode)
- getNodeFactory().getNode(
- C_NodeTypes.IS_NULL_NODE,
- leftOperand,
- getContextManager());
+ UnaryComparisonOperatorNode leftIsNull = new IsNullNode(
+ leftOperand,
+ IsNullNode.Sign.IS_NULL,
+ cm);
leftIsNull.bindComparisonOperator();
- newOr = (OrNode) getNodeFactory().getNode(
- C_NodeTypes.OR_NODE,
- leftIsNull,
- andLeft,
- getContextManager());
+ newOr = new OrNode(leftIsNull, andLeft, cm);
newOr.postBindFixup();
andLeft = newOr;
}
if (rightNullable)
{
- UnaryComparisonOperatorNode rightIsNull = (UnaryComparisonOperatorNode)
- getNodeFactory().getNode(
- C_NodeTypes.IS_NULL_NODE,
- rightOperand,
- getContextManager());
+ UnaryComparisonOperatorNode rightIsNull = new IsNullNode(
+ rightOperand,
+ IsNullNode.Sign.IS_NULL,
+ cm);
rightIsNull.bindComparisonOperator();
- newOr = (OrNode) getNodeFactory().getNode(
- C_NodeTypes.OR_NODE,
- rightIsNull,
- andLeft,
- getContextManager());
+ newOr = new OrNode(rightIsNull, andLeft, cm);
newOr.postBindFixup();
andLeft = newOr;
}
@@ -1439,22 +1419,14 @@ public class SubqueryNode extends ValueN
}
/* Place an AndNode above the <BinaryComparisonOperator> */
- andNode = (AndNode) getNodeFactory().getNode(
- C_NodeTypes.AND_NODE,
- andLeft,
- getTrueNode(),
- getContextManager());
+ andNode = new AndNode(andLeft, getTrueNode(), cm);
/* Build the referenced table map for the new predicate */
tableMap = new JBitSet(numTables);
andNode.postBindFixup();
/* Put the AndNode under a Predicate */
- predicate = (Predicate) getNodeFactory().getNode(
- C_NodeTypes.PREDICATE,
- andNode,
- tableMap,
- getContextManager());
+ predicate = new Predicate(andNode, tableMap, cm);
predicate.categorize();
/* Push the new Predicate to the subquery's list */
@@ -1475,11 +1447,7 @@ public class SubqueryNode extends ValueN
case LT_ANY_SUBQUERY:
case GE_ANY_SUBQUERY:
case GT_ANY_SUBQUERY:
- ucoNode = (UnaryComparisonOperatorNode)
- getNodeFactory().getNode(
- C_NodeTypes.IS_NOT_NULL_NODE,
- this,
- getContextManager());
+ ucoNode = new IsNullNode(this, IsNullNode.Sign.IS_NOT_NULL, cm);
break;
case NOT_IN_SUBQUERY:
@@ -1489,12 +1457,12 @@ public class SubqueryNode extends ValueN
case LT_ALL_SUBQUERY:
case GE_ALL_SUBQUERY:
case GT_ALL_SUBQUERY:
- ucoNode = (UnaryComparisonOperatorNode)
- getNodeFactory().getNode(
- C_NodeTypes.IS_NULL_NODE,
- this,
- getContextManager());
+ ucoNode = new IsNullNode(this, IsNullNode.Sign.IS_NULL, cm);
break;
+ default:
+ if (SanityManager.DEBUG) {
+ SanityManager.NOTREACHED();
+ }
}
ucoNode.bindComparisonOperator();
return ucoNode;
@@ -1515,8 +1483,6 @@ public class SubqueryNode extends ValueN
ValueNode rightOperand)
throws StandardException
{
- BinaryComparisonOperatorNode bcoNode = null;
-
/* NOTE: If we are an expression subquery that's getting
* flattened then our subqueryType is EXPRESSION_SUBQUERY.
* However, we can get the comparison type from the
@@ -1610,13 +1576,12 @@ public class SubqueryNode extends ValueN
"subqueryType (" + subqueryType + ") is an unexpected type");
}
- bcoNode = (BinaryComparisonOperatorNode)
- getNodeFactory().getNode(
- nodeType,
- leftOperand,
- rightOperand,
- Boolean.FALSE,
- getContextManager());
+ BinaryComparisonOperatorNode bcoNode = new BinaryRelationalOperatorNode(
+ nodeType,
+ leftOperand,
+ rightOperand,
+ false,
+ getContextManager());
bcoNode.bindComparisonOperator();
return bcoNode;
@@ -1639,6 +1604,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
+ @Override
ValueNode eliminateNots(boolean underNotNode)
throws StandardException
{
@@ -1754,7 +1720,8 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
- public ValueNode changeToCNF(boolean underTopAndNode)
+ @Override
+ ValueNode changeToCNF(boolean underTopAndNode)
throws StandardException
{
/* Remember whether or not we are immediately under a top leve
@@ -1789,7 +1756,8 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
- public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+ @Override
+ boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
throws StandardException
{
/* We stop here when only considering simple predicates
@@ -1821,7 +1789,7 @@ public class SubqueryNode extends ValueN
** it is an expression subquery that
** has no correlations and is invariant.
*/
- boolean isMaterializable() throws StandardException
+ public boolean isMaterializable() throws StandardException
{
boolean retval = (subqueryType == EXPRESSION_SUBQUERY) &&
!hasCorrelatedCRs() &&
@@ -1853,7 +1821,7 @@ public class SubqueryNode extends ValueN
* @exception StandardException Thrown on error
*/
- public void optimize(DataDictionary dataDictionary, double outerRows)
+ void optimize(DataDictionary dataDictionary, double outerRows)
throws StandardException
{
/* RESOLVE - is there anything else that we need to do for this
@@ -1869,7 +1837,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
- public void modifyAccessPaths() throws StandardException
+ void modifyAccessPaths() throws StandardException
{
resultSet = resultSet.modifyAccessPaths();
}
@@ -1888,6 +1856,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
+ @Override
protected int getOrderableVariantType() throws StandardException
{
/*
@@ -1924,7 +1893,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException Thrown on error
*/
-
+ @Override
void generateExpression(
ExpressionClassBuilder expressionBuilder, MethodBuilder mbex)
throws StandardException
@@ -2001,7 +1970,8 @@ public class SubqueryNode extends ValueN
mb.getField(subRS);
mb.conditionalIfNull();
- ResultSetNode materialSubNode = new MaterializeSubqueryNode(subRS);
+ ResultSetNode materialSubNode =
+ new MaterializeSubqueryNode(subRS, getContextManager());
// Propagate the resultSet's cost estimate to the new node.
materialSubNode.costEstimate = resultSet.getFinalCostEstimate();
@@ -2267,10 +2237,7 @@ public class SubqueryNode extends ValueN
{
if (trueNode == null)
{
- trueNode = (BooleanConstantNode) getNodeFactory().getNode(
- C_NodeTypes.BOOLEAN_CONSTANT_NODE,
- Boolean.TRUE,
- getContextManager());
+ trueNode = new BooleanConstantNode(true, getContextManager());
}
return trueNode;
}
@@ -2282,6 +2249,7 @@ public class SubqueryNode extends ValueN
*
* @exception StandardException on error
*/
+ @Override
void acceptChildren(Visitor v)
throws StandardException
{
@@ -2369,71 +2337,48 @@ public class SubqueryNode extends ValueN
private void changeToCorrespondingExpressionType()
throws StandardException
{
- BinaryOperatorNode bcon = null;
+ int nodeType = 0;
- switch (subqueryType)
+ switch (subqueryType)
{
case EQ_ANY_SUBQUERY:
case IN_SUBQUERY:
- bcon = (BinaryOperatorNode) getNodeFactory().getNode(
- C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
- leftOperand,
- this,
- Boolean.FALSE,
- getContextManager());
+ nodeType = C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE;
break;
case NE_ANY_SUBQUERY:
- bcon = (BinaryOperatorNode) getNodeFactory().getNode(
- C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
- leftOperand,
- this,
- Boolean.FALSE,
- getContextManager());
+ nodeType = C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE;
break;
case LE_ANY_SUBQUERY:
- bcon = (BinaryOperatorNode) getNodeFactory().getNode(
- C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
- leftOperand,
- this,
- Boolean.FALSE,
- getContextManager());
+ nodeType = C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE;
break;
case LT_ANY_SUBQUERY:
- bcon = (BinaryOperatorNode) getNodeFactory().getNode(
- C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE,
- leftOperand,
- this,
- Boolean.FALSE,
- getContextManager());
+ nodeType = C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE;
break;
case GE_ANY_SUBQUERY:
- bcon = (BinaryOperatorNode) getNodeFactory().getNode(
- C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
- leftOperand,
- this,
- Boolean.FALSE,
- getContextManager());
+ nodeType = C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE;
break;
case GT_ANY_SUBQUERY:
- bcon = (BinaryOperatorNode) getNodeFactory().getNode(
- C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE,
- leftOperand,
- this,
- Boolean.FALSE,
- getContextManager());
+ nodeType = C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE;
break;
+ default:
+ if (SanityManager.DEBUG) {
+ SanityManager.NOTREACHED();
+ }
}
+ BinaryRelationalOperatorNode bcon = new BinaryRelationalOperatorNode(
+ nodeType, leftOperand, this, false, getContextManager());
+
// clean up the state of the tree to reflect a bound expression subquery
subqueryType = EXPRESSION_SUBQUERY;
setDataTypeServices(resultSet.getResultColumns());
- parentComparisonOperator = (BinaryComparisonOperatorNode) bcon;
+ parentComparisonOperator = bcon;
/* Set type info for the operator node */
parentComparisonOperator.bindComparisonOperator();
leftOperand = null;
@@ -2495,7 +2440,7 @@ public class SubqueryNode extends ValueN
*
* @return true if it is part of a where clause, otherwise false
*/
- public boolean isWhereSubquery() {
+ boolean isWhereSubquery() {
return whereSubquery;
}
@@ -2503,7 +2448,7 @@ public class SubqueryNode extends ValueN
* Mark this subquery as being part of a where clause.
* @param whereSubquery
*/
- public void setWhereSubquery(boolean whereSubquery) {
+ void setWhereSubquery(boolean whereSubquery) {
this.whereSubquery = whereSubquery;
}
@@ -2519,7 +2464,7 @@ public class SubqueryNode extends ValueN
* @return true if this subquery is a WHERE EXISTS | ANY | IN subquery with
* a subquery in its own WHERE clause
*/
- public boolean isWhereExistsAnyInWithWhereSubquery()
+ boolean isWhereExistsAnyInWithWhereSubquery()
throws StandardException
{
if ( isWhereSubquery() && (isEXISTS() || isANY() || isIN()) ) {
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java Fri Jun 21 07:47:47 2013
@@ -46,7 +46,7 @@ class SubstituteExpressionVisitor implem
/**
* used by GroupByNode to process expressions by complexity level.
*/
- public ValueNode getSource()
+ ValueNode getSource()
{
return source;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java Fri Jun 21 07:47:47 2013
@@ -21,30 +21,21 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
import org.apache.derby.iapi.services.context.ContextService;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.impl.sql.execute.SumAggregator;
-import org.apache.derby.impl.sql.execute.AvgAggregator;
-
-import org.apache.derby.catalog.TypeDescriptor;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
+import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.compile.TypeCompiler;
import org.apache.derby.iapi.sql.compile.TypeCompilerFactory;
-
-import org.apache.derby.iapi.sql.compile.CompilerContext;
-
-import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
/**
- * Defintion for the SUM()/AVG() aggregates.
+ * Definition for the SUM()/AVG() aggregates.
*
*/
-public class SumAvgAggregateDefinition
+class SumAvgAggregateDefinition
implements AggregateDefinition
{
private boolean isSum;
@@ -52,7 +43,7 @@ public class SumAvgAggregateDefinition
* Niladic constructor. Does nothing. For ease
* Of use, only.
*/
- public SumAvgAggregateDefinition() { super(); }
+ SumAvgAggregateDefinition() { super(); }
/**
* Determines the result datatype. Accept NumberDataValues
@@ -138,7 +129,7 @@ public class SumAvgAggregateDefinition
/**
* This is set by the parser.
*/
- public final void setSumOrAvg(boolean isSum)
+ final void setSumOrAvg(boolean isSum)
{
this.isSum = isSum;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java Fri Jun 21 07:47:47 2013
@@ -21,68 +21,63 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.derby.catalog.UUID;
+import org.apache.derby.catalog.types.DefaultInfoImpl;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.reference.Property;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.io.FormatableBitSet;
import org.apache.derby.iapi.services.property.PropertyUtil;
-
+import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.StatementType;
-import org.apache.derby.iapi.sql.compile.CompilerContext;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.catalog.types.DefaultInfoImpl;
-
+import org.apache.derby.iapi.sql.compile.CompilerContext;
+import org.apache.derby.iapi.sql.depend.DependencyManager;
+import org.apache.derby.iapi.sql.depend.ProviderInfo;
+import org.apache.derby.iapi.sql.depend.ProviderList;
+import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList;
import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor;
+import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
-import org.apache.derby.iapi.sql.depend.DependencyManager;
-import org.apache.derby.iapi.sql.depend.ProviderInfo;
-import org.apache.derby.iapi.sql.depend.ProviderList;
-
-import org.apache.derby.iapi.reference.SQLState;
-
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
import org.apache.derby.impl.sql.execute.ColumnInfo;
-import org.apache.derby.impl.sql.execute.ConstraintInfo;
import org.apache.derby.impl.sql.execute.ConstraintConstantAction;
+import org.apache.derby.impl.sql.execute.ConstraintInfo;
import org.apache.derby.impl.sql.execute.IndexConstantAction;
-import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList;
-import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
-
-import org.apache.derby.catalog.UUID;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
/**
* A TableElementList represents the list of columns and other table elements
* such as constraints in a CREATE TABLE or ALTER TABLE statement.
*
*/
-public class TableElementList extends QueryTreeNodeVector
+class TableElementList extends QueryTreeNodeVector
{
private int numColumns;
private TableDescriptor td;
+ public TableElementList(ContextManager cm) {
+ super(cm);
+ setNodeType(C_NodeTypes.TABLE_ELEMENT_LIST);
+ }
+
/**
* Add a TableElementNode to this TableElementList
*
* @param tableElement The TableElementNode to add to this list
*/
- public void addTableElement(TableElementNode tableElement)
+ void addTableElement(TableElementNode tableElement)
{
addElement(tableElement);
if ((tableElement instanceof ColumnDefinitionNode) ||
@@ -101,8 +96,8 @@ public class TableElementList extends Qu
throws StandardException
{
int size = size();
- int collationType = sd.getCollationType();
- for (int index = 0; index < size; index++)
+
+ for (int index = 0; index < size; index++)
{
TableElementNode tableElement = (TableElementNode) elementAt(index);
@@ -133,11 +128,7 @@ public class TableElementList extends Qu
DataTypeDescriptor dtd = cdn.getType();
if ( dtd == null )
{
- if ( cdn.hasGenerationClause() )
- {
- return;
- }
- else
+ if ( !cdn.hasGenerationClause() )
{
throw StandardException.newException
( SQLState.LANG_NEEDS_DATATYPE, cdn.getColumnName() );
@@ -402,7 +393,7 @@ public class TableElementList extends Qu
*
* @return int The number of constraints of the specified type.
*/
- public int countConstraints(int constraintType)
+ int countConstraints(int constraintType)
{
int numConstraints = 0;
int size = size();
@@ -431,7 +422,7 @@ public class TableElementList extends Qu
/**
* Count the number of generation clauses.
*/
- public int countGenerationClauses()
+ int countGenerationClauses()
{
int numGenerationClauses = 0;
int size = size();
@@ -462,7 +453,7 @@ public class TableElementList extends Qu
*
* @return int The number of columns.
*/
- public int countNumberOfColumns()
+ int countNumberOfColumns()
{
return numColumns;
}
@@ -474,7 +465,7 @@ public class TableElementList extends Qu
*
* @return int The number of constraints in the create table.
*/
- public int genColumnInfos( ColumnInfo[] colInfos)
+ int genColumnInfos( ColumnInfo[] colInfos)
throws StandardException
{
int numConstraints = 0;
@@ -559,7 +550,7 @@ public class TableElementList extends Qu
*
* @exception StandardException Thrown on error
*/
- public void appendNewColumnsToRCL(FromBaseTable table)
+ void appendNewColumnsToRCL(FromBaseTable table)
throws StandardException
{
int size = size();
@@ -575,18 +566,13 @@ public class TableElementList extends Qu
ValueNode valueNode;
/* Build a ResultColumn/BaseColumnNode pair for the column */
- valueNode = (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.BASE_COLUMN_NODE,
- cdn.getColumnName(),
+ valueNode = new BaseColumnNode(cdn.getColumnName(),
exposedName,
cdn.getType(),
getContextManager());
- resultColumn = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- cdn.getType(),
- valueNode,
- getContextManager());
+ resultColumn = new ResultColumn(
+ cdn.getType(), valueNode, getContextManager());
resultColumn.setName(cdn.getColumnName());
rcl.addElement(resultColumn);
}
@@ -685,10 +671,7 @@ public class TableElementList extends Qu
*/
ResultColumnList rcl = table.getResultColumns();
int numReferenced = rcl.countReferencedColumns();
- ResultColumnList refRCL =
- (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager());
+ ResultColumnList refRCL = new ResultColumnList(getContextManager());
rcl.copyReferencedColumnsToNewList(refRCL);
/* A column check constraint can only refer to that column. If this is a
@@ -923,13 +906,14 @@ public class TableElementList extends Qu
int count = generatedColumns.size();
for ( int i = 0; i < count; i++ )
{
- ColumnDefinitionNode cdn = (ColumnDefinitionNode) generatedColumns.get( i );
+ ColumnDefinitionNode cdn = generatedColumns.get( i );
GenerationClauseNode generationClauseNode = cdn.getGenerationClauseNode();
- List referencedColumns = generationClauseNode.findReferencedColumns();
+ List<ColumnReference> referencedColumns =
+ generationClauseNode.findReferencedColumns();
int refCount = referencedColumns.size();
for ( int j = 0; j < refCount; j++ )
{
- String name = ((ColumnReference) referencedColumns.get(j)).getColumnName();
+ String name = referencedColumns.get(j).getColumnName();
if ( name != null )
{
@@ -1148,7 +1132,7 @@ public class TableElementList extends Qu
{
ProviderList apl = constraintDN.getAuxiliaryProviderList();
ConstraintInfo refInfo = null;
- ProviderInfo[] providerInfos = null;
+ ProviderInfo[] providerInfos;
if (constraintDN instanceof FKConstraintDefinitionNode)
{
@@ -1193,7 +1177,6 @@ public class TableElementList extends Qu
private boolean columnsMatch(String[] columnNames1, String[] columnNames2)
{
int srcCount, srcSize, destCount,destSize;
- boolean match = true;
if (columnNames1.length != columnNames2.length)
return false;
@@ -1203,7 +1186,7 @@ public class TableElementList extends Qu
for (srcCount = 0; srcCount < srcSize; srcCount++)
{
- match = false;
+ boolean match = false;
for (destCount = 0; destCount < destSize; destCount++) {
if (columnNames1[srcCount].equals(columnNames2[destCount])) {
match = true;
@@ -1592,7 +1575,7 @@ public class TableElementList extends Qu
*
* @return boolean Whether or not a match is found.
*/
- public boolean containsColumnName(String colName)
+ boolean containsColumnName(String colName)
{
return findColumnDefinition(colName) != null;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementNode.java Fri Jun 21 07:47:47 2013
@@ -21,6 +21,7 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
@@ -31,7 +32,7 @@ import org.apache.derby.iapi.sql.compile
*
*/
-public class TableElementNode extends QueryTreeNode
+class TableElementNode extends QueryTreeNode
{
/////////////////////////////////////////////////////////////////////////
//
@@ -68,26 +69,16 @@ public class TableElementNode extends Qu
/////////////////////////////////////////////////////////////////////////
/**
- * Initializer for a TableElementNode
+ * Constructor for a TableElementNode
*
* @param name The name of the table element, if any
*/
- public void init(Object name)
+ TableElementNode(String name, ContextManager cm)
{
- this.name = (String) name;
- }
-
- /**
- * Initializer for a TableElementNode
- *
- * @param name The name of the table element, if any
- */
-
- public void init(Object name, Object elementType)
- {
- this.name = (String) name;
- this.elementType = ((Integer) elementType).intValue();
+ super(cm);
+ setNodeType(C_NodeTypes.TABLE_ELEMENT_NODE);
+ this.name = name;
}
/**
@@ -96,7 +87,7 @@ public class TableElementNode extends Qu
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -166,7 +157,7 @@ public class TableElementNode extends Qu
*
* @return String The name.
*/
- public String getName()
+ String getName()
{
return name;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableName.java Fri Jun 21 07:47:47 2013
@@ -21,21 +21,18 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
import org.apache.derby.iapi.reference.Property;
import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.util.IdUtil;
/**
* A TableName represents a qualified name, externally represented as a schema name
- * and an object name separated by a dot. This class is mis-named: it is used to
+ * and an object name separated by a dot. This class is misnamed: it is used to
* represent the names of other object types in addition to tables.
*
*/
@@ -50,40 +47,49 @@ public class TableName extends QueryTree
private boolean hasSchema;
/**
- * Initializer for when you have both the table and schema names.
+ * Constructor for when we have both the table and schema names.
*
* @param schemaName The name of the schema being referenced
- * @param tableName The name of the table being referenced
+ * @param tableName The name of the table or other object being
+ * referenced
+ * @param cm The context manager
*/
- public void init(Object schemaName, Object tableName)
+ TableName(String schemaName, String tableName, ContextManager cm)
{
+ super(cm);
+ setNodeType(C_NodeTypes.TABLE_NAME);
hasSchema = schemaName != null;
- this.schemaName = (String) schemaName;
- this.tableName = (String) tableName;
+ this.schemaName = schemaName;
+ this.tableName = tableName;
}
/**
- * Initializer for when you have both the table and schema names.
+ * Constructor for when we have both the table and schema names.
*
* @param schemaName The name of the schema being referenced
- * @param tableName The name of the table being referenced
+ * @param tableName The name of the table or other object being
+ * referenced
* @param tokBeginOffset begin position of token for the table name
* identifier from parser. pass in -1 if unknown
* @param tokEndOffset end position of token for the table name
* identifier from parser. pass in -1 if unknown
+ * @param cm The context manager
*/
- public void init
- (
- Object schemaName,
- Object tableName,
- Object tokBeginOffset,
- Object tokEndOffset
- )
- {
- init(schemaName, tableName);
- this.setBeginOffset(((Integer) tokBeginOffset).intValue());
- this.setEndOffset(((Integer) tokEndOffset).intValue());
+ TableName(
+ String schemaName,
+ String tableName,
+ int tokBeginOffset,
+ int tokEndOffset,
+ ContextManager cm)
+ {
+ super(cm);
+ setNodeType(C_NodeTypes.TABLE_NAME);
+ hasSchema = schemaName != null;
+ this.schemaName = schemaName;
+ this.tableName = tableName;
+ this.setBeginOffset(tokBeginOffset);
+ this.setEndOffset(tokEndOffset);
}
/**
@@ -103,7 +109,7 @@ public class TableName extends QueryTree
* @return true if this instance was initialized with not null schemaName
*/
- public boolean hasSchema(){
+ boolean hasSchema(){
return hasSchema;
}
@@ -124,7 +130,7 @@ public class TableName extends QueryTree
* @param schemaName Schema name as a String
*/
- public void setSchemaName(String schemaName)
+ void setSchemaName(String schemaName)
{
this.schemaName = schemaName;
}
@@ -136,7 +142,7 @@ public class TableName extends QueryTree
* @return Full table name as a String
*/
- public String getFullTableName()
+ String getFullTableName()
{
if (schemaName != null)
return schemaName + "." + tableName;
@@ -158,7 +164,7 @@ public class TableName extends QueryTree
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (hasSchema)
@@ -177,7 +183,7 @@ public class TableName extends QueryTree
*
* @return boolean Whether or not the 2 TableNames are equal.
*/
- public boolean equals(TableName otherTableName)
+ boolean equals(TableName otherTableName)
{
if( otherTableName == null)
return false;
@@ -209,7 +215,7 @@ public class TableName extends QueryTree
*
* @return boolean Whether or not the 2 TableNames are equal.
*/
- public boolean equals(String otherSchemaName, String otherTableName)
+ boolean equals(String otherSchemaName, String otherTableName)
{
String fullTableName = getFullTableName();
if (fullTableName == null)
@@ -241,7 +247,7 @@ public class TableName extends QueryTree
*
* @exception StandardException Thrown on error
*/
- public void bind( DataDictionary dataDictionary )
+ void bind( DataDictionary dataDictionary )
throws StandardException
{
schemaName = getSchemaDescriptor(schemaName).getSchemaName();
@@ -254,11 +260,12 @@ public class TableName extends QueryTree
///////////////////////////////////////////////////////////////////////
/**
- * Returns a hashcode for this tableName. This allows us to use TableNames
+ * Returns a hash code for this tableName. This allows us to use TableNames
* as keys in hash lists.
*
- * @return hashcode for this tablename
+ * @return hash code for this table name
*/
+ @Override
public int hashCode()
{
return getFullTableName().hashCode();
@@ -269,6 +276,7 @@ public class TableName extends QueryTree
*
* @param other other tableName
*/
+ @Override
public boolean equals( Object other )
{
if ( !( other instanceof TableName ) ) { return false; }