}
void addColumn(ColumnSchema column, int colIndex,
HsqlArrayList constraints) {
Index index = null;
Table originalTable = table;
Constraint mainConstraint = null;
boolean addFK = false;
boolean addUnique = false;
boolean addCheck = false;
checkAddColumn(column);
Constraint c = (Constraint) constraints.get(0);
if (c.getConstraintType() == Constraint.PRIMARY_KEY) {
c.core.mainCols = new int[]{ colIndex };
database.schemaManager.checkSchemaObjectNotExists(c.getName());
if (table.hasPrimaryKey()) {
throw Error.error(ErrorCode.X_42530);
}
addUnique = true;
} else {
c = null;
}
table = table.moveDefinition(session, table.tableType, column, c,
null, colIndex, 1, emptySet, emptySet);
for (int i = 1; i < constraints.size(); i++) {
c = (Constraint) constraints.get(i);
switch (c.constType) {
case Constraint.UNIQUE : {
if (addUnique) {
throw Error.error(ErrorCode.X_42522);
}
addUnique = true;
c.core.mainCols = new int[]{ colIndex };
database.schemaManager.checkSchemaObjectNotExists(
c.getName());
HsqlName indexName =
database.nameManager.newAutoName("IDX",
c.getName().name,
table.getSchemaName(),
table.getName(),
SchemaObject.INDEX);
// create an autonamed index
index = table.createAndAddIndexStructure(indexName,
c.getMainColumns(), null, null, true, true, false);
// A VoltDB extension to support the assume unique attribute
index = index.setAssumeUnique(c.assumeUnique);
// End of VoltDB extension
c.core.mainTable = table;
c.core.mainIndex = index;
table.addConstraint(c);