Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv abstract Class MethodCallNode

extends JavaValueNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.NewInvocationNode, org.apache.derby.impl.sql.compile.NonStaticMethodCallNode, org.apache.derby.impl.sql.compile.StaticMethodCallNode
Imports
java.lang.reflect.Member, .Modifier, java.sql.ParameterMetaData, .ResultSet, java.util.List, .StringTokenizer, org.apache.derby.catalog.TypeDescriptor, org.apache.derby.catalog.types.RoutineAliasInfo, .TypeDescriptorImpl, .UserDefinedTypeIdImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.LocalField, .MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.loader.ClassInspector, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CompilerContext, .TypeCompiler, .TypeCompilerFactory, .Visitor, org.apache.derby.iapi.store.access.Qualifier, org.apache.derby.iapi.types.DataTypeDescriptor, .JSQLType, .TypeId, org.apache.derby.iapi.util.JBitSet

A MethodCallNode represents a Java method call. Method calls can be done through DML (as expressions) or through the CALL statement.

Field Summary

Modifier and TypeField and Description
protected String
pack-priv boolean
internalCall

True if this is an internal call, just used to set up a generated method call.

pack-priv String
javaClassName

The name of the class containing the method.

protected Member
pack-priv String
pack-priv String[]
methodParameterTypes

The parameter types for the resolved method.

protected JavaValueNode[]
private String[]
procedurePrimitiveArrayType

For resolution of procedure INOUT/OUT parameters to the primitive form, such as int[].

pack-priv RoutineAliasInfo
routineInfo

For a procedure or function call

protected JSQLType[]
Inherited from org.apache.derby.impl.sql.compile.JavaValueNode:
forCallStatementjsqlType

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv void
addParms(List<ValueNode>
A list of the parameters
parameterList
)

Add the parameter list

protected boolean

Returns:

Whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT
areParametersQueryInvariant
()

Return whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT.

