org.apache.derby.impl.sql.compile
Class ParameterNode

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.ValueNode
          extended byorg.apache.derby.impl.sql.compile.ParameterNode
All Implemented Interfaces:
Visitable

public class ParameterNode
extends ValueNode

This node type represents a ? parameter.

Author:
Jeff Lichtman

Field Summary
(package private)  DataValueDescriptor defaultValue
           
private  boolean generated
           
protected  JSQLType jsqlType
          This ParameterNode may turn up as an argument to a replicated Work Unit.
private  int orderableVariantType
           
(package private)  int parameterNumber
           
private  ValueNode returnOutputParameter
          By default, we assume we are just a normal, harmless little ole parameter.
(package private)  DataTypeDescriptor[] typeServices
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
clause, dataTypeServices, IN_HAVING_CLAUSE, IN_SELECT_LIST, IN_UNKNOWN_CLAUSE, IN_WHERE_CLAUSE, transformed
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
ParameterNode()
          Constructor for use by the NodeFactory
 
Method Summary
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          Bind this expression.
 boolean constantExpression(PredicateList whereClause)
          Return whether or not this expression tree represents a constant value.
 void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
          For a ParameterNode, we generate a call to the type factory to get a DataValueDescriptor, and pass the result to the setStorableDataValue method of the ParameterValueSet for the generated class.
(package private)  void generateHolder(ExpressionClassBuilder acb)
           
static void generateParameterHolders(ExpressionClassBuilder acb, java.util.Vector parameterList)
           
static void generateParameterValueSet(ExpressionClassBuilder acb, int numberOfParameters, java.util.Vector parameterList)
          Generate the code to create the ParameterValueSet, if necessary, when constructing the activation.
(package private)  DataValueDescriptor getDefaultValue()
          Get the default value for the parameter.
 JSQLType getJSQLType()
          Get the JSQLType associated with this parameter.
