Search in sources :

Example 6 with TriggerDef

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

the class DatabaseInformationFull method TRIGGER_ROUTINE_USAGE.

Table TRIGGER_ROUTINE_USAGE() {
    Table t = sysTables[TRIGGER_ROUTINE_USAGE];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[TRIGGER_ROUTINE_USAGE]);
        addColumn(t, "TRIGGER_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "TRIGGER_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "TRIGGER_NAME", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TRIGGER_ROUTINE_USAGE].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // column number mappings
    final int trigger_catalog = 0;
    final int trigger_schema = 1;
    final int trigger_name = 2;
    final int specific_catalog = 3;
    final int specific_schema = 4;
    final int specific_name = 5;
    Iterator it;
    Object[] row;
    it = database.schemaManager.databaseObjectIterator(SchemaObject.TRIGGER);
    while (it.hasNext()) {
        TriggerDef trigger = (TriggerDef) it.next();
        if (!session.getGrantee().isAccessible(trigger)) {
            continue;
        }
        OrderedHashSet set = trigger.getReferences();
        for (int i = 0; i < set.size(); i++) {
            HsqlName refName = (HsqlName) set.get(i);
            if (refName.type != SchemaObject.FUNCTION && refName.type != SchemaObject.PROCEDURE) {
                continue;
            }
            if (!session.getGrantee().isAccessible(refName)) {
                continue;
            }
            row = t.getEmptyRowData();
            row[trigger_catalog] = database.getCatalogName().name;
            row[trigger_schema] = trigger.getSchemaName().name;
            row[trigger_name] = trigger.getName().name;
            row[specific_catalog] = database.getCatalogName().name;
            row[specific_schema] = refName.schema.name;
            row[specific_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) TriggerDef(org.hsqldb_voltpatches.TriggerDef) Constraint(org.hsqldb_voltpatches.Constraint) HsqlException(org.hsqldb_voltpatches.HsqlException)

Aggregations

Constraint (org.hsqldb_voltpatches.Constraint)6 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)6 SchemaObject (org.hsqldb_voltpatches.SchemaObject)6 Table (org.hsqldb_voltpatches.Table)6 TextTable (org.hsqldb_voltpatches.TextTable)6 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 Iterator (org.hsqldb_voltpatches.lib.Iterator)6 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)6 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)6 HsqlException (org.hsqldb_voltpatches.HsqlException)4 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)4 ColumnSchema (org.hsqldb_voltpatches.ColumnSchema)1