if (uniqueConstraint == null) {
throw Error.error(ErrorCode.X_42523);
}
Index mainIndex = uniqueConstraint.getMainIndex();
boolean isForward = c.core.mainTable.getSchemaName()
!= table.getSchemaName();
int offset = session.database.schemaManager.getTableIndex(table);
if (offset != -1
&& offset
< session.database.schemaManager.getTableIndex(
c.core.mainTable)) {
isForward = true;
}
HsqlName refIndexName = session.database.nameManager.newAutoName("IDX",
table.getSchemaName(), table.getName(), SchemaObject.INDEX);
Index index = table.createAndAddIndexStructure(session, refIndexName,
c.core.refCols, null, null, false, true, isForward);
HsqlName mainName = session.database.nameManager.newAutoName("REF",
c.getName().name, table.getSchemaName(), table.getName(),
SchemaObject.INDEX);