(getNodeType() != C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NODE) &&
(getNodeType() != C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NOT_NULL_NODE))
return;
DataDictionary dd = getDataDictionary();
ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
int intArray[] = new int[1];
intArray[0] = columnPosition;
for (int index = 0; index < cdl.size(); index++)
{
ConstraintDescriptor existingConstraint =
cdl.elementAt(index);
if (!(existingConstraint instanceof KeyConstraintDescriptor))
continue;
if (!existingConstraint.columnIntersects(intArray))
continue;
int constraintType = existingConstraint.getConstraintType();
// cannot change the length of a column that is part of a
// foreign key constraint. Must be an exact match between pkey
// and fkey columns.
if ((constraintType == DataDictionary.FOREIGNKEY_CONSTRAINT)
&&
(getNodeType() == C_NodeTypes.MODIFY_COLUMN_TYPE_NODE))
{
throw StandardException.newException(
SQLState.LANG_MODIFY_COLUMN_FKEY_CONSTRAINT, name, existingConstraint.getConstraintName());
}
else
{
// a column that is part of a primary key or unique constraint
// is being made nullable; can't be done.
if ((getNodeType() ==
C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NODE) &&
((existingConstraint.getConstraintType() ==
DataDictionary.PRIMARYKEY_CONSTRAINT) ||
(existingConstraint.getConstraintType() ==
DataDictionary.UNIQUE_CONSTRAINT)))
{
throw StandardException.newException(
SQLState.LANG_MODIFY_COLUMN_EXISTING_CONSTRAINT, name);
}
// unique key or primary key.
ConstraintDescriptorList
refcdl = dd.getForeignKeys(existingConstraint.getUUID());
if (refcdl.size() > 0)
{
throw StandardException.newException(
SQLState.LANG_MODIFY_COLUMN_REFERENCED, name, refcdl.elementAt(0).getConstraintName());
}
// Make the statement dependent on the primary key constraint.
getCompilerContext().createDependency(existingConstraint);
}