Search in sources :

Example 76 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class SchemaManager method getAllTables.

/**
     *  Returns an HsqlArrayList containing references to all non-system
     *  tables and views. This includes all tables and views registered with
     *  this Database.
     */
public HsqlArrayList getAllTables() {
    Iterator schemas = allSchemaNameIterator();
    HsqlArrayList alltables = new HsqlArrayList();
    while (schemas.hasNext()) {
        String name = (String) schemas.next();
        HashMappedList current = getTables(name);
        alltables.addAll(current.values());
    }
    return alltables;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator)

Example 77 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class SchemaManager method dropSchema.

void dropSchema(String name, boolean cascade) {
    Schema schema = (Schema) schemaMap.get(name);
    if (schema == null) {
        throw Error.error(ErrorCode.X_42501, name);
    }
    if (cascade) {
        OrderedHashSet externalReferences = new OrderedHashSet();
        getCascadingSchemaReferences(schema.getName(), externalReferences);
        removeSchemaObjects(externalReferences);
    } else {
        if (!schema.isEmpty()) {
            throw Error.error(ErrorCode.X_2B000);
        }
    }
    Iterator tableIterator = schema.schemaObjectIterator(SchemaObject.TABLE);
    while (tableIterator.hasNext()) {
        Table table = ((Table) tableIterator.next());
        database.getGranteeManager().removeDbObject(table.getName());
        table.releaseTriggers();
        database.persistentStoreCollection.releaseStore(table);
    }
    Iterator sequenceIterator = schema.schemaObjectIterator(SchemaObject.SEQUENCE);
    while (sequenceIterator.hasNext()) {
        NumberSequence sequence = ((NumberSequence) sequenceIterator.next());
        database.getGranteeManager().removeDbObject(sequence.getName());
    }
    schema.clearStructures();
    schemaMap.remove(name);
    if (defaultSchemaHsqlName.name.equals(name)) {
        HsqlName hsqlName = database.nameManager.newHsqlName(name, false, SchemaObject.SCHEMA);
        schema = new Schema(hsqlName, database.getGranteeManager().getDBARole());
        defaultSchemaHsqlName = schema.name;
        schemaMap.put(schema.name.name, schema);
    }
    // these are called last and in this particular order
    database.getUserManager().removeSchemaReference(name);
    database.getSessionManager().removeSchemaReference(schema);
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 78 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class SchemaManager method databaseObjectIterator.

public Iterator databaseObjectIterator(int type) {
    Iterator it = schemaMap.values().iterator();
    Iterator objects = new WrapperIterator();
    while (it.hasNext()) {
        Schema temp = (Schema) it.next();
        objects = new WrapperIterator(objects, temp.schemaObjectIterator(type));
    }
    return objects;
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator)

Example 79 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class SchemaManager method getSchemas.

HsqlArrayList getSchemas(Grantee grantee) {
    HsqlArrayList list = new HsqlArrayList();
    Iterator it = schemaMap.values().iterator();
    while (it.hasNext()) {
        Schema schema = (Schema) it.next();
        if (grantee.equals(schema.owner)) {
            list.add(schema);
        }
    }
    return list;
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator)

Example 80 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.

the class SchemaManager method getReferencingObjects.

OrderedHashSet getReferencingObjects(HsqlName table, HsqlName column) {
    OrderedHashSet set = new OrderedHashSet();
    Iterator it = referenceMap.get(table);
    while (it.hasNext()) {
        HsqlName name = (HsqlName) it.next();
        SchemaObject object = getSchemaObject(name);
        OrderedHashSet references = object.getReferences();
        if (references.contains(column)) {
            set.add(name);
        }
    }
    return set;
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Aggregations

Iterator (org.hsqldb_voltpatches.lib.Iterator)102 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)64 SchemaObject (org.hsqldb_voltpatches.SchemaObject)57 Table (org.hsqldb_voltpatches.Table)55 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)51 Constraint (org.hsqldb_voltpatches.Constraint)50 TextTable (org.hsqldb_voltpatches.TextTable)39 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)28 HsqlException (org.hsqldb_voltpatches.HsqlException)18 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)14 NumberType (org.hsqldb_voltpatches.types.NumberType)10 HashSet (org.hsqldb_voltpatches.lib.HashSet)9 Type (org.hsqldb_voltpatches.types.Type)9 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6 IntervalType (org.hsqldb_voltpatches.types.IntervalType)6