protected  int getOrderableVariantType()
          Return the variant type for the underlying expression.
 int getParameterNumber()
          Get the parameter number
 TypeId getTypeId()
          Get the TypeId from this ValueNode.
 void init(java.lang.Object parameterNumber, java.lang.Object defaultValue)
          Initializer for a ParameterNode.
 boolean isConstantExpression()
          Return whether or not this expression tree represents a constant expression.
 boolean isParameterNode()
          Returns TRUE if this is a parameter node.
 boolean isReturnOutputParam()
          Is this as a return output parameter (e.g. ?
 void setDescriptor(DataTypeDescriptor descriptor)
          Set the DataTypeServices for this parameter
 void setDescriptors(DataTypeDescriptor[] descriptors)
          Set the descriptor array
 void setJSQLType(JSQLType type)
          Set the JSQLType of this parameter.
(package private)  void setOrderableVariantType(int type)
          In a special circumstance, we want to consider parameters as constants.
 void setReturnOutputParam(ValueNode valueNode)
          Mark this as a return output parameter (e.g. ?
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, categorize, changeToCNF, checkIsBoolean, checkReliability, checkReliability, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClause, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeServices, init, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isRelationalOperator, optimizableEqualityNode, preprocess, putAndsOnTop, remapColumnReferencesToExpressions, selectivity, setClause, setTransformed, setType, toString, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameterNumber

int parameterNumber

generated

private boolean generated

typeServices

DataTypeDescriptor[] typeServices

defaultValue

DataValueDescriptor defaultValue

jsqlType

protected JSQLType jsqlType
This ParameterNode may turn up as an argument to a replicated Work Unit. If so, the remote system will have figured out the type of this node. That's what this variable is for.


orderableVariantType

private int orderableVariantType

returnOutputParameter

private ValueNode returnOutputParameter
By default, we assume we are just a normal, harmless little ole parameter. But sometimes we may be a return parameter (e.g. ? = CALL myMethod()).

Constructor Detail

ParameterNode

public ParameterNode()
Constructor for use by the NodeFactory

Method Detail

init

public void init(java.lang.Object parameterNumber,
                 java.lang.Object defaultValue)
Initializer for a ParameterNode.

Overrides:
init in class QueryTreeNode
Parameters:
parameterNumber - The number of this parameter, (unique per query starting at 0)
defaultValue - The default value for this parameter

getParameterNumber

public int getParameterNumber()
Get the parameter number

Returns:
The parameter number

setDescriptors

public void setDescriptors(DataTypeDescriptor[] descriptors)
Set the descriptor array

Returns:
Nothing

setDescriptor

public void setDescriptor(DataTypeDescriptor descriptor)
Set the DataTypeServices for this parameter

Overrides:
setDescriptor in class ValueNode
Parameters:
descriptor - The DataTypeServices to set for this parameter
Returns:
Nothing

setReturnOutputParam

public void setReturnOutputParam(ValueNode valueNode)
Mark this as a return output parameter (e.g. ? = CALL myMethod())


isReturnOutputParam

public boolean isReturnOutputParam()
Is this as a return output parameter (e.g. ? = CALL myMethod())

Returns:
true if it is a return param

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws StandardException
Bind this expression. A parameter can't figure out what its type is without knowing where it appears, so this method does nothing. It is up to the node that points to this parameter node to figure out the type of the parameter and set it, using the setDescriptor() method above.

Overrides:
bindExpression in class ValueNode
Parameters:
fromList - The FROM list for the query this expression is in, for binding columns.
subqueryList - The subquery list being built as we find SubqueryNodes
aggregateVector - The aggregate vector being built as we find AggregateNodes
Returns:
The new top of the expression tree.
Throws:
StandardException - Thrown on error

isConstantExpression

public boolean isConstantExpression()
Return whether or not this expression tree represents a constant expression.

Overrides:
isConstantExpression in class ValueNode
Returns:
Whether or not this expression tree represents a constant expression.

constantExpression

public boolean constantExpression(PredicateList whereClause)
Description copied from class: ValueNode
Return whether or not this expression tree represents a constant value. In this case, "constant" means that it will always evaluate to the same thing, even if it includes columns. A column is constant if it is compared to a constant expression.

Overrides:
constantExpression in class ValueNode
Returns:
True means this expression tree represents a constant value.
See Also:
ValueNode.constantExpression(org.apache.derby.impl.sql.compile.PredicateList)

getOrderableVariantType

protected int getOrderableVariantType()
Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (method calls and non-static field access) SCAN_INVARIANT - invariant within a scan (column references from outer tables) QUERY_INVARIANT - invariant within the life of a query (constant expressions)

Overrides:
getOrderableVariantType in class ValueNode
Returns:
The variant type for the underlying expression.

setOrderableVariantType

void setOrderableVariantType(int type)
In a special circumstance, we want to consider parameters as constants. For that situation, we allow a caller to temporarily set us to CONSTANT and then restore us.


setJSQLType

public void setJSQLType(JSQLType type)
Set the JSQLType of this parameter. This supports the unnamed parameters that we use for replicated work units.

Parameters:
type - the JSQLType associated with this parameter

getJSQLType

public JSQLType getJSQLType()
Get the JSQLType associated with this parameter. Again, part of method resolution for replicated work units.

Returns:
the JSQLType that the remote system assigned

generateExpression

public void generateExpression(ExpressionClassBuilder acb,
                               MethodBuilder mb)
                        throws StandardException
For a ParameterNode, we generate a call to the type factory to get a DataValueDescriptor, and pass the result to the setStorableDataValue method of the ParameterValueSet for the generated class. We push the DataValueDescriptor field as the generated expression. Generated code: In the constructor for the generated class: ((ParameterValueSet) pvs). setStorableDataValue( , parameterNumber, jdbcType, className); For the return value: () ( (ParameterValueSet) pvs. getParameter(parameterNumber) ) pvs is a ParameterValueSet that lives in the superclass of the class being generated.

Overrides:
generateExpression in class ValueNode
Parameters:
acb - The ExpressionClassBuilder for the class being built
mb - The method the expression will go into
Throws:
StandardException - Thrown on error

generateHolder

void generateHolder(ExpressionClassBuilder acb)
              throws StandardException
Throws:
StandardException

getTypeId

public TypeId getTypeId()
Description copied from class: ValueNode
Get the TypeId from this ValueNode.

Overrides:
getTypeId in class ValueNode
Returns:
The TypeId from this ValueNode. This may be null if the node isn't bound yet.

generateParameterValueSet

public static void generateParameterValueSet(ExpressionClassBuilder acb,
                                             int numberOfParameters,
                                             java.util.Vector parameterList)
                                      throws StandardException
Generate the code to create the ParameterValueSet, if necessary, when constructing the activation. Also generate the code to call a method that will throw an exception if we try to execute without all the parameters being set. This generated code goes into the Activation's constructor early on.

Parameters:
acb - The ExpressionClassBuilder for the class we're building
numberOfParameters - number of parameters for this statement
parameterList - The parameter list for the statement.
Returns:
Nothing
Throws:
StandardException - on error

generateParameterHolders

public static void generateParameterHolders(ExpressionClassBuilder acb,
                                            java.util.Vector parameterList)
                                     throws StandardException
Throws:
StandardException

getDefaultValue

DataValueDescriptor getDefaultValue()
Get the default value for the parameter. Parameters may get default values for optimization purposes.

Returns:
the value, may be null

isParameterNode

public boolean isParameterNode()
Description copied from class: ValueNode
Returns TRUE if this is a parameter node. We do lots of special things with Parameter Nodes.

Overrides:
isParameterNode in class ValueNode
See Also:
ValueNode.isParameterNode()

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.