    # File lib/sqlite3/database.rb, line 405
        def create_aggregate( name, arity, step=nil, finalize=nil,
          text_rep=Constants::TextRep::ANY, &block )
        # begin
          if block
            proxy = AggregateDefinitionProxy.new
            proxy.instance_eval(&block)
            step ||= proxy.step_callback
            finalize ||= proxy.finalize_callback
          end

          step_callback = proc do |func,*args|
            ctx = @driver.aggregate_context( func )
            unless ctx[:__error]
              begin
                step.call( FunctionProxy.new( @driver, func, ctx ),
                  *args.map{|v| Value.new(self,v)} )
              rescue Exception => e
                ctx[:__error] = e
              end
            end
          end

          finalize_callback = proc do |func|
            ctx = @driver.aggregate_context( func )
            unless ctx[:__error]
              begin
                finalize.call( FunctionProxy.new( @driver, func, ctx ) )
              rescue Exception => e
                @driver.result_error( func,
                  "#{e.message} (#{e.class})", -1 )
              end
            else
              e = ctx[:__error]
              @driver.result_error( func,
                "#{e.message} (#{e.class})", -1 )
            end
          end

          result = @driver.create_function( @handle, name, arity, text_rep, nil,
            nil, step_callback, finalize_callback )
          Error.check( result, self )

          self
        end