# File lib/dbd/pg/database.rb, line 349
349:     def load_type_map
350:         @type_map = Hash.new
351: 
352:         res = _exec("SELECT oid, typname, typelem FROM pg_type WHERE typtype = 'b'")
353: 
354:         res.each do |row|
355:             rowtype = parse_type_name(row["typname"])
356:             @type_map[row["oid"].to_i] = 
357:                 { 
358:                     "type_name" => row["typname"],
359:                     "dbi_type" => 
360:                         if rowtype
361:                             rowtype
362:                         elsif row["typname"] =~ /^_/ and row["typelem"].to_i > 0 then
363:                             # arrays are special and have a subtype, as an
364:                             # oid held in the "typelem" field.
365:                             # Since we may not have a mapping for the
366:                             # subtype yet, defer by storing the typelem
367:                             # integer as a base type in a constructed
368:                             # Type::Array object. dirty, i know.
369:                             #
370:                             # These array objects will be reconstructed
371:                             # after all rows are processed and therefore
372:                             # the oid -> type mapping is complete.
373:                             # 
374:                             DBI::DBD::Pg::Type::Array.new(row["typelem"].to_i)
375:                         else
376:                             DBI::Type::Varchar
377:                         end
378:                 }
379:         end 
380:         # additional conversions
381:         @type_map[705]  ||= DBI::Type::Varchar       # select 'hallo'
382:         @type_map[1114] ||= DBI::Type::Timestamp # TIMESTAMP WITHOUT TIME ZONE
383: 
384:         # remap array subtypes
385:         @type_map.each_key do |key|
386:             if @type_map[key]["dbi_type"].class == DBI::DBD::Pg::Type::Array
387:                 oid = @type_map[key]["dbi_type"].base_type
388:                 if @type_map[oid]
389:                     @type_map[key]["dbi_type"] = DBI::DBD::Pg::Type::Array.new(@type_map[oid]["dbi_type"])
390:                 else
391:                     # punt
392:                     @type_map[key] = DBI::DBD::Pg::Type::Array.new(DBI::Type::Varchar)
393:                 end
394:             end
395:         end
396:     end