This file is indexed.

/usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb is in ruby-dbd-odbc 0.2.5+gem2deb-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#
# See DBI::BaseStatement.
#
class DBI::DBD::ODBC::Statement < DBI::BaseStatement
    def initialize(handle, statement)
        @statement = statement
        @handle = handle
        @params = []
        @arr = []
    end

    #
    # See DBI::BaseStatement#bind_param. This method will also raise
    # DBI::InterfaceError if +param+ is not a Fixnum, to prevent incorrect
    # binding.
    #
    def bind_param(param, value, attribs)
        raise DBI::InterfaceError, "only ? parameters supported" unless param.is_a? Fixnum
        @params[param-1] = value
    end

    def execute
        @handle.execute(*@params)
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    def finish
        @handle.drop
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    def cancel
        @handle.cancel
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    def fetch
        convert_row(@handle.fetch)
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    #
    # See DBI::BaseStatement#fetch_scroll.
    #
    # ODBC has a native version of this method and the constnats in the ODBC
    # driver themselves are supported. If you'd prefer to use DBI constants
    # (recommended), you can use these which map to the ODBC functionality:
    #
    # * DBI::SQL_FETCH_FIRST
    # * DBI::SQL_FETCH_LAST
    # * DBI::SQL_FETCH_NEXT
    # * DBI::SQL_FETCH_PRIOR
    # * DBI::SQL_FETCH_ABSOLUTE
    # * DBI::SQL_FETCH_RELATIVE
    #
    def fetch_scroll(direction, offset)
        direction = case direction
                    when DBI::SQL_FETCH_FIRST    then ::ODBC::SQL_FETCH_FIRST
                    when DBI::SQL_FETCH_LAST     then ::ODBC::SQL_FETCH_LAST
                    when DBI::SQL_FETCH_NEXT     then ::ODBC::SQL_FETCH_NEXT
                    when DBI::SQL_FETCH_PRIOR    then ::ODBC::SQL_FETCH_PRIOR
                    when DBI::SQL_FETCH_ABSOLUTE then ::ODBC::SQL_FETCH_ABSOLUTE
                    when DBI::SQL_FETCH_RELATIVE then ::ODBC::SQL_FETCH_RELATIVE
                    else
                        direction
                    end

        convert_row(@handle.fetch_scroll(direction, offset))
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    #
    # See DBI::BaseStatement#column_info. These additional attributes are also
    # supported:
    #
    # * table: the table this column came from, if available.
    # * nullable: boolean, true if NULL is accepted as a value in this column.
    # * searchable: FIXME DOCUMENT
    # * length: FIXME DOCUMENT
    # * unsigned: For numeric columns, whether or not the result value is signed.
    #
    def column_info
        info = []
        @handle.columns(true).each do |col|
            info << {
                'name'       => col.name, 
                'table'      => col.table,
                'nullable'   => col.nullable,
                'searchable' => col.searchable,
                'precision'  => col.precision,
                'scale'      => col.scale,
                'sql_type'   => col.type,
                'type_name'  => DBI::SQL_TYPE_NAMES[col.type],
                'length'     => col.length,
                'unsigned'   => col.unsigned
            }
        end
        info
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    #
    # See DBI::BaseStatement#rows.
    #
    # For queries which DBI::SQL.query? returns true, will explicitly return 0.
    # Otherwise, it will return the row processed count.
    #
    def rows
        return 0 if DBI::SQL.query?(@statement)
        return @handle.nrows
    rescue DBI::DBD::ODBC::ODBCErr => err
        raise DBI::DatabaseError.new(err.message)
    end

    private # -----------------------------------

    # convert the ODBC datatypes to DBI datatypes
    def convert_row(row)
        return nil if row.nil?
        row.collect do |col|
            case col
            when nil
                nil
            when ODBC::TimeStamp
                DBI::Type::Timestamp.create col.year, col.month, col.day, col.hour, col.minute, col.second
            else
                col.to_s
            end
        end
    end 
end