/* Get the alias descriptor. We're responsible for raising
* the error if it isn't found
*/
AliasDescriptor ad = dd.getAliasDescriptor(sd.getUUID().toString(), aliasName, nameSpace);
// RESOLVE - fix error message
if (ad == null)
{
throw StandardException.newException(SQLState.LANG_OBJECT_NOT_FOUND, ad.getAliasType(nameSpace), aliasName);
}
/* Prepare all dependents to invalidate. (This is their chance
* to say that they can't be invalidated. For example, an open
* cursor referencing a table/view that the user is attempting to
* drop.) If no one objects, then invalidate any dependent objects.
* We check for invalidation before we drop the descriptor
* since the descriptor may be looked up as part of
* decoding tuples in SYSDEPENDS.
*/
int invalidationType = 0;
switch (ad.getAliasType())
{
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
invalidationType = DependencyManager.DROP_METHOD_ALIAS;
break;
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
invalidationType = DependencyManager.DROP_SYNONYM;
break;
}
dm.invalidateFor(ad, invalidationType, lcc);
if (ad.getAliasType() == AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR)
{
// Drop the entry from SYSTABLES as well.
DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
TableDescriptor td = ddg.newTableDescriptor(aliasName, sd,
TableDescriptor.SYNONYM_TYPE, TableDescriptor.DEFAULT_LOCK_GRANULARITY);
dd.dropTableDescriptor(td, sd, tc);
}
else
dd.dropAllRoutinePermDescriptors(ad.getUUID(), tc);
/* Drop the alias */
dd.dropAliasDescriptor(ad, tc);
}