pack-priv final void
bindParameters(FromList
The FROM list for the query this expression is in, for binding columns.
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Bind this expression.

pack-priv boolean

Returns:

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.
categorize
(JBitSet
JBitSet with bit map of referenced FromTables
referencedTabs
,
boolean
Whether or not to consider method calls, field references and conditional nodes when building bit map
simplePredsOnly
)

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.categorize.

Categorize this predicate.

private void
generateAndCastOneParameter(ExpressionClassBuilder acb, MethodBuilder mb, int param, String parameterType)

Generate and cast one parameter, pushing the result onto the stack.

pack-priv void
generateOneParameter(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
the method the expression will go into
mb
,
int
Identifies which parameter to generate. 0 based.
parameterNumber
)

Generate one parameter to the given method call.

public int

Returns:

Count of arguments to the method.
generateParameters
(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
the method the expression will go into
mb
)

Generate the parameters to the given method call

private void
generateVarargs(ExpressionClassBuilder acb, MethodBuilder mb)

Generate the trailing routine arguments into a varargs array and push that array onto the stack.

pack-priv void
getCorrelationTables(JBitSet
The JBitSet of the tables that we are correlated with.
correlationMap
)

Build a JBitSet of all of the tables that we are correlated with.

pack-priv DataTypeDescriptor
public int
getFirstVarargIdx()

Get the index of the first vararg if this is a varargs method

pack-priv TableName
getFullName()

Get the schema-qualified name of the the routine.

protected boolean[]

Returns:

array of booleans denoting wheter or not a given method parameter is a ?.
getIsParam
()

Build an array of booleans denoting whether or not a given method parameter is a ?.

public String

Returns:

the name of the class that contains the method, null if not known. It may not be known until this node has been bound.
getJavaClassName
()

pack-priv String
pack-priv Class<?>[]

Returns:

the Classes of our parameters
getMethodParameterClasses
()

Get the resolved Classes of our parameters

pack-priv JavaValueNode[]

Returns:

The method parameters
getMethodParms
()

Get the method parameters.

protected String[]

Returns:

array of type names
getObjectSignature
()

Build an array of names of the argument types.

pack-priv static String
pack-priv int

Returns:

The variant type for the underlying expression.
getOrderableVariantType
()

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getOrderableVariantType.

Return the variant type for the underlying expression.

public static String
pack-priv String[]
getPrimitiveSignature(boolean castToPrimitiveAsNecessary)

public Member

Returns:

get the Java method or constructor determined during the bind() phase.
getResolvedMethod
()

protected int
getRoutineArgIdx(int invocationArgIdx)

Get the offset into the routine arguments corresponding to the index of the invocation parameter.

protected int
getRoutineArgIdx(RoutineAliasInfo rai, int invocationArgIdx)

public RoutineAliasInfo
getRoutineInfo()

Get the details on the invoked routines.

private String
getVarargTypeName(String arrayTypeName)

Turn an array type name into the corresponding vararg type name

private int
public boolean
hasVarargs()

Return true if the routine has varargs

public boolean
isVararg(int parameterNumber)

Return true if the parameter is a vararg

private String[]

Returns:

The valid array of types for resolution.
parseValidateSignature
(String externalName, int
Character offset of first paren
offset
,
boolean
Can ResultSet[] parameters be specified.
hasDynamicResultSets
)

Parse the user supplied signature for a method and validate it, need to match the number of parameters passed in and match the valid types for the parameter.

pack-priv void
preprocess(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.preprocess.

Preprocess an expression tree.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object.

pack-priv JavaValueNode

Returns:

JavaValueNode The remapped expression tree.
remapColumnReferencesToExpressions
()

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.remapColumnReferencesToExpressions.

Remap all ColumnReferences in this tree to be clones of the underlying expression.

protected void
resolveMethodCall(String javaClassName, boolean staticMethod)

pack-priv void
setNullParameterInfo(String[]
String[] with the java type names for the parameters as declared by the method
parmTypeNames
)

Set the appropriate type information for a null passed as a parameter.

protected boolean
someParametersAreNull()

Return true if some parameters are null, false otherwise.

protected String
stripOneArrayLevel(String typeName)

Strip the trailing [] from a type name

pack-priv void
throwNoMethodFound(String
Type name for receiver
receiverTypeName
,
String[]
Type names for parameters as object types
parmTypeNames
,
String[]
Type names for parameters as primitive types
primParmTypeNames
)

Build parameters for error message and throw the exception when there is no matching signature found.

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.toString.

Convert this object to a String.

Inherited from org.apache.derby.impl.sql.compile.JavaValueNode:
bindExpressioncastToPrimitivecheckReliabilitygenerategenerateExpressiongenerateReceivergenerateReceivergetCollationTypegetConstantValueAsObjectgetJavaTypeNamegetJSQLTypegetPrimitiveTypeNamegetReceiverExpressionisPrimitiveTypemapToTypeIDmarkForCallStatementmarkReturnValueDiscardedmustCastToPrimitivereturnValueDiscardedreturnValueToSQLDomainsetCollationTypesetJavaTypeNamevalueReturnedToSQLDomain

Field Detail

actualMethodReturnTypeback to summary
protected String actualMethodReturnType
internalCallback to summary
pack-priv boolean internalCall

True if this is an internal call, just used to set up a generated method call.

javaClassNameback to summary
pack-priv String javaClassName

The name of the class containing the method. May not be known until bindExpression() has been called.

See Also
bindExpression, getJavaClassName()
methodback to summary
protected Member method
methodNameback to summary
pack-priv String methodName
methodParameterTypesback to summary
pack-priv String[] methodParameterTypes

The parameter types for the resolved method.

methodParmsback to summary
protected JavaValueNode[] methodParms
procedurePrimitiveArrayTypeback to summary
private String[] procedurePrimitiveArrayType

For resolution of procedure INOUT/OUT parameters to the primitive form, such as int[]. May be null.

routineInfoback to summary
pack-priv RoutineAliasInfo routineInfo

For a procedure or function call

signatureback to summary
protected JSQLType[] signature

Constructor Detail

MethodCallNodeback to summary
pack-priv MethodCallNode(String methodName, ContextManager cm)

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
addParmsback to summary
pack-priv void addParms(List<ValueNode> parameterList) throws StandardException

Add the parameter list

Parameters
parameterList:List<ValueNode>

A list of the parameters

Exceptions
StandardException:
Thrown on error
areParametersQueryInvariantback to summary
protected boolean areParametersQueryInvariant() throws StandardException

Return whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT. This is useful for VTIs - a VTI is a candidate for materialization if all of its parameters are QUERY_INVARIANT or CONSTANT

Returns:boolean

Whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT

Exceptions
StandardException:
thrown on error
bindParametersback to summary
pack-priv final void bindParameters(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException

Bind this expression. This means binding the sub-expressions, as well as figuring out what the return type is for this expression.

Parameters
fromList:FromList

The FROM list for the query this expression is in, for binding columns.

subqueryList:SubqueryList

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

The aggregate list being built as we find AggregateNodes

Exceptions
StandardException:
Thrown on error
categorizeback to summary
pack-priv boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.categorize.

Categorize this predicate. Initially, this means building a bit map of the referenced tables for each predicate. If the source of this ColumnReference (at the next underlying level) is not a ColumnReference or a VirtualColumnNode then this predicate will not be pushed down. For example, in: select * from (select 1 from s) a (x) where x = 1 we will not push down x = 1.

Note

It would be easy to handle the case of a constant, but if the inner SELECT returns an arbitrary expression, then we would have to copy that tree into the pushed predicate, and that tree could contain subqueries and method calls. RESOLVE - revisit this issue once we have views.

Parameters
referencedTabs:JBitSet

JBitSet with bit map of referenced FromTables

simplePredsOnly:boolean

Whether or not to consider method calls, field references and conditional nodes when building bit map

Returns:boolean

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.

Exceptions
StandardException:
Thrown on error
generateAndCastOneParameterback to summary
private void generateAndCastOneParameter(ExpressionClassBuilder acb, MethodBuilder mb, int param, String parameterType) throws StandardException

Generate and cast one parameter, pushing the result onto the stack.

generateOneParameterback to summary
pack-priv void generateOneParameter(ExpressionClassBuilder acb, MethodBuilder mb, int parameterNumber) throws StandardException

Generate one parameter to the given method call. This method is overriden by RepStaticMethodCallNode.

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

the method the expression will go into

parameterNumber:int

Identifies which parameter to generate. 0 based.

Exceptions
StandardException:
Thrown on error
generateParametersback to summary
public int generateParameters(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Generate the parameters to the given method call

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

the method the expression will go into

Returns:int

Count of arguments to the method.

Exceptions
StandardException:
Thrown on error
generateVarargsback to summary
private void generateVarargs(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Generate the trailing routine arguments into a varargs array and push that array onto the stack.

getCorrelationTablesback to summary
pack-priv void getCorrelationTables(JBitSet correlationMap) throws StandardException

Build a JBitSet of all of the tables that we are correlated with.

Parameters
correlationMap:JBitSet

The JBitSet of the tables that we are correlated with.

getDataTypeback to summary
pack-priv DataTypeDescriptor getDataType() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getDataType.

Override method in ancestor.

Annotations
@Override
getFirstVarargIdxback to summary
public int getFirstVarargIdx()

Get the index of the first vararg if this is a varargs method

getFullNameback to summary
pack-priv TableName getFullName()

Get the schema-qualified name of the the routine. Is non-null only for StaticMethodCallNodes.

getIsParamback to summary
protected boolean[] getIsParam()

Build an array of booleans denoting whether or not a given method parameter is a ?.

Returns:boolean[]

array of booleans denoting wheter or not a given method parameter is a ?.

getJavaClassNameback to summary
public String getJavaClassName()
Returns:String

the name of the class that contains the method, null if not known. It may not be known until this node has been bound.

getMethodNameback to summary
pack-priv String getMethodName()
getMethodParameterClassesback to summary
pack-priv Class<?>[] getMethodParameterClasses()

Get the resolved Classes of our parameters

Returns:Class<?>[]

the Classes of our parameters

getMethodParmsback to summary
pack-priv JavaValueNode[] getMethodParms()

Get the method parameters.

Returns:JavaValueNode[]

The method parameters

getObjectSignatureback to summary
protected String[] getObjectSignature() throws StandardException

Build an array of names of the argument types. These types are biased toward Java objects. That is, if an argument is of SQLType, then we map it to the corresponding Java synonym class (e.g., SQLINT is mapped to 'java.lang.Integer').

Returns:String[]

array of type names

Exceptions
StandardException:
Thrown on error
getObjectTypeNameback to summary
pack-priv static String getObjectTypeName(JSQLType jsqlType, TypeCompilerFactory tcf) throws StandardException
Annotations
@SuppressWarnings:fallthrough
getOrderableVariantTypeback to summary
pack-priv int getOrderableVariantType() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getOrderableVariantType.

Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (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)

Returns:int

The variant type for the underlying expression.

Annotations
@Override
getParameterTypeNameback to summary
public static String getParameterTypeName(JavaValueNode param) throws StandardException
getPrimitiveSignatureback to summary
pack-priv String[] getPrimitiveSignature(boolean castToPrimitiveAsNecessary) throws StandardException
getResolvedMethodback to summary
public Member getResolvedMethod()
Returns:Member

get the Java method or constructor determined during the bind() phase.

getRoutineArgIdxback to summary
protected int getRoutineArgIdx(int invocationArgIdx)

Get the offset into the routine arguments corresponding to the index of the invocation parameter. The two indexes may be different in the case of varargs methods. There may be more invocation args than declared routine args. For a varargs routine, all of the trailing invocation parameters correspond to the last argument declared by the CREATE FUNCTION/PROCEDURE statement.

getRoutineArgIdxback to summary
protected int getRoutineArgIdx(RoutineAliasInfo rai, int invocationArgIdx)
getRoutineInfoback to summary
public RoutineAliasInfo getRoutineInfo()

Get the details on the invoked routines.

getVarargTypeNameback to summary
private String getVarargTypeName(String arrayTypeName)

Turn an array type name into the corresponding vararg type name

getVariantTypeOfParamsback to summary
private int getVariantTypeOfParams() throws StandardException
hasVarargsback to summary
public boolean hasVarargs()

Return true if the routine has varargs

isVarargback to summary
public boolean isVararg(int parameterNumber)

Return true if the parameter is a vararg

parseValidateSignatureback to summary
private String[] parseValidateSignature(String externalName, int offset, boolean hasDynamicResultSets) throws StandardException

Parse the user supplied signature for a method and validate it, need to match the number of parameters passed in and match the valid types for the parameter.

Parameters
offset:int

Character offset of first paren

hasDynamicResultSets:boolean

Can ResultSet[] parameters be specified.

Returns:String[]

The valid array of types for resolution.

preprocessback to summary
pack-priv void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.preprocess.

Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening.

Note

This is done before the outer ResultSetNode is preprocessed.

Parameters
numTables:int

Number of tables in the DML Statement

outerFromList:FromList

FromList from outer query block

outerSubqueryList:SubqueryList

SubqueryList from outer query block

outerPredicateList:PredicateList

PredicateList from outer query block

Exceptions
StandardException:
Thrown on error
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override
remapColumnReferencesToExpressionsback to summary
pack-priv JavaValueNode remapColumnReferencesToExpressions() throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.remapColumnReferencesToExpressions.

Remap all ColumnReferences in this tree to be clones of the underlying expression.

Returns:JavaValueNode

JavaValueNode The remapped expression tree.

Exceptions
StandardException:
Thrown on error
resolveMethodCallback to summary
protected void resolveMethodCall(String javaClassName, boolean staticMethod) throws StandardException
setNullParameterInfoback to summary
pack-priv void setNullParameterInfo(String[] parmTypeNames) throws StandardException

Set the appropriate type information for a null passed as a parameter. This method is called after method resolution, when a signature was successfully matched.

Parameters
parmTypeNames:String[]

String[] with the java type names for the parameters as declared by the method

Exceptions
StandardException:
Thrown on error
someParametersAreNullback to summary
protected boolean someParametersAreNull()

Return true if some parameters are null, false otherwise.

stripOneArrayLevelback to summary
protected String stripOneArrayLevel(String typeName)

Strip the trailing [] from a type name

throwNoMethodFoundback to summary
pack-priv void throwNoMethodFound(String receiverTypeName, String[] parmTypeNames, String[] primParmTypeNames) throws StandardException

Build parameters for error message and throw the exception when there is no matching signature found.

Parameters
receiverTypeName:String

Type name for receiver

parmTypeNames:String[]

Type names for parameters as object types

primParmTypeNames:String[]

Type names for parameters as primitive types

Exceptions
StandardException:
Thrown on error
toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override