Search in sources :

Example 6 with RoutineSchema

use of org.hsqldb_voltpatches.RoutineSchema in project voltdb by VoltDB.

the class DatabaseInformationFull method ROUTINE_COLUMN_USAGE.

Table ROUTINE_COLUMN_USAGE() {
    Table t = sysTables[ROUTINE_COLUMN_USAGE];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[ROUTINE_COLUMN_USAGE]);
        addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
        addColumn(t, "ROUTINE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "ROUTINE_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "ROUTINE_NAME", SQL_IDENTIFIER);
        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[ROUTINE_COLUMN_USAGE].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 3, 4, 5, 0, 1, 2, 6, 7, 8, 9 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // column number mappings
    final int specific_catalog = 0;
    final int specific_schema = 1;
    final int specific_name = 2;
    final int routine_catalog = 3;
    final int routine_schema = 4;
    final int routine_name = 5;
    final int table_catalog = 6;
    final int table_schema = 7;
    final int table_name = 8;
    final int column_name = 9;
    //
    Iterator it;
    Object[] row;
    it = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
    while (it.hasNext()) {
        RoutineSchema routine = (RoutineSchema) it.next();
        if (!session.getGrantee().isAccessible(routine)) {
            continue;
        }
        Routine[] specifics = routine.getSpecificRoutines();
        for (int m = 0; m < specifics.length; m++) {
            OrderedHashSet set = specifics[m].getReferences();
            for (int i = 0; i < set.size(); i++) {
                HsqlName refName = (HsqlName) set.get(i);
                if (refName.type != SchemaObject.COLUMN) {
                    continue;
                }
                if (!session.getGrantee().isAccessible(refName)) {
                    continue;
                }
                row = t.getEmptyRowData();
                //
                row[specific_catalog] = database.getCatalogName().name;
                row[specific_schema] = specifics[m].getSchemaName().name;
                row[specific_name] = specifics[m].getName().name;
                row[routine_catalog] = database.getCatalogName().name;
                row[routine_schema] = routine.getSchemaName().name;
                row[routine_name] = routine.getName().name;
                row[table_catalog] = database.getCatalogName().name;
                row[table_schema] = refName.parent.schema.name;
                row[table_name] = refName.parent.name;
                row[column_name] = refName.name;
                try {
                    t.insertSys(store, row);
                } catch (HsqlException e) {
                }
            }
        }
    }
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject) Routine(org.hsqldb_voltpatches.Routine) Constraint(org.hsqldb_voltpatches.Constraint) HsqlException(org.hsqldb_voltpatches.HsqlException) RoutineSchema(org.hsqldb_voltpatches.RoutineSchema)

Example 7 with RoutineSchema

use of org.hsqldb_voltpatches.RoutineSchema in project voltdb by VoltDB.

the class DatabaseInformationFull method ROUTINE_JAR_USAGE.

Table ROUTINE_JAR_USAGE() {
    Table t = sysTables[ROUTINE_JAR_USAGE];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[ROUTINE_JAR_USAGE]);
        addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
        addColumn(t, "JAR_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "JAR_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "JAR_NAME", SQL_IDENTIFIER);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_JAR_USAGE].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
        return t;
    }
    // column number mappings
    final int specific_catalog = 0;
    final int specific_schema = 1;
    final int specific_name = 2;
    final int jar_catalog = 3;
    final int jar_schema = 4;
    final int jar_name = 5;
    //
    Iterator it;
    Object[] row;
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    it = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
    while (it.hasNext()) {
        RoutineSchema routine = (RoutineSchema) it.next();
        if (!session.getGrantee().isAccessible(routine)) {
            continue;
        }
        Routine[] specifics = routine.getSpecificRoutines();
        for (int m = 0; m < specifics.length; m++) {
            if (specifics[m].getLanguage() != Routine.LANGUAGE_JAVA) {
                continue;
            }
            row = t.getEmptyRowData();
            row[specific_catalog] = database.getCatalogName().name;
            row[specific_schema] = routine.getSchemaName().name;
            row[specific_name] = routine.getName().name;
            row[jar_catalog] = database.getCatalogName().name;
            row[jar_schema] = database.schemaManager.getSQLJSchemaHsqlName();
            row[jar_name] = "CLASSPATH";
            t.insertSys(store, row);
        }
    }
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject) Routine(org.hsqldb_voltpatches.Routine) Constraint(org.hsqldb_voltpatches.Constraint) RoutineSchema(org.hsqldb_voltpatches.RoutineSchema)

Aggregations

Constraint (org.hsqldb_voltpatches.Constraint)7 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)7 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 SchemaObject (org.hsqldb_voltpatches.SchemaObject)7 Table (org.hsqldb_voltpatches.Table)7 TextTable (org.hsqldb_voltpatches.TextTable)7 Iterator (org.hsqldb_voltpatches.lib.Iterator)7 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)7 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)7 HsqlException (org.hsqldb_voltpatches.HsqlException)5 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)5 Grantee (org.hsqldb_voltpatches.rights.Grantee)1 Right (org.hsqldb_voltpatches.rights.Right)1 CharacterType (org.hsqldb_voltpatches.types.CharacterType)1 IntervalType (org.hsqldb_voltpatches.types.IntervalType)1 NumberType (org.hsqldb_voltpatches.types.NumberType)1 Type (org.hsqldb_voltpatches.types.Type)1