** we must have just read ourselves in.
** So we will get the corresponding schema
** descriptor from the data dictionary.
*/
SchemaDescriptor tdSd = td.getSchemaDescriptor();
SchemaDescriptor constraintSd =
constraintSchemaName == null ? tdSd : dd.getSchemaDescriptor(constraintSchemaName, tc, true);
/* Get the constraint descriptor for the index, along
* with an exclusive row lock on the row in sys.sysconstraints
* in order to ensure that no one else compiles against the
* index.
*/
if (constraintName == null) // this means "alter table drop primary key"
conDesc = dd.getConstraintDescriptors(td).getPrimaryKey();
else
conDesc = dd.getConstraintDescriptorByName(td, constraintSd, constraintName, true);
// Error if constraint doesn't exist
if (conDesc == null)
{
String errorName = constraintName == null ? "PRIMARY KEY" :
(constraintSd.getSchemaName() + "."+ constraintName);
throw StandardException.newException(SQLState.LANG_DROP_NON_EXISTENT_CONSTRAINT,
errorName,
td.getQualifiedName());
}