java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.JavaValueNode
org.apache.derby.impl.sql.compile.MethodCallNode
org.apache.derby.impl.sql.compile.StaticMethodCallNode
- All Implemented Interfaces:
- org.apache.derby.iapi.sql.compile.Visitable
- public class StaticMethodCallNode
- extends MethodCallNode
A StaticMethodCallNode represents a static method call from a Class
(as opposed to from an Object).
For a procedure the call requires that the arguments be ? parameters.
The parameter is *logically* passed into the method call a number of different ways.
For a application call like CALL MYPROC(?) the logically Java method call is
(in psuedo Java/SQL code) (examples with CHAR(10) parameter)
Fixed length IN parameters - com.acme.MyProcedureMethod(?)
Variable length IN parameters - com.acme.MyProcedureMethod(CAST (? AS CHAR(10))
Fixed length INOUT parameter -
String[] holder = new String[] {?}; com.acme.MyProcedureMethod(holder); ? = holder[0]
Variable length INOUT parameter -
String[] holder = new String[] {CAST (? AS CHAR(10)}; com.acme.MyProcedureMethod(holder); ? = CAST (holder[0] AS CHAR(10))
Fixed length OUT parameter -
String[] holder = new String[1]; com.acme.MyProcedureMethod(holder); ? = holder[0]
Variable length INOUT parameter -
String[] holder = new String[1]; com.acme.MyProcedureMethod(holder); ? = CAST (holder[0] AS CHAR(10))
For static method calls there is no pre-definition of an IN or INOUT parameter, so a call to CallableStatement.registerOutParameter()
makes the parameter an INOUT parameter, provided:
- the parameter is passed directly to the method call (no casts or expressions).
- the method's parameter type is a Java array type.
Since this is a dynmaic decision we compile in code to take both paths, based upon a boolean isINOUT which is dervied from the
ParameterValueSet. Code is logically (only single parameter String[] shown here). Note, no casts can exist here.
boolean isINOUT = getParameterValueSet().getParameterMode(0) == PARAMETER_IN_OUT;
if (isINOUT) {
String[] holder = new String[] {?}; com.acme.MyProcedureMethod(holder); ? = holder[0]
} else {
com.acme.MyProcedureMethod(?)
}
| Methods inherited from class org.apache.derby.impl.sql.compile.MethodCallNode |
accept, addParms, addParms, areParametersQueryInvariant, bindParameters, generateParameters, getIsParam, getJavaClassName, getMethodName, getMethodParms, getObjectSignature, getOrderableVariantType, getParameterTypeName, getPrimitiveSignature, getSignature, init, preprocess, printSubNodes, remapColumnReferencesToExpressions, resolveMethodCall, setClause, setNullParameterInfo, someParametersAreNull, throwNoMethodFound |
| Methods inherited from class org.apache.derby.impl.sql.compile.JavaValueNode |
castToPrimitive, checkReliability, generate, generateReceiver, generateReceiver, getConstantValueAsObject, getJavaTypeName, getJSQLType, getPrimitiveTypeName, getReceiverExpression, isPrimitiveType, mapToTypeID, markForCallStatement, markReturnValueDiscarded, mustCastToPrimitive, returnValueDiscarded, returnValueToSQLDomain, setJavaTypeName, valueReturnedToSQLDomain |
| Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
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, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist |
procedureName
private TableName procedureName
outParamArrays
private org.apache.derby.iapi.services.compiler.LocalField[] outParamArrays
applicationParameterNumbers
private int[] applicationParameterNumbers
isSystemCode
private boolean isSystemCode
alreadyBound
private boolean alreadyBound
returnsNullOnNullState
private org.apache.derby.iapi.services.compiler.LocalField returnsNullOnNullState
ad
org.apache.derby.iapi.sql.dictionary.AliasDescriptor ad
StaticMethodCallNode
public StaticMethodCallNode()
init
public void init(java.lang.Object methodName,
java.lang.Object javaClassName)
- Intializer for a NonStaticMethodCallNode
- Overrides:
init in class QueryTreeNode
bindExpression
public JavaValueNode bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.Vector aggregateVector)
throws org.apache.derby.iapi.error.StandardException
- Bind this expression. This means binding the sub-expressions,
as well as figuring out what the return type is for this expression.
- Specified by:
bindExpression in class JavaValueNode
generateOneParameter
public void generateOneParameter(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb,
int parameterNumber)
throws org.apache.derby.iapi.error.StandardException
- Push extra code to generate the casts within the
arrays for the parameters passed as arrays.
- Overrides:
generateOneParameter in class MethodCallNode
categorize
public boolean categorize(org.apache.derby.iapi.util.JBitSet referencedTabs,
boolean simplePredsOnly)
throws org.apache.derby.iapi.error.StandardException
- 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.
- Overrides:
categorize in class MethodCallNode
toString
public java.lang.String toString()
- Convert this object to a String. See comments in QueryTreeNode.java
for how this should be done for tree printing.
- Overrides:
toString in class MethodCallNode
generateExpression
public void generateExpression(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
throws org.apache.derby.iapi.error.StandardException
- Do code generation for this method call
- Specified by:
generateExpression in class JavaValueNode