Search in sources :

Example 41 with HsqlName

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

the class DatabaseInformationMain method addColumn.

protected final void addColumn(Table t, String name, Type type) {
    HsqlName cn;
    ColumnSchema c;
    cn = database.nameManager.newInfoSchemaColumnName(name, t.getName());
    c = new ColumnSchema(cn, type, true, false, null);
    t.addColumn(c);
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) ColumnSchema(org.hsqldb_voltpatches.ColumnSchema)

Example 42 with HsqlName

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

the class DatabaseInformationFull method SQL_SIZING_PROFILES.

Table SQL_SIZING_PROFILES() {
    Table t = sysTables[SQL_SIZING_PROFILES];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[SQL_SIZING_PROFILES]);
        addColumn(t, "SIZING_ID", CARDINAL_NUMBER);
        addColumn(t, "SIZING_NAME", CHARACTER_DATA);
        addColumn(t, "PROFILE_ID", CARDINAL_NUMBER);
        addColumn(t, "PROFILE_NAME", CHARACTER_DATA);
        addColumn(t, "REQUIRED_VALUE", CARDINAL_NUMBER);
        addColumn(t, "COMMENTS", CHARACTER_DATA);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[SQL_SIZING_PROFILES].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
    /*
                Result rs = sys.executeDirectStatement(
                    "VALUES "
                    + ";");

                t.insertSys(store, rs);
        */
    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) Session(org.hsqldb_voltpatches.Session)

Example 43 with HsqlName

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

the class DatabaseInformationFull method ENABLED_ROLES.

/**
     * ENABLED_ROLES<p>
     *
     * <b>Function</b><p>
     *
     * Identify the enabled roles for the current SQL-session.<p>
     *
     * Definition<p>
     *
     * <pre class="SqlCodeExample">
     * CREATE RECURSIVE VIEW ENABLED_ROLES ( ROLE_NAME ) AS
     *      VALUES ( CURRENT_ROLE )
     *      UNION
     *      SELECT RAD.ROLE_NAME
     *        FROM DEFINITION_SCHEMA.ROLE_AUTHORIZATION_DESCRIPTORS RAD
     *        JOIN ENABLED_ROLES R
     *          ON RAD.GRANTEE = R.ROLE_NAME;
     *
     * GRANT SELECT ON TABLE ENABLED_ROLES
     *    TO PUBLIC WITH GRANT OPTION;
     * </pre>
     */
Table ENABLED_ROLES() {
    Table t = sysTables[ENABLED_ROLES];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[ENABLED_ROLES]);
        addColumn(t, "ROLE_NAME", SQL_IDENTIFIER);
        // true PK
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ENABLED_ROLES].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0 }, true);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // Intermediate holders
    Iterator grantees;
    Grantee grantee;
    Object[] row;
    // initialization
    grantees = session.getGrantee().getAllRoles().iterator();
    while (grantees.hasNext()) {
        grantee = (Grantee) grantees.next();
        row = t.getEmptyRowData();
        row[0] = grantee.getNameString();
        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)

Example 44 with HsqlName

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

the class UserManager method getInitialSchemaSQL.

public String[] getInitialSchemaSQL() {
    HsqlArrayList list = new HsqlArrayList(userList.size());
    for (int i = 0; i < userList.size(); i++) {
        User user = (User) userList.get(i);
        if (user.isSystem) {
            continue;
        }
        HsqlName name = user.getInitialSchema();
        if (name == null) {
            continue;
        }
        list.add(user.getInitialSchemaSQL());
    }
    String[] array = new String[list.size()];
    list.toArray(array);
    return array;
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 45 with HsqlName

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

the class Right method removeDroppedColumns.

void removeDroppedColumns(OrderedHashSet columnSet, Table table) {
    for (int i = 0; i < columnSet.size(); i++) {
        HsqlName name = (HsqlName) columnSet.get(i);
        if (table.findColumn(name.name) >= 0) {
            columnSet.remove(i);
            i--;
        }
    }
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

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