use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class ParserRoutine method readSelectSingleRowStatement.
private Statement readSelectSingleRowStatement(RangeVariable[] rangeVars) {
OrderedHashSet variableNames = new OrderedHashSet();
QuerySpecification select = XreadSelect();
readThis(Tokens.INTO);
readColumnNamesForSelectInto(variableNames, rangeVars);
XreadTableExpression(select);
select.setAsTopLevel();
select.resolve(session);
int[] indexes = new int[variableNames.size()];
ColumnSchema[] variables = new ColumnSchema[variableNames.size()];
Statement statement = new StatementSimple(StatementTypes.ASSIGNMENT, variables, null, indexes);
return statement;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class TableWorks method dropColumn.
void dropColumn(int colIndex, boolean cascade) {
OrderedHashSet constraintNameSet = new OrderedHashSet();
OrderedHashSet dependentConstraints = table.getDependentConstraints(colIndex);
OrderedHashSet cascadingConstraints = table.getContainingConstraints(colIndex);
OrderedHashSet indexNameSet = table.getContainingIndexNames(colIndex);
HsqlName columnName = table.getColumn(colIndex).getName();
OrderedHashSet referencingObjects = database.schemaManager.getReferencingObjects(table.getName(), columnName);
if (table.isText() && !table.isEmpty(session)) {
throw Error.error(ErrorCode.X_S0521);
}
if (!cascade) {
if (!cascadingConstraints.isEmpty()) {
Constraint c = (Constraint) cascadingConstraints.get(0);
HsqlName name = c.getName();
throw Error.error(ErrorCode.X_42536, name.getSchemaQualifiedStatementName());
}
if (!referencingObjects.isEmpty()) {
for (int i = 0; i < referencingObjects.size(); i++) {
HsqlName name = (HsqlName) referencingObjects.get(i);
throw Error.error(ErrorCode.X_42536, name.getSchemaQualifiedStatementName());
}
}
}
dependentConstraints.addAll(cascadingConstraints);
cascadingConstraints.clear();
OrderedHashSet tableSet = new OrderedHashSet();
for (int i = 0; i < dependentConstraints.size(); i++) {
Constraint c = (Constraint) dependentConstraints.get(i);
if (c.constType == Constraint.FOREIGN_KEY) {
tableSet.add(c.getMain());
constraintNameSet.add(c.getMainName());
constraintNameSet.add(c.getRefName());
indexNameSet.add(c.getRefIndex().getName());
}
if (c.constType == Constraint.MAIN) {
tableSet.add(c.getRef());
constraintNameSet.add(c.getMainName());
constraintNameSet.add(c.getRefName());
indexNameSet.add(c.getRefIndex().getName());
}
constraintNameSet.add(c.getName());
}
tableSet = makeNewTables(tableSet, constraintNameSet, indexNameSet);
Table tn = table.moveDefinition(session, table.tableType, null, null, null, colIndex, -1, constraintNameSet, indexNameSet);
tn.moveData(session, table, colIndex, -1);
//
database.schemaManager.removeSchemaObjects(referencingObjects);
database.schemaManager.removeSchemaObjects(constraintNameSet);
setNewTableInSchema(tn);
setNewTablesInSchema(tableSet);
updateConstraints(tn, emptySet);
updateConstraints(tableSet, constraintNameSet);
database.persistentStoreCollection.releaseStore(table);
database.schemaManager.recompileDependentObjects(tableSet);
database.schemaManager.recompileDependentObjects(tn);
table = tn;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class Table method updateConstraintPath.
void updateConstraintPath() {
if (fkMainConstraints.length == 0) {
return;
}
OrderedHashSet list = new OrderedHashSet();
getConstraintPath(defaultColumnMap, list);
if (list.size() == 0) {
return;
}
fkPath = new Constraint[list.size()];
list.toArray(fkPath);
for (int i = 0; i < fkPath.length; i++) {
Constraint c = fkPath[i];
HsqlName tableName = c.getMain().getName();
if (c.getMain() != database.schemaManager.getUserTable(null, tableName)) {
throw Error.runtimeError(ErrorCode.U_S0500, "table constraint");
}
tableName = c.getRef().getName();
if (c.getRef() != database.schemaManager.getUserTable(null, tableName)) {
throw Error.runtimeError(ErrorCode.U_S0500, "table constraint");
}
}
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class Table method getReferences.
@Override
public OrderedHashSet getReferences() {
OrderedHashSet set = new OrderedHashSet();
for (int i = 0; i < colTypes.length; i++) {
if (colTypes[i].isDomainType() || colTypes[i].isDistinctType()) {
HsqlName name = ((SchemaObject) colTypes[i]).getName();
set.add(name);
}
}
return set;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class TableWorks method addLimitConstraint.
/* addUniqueExprConstraint */
// A VoltDB extension to support LIMIT PARTITION ROWS
void addLimitConstraint(Constraint c) {
// Find any pre-existing LIMIT constraint on the table and remove it
for (Constraint cst : table.constraintList) {
if (cst.getConstraintType() == Constraint.LIMIT) {
OrderedHashSet constraintNameSet = new OrderedHashSet();
HsqlName name = cst.getName();
constraintNameSet.add(name);
updateConstraints(table, constraintNameSet);
database.schemaManager.removeSchemaObject(name);
// Highlander rules for Constraint.LIMIT
break;
}
}
table.addConstraint(c);
database.schemaManager.addSchemaObject(c);
}
Aggregations