it = database.schemaManager.databaseObjectIterator(
SchemaObject.SPECIFIC_ROUTINE);
while (it.hasNext()) {
Routine routine = (Routine) it.next();
boolean isFullyAccessible;
if (!session.getGrantee().isAccessible(routine)) {
continue;
}
isFullyAccessible = session.getGrantee().isFullyAccessibleByRole(
routine.getName());
row = t.getEmptyRowData();
Type type = routine.isProcedure() ? null
: routine.getReturnType();
//
row[specific_catalog] = database.getCatalogName().name;
row[specific_schema] = routine.getSchemaName().name;
row[specific_name] = routine.getSpecificName().name;
row[routine_catalog] = database.getCatalogName().name;
row[routine_schema] = routine.getSchemaName().name;
row[routine_name] = routine.getName().name;
row[routine_type] = routine.isProcedure() ? Tokens.T_PROCEDURE
: Tokens.T_FUNCTION;
row[module_catalog] = null;
row[module_schema] = null;
row[module_name] = null;
row[udt_catalog] = null;
row[udt_schema] = null;
row[udt_name] = null;
row[data_type] = type == null ? null
: type.getNameString();
if (type != null) {
// common type block
if (type.isCharacterType()) {
row[character_maximum_length] =
ValuePool.getLong(type.precision);
row[character_octet_length] =
ValuePool.getLong(type.precision * 2);
row[character_set_catalog] =
database.getCatalogName().name;
row[character_set_schema] =
((CharacterType) type).getCharacterSet()
.getSchemaName().name;
row[character_set_name] =
((CharacterType) type).getCharacterSet().getName()
.name;
row[collation_catalog] = database.getCatalogName().name;
row[collation_schema] =
((CharacterType) type).getCollation().getSchemaName()
.name;
row[collation_name] =
((CharacterType) type).getCollation().getName().name;
} else if (type.isNumberType()) {
row[numeric_precision] = ValuePool.getLong(
((NumberType) type).getNumericPrecisionInRadix());
row[declared_numeric_precision] = ValuePool.getLong(
((NumberType) type).getNumericPrecisionInRadix());
if (type.isExactNumberType()) {
row[numeric_scale] = row[declared_numeric_scale] =
ValuePool.getLong(type.scale);
}
row[numeric_precision_radix] =
ValuePool.getLong(type.getPrecisionRadix());
} else if (type.isBooleanType()) {
//
} else if (type.isDateTimeType()) {
row[datetime_precision] = ValuePool.getLong(type.scale);
} else if (type.isIntervalType()) {
row[data_type] = "INTERVAL";
row[interval_type] =
((IntervalType) type).getQualifier(type.typeCode);
row[interval_precision] =
ValuePool.getLong(type.precision);
row[datetime_precision] = ValuePool.getLong(type.scale);
} else if (type.isBinaryType()) {
row[character_maximum_length] =
ValuePool.getLong(type.precision);
row[character_octet_length] =
ValuePool.getLong(type.precision);
} else if (type.isBitType()) {
row[character_maximum_length] =
ValuePool.getLong(type.precision);
row[character_octet_length] =
ValuePool.getLong(type.precision);
} else if (type.isArrayType()) {
row[maximum_cardinality] =
ValuePool.getLong(type.arrayLimitCardinality());
row[data_type] = "ARRAY";
}
row[dtd_identifier] = type.getDefinition();
row[declared_data_type] = row[data_type];
// end common block
}
row[type_udt_catalog] = null;
row[type_udt_schema] = null;
row[type_udt_name] = null;
row[scope_catalog] = null;
row[scope_schema] = null;
row[scope_name] = null;
row[routine_body] = routine.getLanguage() == Routine.LANGUAGE_JAVA
? "EXTERNAL"
: "SQL";
row[routine_definition] = isFullyAccessible ? routine.getSQL()
: null;
row[external_name] = routine.getExternalName();
row[external_language] = routine.getLanguage()
== Routine.LANGUAGE_JAVA ? "JAVA"
: null;
row[parameter_style] = routine.getLanguage()
== Routine.LANGUAGE_JAVA ? "JAVA"
: null;
row[is_deterministic] = routine.isDeterministic() ? "YES"
: "NO";
row[sql_data_access] = routine.getDataImpactString();
row[is_null_call] = type == null ? null
: routine.isNullInputOutput()
? "YES"
: "NO";
row[sql_path] = null;
row[schema_level_routine] = "YES";
row[max_dynamic_result_sets] = ValuePool.getLong(0);