Search in sources :

Example 11 with HsqlName

use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.

the class SchemaManager method removeReferencingObject.

private void removeReferencingObject(SchemaObject object) {
    OrderedHashSet set = object.getReferences();
    if (set == null) {
        return;
    }
    for (int i = 0; i < set.size(); i++) {
        HsqlName referenced = (HsqlName) set.get(i);
        referenceMap.remove(referenced, object.getName());
    }
}
Also used : OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 12 with HsqlName

use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.

the class SchemaManager method removeSchemaObjects.

void removeSchemaObjects(OrderedHashSet set) {
    for (int i = 0; i < set.size(); i++) {
        HsqlName name = (HsqlName) set.get(i);
        removeSchemaObject(name);
    }
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 13 with HsqlName

use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.

the class SchemaManager method addSchemaObject.

void addSchemaObject(SchemaObject object) {
    HsqlName name = object.getName();
    Schema schema = (Schema) schemaMap.get(name.schema.name);
    SchemaObjectSet set = getSchemaObjectSet(schema, name.type);
    switch(name.type) {
        case SchemaObject.PROCEDURE:
        case SchemaObject.FUNCTION:
            RoutineSchema routine = (RoutineSchema) set.getObject(name.name);
            if (routine == null) {
                routine = new RoutineSchema(name.type, name);
                routine.addSpecificRoutine(database, (Routine) object);
                set.add(routine);
            } else {
                ((Routine) object).setName(routine.getName());
                routine.addSpecificRoutine(database, (Routine) object);
            }
            addReferences(object);
            return;
    }
    set.add(object);
    addReferences(object);
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 14 with HsqlName

use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.

the class DatabaseInformationFull method ROLE_ROUTINE_GRANTS.

Table ROLE_ROUTINE_GRANTS() {
    Table t = sysTables[ROLE_ROUTINE_GRANTS];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[ROLE_ROUTINE_GRANTS]);
        // not null
        addColumn(t, "GRANTOR", SQL_IDENTIFIER);
        // not null
        addColumn(t, "GRANTEE", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
        // not null
        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, "PRIVILEGE_TYPE", CHARACTER_DATA);
        addColumn(t, "IS_GRANTABLE", YES_OR_NO);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROLE_ROUTINE_GRANTS].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
    Result rs = sys.executeDirectStatement("SELECT GRANTOR, GRANTEE, SPECIFIC_CATALOG, SPECIFIC_SCHEMA, " + "SPECIFIC_NAME, ROUTINE_CATALOG, ROUTINE_SCHEMA, ROUTINE_NAME, " + "PRIVILEGE_TYPE, IS_GRANTABLE, 'NO' " + "FROM INFORMATION_SCHEMA.ROUTINE_PRIVILEGES " + "JOIN INFORMATION_SCHEMA.APPLICABLE_ROLES ON GRANTEE = ROLE_NAME;");
    t.insertSys(store, rs);
    sys.close();
    // Column number mappings
    final int grantor = 0;
    final int grantee = 1;
    final int table_name = 2;
    final int specific_catalog = 3;
    final int specific_schema = 4;
    final int specific_name = 5;
    final int routine_catalog = 6;
    final int routine_schema = 7;
    final int routine_name = 8;
    final int privilege_type = 9;
    final int is_grantable = 10;
    //
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) Constraint(org.hsqldb_voltpatches.Constraint) Session(org.hsqldb_voltpatches.Session) Result(org.hsqldb_voltpatches.result.Result)

Example 15 with HsqlName

use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.

the class DatabaseInformationFull method SCHEMATA.

