23: def column_info
24: a = []
25: 0.upto(@pg_result.num_fields-1) do |i|
26: str = @pg_result.fname(i)
27:
28: typeinfo = nil
29:
30: begin
31: typmod = @pg_result.fmod(i)
32: rescue
33: end
34:
35: if typmod and typ = @pg_result.ftype(i)
36: res = @db._exec("select format_type(#{typ}, #{typmod})")
37: typeinfo = DBI::DBD::Pg.parse_type(res[0].values[0])
38: end
39:
40: h = { "name" => str }.merge(@db.type_map[@pg_result.ftype(i)])
41:
42: if typeinfo
43: h["precision"] = typeinfo[:size]
44: h["scale"] = typeinfo[:decimal]
45: h["type"] = typeinfo[:type]
46: h["array_of_type"] = typeinfo[:array]
47:
48: if typeinfo[:array]
49: h['dbi_type'] =
50: DBI::DBD::Pg::Type::Array.new(
51: DBI::TypeUtil.type_name_to_module(typeinfo[:type])
52: )
53: end
54: end
55:
56: a.push h
57: end
58:
59: return a
60: end