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 [18/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/UnionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java Fri Jun 21 07:47:47 2013
@@ -21,31 +21,23 @@
package org.apache.derby.impl.sql.compile;
+import java.util.Properties;
+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.MethodBuilder;
-
+import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.Optimizable;
-import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.CostEstimate;
import org.apache.derby.iapi.sql.compile.RowOrdering;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
-
import org.apache.derby.iapi.types.DataTypeDescriptor;
-
import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
/**
* A UnionNode represents a UNION in a DML statement. It contains a boolean
@@ -53,7 +45,7 @@ import org.apache.derby.iapi.services.cl
*
*/
-public class UnionNode extends SetOperatorNode
+class UnionNode extends SetOperatorNode
{
/* Only optimize it once */
/* Only call addNewNodes() once */
@@ -67,7 +59,7 @@ public class UnionNode extends SetOperat
/**
- * Initializer for a UnionNode.
+ * Constructor for a UnionNode.
*
* @param leftResult The ResultSetNode on the left side of this union
* @param rightResult The ResultSetNode on the right side of this union
@@ -78,24 +70,24 @@ public class UnionNode extends SetOperat
* @exception StandardException Thrown on error
*/
- public void init(
- Object leftResult,
- Object rightResult,
- Object all,
- Object tableConstructor,
- Object tableProperties)
- throws StandardException
- {
- super.init(leftResult, rightResult, all, tableProperties);
+ UnionNode(ResultSetNode leftResult,
+ ResultSetNode rightResult,
+ boolean all,
+ boolean tableConstructor,
+ Properties tableProperties,
+ ContextManager cm) throws StandardException {
+
+ super(leftResult, rightResult, all, tableProperties, cm);
+ setNodeType(C_NodeTypes.UNION_NODE);
- /* Is this a UNION ALL for a table constructor? */
- this.tableConstructor = ((Boolean) tableConstructor).booleanValue();
- } // end of init
+ // Is this a UNION ALL for a table constructor?
+ this.tableConstructor = tableConstructor;
+ }
/**
* Mark this as the top node of a table constructor.
*/
- public void markTopTableConstructor()
+ void markTopTableConstructor()
{
topTableConstructor = true;
}
@@ -119,7 +111,8 @@ public class UnionNode extends SetOperat
* @exception StandardException Thrown if a ? parameter found
* directly under a ResultColumn
*/
- public void rejectParameters() throws StandardException
+ @Override
+ void rejectParameters() throws StandardException
{
if ( ! tableConstructor())
super.rejectParameters();
@@ -136,6 +129,7 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
+ @Override
void setTableConstructorTypes(ResultColumnList typeColumns)
throws StandardException
{
@@ -197,6 +191,7 @@ public class UnionNode extends SetOperat
* If this node represents a regular UNION, put a ProjectRestrictNode on
* top of this node and enhance the RCL in that node.
*/
+ @Override
ResultSetNode enhanceRCLForInsert(
InsertNode target, boolean inOrder, int[] colMap)
throws StandardException
@@ -227,6 +222,7 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
+ @Override
public CostEstimate optimizeIt(Optimizer optimizer,
OptimizablePredicateList predList,
CostEstimate outerCost,
@@ -292,15 +288,15 @@ public class UnionNode extends SetOperat
getRightOptPredicateList(),
outerCost);
- CostEstimate costEstimate = getCostEstimate(optimizer);
+ CostEstimate costEst = getCostEstimate(optimizer);
/* The cost is the sum of the two child costs */
- costEstimate.setCost(leftResultSet.getCostEstimate().getEstimatedCost(),
+ costEst.setCost(leftResultSet.getCostEstimate().getEstimatedCost(),
leftResultSet.getCostEstimate().rowCount(),
leftResultSet.getCostEstimate().singleScanRowCount() +
rightResultSet.getCostEstimate().singleScanRowCount());
- costEstimate.add(rightResultSet.costEstimate, costEstimate);
+ costEst.add(rightResultSet.costEstimate, costEst);
/*
** Get the cost of this result set in the context of the whole plan.
@@ -313,12 +309,12 @@ public class UnionNode extends SetOperat
(ConglomerateDescriptor) null,
outerCost,
optimizer,
- costEstimate
+ costEst
);
- optimizer.considerCost(this, predList, costEstimate, outerCost);
+ optimizer.considerCost(this, predList, costEst, outerCost);
- return costEstimate;
+ return costEst;
}
/**
@@ -341,7 +337,8 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
- public void pushExpressions(PredicateList predicateList)
+ @Override
+ void pushExpressions(PredicateList predicateList)
throws StandardException
{
// If left or right side is a UnionNode, further push the predicate list
@@ -364,6 +361,7 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
+ @Override
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException
{
Optimizable retOptimizable;
@@ -382,7 +380,8 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
- public ResultSetNode modifyAccessPaths() throws StandardException
+ @Override
+ ResultSetNode modifyAccessPaths() throws StandardException
{
ResultSetNode retRSN;
retRSN = super.modifyAccessPaths();
@@ -444,19 +443,14 @@ public class UnionNode extends SetOperat
*/
if (! columnTypesAndLengthsMatch())
{
- treeTop =
- (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.NORMALIZE_RESULT_SET_NODE,
- treeTop, null, null, Boolean.FALSE,
- getContextManager());
+ treeTop = new NormalizeResultSetNode(
+ treeTop, null, null, false, getContextManager());
}
- treeTop = (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.DISTINCT_NODE,
- treeTop.genProjectRestrict(),
- Boolean.FALSE,
- tableProperties,
- getContextManager());
+ treeTop = new DistinctNode(treeTop.genProjectRestrict(),
+ false,
+ tableProperties,
+ getContextManager());
/* HACK - propagate our table number up to the new DistinctNode
* so that arbitrary hash join will work correctly. (Otherwise it
* could have a problem dividing up the predicate list at the end
@@ -474,12 +468,10 @@ public class UnionNode extends SetOperat
for (int i=0; i < orderByLists.length; i++) {
if (orderByLists[i] != null)
{
- treeTop = (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.ORDER_BY_NODE,
- treeTop,
- orderByLists[i],
- tableProperties,
- getContextManager());
+ treeTop = new OrderByNode(treeTop,
+ orderByLists[i],
+ tableProperties,
+ getContextManager());
}
// Do this only after the main ORDER BY; any extra added by
@@ -490,13 +482,12 @@ public class UnionNode extends SetOperat
newRcl.genVirtualColumnNodes(treeTop,
treeTop.getResultColumns());
- treeTop = (ResultSetNode)getNodeFactory().getNode(
- C_NodeTypes.ROW_COUNT_NODE,
+ treeTop = new RowCountNode(
treeTop,
newRcl,
offset,
fetchFirst,
- Boolean.valueOf( hasJDBClimitClause ),
+ hasJDBClimitClause,
getContextManager());
}
}
@@ -510,7 +501,7 @@ public class UnionNode extends SetOperat
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -530,7 +521,7 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public void bindExpressions(FromList fromListParam)
throws StandardException
{
@@ -617,6 +608,7 @@ public class UnionNode extends SetOperat
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -696,7 +688,8 @@ public class UnionNode extends SetOperat
* @return The final CostEstimate for this UnionNode, which is
* the sum of the two child costs.
*/
- public CostEstimate getFinalCostEstimate()
+ @Override
+ CostEstimate getFinalCostEstimate()
throws StandardException
{
// If we already found it, just return it.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java Fri Jun 21 07:47:47 2013
@@ -22,12 +22,13 @@
package org.apache.derby.impl.sql.compile;
import java.util.List;
+import org.apache.derby.iapi.error.StandardException;
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.error.StandardException;
-import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
import org.apache.derby.iapi.types.DataTypeDescriptor;
-
+import org.apache.derby.iapi.types.DataValueDescriptor;
/**
* An UntypedNullConstantNode represents a SQL NULL before it has
@@ -42,9 +43,10 @@ public final class UntypedNullConstantNo
* contain no state (not too surprising).
*/
- public UntypedNullConstantNode()
+ UntypedNullConstantNode(ContextManager cm)
{
- super();
+ super(cm);
+ setNodeType(C_NodeTypes.UNTYPED_NULL_CONSTANT_NODE);
}
/**
@@ -83,7 +85,8 @@ public final class UntypedNullConstantNo
* @param typeDescriptor A description of the required data type.
*
*/
- public DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor)
+ @Override
+ DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor)
throws StandardException
{
/*
@@ -97,8 +100,10 @@ public final class UntypedNullConstantNo
* This does nothing-- the node is actually bound when
* bindUntypedNullsToResultColumns is called.
*/
- ValueNode bindExpression(
- FromList fromList, SubqueryList subqueryList, List aggregates)
+ @Override
+ ValueNode bindExpression(FromList fromList,
+ SubqueryList subqueryList,
+ List<AggregateNode> aggregates)
{
return this;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java Fri Jun 21 07:47:47 2013
@@ -21,50 +21,43 @@
package org.apache.derby.impl.sql.compile;
+import java.lang.reflect.Modifier;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import org.apache.derby.catalog.DefaultInfo;
import org.apache.derby.catalog.UUID;
-
+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.MethodBuilder;
-import org.apache.derby.iapi.sql.conn.Authorizer;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.io.FormatableBitSet;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.StatementType;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.conn.Authorizer;
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-import org.apache.derby.impl.sql.execute.FKInfo;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.sql.dictionary.CheckConstraintDescriptor;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
import org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList;
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList;
import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor;
-import org.apache.derby.iapi.sql.dictionary.CheckConstraintDescriptor;
+import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.sql.dictionary.GenericDescriptorList;
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.sql.dictionary.TriggerDescriptor;
-
-import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.sql.execute.ConstantAction;
import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
-import org.apache.derby.iapi.sql.StatementType;
-
import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
import org.apache.derby.iapi.store.access.TransactionController;
-
-import org.apache.derby.vti.DeferModification;
-
-import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.reference.ClassName;
-
+import org.apache.derby.iapi.types.TypeId;
import org.apache.derby.iapi.util.ReuseFactory;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
+import org.apache.derby.vti.DeferModification;
/**
* An UpdateNode represents an UPDATE statement. It is the top node of the
@@ -79,32 +72,31 @@ public final class UpdateNode extends DM
{
//Note: These are public so they will be visible to
//the RepUpdateNode.
- public int[] changedColumnIds;
- public boolean deferred;
- public ValueNode checkConstraints;
- public FKInfo fkInfo;
+ int[] changedColumnIds;
+ boolean deferred;
+ ValueNode checkConstraints;
protected FromTable targetTable;
protected FormatableBitSet readColsBitSet;
protected boolean positionedUpdate;
/* Column name for the RowLocation in the ResultSet */
- public static final String COLUMNNAME = "###RowLocationToUpdate";
+ static final String COLUMNNAME = "###RowLocationToUpdate";
/**
- * Initializer for an UpdateNode.
+ * Constructor for an UpdateNode.
*
* @param targetTableName The name of the table to update
- * @param resultSet The ResultSet that will generate
- * the rows to update from the given table
+ * @param resultSet The ResultSet that we will generate
+ * @param cm The context manager
*/
-
- public void init(
- Object targetTableName,
- Object resultSet)
+ UpdateNode(TableName targetTableName,
+ ResultSetNode resultSet,
+ ContextManager cm)
{
- super.init(resultSet);
- this.targetTableName = (TableName) targetTableName;
+ super(resultSet, cm);
+ setNodeType(C_NodeTypes.UPDATE_NODE);
+ this.targetTableName = targetTableName;
}
/**
@@ -113,7 +105,7 @@ public final class UpdateNode extends DM
*
* @return This object as a String
*/
-
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -127,7 +119,8 @@ public final class UpdateNode extends DM
}
}
- public String statementToString()
+ @Override
+ String statementToString()
{
return "UPDATE";
}
@@ -138,8 +131,8 @@ public final class UpdateNode extends DM
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -170,21 +163,17 @@ public final class UpdateNode extends DM
*
* @exception StandardException Thrown on error
*/
-
+ @Override
public void bindStatement() throws StandardException
{
// We just need select privilege on the expressions
getCompilerContext().pushCurrentPrivType( Authorizer.SELECT_PRIV);
- FromList fromList = (FromList) getNodeFactory().getNode(
- C_NodeTypes.FROM_LIST,
- getNodeFactory().doJoinOrderOptimization(),
- getContextManager());
- ResultColumn rowLocationColumn = null;
- ValueNode rowLocationNode = null;
+ FromList fromList = new FromList(
+ getOptimizerFactory().doJoinOrderOptimization(),
+ getContextManager());
TableName cursorTargetTableName = null;
CurrentOfNode currentOfNode = null;
- FromList resultFromList;
ResultColumnList afterColumns = null;
DataDictionary dataDictionary = getDataDictionary();
@@ -335,11 +324,10 @@ public final class UpdateNode extends DM
** Get the result FromTable, which should be the only table in the
** from list.
*/
- resultFromList = resultSet.getFromList();
- if (SanityManager.DEBUG)
- SanityManager.ASSERT(resultFromList.size() == 1,
- "More than one table in result from list in an update.");
-
+ if (SanityManager.DEBUG) {
+ SanityManager.ASSERT(resultSet.getFromList().size() == 1,
+ "More than one table in result from list in an update.");
+ }
/* Normalize the SET clause's result column list for synonym */
if (synonymTableName != null)
normalizeSynonymColumns( resultSet.resultColumns, targetTable );
@@ -469,7 +457,6 @@ public final class UpdateNode extends DM
if (i > size)
{
readColsBitSet = null;
- allColumns = true;
}
}
finally
@@ -478,6 +465,8 @@ public final class UpdateNode extends DM
}
}
+ ValueNode rowLocationNode;
+
if (targetVTI == null)
{
/* Append the list of "after" columns to the list of "before" columns,
@@ -487,24 +476,18 @@ public final class UpdateNode extends DM
resultColumnList.appendResultColumns(afterColumns, false);
/* Generate the RowLocation column */
- rowLocationNode = (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.CURRENT_ROW_LOCATION_NODE,
- getContextManager());
+ rowLocationNode = new CurrentRowLocationNode(getContextManager());
}
else
{
- rowLocationNode = (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.INT_CONSTANT_NODE,
- ReuseFactory.getInteger( 0),
- getContextManager());
+ rowLocationNode = new NumericConstantNode(
+ TypeId.getBuiltInTypeId(Types.INTEGER),
+ ReuseFactory.getInteger( 0),
+ getContextManager());
}
- rowLocationColumn =
- (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- COLUMNNAME,
- rowLocationNode,
- getContextManager());
+ ResultColumn rowLocationColumn = new ResultColumn(
+ COLUMNNAME, rowLocationNode, getContextManager());
rowLocationColumn.markGenerated();
/* Append to the ResultColumnList */
@@ -530,11 +513,8 @@ public final class UpdateNode extends DM
getResultColumns().
bindUntypedNullsToResultColumns(resultColumnList);
- if (null != rowLocationColumn)
- {
- /* Bind the new ResultColumn */
- rowLocationColumn.bindResultColumnToExpression();
- }
+ /* Bind the new ResultColumn */
+ rowLocationColumn.bindResultColumnToExpression();
resultColumnList.checkStorableExpressions();
@@ -543,10 +523,8 @@ public final class UpdateNode extends DM
*/
if (! resultColumnList.columnTypesAndLengthsMatch())
{
- resultSet = (ResultSetNode) getNodeFactory().getNode(
- C_NodeTypes.NORMALIZE_RESULT_SET_NODE,
- resultSet, resultColumnList, null, Boolean.TRUE,
- getContextManager());
+ resultSet = new NormalizeResultSetNode(
+ resultSet, resultColumnList, null, true, getContextManager());
if (hasCheckConstraints(dataDictionary, targetTableDescriptor) || hasGenerationClauses( targetTableDescriptor ) )
@@ -560,9 +538,7 @@ public final class UpdateNode extends DM
* order to bind the check constraints.
*/
int afterColumnsSize = afterColumns.size();
- afterColumns = (ResultColumnList) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN_LIST,
- getContextManager());
+ afterColumns = new ResultColumnList(getContextManager());
ResultColumnList normalizedRCs = resultSet.getResultColumns();
for (int index = 0; index < afterColumnsSize; index++)
{
@@ -592,7 +568,7 @@ public final class UpdateNode extends DM
/* Get and bind all constraints on the columns being updated */
checkConstraints = bindConstraints( dataDictionary,
- getNodeFactory(),
+ getOptimizerFactory(),
targetTableDescriptor,
null,
sourceRCL,
@@ -619,6 +595,7 @@ public final class UpdateNode extends DM
} // end of bind()
+ @Override
int getPrivType()
{
return Authorizer.UPDATE_PRIV;
@@ -631,7 +608,8 @@ public final class UpdateNode extends DM
*
* @exception StandardException Thrown on error
*/
- public boolean referencesSessionSchema()
+ @Override
+ public boolean referencesSessionSchema()
throws StandardException
{
//If this node references a SESSION schema table, then return true.
@@ -644,7 +622,8 @@ public final class UpdateNode extends DM
*
* @exception StandardException Thrown on failure
*/
- public ConstantAction makeConstantAction() throws StandardException
+ @Override
+ public ConstantAction makeConstantAction() throws StandardException
{
/*
** Updates are also deferred if they update a column in the index
@@ -682,7 +661,7 @@ public final class UpdateNode extends DM
deferred, changedColumnIds);
}
- int lockMode = resultSet.updateTargetLockMode();
+ int lckMode = resultSet.updateTargetLockMode();
long heapConglomId = targetTableDescriptor.getHeapConglomerateId();
TransactionController tc =
getLanguageConnectionContext().getTransactionCompile();
@@ -700,7 +679,7 @@ public final class UpdateNode extends DM
*/
if (targetTableDescriptor.getLockGranularity() == TableDescriptor.TABLE_LOCK_GRANULARITY)
{
- lockMode = TransactionController.MODE_TABLE;
+ lckMode = TransactionController.MODE_TABLE;
}
@@ -714,7 +693,7 @@ public final class UpdateNode extends DM
indexNames,
deferred,
targetTableDescriptor.getUUID(),
- lockMode,
+ lckMode,
false,
changedColumnIds, null, null,
getFKInfo(),
@@ -780,6 +759,7 @@ public final class UpdateNode extends DM
*
* @exception StandardException Thrown on error
*/
+ @Override
void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -843,6 +823,7 @@ public final class UpdateNode extends DM
*
* @return the type of statement
*/
+ @Override
protected final int getStatementType()
{
return StatementType.UPDATE;
@@ -982,7 +963,7 @@ public final class UpdateNode extends DM
*
* @exception StandardException Thrown on error
*/
- public static FormatableBitSet getUpdateReadMap
+ static FormatableBitSet getUpdateReadMap
(
DataDictionary dd,
TableDescriptor baseTable,
@@ -1224,7 +1205,6 @@ public final class UpdateNode extends DM
int count = updateColumnList.size();
ColumnDescriptorList generatedColumns = baseTable.getGeneratedColumns();
int generatedColumnCount = generatedColumns.size();
- int columnCount = baseTable.getMaxColumnID();
HashSet<String> updatedColumns = new HashSet<String>();
UUID tableID = baseTable.getObjectID();
@@ -1265,10 +1245,10 @@ public final class UpdateNode extends DM
addedGeneratedColumns.add( tableID, gc );
// we will fill in the real value later on in parseAndBindGenerationClauses();
- ValueNode dummy = (ValueNode) getNodeFactory().getNode
- ( C_NodeTypes.UNTYPED_NULL_CONSTANT_NODE, getContextManager());
- ResultColumn newResultColumn = (ResultColumn) getNodeFactory().getNode
- ( C_NodeTypes.RESULT_COLUMN, gc.getType(), dummy, getContextManager());
+ ValueNode dummy =
+ new UntypedNullConstantNode(getContextManager());
+ ResultColumn newResultColumn = new ResultColumn(
+ gc.getType(), dummy, getContextManager());
newResultColumn.setColumnDescriptor( baseTable, gc );
newResultColumn.setName( gc.getColumnName() );
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java Fri Jun 21 07:47:47 2013
@@ -21,34 +21,24 @@
package org.apache.derby.impl.sql.compile;
-import java.lang.reflect.Method;
-
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
+import org.apache.derby.catalog.types.AggregateAliasInfo;
+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.context.ContextManager;
import org.apache.derby.iapi.services.context.ContextService;
import org.apache.derby.iapi.services.loader.ClassFactory;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.catalog.TypeDescriptor;
-import org.apache.derby.catalog.types.AggregateAliasInfo;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.JSQLType;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.NodeFactory;
-import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
import org.apache.derby.iapi.sql.compile.TypeCompilerFactory;
-
-import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.JSQLType;
/**
* Definition for user-defined aggregates.
*
*/
-public class UserAggregateDefinition implements AggregateDefinition
+class UserAggregateDefinition implements AggregateDefinition
{
///////////////////////////////////////////////////////////////////////////////////
//
@@ -81,7 +71,7 @@ public class UserAggregateDefinition imp
/**
* Conjure out of thin air.
*/
- public UserAggregateDefinition( AliasDescriptor alias )
+ UserAggregateDefinition( AliasDescriptor alias )
{
_alias = alias;
}
@@ -212,8 +202,8 @@ public class UserAggregateDefinition imp
* Wrap the input operand in an implicit CAST node as necessary in order to
* coerce it the correct type for the aggregator. Return null if no cast is necessary.
*/
- public final ValueNode castInputValue
- ( ValueNode inputValue, NodeFactory nodeFactory, ContextManager cm )
+ final ValueNode castInputValue
+ ( ValueNode inputValue, ContextManager cm )
throws StandardException
{
AggregateAliasInfo aai = (AggregateAliasInfo) _alias.getAliasInfo();
@@ -224,7 +214,8 @@ public class UserAggregateDefinition imp
if ( expectedInputType.isExactTypeAndLengthMatch( actualInputType ) ) { return null; }
else
{
- return StaticMethodCallNode.makeCast( inputValue, expectedInputType, nodeFactory, cm );
+ return StaticMethodCallNode.makeCast(
+ inputValue, expectedInputType, cm);
}
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,24 +21,16 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.services.loader.ClassFactory;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DataValueFactory;
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
import org.apache.derby.catalog.types.UserDefinedTypeIdImpl;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.reference.ClassName;
import org.apache.derby.iapi.services.compiler.LocalField;
import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.loader.ClassFactory;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.reference.ClassName;
-
-public class UserDefinedTypeCompiler extends BaseTypeCompiler
+class UserDefinedTypeCompiler extends BaseTypeCompiler
{
/* TypeCompiler methods */
@@ -139,6 +131,7 @@ public class UserDefinedTypeCompiler ext
return "getNullObject";
}
+ @Override
public void generateDataValue(MethodBuilder mb, int collationType,
LocalField field)
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java Fri Jun 21 07:47:47 2013
@@ -21,43 +21,26 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.UserDataValue;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-import org.apache.derby.iapi.services.io.StoredFormatIds;
-
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.iapi.types.DataValueFactory;
-
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.reference.ClassName;
-
-import org.apache.derby.catalog.TypeDescriptor;
-
-import org.apache.derby.iapi.util.ReuseFactory;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-import org.apache.derby.iapi.types.*;
-
import java.lang.reflect.Modifier;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
+import org.apache.derby.catalog.TypeDescriptor;
+import org.apache.derby.iapi.error.StandardException;
+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.io.StoredFormatIds;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.SQLDate;
+import org.apache.derby.iapi.types.SQLTime;
+import org.apache.derby.iapi.types.SQLTimestamp;
+import org.apache.derby.iapi.types.TypeId;
/**
User type constants. These are created by built-in types
@@ -67,10 +50,10 @@ import java.sql.Types;
This is also used to represent nulls in user types, which occurs
when NULL is inserted into or supplied as the update value for
- a usertype column.
+ a user type column.
*/
-public class UserTypeConstantNode extends ConstantNode {
+class UserTypeConstantNode extends ConstantNode {
/*
** This value field hides the value in the super-type. It is here
** Because user-type constants work differently from built-in constants.
@@ -80,96 +63,104 @@ public class UserTypeConstantNode extend
** RESOLVE: This is a bit of a mess, and should be fixed. All constants
** should be represented the same way.
*/
- Object value;
+ Object val;
- /**
- * Initializer for a typed null node
- * or a date, time, or timestamp value. Parameters may be:
- *
- * <ul>
- * <li>arg1 The TypeId for the type of the node</li>
- * <li>arg2 The factory to get the TypeId and DataTypeServices factories from.</li>
- * </ul>
- *
- * <p>
- * - OR -
- * </p>
- *
- * <ul>
- * <li>arg1 the date, time, or timestamp value</li>
- * </ul>
- *
- * @exception StandardException thrown on failure
- */
- public void init(Object arg1)
- throws StandardException {
- DataValueDescriptor dvd = null;
-
- if (arg1 instanceof TypeId)
- {
- super.init(
- arg1,
- Boolean.TRUE,
- ReuseFactory.getInteger(
- TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN));
- }
- else
- {
- Integer maxWidth = null;
- TypeId typeId = null;
-
- if( arg1 instanceof DataValueDescriptor)
- dvd = (DataValueDescriptor) arg1;
- if (arg1 instanceof Date
- || (dvd != null && dvd.getTypeFormatId() == StoredFormatIds.SQL_DATE_ID))
- {
- maxWidth = ReuseFactory.getInteger(TypeId.DATE_MAXWIDTH);
- typeId = TypeId.getBuiltInTypeId(Types.DATE);
- }
- else if (arg1 instanceof Time
- || (dvd != null && dvd.getTypeFormatId() == StoredFormatIds.SQL_TIME_ID))
- {
- maxWidth = ReuseFactory.getInteger(TypeId.TIME_MAXWIDTH);
- typeId = TypeId.getBuiltInTypeId(Types.TIME);
- }
- else if (arg1 instanceof Timestamp
- || (dvd != null && dvd.getTypeFormatId() == StoredFormatIds.SQL_TIMESTAMP_ID))
- {
- maxWidth = ReuseFactory.getInteger(TypeId.TIMESTAMP_MAXWIDTH);
- typeId = TypeId.getBuiltInTypeId(Types.TIMESTAMP);
- }
- else
- {
- if (SanityManager.DEBUG)
- {
- SanityManager.THROWASSERT(
- "Unexpected class " + arg1.getClass().getName());
- }
- }
-
- super.init(
- typeId,
- (arg1 == null) ? Boolean.TRUE : Boolean.FALSE,
- maxWidth);
-
- if( dvd != null)
- setValue( dvd);
- else if (arg1 instanceof Date)
- {
- setValue(new SQLDate((Date) arg1));
- }
- else if (arg1 instanceof Time)
- {
- setValue(new SQLTime((Time) arg1));
- }
- else if (arg1 instanceof Timestamp)
- {
- setValue(new SQLTimestamp((Timestamp) arg1));
- }
-
- value = arg1;
- }
- }
+ UserTypeConstantNode(TypeId t, ContextManager cm)
+ throws StandardException {
+ super(t, true, TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN, cm);
+ setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
+ }
+
+ UserTypeConstantNode(Date d, ContextManager cm)
+ throws StandardException {
+ super(TypeId.getBuiltInTypeId(Types.DATE),
+ d == null,
+ TypeId.DATE_MAXWIDTH,
+ cm);
+ setValue(new SQLDate(d));
+ val = d;
+ setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
+ }
+
+ UserTypeConstantNode(Time t, ContextManager cm)
+ throws StandardException {
+ super(TypeId.getBuiltInTypeId(Types.TIME),
+ t == null,
+ TypeId.TIME_MAXWIDTH,
+ cm);
+ setValue(new SQLTime(t));
+ val = t;
+ setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
+ }
+
+ UserTypeConstantNode(Timestamp t, ContextManager cm)
+ throws StandardException {
+ super(TypeId.getBuiltInTypeId(Types.TIMESTAMP),
+ t == null,
+ TypeId.TIMESTAMP_MAXWIDTH,
+ cm);
+ setValue(new SQLTimestamp(t));
+ val = t;
+ setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
+ }
+
+ /**
+ * @param dvd Must contain a Date, Time or Timestamp value
+ * @param cm context manager
+ * @throws StandardException
+ */
+ UserTypeConstantNode(DataValueDescriptor dvd, ContextManager cm)
+ throws StandardException {
+ super(getTypeId(dvd),
+ dvd == null,
+ getWidth(dvd),
+ cm);
+ setValue(dvd);
+ val = dvd;
+ setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
+ }
+
+ private static TypeId getTypeId(DataValueDescriptor dvd) {
+ if (dvd != null) {
+ switch (dvd.getTypeFormatId()) {
+ case StoredFormatIds.SQL_DATE_ID:
+ return TypeId.getBuiltInTypeId(Types.DATE);
+ case StoredFormatIds.SQL_TIME_ID:
+ return TypeId.getBuiltInTypeId(Types.TIME);
+ case StoredFormatIds.SQL_TIMESTAMP_ID:
+ return TypeId.getBuiltInTypeId(Types.TIMESTAMP);
+ default:
+ if (SanityManager.DEBUG) {
+ SanityManager.THROWASSERT(
+ "Unexpected class " + dvd.getClass().getName());
+ }
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ private static int getWidth(DataValueDescriptor dvd) {
+ if (dvd != null) {
+ switch (dvd.getTypeFormatId()) {
+ case StoredFormatIds.SQL_DATE_ID:
+ return TypeId.DATE_MAXWIDTH;
+ case StoredFormatIds.SQL_TIME_ID:
+ return TypeId.TIME_MAXWIDTH;
+ case StoredFormatIds.SQL_TIMESTAMP_ID:
+ return TypeId.TIMESTAMP_MAXWIDTH;
+ default:
+ if (SanityManager.DEBUG) {
+ SanityManager.THROWASSERT(
+ "Unexpected class " + dvd.getClass().getName());
+ }
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+ }
/**
* Return the object value of this user defined type.
@@ -178,15 +169,16 @@ public class UserTypeConstantNode extend
* getValue() returns the DataValueDescriptor for the built-in
* types that are implemented as user types (date, time, timestamp)
*/
- public Object getObjectValue() { return value; }
+ public Object getObjectValue() { return val; }
/**
* Return whether or not this node represents a typed null constant.
*
*/
- public boolean isNull()
+ @Override
+ boolean isNull()
{
- return (value == null);
+ return (val == null);
}
/**
@@ -200,9 +192,10 @@ public class UserTypeConstantNode extend
* (null if not a bind time constant.)
*
*/
- public Object getConstantValueAsObject()
+ @Override
+ Object getConstantValueAsObject()
{
- return value;
+ return val;
}
/**
@@ -231,6 +224,7 @@ public class UserTypeConstantNode extend
*
* @exception StandardException Thrown on error
*/
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException {
@@ -243,7 +237,7 @@ public class UserTypeConstantNode extend
*/
/* Are we generating a SQL null value? */
- if (value == null)
+ if (val == null)
{
acb.generateNull(mb, tc, getTypeServices().getCollationType());
}
@@ -283,7 +277,7 @@ public class UserTypeConstantNode extend
*/
String typeName = getTypeId().getCorrespondingJavaTypeName();
- mb.push(value.toString());
+ mb.push(val.toString());
mb.callMethod(VMOpcode.INVOKESTATIC, typeName, "valueOf", typeName, 1);
LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, fieldType);
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java Fri Jun 21 07:47:47 2013
@@ -21,18 +21,16 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.sql.compile.Visitable;
-
-import org.apache.derby.vti.DeferModification;
-
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.sql.compile.Visitable;
+import org.apache.derby.iapi.sql.compile.Visitor;
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
+import org.apache.derby.vti.DeferModification;
/**
* This class applies a VTI modification deferral policy to a statement to
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Fri Jun 21 07:47:47 2013
@@ -22,13 +22,12 @@
package org.apache.derby.impl.sql.compile;
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.sanity.SanityManager;
import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.sql.compile.NodeFactory;
import org.apache.derby.iapi.sql.compile.Optimizable;
import org.apache.derby.iapi.sql.compile.TypeCompiler;
import org.apache.derby.iapi.store.access.Qualifier;
@@ -61,8 +60,8 @@ public abstract class ValueNode extends
** Binding will replace all untyped ValueNodes with typed ValueNodes
** when it figures out what their types should be.
*/
- public ValueNode()
- {
+ ValueNode(ContextManager cm) {
+ super(cm);
}
/**
@@ -74,13 +73,7 @@ public abstract class ValueNode extends
throws StandardException
{
- setType(
- new DataTypeDescriptor(
- (TypeId) typeId,
- isNullable,
- maximumWidth
- )
- );
+ setType(new DataTypeDescriptor(typeId, isNullable, maximumWidth));
}
/**
@@ -94,7 +87,7 @@ public abstract class ValueNode extends
{
setType(
new DataTypeDescriptor(
- (TypeId) typeId,
+ typeId,
precision,
scale,
isNullable,
@@ -104,73 +97,13 @@ public abstract class ValueNode extends
}
/**
- * Initializer for numeric types.
- *
- *
- * @param typeId The TypeID of this new node
- * @param precision The precision of this new node
- * @param scale The scale of this new node
- * @param isNullable The nullability of this new node
- * @param maximumWidth The maximum width of this new node
- *
- * @exception StandardException
- */
-
- public void init(
- Object typeId,
- Object precision,
- Object scale,
- Object isNullable,
- Object maximumWidth)
- throws StandardException
- {
- setType(
- new DataTypeDescriptor(
- (TypeId) typeId,
- ((Integer) precision).intValue(),
- ((Integer) scale).intValue(),
- ((Boolean) isNullable).booleanValue(),
- ((Integer) maximumWidth).intValue()
- )
- );
- }
-
- /**
- * Initializer for non-numeric types.
- *
- *
- * @param tcf The factory to get the
- * DataTypeServicesFactory from
- * @param typeId The TypeID of this new node
- * @param isNullable The nullability of this new node
- * @param maximumWidth The maximum width of this new node
- *
- * @exception StandardException
- */
-
- ValueNode(
- Object tcf,
- Object typeId,
- Object isNullable,
- Object maximumWidth)
- throws StandardException
- {
- setType(new DataTypeDescriptor(
- (TypeId) typeId,
- ((Boolean) isNullable).booleanValue(),
- ((Integer) maximumWidth).intValue()
- )
- );
- }
-
-
- /**
* Convert this object to a String. See comments in QueryTreeNode.java
* for how this should be done for tree printing.
*
* @return This object as a String
*/
+ @Override
public String toString()
{
if (SanityManager.DEBUG)
@@ -192,7 +125,7 @@ public abstract class ValueNode extends
* @return The DataTypeServices from this ValueNode. This
* may be null if the node isn't bound yet.
*/
- public DataTypeDescriptor getTypeServices()
+ DataTypeDescriptor getTypeServices()
{
return dataTypeServices;
}
@@ -246,7 +179,7 @@ public abstract class ValueNode extends
* @return The TypeId from this ValueNode. This
* may be null if the node isn't bound yet.
*/
- public TypeId getTypeId() throws StandardException
+ TypeId getTypeId() throws StandardException
{
DataTypeDescriptor dtd = getTypeServices();
if (dtd != null)
@@ -269,7 +202,7 @@ public abstract class ValueNode extends
* @return This ValueNode's TypeCompiler
*
*/
- public final TypeCompiler getTypeCompiler() throws StandardException
+ final TypeCompiler getTypeCompiler() throws StandardException
{
return getTypeCompiler(getTypeId());
}
@@ -282,7 +215,7 @@ public abstract class ValueNode extends
* ValueNode
*/
- public void setType(DataTypeDescriptor dataTypeServices) throws StandardException
+ void setType(DataTypeDescriptor dataTypeServices) throws StandardException
{
// bind the type in case it is a user defined type. this will create a dependency on the udt.
if ( dataTypeServices != null )
@@ -338,7 +271,7 @@ public abstract class ValueNode extends
* is not sourced by a column.
*/
- public ResultColumn getSourceResultColumn()
+ ResultColumn getSourceResultColumn()
{
return null;
}
@@ -387,9 +320,10 @@ public abstract class ValueNode extends
* @exception StandardException Thrown on error
*/
- ValueNode bindExpression(
- FromList fromList, SubqueryList subqueryList, List aggregates, boolean forQueryRewrite)
- throws StandardException
+ ValueNode bindExpression(FromList fromList,
+ SubqueryList subqueryList,
+ List<AggregateNode> aggregates,
+ boolean forQueryRewrite) throws StandardException
{
/* There are a bizillion classes which extend ValueNode. Here is info
* on some of the classes that bindExpression() should not be called on
@@ -418,7 +352,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode genSQLJavaSQLTree()
+ ValueNode genSQLJavaSQLTree()
throws StandardException
{
if (SanityManager.DEBUG)
@@ -429,15 +363,10 @@ public abstract class ValueNode extends
"genSQLJavaSQLTree() only expected to be called on user types");
}
- JavaValueNode stjvn = (JavaValueNode) getNodeFactory().getNode(
- C_NodeTypes.SQL_TO_JAVA_VALUE_NODE,
- this,
- getContextManager());
-
- ValueNode jtsvn = (ValueNode) getNodeFactory().getNode(
- C_NodeTypes.JAVA_TO_SQL_VALUE_NODE,
- stjvn,
- getContextManager());
+ final ContextManager cm = getContextManager();
+ JavaValueNode stjvn = new SQLToJavaValueNode(this, cm);
+
+ ValueNode jtsvn = new JavaToSQLValueNode(stjvn, cm);
DataTypeDescriptor resultType;
if ( (getTypeServices() != null) && getTypeId().userType() ) { resultType = getTypeServices(); }
@@ -463,7 +392,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode preprocess(int numTables,
+ ValueNode preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
@@ -532,24 +461,19 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode genEqualsFalseTree()
+ ValueNode genEqualsFalseTree()
throws StandardException
{
BinaryRelationalOperatorNode equalsNode;
BooleanConstantNode falseNode;
boolean nullableResult;
- NodeFactory nodeFactory = getNodeFactory();
- falseNode = (BooleanConstantNode) nodeFactory.getNode(
- C_NodeTypes.BOOLEAN_CONSTANT_NODE,
- Boolean.FALSE,
- getContextManager());
- equalsNode = (BinaryRelationalOperatorNode)
- nodeFactory.getNode(
+ falseNode = new BooleanConstantNode(false, getContextManager());
+ equalsNode = new BinaryRelationalOperatorNode(
C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
this,
falseNode,
- Boolean.FALSE,
+ false,
getContextManager());
nullableResult = getTypeServices().isNullable();
equalsNode.setType(new DataTypeDescriptor(
@@ -566,16 +490,13 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode genIsNullTree()
+ ValueNode genIsNullTree()
throws StandardException
{
IsNullNode isNullNode;
- isNullNode = (IsNullNode)
- getNodeFactory().getNode(
- C_NodeTypes.IS_NULL_NODE,
- this,
- getContextManager());
+ isNullNode = new IsNullNode(
+ this, IsNullNode.Sign.IS_NULL, getContextManager());
isNullNode.setType(new DataTypeDescriptor(
TypeId.BOOLEAN_ID,
false)
@@ -611,20 +532,12 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode putAndsOnTop()
+ ValueNode putAndsOnTop()
throws StandardException
{
- NodeFactory nodeFactory = getNodeFactory();
-
- QueryTreeNode trueNode = (QueryTreeNode) nodeFactory.getNode(
- C_NodeTypes.BOOLEAN_CONSTANT_NODE,
- Boolean.TRUE,
- getContextManager());
- AndNode andNode = (AndNode) nodeFactory.getNode(
- C_NodeTypes.AND_NODE,
- this,
- trueNode,
- getContextManager());
+ BooleanConstantNode trueNode =
+ new BooleanConstantNode(true, getContextManager());
+ AndNode andNode = new AndNode(this, trueNode, getContextManager());
andNode.postBindFixup();
return andNode;
}
@@ -635,7 +548,7 @@ public abstract class ValueNode extends
*
* @return Boolean which reflects validity of the tree.
*/
- public boolean verifyPutAndsOnTop()
+ boolean verifyPutAndsOnTop()
{
return true;
}
@@ -668,7 +581,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode changeToCNF(boolean underTopAndNode)
+ ValueNode changeToCNF(boolean underTopAndNode)
throws StandardException
{
return this;
@@ -683,7 +596,7 @@ public abstract class ValueNode extends
*
* @return Boolean which reflects validity of the tree.
*/
- public boolean verifyChangeToCNF()
+ boolean verifyChangeToCNF()
{
return true;
}
@@ -714,7 +627,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+ boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
throws StandardException
{
return true;
@@ -735,7 +648,7 @@ public abstract class ValueNode extends
*
* @return the default schema name for an expression -- null
*/
- public String getSchemaName() throws StandardException
+ String getSchemaName() throws StandardException
{
return null;
}
@@ -755,7 +668,7 @@ public abstract class ValueNode extends
*
* @return the default table name for an expression -- null
*/
- public String getTableName()
+ String getTableName()
{
return null;
}
@@ -774,7 +687,7 @@ public abstract class ValueNode extends
*
* @return the default column name for an expression -- null.
*/
- public String getColumnName()
+ String getColumnName()
{
return null;
}
@@ -799,7 +712,7 @@ public abstract class ValueNode extends
*
* @return boolean Whether or not this expression tree is cloneable.
*/
- public boolean isCloneable()
+ boolean isCloneable()
{
return false;
}
@@ -811,7 +724,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode getClone() throws StandardException
+ ValueNode getClone() throws StandardException
{
if (SanityManager.DEBUG)
{
@@ -828,7 +741,7 @@ public abstract class ValueNode extends
* @param oldVN The ValueNode to copy from.
*
*/
- public void copyFields(ValueNode oldVN) throws StandardException
+ void copyFields(ValueNode oldVN) throws StandardException
{
dataTypeServices = oldVN.getTypeServices();
}
@@ -841,7 +754,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
- public ValueNode remapColumnReferencesToExpressions() throws StandardException
+ ValueNode remapColumnReferencesToExpressions() throws StandardException
{
return this;
}
@@ -851,7 +764,7 @@ public abstract class ValueNode extends
*
* @return Whether or not this expression tree represents a constant expression.
*/
- public boolean isConstantExpression()
+ boolean isConstantExpression()
{
return false;
}
@@ -864,7 +777,7 @@ public abstract class ValueNode extends
*
* @return True means this expression tree represents a constant value.
*/
- public boolean constantExpression(PredicateList whereClause)
+ boolean constantExpression(PredicateList whereClause)
{
return false;
}
@@ -970,7 +883,7 @@ public abstract class ValueNode extends
*
* @exception StandardException Thrown on error
*/
-
+ @Override
final void generate(ActivationClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -1258,7 +1171,7 @@ public abstract class ValueNode extends
* @see BinaryRelationalOperatorNode
* @see IsNullNode
*/
- public boolean isRelationalOperator()
+ boolean isRelationalOperator()
{
return false;
}
@@ -1268,7 +1181,7 @@ public abstract class ValueNode extends
*
* @see ValueNode#isRelationalOperator
*/
- public boolean isBinaryEqualsOperatorNode()
+ boolean isBinaryEqualsOperatorNode()
{
return false;
}
@@ -1281,7 +1194,7 @@ public abstract class ValueNode extends
* an equals operator of the form "col = ?" that we generated
* during preprocessing to allow index multi-probing.
*/
- public boolean isInListProbeNode()
+ boolean isInListProbeNode()
{
return false;
}
@@ -1305,7 +1218,7 @@ public abstract class ValueNode extends
* @param isNullOkay if set to true we also consider IS NULL predicates;
* otherwise consider only = predicates.
*/
- public boolean optimizableEqualityNode(Optimizable optTable,
+ boolean optimizableEqualityNode(Optimizable optTable,
int columnNumber,
boolean isNullOkay)
throws StandardException
@@ -1321,7 +1234,7 @@ public abstract class ValueNode extends
*
* @return Whether this node's type will be determined from the context
*/
- public boolean requiresTypeFromContext()
+ boolean requiresTypeFromContext()
{
return false;
}
@@ -1331,7 +1244,7 @@ public abstract class ValueNode extends
* with Parameter Nodes.
*
*/
- public boolean isParameterNode()
+ boolean isParameterNode()
{
return false;
}
@@ -1385,7 +1298,7 @@ public abstract class ValueNode extends
*
* @throws StandardException
*/
- protected abstract boolean isEquivalent(ValueNode other)
+ abstract boolean isEquivalent(ValueNode other)
throws StandardException;
/**
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java Fri Jun 21 07:47:47 2013
@@ -22,34 +22,32 @@
package org.apache.derby.impl.sql.compile;
import java.util.List;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.loader.ClassFactory;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.iapi.store.access.Qualifier;
import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.iapi.types.DataValueDescriptor;
import org.apache.derby.iapi.types.StringDataValue;
import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.services.loader.ClassFactory;
-
-import org.apache.derby.iapi.store.access.Qualifier;
-
import org.apache.derby.iapi.util.JBitSet;
-
/**
* A ValueNodeList represents a list of ValueNodes within a specific predicate
- * (eg, IN list, NOT IN list or BETWEEN) in a DML statement.
- * It extends QueryTreeNodeVector.
- *
+ * e.g. IN list, NOT IN list or BETWEEN in a DML statement.
*/
-public class ValueNodeList extends QueryTreeNodeVector
+class ValueNodeList extends QueryTreeNodeVector
{
+ ValueNodeList(ContextManager cm) {
+ super(cm);
+ setNodeType(C_NodeTypes.VALUE_NODE_LIST);
+ }
+
/**
* Add a ValueNode to the list.
*
@@ -58,7 +56,7 @@ public class ValueNodeList extends Query
* @exception StandardException Thrown on error
*/
- public void addValueNode(ValueNode valueNode) throws StandardException
+ void addValueNode(ValueNode valueNode) throws StandardException
{
addElement(valueNode);
}
@@ -97,7 +95,7 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public void genSQLJavaSQLTrees()
+ void genSQLJavaSQLTrees()
throws StandardException
{
int size = size();
@@ -149,7 +147,7 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public DataTypeDescriptor getDominantTypeServices() throws StandardException
+ DataTypeDescriptor getDominantTypeServices() throws StandardException
{
DataTypeDescriptor dominantDTS = null;
//Following 2 will hold the collation derivation and type of the first
@@ -230,7 +228,7 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public DataTypeDescriptor getTypeServices() throws StandardException
+ DataTypeDescriptor getTypeServices() throws StandardException
{
int size = size();
@@ -290,7 +288,7 @@ public class ValueNodeList extends Query
* @param leftOperand Check for compatibility against this parameter's type
*
*/
- public void compatible(ValueNode leftOperand) throws StandardException
+ void compatible(ValueNode leftOperand) throws StandardException
{
int size = size();
TypeId leftType;
@@ -329,14 +327,11 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public void comparable(ValueNode leftOperand) throws StandardException
+ void comparable(ValueNode leftOperand) throws StandardException
{
int size = size();
- TypeId leftType;
ValueNode valueNode;
- leftType = leftOperand.getTypeId();
-
for (int index = 0; index < size; index++)
{
valueNode = (ValueNode) elementAt(index);
@@ -363,7 +358,7 @@ public class ValueNodeList extends Query
* @return boolean Whether or not any of the elements in the list
* are nullable.
*/
- public boolean isNullable()
+ boolean isNullable()
throws StandardException
{
int size = size();
@@ -383,7 +378,7 @@ public class ValueNodeList extends Query
*
* @return boolean Whether or not the list contains a ParameterNode
*/
- public boolean containsParameterNode()
+ boolean containsParameterNode()
{
int size = size();
@@ -402,7 +397,7 @@ public class ValueNodeList extends Query
*
* @return boolean Whether or not the list contains all ParameterNodes
*/
- public boolean containsAllParameterNodes()
+ boolean containsAllParameterNodes()
{
int size = size();
@@ -421,7 +416,7 @@ public class ValueNodeList extends Query
*
* @return boolean Whether or not the list contains all ConstantNodes
*/
- public boolean containsAllConstantNodes()
+ boolean containsAllConstantNodes()
{
int size = size();
@@ -441,7 +436,7 @@ public class ValueNodeList extends Query
* @return boolean True if every node in this list is either a constant
* node or parameter node.
*/
- public boolean containsOnlyConstantAndParamNodes()
+ boolean containsOnlyConstantAndParamNodes()
{
int size = size();
@@ -514,7 +509,7 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public void setParameterDescriptor(DataTypeDescriptor descriptor)
+ void setParameterDescriptor(DataTypeDescriptor descriptor)
throws StandardException
{
int size = size();
@@ -540,7 +535,7 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public void preprocess(int numTables,
+ void preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
@@ -566,7 +561,7 @@ public class ValueNodeList extends Query
*
* @exception StandardException Thrown on error
*/
- public ValueNodeList remapColumnReferencesToExpressions()
+ ValueNodeList remapColumnReferencesToExpressions()
throws StandardException
{
int size = size();
@@ -613,7 +608,7 @@ public class ValueNodeList extends Query
*
* @return Whether or not this expression tree represents a constant expression.
*/
- public boolean isConstantExpression()
+ boolean isConstantExpression()
{
int size = size();
@@ -632,7 +627,7 @@ public class ValueNodeList extends Query
}
/** @see ValueNode#constantExpression */
- public boolean constantExpression(PredicateList whereClause)
+ boolean constantExpression(PredicateList whereClause)
{
int size = size();
@@ -676,7 +671,7 @@ public class ValueNodeList extends Query
* or a VirtualColumnNode.
* @exception StandardException Thrown on error
*/
- public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
+ boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
throws StandardException
{
/* We stop here when only considering simple predicates
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java Fri Jun 21 07:47:47 2013
@@ -21,38 +21,51 @@
package org.apache.derby.impl.sql.compile;
-import org.apache.derby.iapi.types.BitDataValue;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataValueFactory;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.util.ReuseFactory;
-
-
import java.sql.Types;
+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.C_NodeTypes;
+import org.apache.derby.iapi.types.TypeId;
public final class VarbitConstantNode extends BitConstantNode
{
- /**
- * Initializer for a VarbitConstantNode.
- *
- * @param arg1 The TypeId for the type of the node OR A Bit containing the value of the constant
- *
- * @exception StandardException
- */
-
- public void init(
- Object arg1)
- throws StandardException
- {
- init(
- arg1,
- Boolean.TRUE,
- ReuseFactory.getInteger(0));
-
- }
+ /**
+ * Construct constant node for one of VARBINARY, LONG VARBINARY and
+ * BLOB types.
+ * @param t the type for which we want a constant node
+ * @param cm context manager
+ * @throws StandardException
+ */
+ VarbitConstantNode(TypeId t, ContextManager cm)
+ throws StandardException {
+ super(t, cm);
+
+ int nodeType = 0;
+ switch (t.getJDBCTypeId()) {
+ case Types.VARBINARY:
+ nodeType = C_NodeTypes.VARBIT_CONSTANT_NODE;
+ break;
+ case Types.LONGVARBINARY:
+ nodeType = C_NodeTypes.LONGVARBIT_CONSTANT_NODE;
+ break;
+ case Types.BLOB:
+ nodeType = C_NodeTypes.BLOB_CONSTANT_NODE;
+ break;
+ default:
+ if (SanityManager.DEBUG) {
+ SanityManager.NOTREACHED();
+ }
+ }
+
+ setNodeType(nodeType);
+ }
+
+ VarbitConstantNode(
+ String hexValue,
+ int bitLength,
+ ContextManager cm) throws StandardException {
+ super(hexValue, bitLength, cm);
+ setNodeType(C_NodeTypes.VARBIT_CONSTANT_NODE);
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java Fri Jun 21 07:47:47 2013
@@ -21,12 +21,11 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.sql.compile.Visitable;
import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.error.StandardException;
-
/**
* If a RCL (SELECT list) contains an aggregate, then we must verify
* that the RCL (SELECT list) is valid.
@@ -39,11 +38,11 @@ import org.apache.derby.iapi.error.Stand
* an aggregate are grouping columns.
*
*/
-public class VerifyAggregateExpressionsVisitor implements Visitor
+class VerifyAggregateExpressionsVisitor implements Visitor
{
private GroupByList groupByList;
- public VerifyAggregateExpressionsVisitor(GroupByList groupByList)
+ VerifyAggregateExpressionsVisitor(GroupByList groupByList)
{
this.groupByList = groupByList;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java Fri Jun 21 07:47:47 2013
@@ -21,14 +21,12 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.iapi.error.StandardException;
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.types.DataTypeDescriptor;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
/**
* A VirtualColumnNode represents a virtual column reference to a column in
@@ -40,7 +38,7 @@ import org.apache.derby.impl.sql.compile
*
*/
-public class VirtualColumnNode extends ValueNode
+class VirtualColumnNode extends ValueNode
{
/* A VirtualColumnNode contains a pointer to the immediate child result
* that is materializing the virtual column and the ResultColumn
@@ -58,24 +56,24 @@ public class VirtualColumnNode extends V
/**
- * Initializer for a VirtualColumnNode.
+ * Constructor for a VirtualColumnNode.
*
* @param sourceResultSet The ResultSetNode where the value is originating
* @param sourceColumn The ResultColumn where the value is originating
* @param columnId The columnId within the current Row
+ * @param cm The context manager
*/
-
- public void init(
- Object sourceResultSet,
- Object sourceColumn,
- Object columnId) throws StandardException
- {
- ResultColumn source = (ResultColumn) sourceColumn;
-
- this.sourceResultSet = (ResultSetNode) sourceResultSet;
- this.sourceColumn = source;
- this.columnId = ((Integer) columnId).intValue();
- setType(source.getTypeServices());
+ VirtualColumnNode(ResultSetNode sourceResultSet,
+ ResultColumn sourceColumn,
+ int columnId,
+ ContextManager cm) throws StandardException
+ {
+ super(cm);
+ setNodeType(C_NodeTypes.VIRTUAL_COLUMN_NODE);
+ this.sourceResultSet = sourceResultSet;
+ this.sourceColumn = sourceColumn;
+ this.columnId = columnId;
+ setType(sourceColumn.getTypeServices());
}
@@ -85,8 +83,8 @@ public class VirtualColumnNode extends V
*
* @param depth The depth of this node in the tree
*/
-
- public void printSubNodes(int depth)
+ @Override
+ void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
{
@@ -104,7 +102,7 @@ public class VirtualColumnNode extends V
*
* @return ResultSetNode
*/
- public ResultSetNode getSourceResultSet()
+ ResultSetNode getSourceResultSet()
{
return sourceResultSet;
}
@@ -114,7 +112,7 @@ public class VirtualColumnNode extends V
*
* @return ResultSetNode
*/
- public ResultColumn getSourceColumn()
+ ResultColumn getSourceColumn()
{
return sourceColumn;
}
@@ -129,7 +127,8 @@ public class VirtualColumnNode extends V
* is in. If the column is not in a table (i.e. is a
* derived column), it returns NULL.
*/
- public String getTableName()
+ @Override
+ String getTableName()
{
return sourceColumn.getTableName();
}
@@ -144,7 +143,8 @@ public class VirtualColumnNode extends V
* @return A String containing the name of the schema for the Column's table.
* If the column is not in a schema (i.e. derived column), it returns NULL.
*/
- public String getSchemaName() throws StandardException
+ @Override
+ String getSchemaName() throws StandardException
{
return sourceColumn.getSchemaName();
}
@@ -155,6 +155,7 @@ public class VirtualColumnNode extends V
* @return TRUE, if the column is a base column of a table and is
* writable by a positioned update.
*/
+ @Override
public boolean updatableByCursor()
{
return sourceColumn.updatableByCursor();
@@ -165,7 +166,8 @@ public class VirtualColumnNode extends V
*
* @return ResultSetNode
*/
- public ResultColumn getSourceResultColumn()
+ @Override
+ ResultColumn getSourceResultColumn()
{
return sourceColumn;
}
@@ -194,7 +196,8 @@ public class VirtualColumnNode extends V
*
* @return boolean Whether or not this expression tree is cloneable.
*/
- public boolean isCloneable()
+ @Override
+ boolean isCloneable()
{
return true;
}
@@ -212,6 +215,7 @@ public class VirtualColumnNode extends V
*
* @exception StandardException Thrown on error
*/
+ @Override
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
throws StandardException
{
@@ -260,6 +264,7 @@ public class VirtualColumnNode extends V
* @return The variant type for the underlying expression.
* @exception StandardException thrown on error
*/
+ @Override
protected int getOrderableVariantType() throws StandardException
{
/*
@@ -274,12 +279,14 @@ public class VirtualColumnNode extends V
* @return The DataTypeServices from this Node. This
* may be null if the node isn't bound yet.
*/
- public DataTypeDescriptor getTypeServices()
+ @Override
+ final public DataTypeDescriptor getTypeServices()
{
return sourceColumn.getTypeServices();
}
- public void setType(DataTypeDescriptor dtd) throws StandardException
+ @Override
+ final public void setType(DataTypeDescriptor dtd) throws StandardException
{
sourceColumn.setType(dtd);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java Fri Jun 21 07:47:47 2013
@@ -22,11 +22,10 @@
package org.apache.derby.impl.sql.compile;
import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.reference.SQLState;
-
-import java.sql.Types;
+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;
/**
* This class represents an OLAP window definition.
@@ -45,25 +44,23 @@ public final class WindowDefinitionNode
private OrderByList orderByList;
/**
- * Initializer.
+ * Constructor.
*
- * @param arg1 The window name, null if in-lined definition
- * @param arg2 ORDER BY list
+ * @param windowName The window name, null if in-lined definition
+ * @param orderByList ORDER BY list
+ * @param cm The context manager
* @exception StandardException
*/
- public void init(Object arg1,
- Object arg2)
- throws StandardException
- {
- String name = (String)arg1;
-
- orderByList = (OrderByList)arg2;
+ WindowDefinitionNode(String windowName,
+ OrderByList orderByList,
+ ContextManager cm) throws StandardException {
+ super(windowName != null ? windowName : "IN-LINE", cm);
+ setNodeType(C_NodeTypes.WINDOW_DEFINITION_NODE);
+ this.orderByList = orderByList;
- if (name != null) {
- super.init(arg1);
+ if (windowName != null) {
inlined = false;
} else {
- super.init("IN-LINE");
inlined = true;
}
@@ -78,6 +75,7 @@ public final class WindowDefinitionNode
* java.lang.Object override.
* @see QueryTreeNode#toString
*/
+ @Override
public String toString() {
return ("name: " + getName() + "\n" +
"inlined: " + inlined + "\n" +
@@ -92,7 +90,7 @@ public final class WindowDefinitionNode
*
* @param depth The depth of this node in the tree
*/
-
+ @Override
public void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionNode.java Fri Jun 21 07:47:47 2013
@@ -22,12 +22,10 @@ package org.apache.derby.impl.sql.compil
import java.util.List;
import org.apache.derby.iapi.error.StandardException;
+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.CompilerContext;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-import org.apache.derby.iapi.reference.SQLState;
-
-
/**
* Superclass of any window function call.
@@ -47,22 +45,24 @@ public abstract class WindowFunctionNode
private ColumnReference generatedRef;
/**
- * Initializer for a WindowFunctionNode
- * @param arg1 null (operand)
- * @param arg2 function mame (operator)
- * @param arg3 window node (definition or reference)
- * @exception StandardException
- */
- public void init(Object arg1, Object arg2, Object arg3)
- {
- super.init(arg1, arg2, null);
- this.window = (WindowNode)arg3;
+ * @param op operand (null for now)
+ * @param functionName operator
+ * @param w window node (definition or reference)
+ * @param cm context manager
+ * @throws StandardException
+ */
+ WindowFunctionNode(
+ ValueNode op, String functionName, WindowNode w, ContextManager cm)
+ throws StandardException {
+ super(op, functionName, (String)null, cm);
+ this.window = w;
}
/**
* ValueNode override.
* @see ValueNode#isConstantExpression
*/
+ @Override
public boolean isConstantExpression()
{
return false;
@@ -72,6 +72,7 @@ public abstract class WindowFunctionNode
* ValueNode override.
* @see ValueNode#isConstantExpression
*/
+ @Override
public boolean constantExpression(PredicateList whereClause)
{
// Without this, an ORDER by on ROW_NUMBER could get optimised away
@@ -104,6 +105,7 @@ public abstract class WindowFunctionNode
* ValueNode override.
* @see ValueNode#bindExpression
*/
+ @Override
ValueNode bindExpression(
FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
throws StandardException
@@ -148,7 +150,7 @@ public abstract class WindowFunctionNode
* QueryTreeNode override.
* @see QueryTreeNode#printSubNodes
*/
-
+ @Override
public void printSubNodes(int depth)
{
if (SanityManager.DEBUG)
@@ -186,20 +188,14 @@ public abstract class WindowFunctionNode
String generatedColName;
CompilerContext cc = getCompilerContext();
generatedColName ="SQLCol" + cc.getNextColumnNumber();
- generatedRC = (ResultColumn) getNodeFactory().getNode(
- C_NodeTypes.RESULT_COLUMN,
- generatedColName,
- this,
- getContextManager());
+ generatedRC = new ResultColumn(
+ generatedColName, this, getContextManager());
generatedRC.markGenerated();
// Parse time.
//
- generatedRef = (ColumnReference) getNodeFactory().getNode(
- C_NodeTypes.COLUMN_REFERENCE,
- generatedRC.getName(),
- null,
- getContextManager());
+ generatedRef = new ColumnReference(
+ generatedRC.getName(), null, getContextManager());
// RESOLVE - unknown nesting level, but not correlated, so nesting
// levels must be 0
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowList.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowList.java Fri Jun 21 07:47:47 2013
@@ -21,6 +21,8 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.iapi.services.context.ContextManager;
+
/**
* A WindowList represents the list of windows (definitions) for a table
* expression, either defined explicitly in a WINDOW clause, or inline in the
@@ -28,8 +30,12 @@ package org.apache.derby.impl.sql.compil
*
*/
-public class WindowList extends OrderedColumnList
+class WindowList extends OrderedColumnList
{
+ WindowList(ContextManager cm) {
+ super(cm);
+ }
+
/**
* @param window the window definition to add to the list
*/