tableSchema = table.getSchemaName().name;
tableName = table.getName().name;
columnCount = table.getColumnCount();
for (int i = 0; i < columnCount; i++) {
ColumnSchema column = table.getColumn(i);
Type type = column.getDataType();
if (translateTTI) {
if (type.isIntervalType()) {
type = ((IntervalType) type).getCharacterType();
} else if (type.isDateTimeTypeWithZone()) {
type = ((DateTimeType) type)
.getDateTimeTypeWithoutZone();
}
}
row = t.getEmptyRowData();
//
row[itable_cat] = tableCatalog;
row[itable_schem] = tableSchema;
row[itable_name] = tableName;
row[icolumn_name] = column.getName().name;
row[idata_type] = ValuePool.getInt(type.getJDBCTypeCode());
row[itype_name] = type.getNameString();
row[icolumn_size] = ValuePool.INTEGER_0;
row[ichar_octet_length] = ValuePool.INTEGER_0;
if (type.isArrayType()) {
row[itype_name] = type.getDefinition();
}
if (type.isCharacterType()) {
row[icolumn_size] =
ValuePool.getInt(type.getJDBCPrecision());
// this is length not octet_length, for character columns
row[ichar_octet_length] =
ValuePool.getInt(type.getJDBCPrecision());
}
if (type.isBinaryType()) {
row[icolumn_size] =
ValuePool.getInt(type.getJDBCPrecision());
row[ichar_octet_length] =
ValuePool.getInt(type.getJDBCPrecision());
}
if (type.isNumberType()) {
row[icolumn_size] = ValuePool.getInt(
((NumberType) type).getNumericPrecisionInRadix());
row[inum_prec_radix] =
ValuePool.getInt(type.getPrecisionRadix());
if (type.isExactNumberType()) {
row[idecimal_digits] = ValuePool.getLong(type.scale);
}
}
if (type.isDateTimeType()) {
int size = (int) column.getDataType().displaySize();
row[icolumn_size] = ValuePool.getInt(size);
row[isql_datetime_sub] = ValuePool.getInt(
((DateTimeType) type).getSqlDateTimeSub());
}
row[inullable] = ValuePool.getInt(column.getNullability());
row[iremark] = ti.getColRemarks(i);
row[icolumn_def] = column.getDefaultSQL();
row[isql_data_type] = ValuePool.getInt(type.typeCode);
row[iordinal_position] = ValuePool.getInt(i + 1);
row[iis_nullable] = column.isNullable() ? "YES"
: "NO";
if (type.isDistinctType()) {
row[isource_data_type] =
type.getName().getSchemaQualifiedStatementName();
}
// JDBC 4.0
row[iis_autoinc] = column.isIdentity() ? "YES"
: "NO";
row[iis_generated] = column.isGenerated() ? "YES"
: "NO";
t.insertSys(session, store, row);
}
}