private void dropSubKeyConstraint(ConstraintDescriptor constraint, TransactionController tc)
throws StandardException
{
ExecIndexRow keyRow1 = null;
DataValueDescriptor constraintIdOrderable;
TabInfo ti;
int baseNum;
int indexNum;
if (constraint.getConstraintType()
== DataDictionary.FOREIGNKEY_CONSTRAINT)
{
baseNum = SYSFOREIGNKEYS_CATALOG_NUM;
indexNum = SYSFOREIGNKEYSRowFactory.SYSFOREIGNKEYS_INDEX1_ID;
/*
** If we have a foreign key, we need to decrement the
** reference count of the contraint that this FK references.
** We need to do this *before* we drop the foreign key
** because of the way FK.getReferencedConstraint() works.
*/
if (constraint.getConstraintType()
== DataDictionary.FOREIGNKEY_CONSTRAINT)
{
ReferencedKeyConstraintDescriptor refDescriptor =
(ReferencedKeyConstraintDescriptor)
getConstraintDescriptor(
((ForeignKeyConstraintDescriptor)constraint).
getReferencedConstraintId());
if (refDescriptor != null)
{
refDescriptor.decrementReferenceCount();
int[] colsToSet = new int[1];
colsToSet[0] = SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_REFERENCECOUNT;
updateConstraintDescriptor(refDescriptor,
refDescriptor.getUUID(),
colsToSet,
tc);
}
}
}
else
{
baseNum = SYSKEYS_CATALOG_NUM;
indexNum = SYSKEYSRowFactory.SYSKEYS_INDEX1_ID;
}
ti = getNonCoreTI(baseNum);
/* Use constraintIdOrderable in both start
* and stop position for index 1 scan.
*/
constraintIdOrderable = getValueAsDVD(constraint.getUUID());
/* Set up the start/stop position for the scan */
keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
keyRow1.setColumn(1, constraintIdOrderable);
ti.deleteRow( tc, keyRow1, indexNum);
}