    # File lib/active_record/connection_adapters/postgresql_adapter.rb, line 665
          def indexes(table_name, name = nil)
             schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
             result = query("SELECT distinct i.relname, d.indisunique, d.indkey, t.oid\nFROM pg_class t, pg_class i, pg_index d\nWHERE i.relkind = 'i'\nAND d.indexrelid = i.oid\nAND d.indisprimary = 'f'\nAND t.oid = d.indrelid\nAND t.relname = '\#{table_name}'\nAND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (\#{schemas}) )\nORDER BY i.relname\n", name)

            indexes = []

            indexes = result.map do |row|
              index_name = row[0]
              unique = row[1] == 't'
              indkey = row[2].split(" ")
              oid = row[3]

              columns = query("SELECT a.attname, a.attnum\nFROM pg_attribute a\nWHERE a.attrelid = \#{oid}\nAND a.attnum IN (\#{indkey.join(\",\")})\n", "Columns for index #{row[0]} on #{table_name}").inject({}) {|attlist, r| attlist[r[1]] = r[0]; attlist}

              column_names = indkey.map {|attnum| columns[attnum] }
              IndexDefinition.new(table_name, index_name, unique, column_names)

            end

            indexes
          end