/** * Bind this expression. This means binding the sub-expressions, as well as figuring out what the * return type is for this expression. * * @param fromList The FROM list for the query this expression is in, for binding columns. * @param subqueryList The subquery list being built as we find SubqueryNodes * @param aggregateVector The aggregate vector being built as we find AggregateNodes * @return The new top of the expression tree. * @exception StandardException Thrown on error */ public ValueNode bindExpression( FromList fromList, SubqueryList subqueryList, List aggregateVector) throws StandardException { // method invocations are not allowed in ADD TABLE clauses. // And neither are field references. javaNode.checkReliability(this); /* Bind the expression under us */ javaNode = javaNode.bindExpression(fromList, subqueryList, aggregateVector); if (javaNode instanceof StaticMethodCallNode) { AggregateNode agg = ((StaticMethodCallNode) javaNode).getResolvedAggregate(); if (agg != null) { return agg.bindExpression(fromList, subqueryList, aggregateVector); } } DataTypeDescriptor dts = javaNode.getDataType(); if (dts == null) { throw StandardException.newException( SQLState.LANG_NO_CORRESPONDING_S_Q_L_TYPE, javaNode.getJavaTypeName()); } TypeDescriptor catalogType = dts.getCatalogType(); if (catalogType.isRowMultiSet() || (catalogType.getTypeName().equals("java.sql.ResultSet"))) { throw StandardException.newException(SQLState.LANG_TABLE_FUNCTION_NOT_ALLOWED); } setType(dts); // For functions returning string types we should set the collation to match the // java method's schema DERBY-2972. This is propogated from // RoutineAliasInfo to javaNode. if (dts.getTypeId().isStringTypeId()) { this.setCollationInfo( javaNode.getCollationType(), StringDataValue.COLLATION_DERIVATION_IMPLICIT); } return this; }