# File lib/sqlite3/database.rb, line 116
    def execute sql, bind_vars = [], *args, &block
      # FIXME: This is a terrible hack and should be removed but is required
      # for older versions of rails
      hack = Object.const_defined?(:ActiveRecord) && sql =~ /^PRAGMA index_list/

      if bind_vars.nil? || !args.empty?
        if args.empty?
          bind_vars = []
        else
          bind_vars = [bind_vars] + args
        end

        warn("\#{caller[0]} is calling SQLite3::Database#execute with nil or multiple bind params\nwithout using an array.  Please switch to passing bind parameters as an array.\nSupport for bind parameters as *args will be removed in 2.0.0.\n") if $VERBOSE
      end

      prepare( sql ) do |stmt|
        stmt.bind_params(bind_vars)
        columns = stmt.columns
        stmt    = ResultSet.new(self, stmt).to_a if type_translation

        if block_given?
          stmt.each do |row|
            if @results_as_hash
              yield type_translation ? row : ordered_map_for(columns, row)
            else
              yield row
            end
          end
        else
          if @results_as_hash
            stmt.map { |row|
              h = type_translation ? row : ordered_map_for(columns, row)

              # FIXME UGH TERRIBLE HACK!
              h['unique'] = h['unique'].to_s if hack

              h
            }
          else
            stmt.to_a
          end
        end
      end
    end