Search in sources :

Example 46 with HsqlName

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

the class UserManager method removeSchemaReference.

public synchronized void removeSchemaReference(String schemaName) {
    for (int i = 0; i < userList.size(); i++) {
        User user = (User) userList.get(i);
        HsqlName schema = user.getInitialSchema();
        if (schema == null) {
            continue;
        }
        if (schemaName.equals(schema.name)) {
            user.setInitialSchema(null);
        }
    }
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 47 with HsqlName

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

the class ParserCommand method compileLock.

private Statement compileLock() {
    read();
    readThis(Tokens.TABLE);
    OrderedHashSet readSet = new OrderedHashSet();
    OrderedHashSet writeSet = new OrderedHashSet();
    outerloop: while (true) {
        Table table = readTableName();
        switch(token.tokenType) {
            case Tokens.READ:
                read();
                readSet.add(table.getName());
                break;
            case Tokens.WRITE:
                read();
                writeSet.add(table.getName());
                break;
            default:
                throw unexpectedToken();
        }
        if (token.tokenType == Tokens.COMMA) {
            read();
            continue;
        }
        break outerloop;
    }
    HsqlName[] readTableNames = new HsqlName[readSet.size()];
    readSet.toArray(readTableNames);
    HsqlName[] writeTableNames = new HsqlName[writeSet.size()];
    writeSet.toArray(writeTableNames);
    Statement cs = new StatementSession(StatementTypes.TRANSACTION_LOCK_TABLE, readTableNames, writeTableNames);
    return cs;
}
Also used : OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 48 with HsqlName

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

the class ParserDDL method compileAlterTableAddForeignKeyConstraint.

Statement compileAlterTableAddForeignKeyConstraint(Table table, HsqlName name) {
    if (name == null) {
        name = database.nameManager.newAutoName("FK", table.getSchemaName(), table.getName(), SchemaObject.CONSTRAINT);
    }
    OrderedHashSet set = readColumnNames(false);
    Constraint c = readFKReferences(table, name, set);
    HsqlName mainTableName = c.getMainTableName();
    c.core.mainTable = database.schemaManager.getTable(session, mainTableName.name, mainTableName.schema.name);
    c.setColumnsIndexes(table);
    String sql = getLastPart();
    Object[] args = new Object[] { c };
    return new StatementSchema(sql, StatementTypes.ALTER_TABLE, args, c.core.mainTableName, table.getName());
}
Also used : OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 49 with HsqlName

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

the class ParserDDL method compileCreateView.

StatementSchema compileCreateView() {
    read();
    HsqlName name = readNewSchemaObjectName(SchemaObject.VIEW);
    name.setSchemaIfNull(session.getCurrentSchemaHsqlName());
    HsqlName[] colList = null;
    if (token.tokenType == Tokens.OPENBRACKET) {
        colList = readColumnNames(name);
    }
    readThis(Tokens.AS);
    startRecording();
    int position = getPosition();
    QueryExpression queryExpression;
    try {
        queryExpression = XreadQueryExpression();
    } catch (HsqlException e) {
        queryExpression = XreadJoinedTable();
    }
    Token[] statement = getRecordedStatement();
    String sql = getLastPart(position);
    int check = SchemaObject.ViewCheckModes.CHECK_NONE;
    if (token.tokenType == Tokens.WITH) {
        read();
        check = SchemaObject.ViewCheckModes.CHECK_CASCADE;
        if (readIfThis(Tokens.LOCAL)) {
            check = SchemaObject.ViewCheckModes.CHECK_LOCAL;
        } else {
            readIfThis(Tokens.CASCADED);
        }
        readThis(Tokens.CHECK);
        readThis(Tokens.OPTION);
    }
    View view = new View(session, database, name, colList, sql, check);
    queryExpression.setAsTopLevel();
    queryExpression.setView(view);
    queryExpression.resolve(session);
    view.compile(session);
    checkSchemaUpdateAuthorisation(name.schema);
    database.schemaManager.checkSchemaObjectNotExists(name);
    String statementSQL = Token.getSQL(statement);
    view.statement = statementSQL;
    String fullSQL = getLastPart();
    Object[] args = new Object[] { view };
    return new StatementSchema(fullSQL, StatementTypes.CREATE_VIEW, args, null, null);
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 50 with HsqlName

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

the class SchemaManager method getTableIndex.

/**
     *  Returns index of a table or view in the HashMappedList that
     *  contains the table objects for this Database.
     *
     * @param  table the Table object
     * @return  the index of the specified table or view, or -1 if not found
     */
int getTableIndex(Table table) {
    Schema schema = (Schema) schemaMap.get(table.getSchemaName().name);
    if (schema == null) {
        return -1;
    }
    HsqlName name = table.getName();
    return schema.tableList.getIndex(name.name);
}
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