/**
     * SCHEMATA<p>
     *
     * <b>Function</b><p>
     *
     * The SCHEMATA view has one row for each accessible schema. <p>
     *
     * <b>Definition</b><p>
     *
     * <pre class="SqlCodeExample">
     * CREATE TABLE SCHEMATA (
     *      CATALOG_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER,
     *      SCHEMA_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER,
     *      SCHEMA_OWNER INFORMATION_SCHEMA.SQL_IDENTIFIER
     *          CONSTRAINT SCHEMA_OWNER_NOT_NULL
     *              NOT NULL,
     *      DEFAULT_CHARACTER_SET_CATALOG INFORMATION_SCHEMA.SQL_IDENTIFIER
     *          CONSTRAINT DEFAULT_CHARACTER_SET_CATALOG_NOT_NULL
     *              NOT NULL,
     *      DEFAULT_CHARACTER_SET_SCHEMA INFORMATION_SCHEMA.SQL_IDENTIFIER
     *          CONSTRAINT DEFAULT_CHARACTER_SET_SCHEMA_NOT_NULL
     *              NOT NULL,
     *      DEFAULT_CHARACTER_SET_NAME INFORMATION_SCHEMA.SQL_IDENTIFIER
     *          CONSTRAINT DEFAULT_CHARACTER_SET_NAME_NOT_NULL
     *              NOT NULL,
     *      SQL_PATH INFORMATION_SCHEMA.CHARACTER_DATA,
     *
     *      CONSTRAINT SCHEMATA_PRIMARY_KEY
     *          PRIMARY KEY ( CATALOG_NAME, SCHEMA_NAME ),
     *      CONSTRAINT SCHEMATA_FOREIGN_KEY_AUTHORIZATIONS
     *          FOREIGN KEY ( SCHEMA_OWNER )
     *              REFERENCES AUTHORIZATIONS,
     *      CONSTRAINT SCHEMATA_FOREIGN_KEY_CATALOG_NAMES
     *          FOREIGN KEY ( CATALOG_NAME )
     *              REFERENCES CATALOG_NAMES
     *      )
     * </pre>
     *
     * <b>Description</b><p>
     *
     * <ol>
     *      <li>The value of CATALOG_NAME is the name of the catalog of the
     *          schema described by this row.<p>
     *
     *      <li>The value of SCHEMA_NAME is the unqualified schema name of
     *          the schema described by this row.<p>
     *
     *      <li>The values of SCHEMA_OWNER are the authorization identifiers
     *          that own the schemata.<p>
     *
     *      <li>The values of DEFAULT_CHARACTER_SET_CATALOG,
     *          DEFAULT_CHARACTER_SET_SCHEMA, and DEFAULT_CHARACTER_SET_NAME
     *          are the catalog name, unqualified schema name, and qualified
     *          identifier, respectively, of the default character set for
     *          columns and domains in the schemata.<p>
     *
     *      <li>Case:<p>
     *          <ul>
     *              <li>If &lt;schema path specification&gt; was specified in
     *                  the &lt;schema definition&gt; that defined the schema
     *                  described by this row and the character representation
     *                  of the &lt;schema path specification&gt; can be
     *                  represented without truncation, then the value of
     *                  SQL_PATH is that character representation.<p>
     *
     *              <li>Otherwise, the value of SQL_PATH is the null value.
     *         </ul>
     * </ol>
     *
     * @return Table
     */
Table SCHEMATA() {
    Table t = sysTables[SCHEMATA];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[SCHEMATA]);
        addColumn(t, "CATALOG_NAME", SQL_IDENTIFIER);
        addColumn(t, "SCHEMA_NAME", SQL_IDENTIFIER);
        addColumn(t, "SCHEMA_OWNER", SQL_IDENTIFIER);
        addColumn(t, "DEFAULT_CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "DEFAULT_CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "DEFAULT_CHARACTER_SET_NAME", SQL_IDENTIFIER);
        addColumn(t, "SQL_PATH", CHARACTER_DATA);
        // order: CATALOG_NAME, SCHEMA_NAME
        // false PK, as rows may have NULL CATALOG_NAME
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SCHEMATA].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // Intermediate holders
    Iterator schemas;
    String schema;
    String dcsSchema = SqlInvariants.INFORMATION_SCHEMA;
    String dcsName = ValuePool.getString("UTF16");
    String sqlPath = null;
    Grantee user = session.getGrantee();
    Object[] row;
    // column number mappings
    final int schema_catalog = 0;
    final int schema_name = 1;
    final int schema_owner = 2;
    final int default_character_set_catalog = 3;
    final int default_character_set_schema = 4;
    final int default_character_set_name = 5;
    final int sql_path = 6;
    // Initialization
    schemas = database.schemaManager.fullSchemaNamesIterator();
    // Do it.
    while (schemas.hasNext()) {
        schema = (String) schemas.next();
        if (!user.hasSchemaUpdateOrGrantRights(schema)) {
            continue;
        }
        row = t.getEmptyRowData();
        row[schema_catalog] = database.getCatalogName().name;
        row[schema_name] = schema;
        row[schema_owner] = database.schemaManager.toSchemaOwner(schema).getNameString();
        row[default_character_set_catalog] = database.getCatalogName().name;
        row[default_character_set_schema] = dcsSchema;
        row[default_character_set_name] = dcsName;
        row[sql_path] = sqlPath;
        t.insertSys(store, row);
    }
    return t;
}
Also used : Grantee(org.hsqldb_voltpatches.rights.Grantee) 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) Constraint(org.hsqldb_voltpatches.Constraint)

Aggregations

HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)204 Table (org.hsqldb_voltpatches.Table)86 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)73 TextTable (org.hsqldb_voltpatches.TextTable)65 Iterator (org.hsqldb_voltpatches.lib.Iterator)64 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)61 SchemaObject (org.hsqldb_voltpatches.SchemaObject)60 Constraint (org.hsqldb_voltpatches.Constraint)59 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)48 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)22 HsqlException (org.hsqldb_voltpatches.HsqlException)20 Type (org.hsqldb_voltpatches.types.Type)20 Session (org.hsqldb_voltpatches.Session)16 Result (org.hsqldb_voltpatches.result.Result)15 Grantee (org.hsqldb_voltpatches.rights.Grantee)12 NumberType (org.hsqldb_voltpatches.types.NumberType)10 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 Index (org.hsqldb_voltpatches.index.Index)6