use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class TransactionManager method lockTablesTPL.
void lockTablesTPL(Session session, Statement cs) {
if (cs == null || session.abortTransaction) {
return;
}
HsqlName[] nameList = cs.getTableNamesForWrite();
for (int i = 0; i < nameList.length; i++) {
HsqlName name = nameList[i];
if (name.schema == SqlInvariants.SYSTEM_SCHEMA_HSQLNAME) {
continue;
}
tableWriteLocks.put(name, session);
}
nameList = cs.getTableNamesForRead();
for (int i = 0; i < nameList.length; i++) {
HsqlName name = nameList[i];
if (name.schema == SqlInvariants.SYSTEM_SCHEMA_HSQLNAME) {
continue;
}
tableReadLocks.put(name, session);
}
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName 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.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class TableWorks method addUniqueExprConstraint.
/**
* A VoltDB extended variant of addUniqueConstraint that supports indexed generalized non-column expressions.
* @param cols
* @param indexExprs
* @param name HsqlName
*/
public void addUniqueExprConstraint(int[] cols, Expression[] indexExprs, HsqlName name, boolean isAutogeneratedName, boolean assumeUnique) {
database.schemaManager.checkSchemaObjectNotExists(name);
if (table.getUniqueConstraintForExprs(indexExprs) != null) {
throw Error.error(ErrorCode.X_42522);
}
// create an autonamed index
HsqlName indexname = database.nameManager.newAutoName("IDX", name.name, table.getSchemaName(), table.getName(), SchemaObject.INDEX);
Index exprIndex = table.createIndexStructure(indexname, cols, null, null, true, true, false);
exprIndex = exprIndex.withExpressions(indexExprs);
Constraint constraint = new Constraint(name, isAutogeneratedName, table, exprIndex, Constraint.UNIQUE).setAssumeUnique(assumeUnique);
Table tn = table.moveDefinition(session, table.tableType, null, constraint, exprIndex, -1, 0, emptySet, emptySet);
tn.moveData(session, table, -1, 0);
database.persistentStoreCollection.releaseStore(table);
table = tn;
database.schemaManager.addSchemaObject(constraint);
setNewTableInSchema(table);
updateConstraints(table, emptySet);
database.schemaManager.recompileDependentObjects(table);
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName 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.HsqlNameManager.HsqlName 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;
}
Aggregations