protected override void ExecuteStatement(ExecutionContext context)
{
if (!context.DirectAccess.ObjectExists(DbObjectType.Routine, FunctionName)) {
if (IfExists)
return;
throw new ObjectNotFoundException(FunctionName);
}
//if (!context.User.CanDrop(DbObjectType.Routine, FunctionName))
// throw new MissingPrivilegesException(context.User.Name, FunctionName, Privileges.Drop);
if (context.DirectAccess.IsSystemFunction(new Invoke(FunctionName), context.Request))
throw new InvalidOperationException(String.Format("Cannot drop the system function '{0}'.", FunctionName));
var routine = context.DirectAccess.GetObject(DbObjectType.Routine, FunctionName);
if (!(routine is IFunction))
throw new InvalidOperationException(String.Format("The routine '{0}' is not a function.", FunctionName));
if (!context.DirectAccess.DropObject(DbObjectType.Routine, FunctionName))
throw new InvalidOperationException(String.Format("Unable to drop the function '{0}' from the system.", FunctionName));
}