}
columnCount = table.getColumnCount();
for (int i = 0; i < columnCount; i++) {
ColumnSchema column = table.getColumn(i);
type = column.getDataType();
if (!columnList.contains(column.getName())) {
continue;
}
row = t.getEmptyRowData();
row[table_cat] = database.getCatalogName().name;
row[table_schem] = table.getSchemaName().name;
row[table_name] = table.getName().name;
row[column_name] = column.getName().name;
row[ordinal_position] = ValuePool.getLong(i + 1);
row[column_default] = column.getDefaultSQL();
row[is_nullable] = column.isNullable() ? "YES"
: "NO";
row[data_type] = type.getFullNameString();
// 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());
}
if (type.isDomainType()) {
row[domain_catalog] = database.getCatalogName().name;
row[domain_schema] = type.getSchemaName().name;
row[domain_name] = type.getName().name;
}
if (type.isDistinctType()) {
row[udt_catalog] = database.getCatalogName().name;
row[udt_schema] = type.getSchemaName().name;
row[udt_name] = type.getName().name;
}
row[scope_catalog] = null;
row[scope_schema] = null;
row[scope_name] = null;
row[dtd_identifier] = null;
row[is_self_referencing] = null;
row[is_identity] = column.isIdentity() ? "YES"
: "NO";
if (column.isIdentity()) {
NumberSequence sequence = column.getIdentitySequence();
row[identity_generation] = sequence.isAlways() ? "ALWAYS"
: "BY DEFAULT";
row[identity_start] =
Long.toString(sequence.getStartValue());
row[identity_increment] =
Long.toString(sequence.getIncrement());
row[identity_maximum] =
Long.toString(sequence.getMaxValue());
row[identity_minimum] =
Long.toString(sequence.getMinValue());
row[identity_cycle] = sequence.isCycle() ? "YES"
: "NO";
}
row[is_generated] = "NEVER";
if (column.isGenerated()) {
row[is_generated] = "ALWAYS";
row[generation_expression] =
column.getGeneratingExpression().getSQL();
}
row[is_updatable] = table.isWritable() ? "YES"
: "NO";
row[declared_data_type] = row[data_type];