aggregateVector);
// Is the parameter list to the constructor valid for a VTI?
methodParms = methodCall.getMethodParms();
RoutineAliasInfo routineInfo = methodCall.getRoutineInfo();
if (
(routineInfo !=null) &&
routineInfo.getReturnType().isRowMultiSet() &&
(routineInfo.getParameterStyle() == RoutineAliasInfo.PS_DERBY_JDBC_RESULT_SET)
) {
isDerbyStyleTableFunction = true;
}
/* If we have a valid constructor, does class implement the correct interface?
* If version2 is true, then it must implement PreparedStatement, otherwise
* it can implement either PreparedStatement or ResultSet. (We check for
* PreparedStatement first.)
*/
if ( isConstructor() )
{
NewInvocationNode constructor = (NewInvocationNode) methodCall;
if (!constructor.assignableTo("java.sql.PreparedStatement"))
{
if (version2)
{
throw StandardException.newException(SQLState.LANG_DOES_NOT_IMPLEMENT,
getVTIName(),
"java.sql.PreparedStatement");
}
else if (! constructor.assignableTo("java.sql.ResultSet"))
{
throw StandardException.newException(SQLState.LANG_DOES_NOT_IMPLEMENT,
getVTIName(),
"java.sql.ResultSet");
}
}
else
{
version2 = true;
}
/* If this is a version 2 VTI */
if (version2)
{
// Does it support predicates
implementsPushable = constructor.assignableTo("org.apache.derby.vti.IQualifyable");
}
// Remember whether or not the VTI implements the VTICosting interface
implementsVTICosting = constructor.assignableTo(ClassName.VTICosting);
}
if ( isDerbyStyleTableFunction )
{
implementsVTICosting = implementsDerbyStyleVTICosting( methodCall.getJavaClassName() );
}
/* Build the RCL for this VTI. We instantiate an object in order
* to get the ResultSetMetaData.
*
* If we have a special trigger vti, then we branch off and get
* its rcl from the trigger table that is waiting for us in
* the compiler context.
*/
UUID triggerTableId;
if ((isConstructor()) && ((triggerTableId = getSpecialTriggerVTITableName(lcc, methodCall.getJavaClassName())) != null) )
{
TableDescriptor td = getDataDictionary().getTableDescriptor(triggerTableId);
resultColumns = genResultColList(td);
// costing info
vtiCosted = true;
estimatedCost = 50d;
estimatedRowCount = 5d;
supportsMultipleInstantiations = true;
}
else
{
resultColumns = (ResultColumnList) getNodeFactory().getNode(
C_NodeTypes.RESULT_COLUMN_LIST,
getContextManager());
// if this is a Derby-style Table Function, then build the result
// column list from the RowMultiSetImpl return datatype
if ( isDerbyStyleTableFunction ) {
createResultColumnsForTableFunction( routineInfo.getReturnType() );
}
else
{
ResultSetMetaData rsmd = getResultSetMetaData();