use of org.apache.derby.impl.sql.execute.ConstraintConstantAction in project derby by apache.
the class AlterTableNode method prepConstantAction.
/**
* Generate arguments to constant action. Called by makeConstantAction() in this class and in
* our subclass RepAlterTableNode.
*
* @exception StandardException Thrown on failure
*/
private void prepConstantAction() throws StandardException {
if (tableElementList != null) {
genColumnInfo();
}
if (numConstraints > 0) {
conActions = new ConstraintConstantAction[numConstraints];
tableElementList.genConstraintActions(false, conActions, getRelativeName(), schemaDescriptor, getDataDictionary());
for (int conIndex = 0; conIndex < conActions.length; conIndex++) {
ConstraintConstantAction cca = conActions[conIndex];
if (cca instanceof CreateConstraintConstantAction) {
int constraintType = cca.getConstraintType();
if (constraintType == DataDictionary.PRIMARYKEY_CONSTRAINT) {
DataDictionary dd = getDataDictionary();
// Check to see if a constraint of the same type
// already exists
ConstraintDescriptorList cdl = dd.getConstraintDescriptors(baseTable);
if (cdl.getPrimaryKey() != null) {
throw StandardException.newException(SQLState.LANG_ADD_PRIMARY_KEY_FAILED1, baseTable.getQualifiedName());
}
}
}
}
}
}
Aggregations