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);
}
}
}
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;
}
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());
}
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);
}
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);
}
Aggregations