use of org.hsqldb_voltpatches.lib.OrderedHashSet 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.lib.OrderedHashSet in project voltdb by VoltDB.
the class ParserDDL method getBaseColumnNames.
/// Collect the names of the unique columns underlying a list of indexed expressions.
private OrderedHashSet getBaseColumnNames(java.util.List<Expression> indexExprs) {
OrderedHashSet set = new OrderedHashSet();
HsqlList col_list = new HsqlArrayList();
for (Expression expression : indexExprs) {
expression.collectAllColumnExpressions(col_list);
}
for (int i = 0; i < col_list.size(); i++) {
String colName = ((ExpressionColumn) col_list.get(i)).columnName;
set.add(colName);
}
return set;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class SchemaManager method getSQLArray.
public String[] getSQLArray() {
OrderedHashSet resolved = new OrderedHashSet();
OrderedHashSet unresolved = new OrderedHashSet();
HsqlArrayList list = new HsqlArrayList();
Iterator schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (isSystemSchema(schema.name.name)) {
continue;
}
if (isLobsSchema(schema.name.name)) {
continue;
}
list.addAll(schema.getSQLArray(resolved, unresolved));
}
while (true) {
Iterator it = unresolved.iterator();
if (!it.hasNext()) {
break;
}
while (it.hasNext()) {
SchemaObject object = (SchemaObject) it.next();
OrderedHashSet references = object.getReferences();
boolean isResolved = true;
for (int j = 0; j < references.size(); j++) {
HsqlName name = (HsqlName) references.get(j);
if (name.type == SchemaObject.COLUMN || name.type == SchemaObject.CONSTRAINT) {
name = name.parent;
}
if (!resolved.contains(name)) {
isResolved = false;
break;
}
}
if (isResolved) {
if (object.getType() == SchemaObject.TABLE) {
list.addAll(((Table) object).getSQL(resolved, unresolved));
} else {
list.add(object.getSQL());
resolved.add(object.getName());
}
it.remove();
}
}
}
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (database.schemaManager.isSystemSchema(schema.name.name)) {
continue;
}
if (database.schemaManager.isLobsSchema(schema.name.name)) {
// continue;
}
list.addAll(schema.getTriggerSQL());
list.addAll(schema.getSequenceRestartSQL());
}
if (defaultSchemaHsqlName != null) {
StringBuffer sb = new StringBuffer();
sb.append(Tokens.T_SET).append(' ').append(Tokens.T_DATABASE);
sb.append(' ').append(Tokens.T_DEFAULT).append(' ');
sb.append(Tokens.T_INITIAL).append(' ').append(Tokens.T_SCHEMA);
sb.append(' ').append(defaultSchemaHsqlName.statementName);
list.add(sb.toString());
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class RoutineSchema method getComponents.
public OrderedHashSet getComponents() {
OrderedHashSet set = new OrderedHashSet();
set.addAll(routines);
return set;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class SchemaManager method checkObjectIsReferenced.
void checkObjectIsReferenced(HsqlName name) {
OrderedHashSet set = getReferencingObjects(name);
HsqlName refName = null;
for (int i = 0; i < set.size(); i++) {
refName = (HsqlName) set.get(i);
if (refName.parent != name) {
break;
}
refName = null;
}
if (refName == null) {
return;
}
throw Error.error(ErrorCode.X_42502, refName.getSchemaQualifiedStatementName());
}
Aggregations