# File lib/rubyrep/connection_extenders/postgresql_extender.rb, line 202
      def columns(table_name, name = nil)
        jdbc_connection = @connection.connection # the actual JDBC DatabaseConnection
        @unquoted_schema ||= select_one("show search_path")['search_path']

        # check if table exists
        table_results = jdbc_connection.meta_data.get_tables(
          jdbc_connection.catalog,
          @unquoted_schema,
          table_name,
          ["TABLE","VIEW","SYNONYM"].to_java(:string)
        )
        table_exists = table_results.next
        table_results.close
        raise "table '#{table_name}' not found" unless table_exists

        # get ResultSet for columns of table
        column_results = jdbc_connection.meta_data.get_columns(
          jdbc_connection.catalog,
          @unquoted_schema,
          table_name,
          nil
        )
        
        # create the Column objects
        columns = []
        while column_results.next
          
          # generate type clause
          type_clause = column_results.get_string('TYPE_NAME')
          precision = column_results.get_int('COLUMN_SIZE')
          scale = column_results.get_int('DECIMAL_DIGITS')
          if precision > 0
            type_clause += "(#{precision}#{scale > 0 ? ",#{scale}" : ""})"
          end

          # create column
          columns << ::ActiveRecord::ConnectionAdapters::JdbcColumn.new(
            @config,
            column_results.get_string('COLUMN_NAME'),
            column_results.get_string('COLUMN_DEF'),
            type_clause,
            column_results.get_string('IS_NULLABLE').strip == "NO"
          )
        end
        column_results.close
        
        columns
      end