addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(
sysTableHsqlNames[VIEW_COLUMN_USAGE].name, false,
SchemaObject.INDEX);
t.createPrimaryKeyConstraint(name, new int[] {
0, 1, 2, 3, 4, 5, 6
}, false);
return t;
}
PersistentStore store = session.sessionData.getRowStore(t);
// Calculated column values
String viewCatalog;
String viewSchema;
String viewName;
// Intermediate holders
Iterator tables;
View view;
Table table;
Object[] row;
Iterator iterator;
// Column number mappings
final int view_catalog = 0;
final int view_schema = 1;
final int view_name = 2;
final int table_catalog = 3;
final int table_schema = 4;
final int table_name = 5;
final int column_name = 6;
// Initialization
tables =
database.schemaManager.databaseObjectIterator(SchemaObject.TABLE);
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
if (table.isView()
&& session.getGrantee().isFullyAccessibleByRole(
table.getName())) {
// fall through
} else {
continue;
}
viewCatalog = database.getCatalogName().name;
viewSchema = table.getSchemaName().name;
viewName = table.getName().name;
view = (View) table;
OrderedHashSet references = view.getReferences();
iterator = references.iterator();
while (iterator.hasNext()) {
HsqlName refName = (HsqlName) iterator.next();
if (refName.type != SchemaObject.COLUMN) {
continue;
}