* visible columns of all accessible
* tables defined within this database.<p>
*/
final Table SYSTEM_COLUMNS() {
Table t = sysTables[SYSTEM_COLUMNS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[SYSTEM_COLUMNS]);
addColumn(t, "TABLE_CAT", SQL_IDENTIFIER); // 0
addColumn(t, "TABLE_SCHEM", SQL_IDENTIFIER); // 1
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER); // not null
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER); // not null
addColumn(t, "DATA_TYPE", Type.SQL_SMALLINT); // not null
addColumn(t, "TYPE_NAME", SQL_IDENTIFIER); // not null
addColumn(t, "COLUMN_SIZE", Type.SQL_INTEGER); // 6
addColumn(t, "BUFFER_LENGTH", Type.SQL_INTEGER); // 7
addColumn(t, "DECIMAL_DIGITS", Type.SQL_INTEGER); // 8
addColumn(t, "NUM_PREC_RADIX", Type.SQL_INTEGER); // 9
addColumn(t, "NULLABLE", Type.SQL_INTEGER); // not null
addColumn(t, "REMARKS", CHARACTER_DATA); // 11
addColumn(t, "COLUMN_DEF", CHARACTER_DATA); // 12
addColumn(t, "SQL_DATA_TYPE", Type.SQL_INTEGER); // 13
addColumn(t, "SQL_DATETIME_SUB", Type.SQL_INTEGER); // 14
addColumn(t, "CHAR_OCTET_LENGTH", Type.SQL_INTEGER); // 15
addColumn(t, "ORDINAL_POSITION", Type.SQL_INTEGER); // not null
addColumn(t, "IS_NULLABLE", YES_OR_NO); // not null
addColumn(t, "SCOPE_CATLOG", SQL_IDENTIFIER); // 18
addColumn(t, "SCOPE_SCHEMA", SQL_IDENTIFIER); // 19
addColumn(t, "SCOPE_TABLE", SQL_IDENTIFIER); // 20
addColumn(t, "SOURCE_DATA_TYPE", SQL_IDENTIFIER); // 21
// ----------------------------------------------------------------
// JDBC 4.0 - added Mustang b86
// ----------------------------------------------------------------
addColumn(t, "IS_AUTOINCREMENT", Type.SQL_BOOLEAN); // not null
// ----------------------------------------------------------------
// HSQLDB-specific
// ----------------------------------------------------------------
addColumn(t, "TYPE_SUB", Type.SQL_INTEGER); // not null
// order: TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION
// added for unique: TABLE_CAT
// false PK, as TABLE_SCHEM and/or TABLE_CAT may be null
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(
sysTableHsqlNames[SYSTEM_COLUMNS].name, false,
SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] {
0, 1, 2, 16
}, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// calculated column values
String tableCatalog;
String tableSchema;
String tableName;
// intermediate holders
int columnCount;
Iterator tables;
Table table;
Object[] row;
DITableInfo ti;
// column number mappings
final int itable_cat = 0;
final int itable_schem = 1;
final int itable_name = 2;
final int icolumn_name = 3;
final int idata_type = 4;
final int itype_name = 5;
final int icolumn_size = 6;
final int ibuffer_length = 7;
final int idecimal_digits = 8;
final int inum_prec_radix = 9;
final int inullable = 10;
final int iremark = 11;
final int icolumn_def = 12;
final int isql_data_type = 13;
final int isql_datetime_sub = 14;
final int ichar_octet_length = 15;
final int iordinal_position = 16;
final int iis_nullable = 17;
final int iscope_cat = 18;
final int iscope_schem = 19;
final int iscope_table = 20;
final int isrc_data_type = 21;
// JDBC 4.0
final int iis_autoinc = 22;
// HSQLDB-specific
final int itype_sub = 23;
// Initialization
tables = allTables();
ti = new DITableInfo();
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
/** @todo - requires access to the actual columns */
if (!isAccessibleTable(table)) {
continue;
}
ti.setTable(table);
tableCatalog = table.getCatalogName().name;
tableSchema = table.getSchemaName().name;
tableName = ti.getName();
columnCount = table.getColumnCount();
Type[] types = table.getColumnTypes();
for (int i = 0; i < columnCount; i++) {
ColumnSchema column = table.getColumn(i);
row = t.getEmptyRowData();
//
row[itable_cat] = tableCatalog;