ConstraintDescriptorList cdl,
Dependent dependent
)
throws StandardException
{
CompilerContext compilerContext = getCompilerContext();
int cdlSize = cdl.size();
for (int index = 0; index < cdlSize; index++)
{
ConstraintDescriptor cd = cdl.elementAt(index);
/*
** The dependent now depends on this constraint.
** the default dependent is the statement
** being compiled.
*/
if (dependent == null)
{
compilerContext.createDependency(cd);
}
else
{
compilerContext.createDependency(dependent, cd);
}
/*
** We are also dependent on all referencing keys --
** if one of them is deleted, we'll have to recompile.
** Also, if there is a BULK_INSERT on the table
** we are going to scan to validate the constraint,
** the index number will change, so we'll add a
** dependency on all tables we will scan.
*/
if (cd instanceof ReferencedKeyConstraintDescriptor)
{
ConstraintDescriptorList fkcdl = dd.getActiveConstraintDescriptors
( ((ReferencedKeyConstraintDescriptor)cd).getForeignKeyConstraints(ConstraintDescriptor.ENABLED) );
int fklSize = fkcdl.size();
for (int inner = 0; inner < fklSize; inner++)
{
ConstraintDescriptor fkcd = fkcdl.elementAt(inner);
if (dependent == null)
{
compilerContext.createDependency(fkcd);
compilerContext.createDependency(fkcd.getTableDescriptor());
}
else
{
compilerContext.createDependency(dependent, fkcd);
compilerContext.createDependency(dependent, fkcd.getTableDescriptor());
}
}
}
else if (cd instanceof ForeignKeyConstraintDescriptor)
{
ForeignKeyConstraintDescriptor fkcd = (ForeignKeyConstraintDescriptor) cd;
if (dependent == null)
{
compilerContext.createDependency(fkcd.getReferencedConstraint().getTableDescriptor());
}
else
{
compilerContext.createDependency(dependent,
fkcd.getReferencedConstraint().getTableDescriptor());
}
}
}
}