    # File lib/amalgalite/database.rb, line 782
        def remove_aggregate( name, klass_or_arity = nil )
          klass = nil
          case klass_or_arity
          when Integer
            arity = klass_or_arity
          when NilClass
            arity = nil
          else
            klass = klass_or_arity
            arity = klass.new.arity
          end
          to_remove = []
          if arity then
            signature = ::Amalgalite::SQLite3::Database::Function.signature( name, arity )
            db_aggregate = @aggregates[ signature ]
            raise AggregateError, "db aggregate '#{name}' with arity #{arity} does not appear to be defined" unless db_aggregate
            to_remove << db_aggregate
          else
            possibles = @aggregates.values.select { |a| a.new.name == name }
            raise AggregateError, "no db aggregate '#{name}' appears to be defined" if possibles.empty?
            to_remove = possibles
          end

          to_remove.each do |db_aggregate|
            i = db_aggregate.new
            @api.remove_aggregate( i.name, i.arity, db_aggregate )
            @aggregates.delete( i.signature )
          end
        end