anchor.diff:           codec_state :: any()}).
   -record(oid_db,
           {by_oid :: kv(oid(), #type{}),
  -         by_name :: kv(epgsql:type_name(), #type{})}).
  +         by_name :: kv(epgsql:type_name(), oid())}).
   
   -type oid() :: non_neg_integer().
  +%% Row of `typname', `oid', `typarray' from pg_type table.
   -type oid_entry() :: {epgsql:type_name(), Oid :: oid(), ArrayOid :: oid()}.
   -type oid_info() :: {Oid :: oid(), epgsql:type_name(), IsArray :: boolean()}.
   -opaque db() :: #oid_db{}.
   -opaque type_info() :: #type{}.
  -
  --define(RECORD_OID, 2249).
   
   
   %%
  
positive.code:     Types = join(",",
                   [["'", ToBin(TypeName) | "'"]
                    || TypeName <- TypeNames]),
      [<<"SELECT typname, oid::int4, typarray::int4 "
         "FROM pg_type "
         "WHERE typname IN (">>, Types, <<") ORDER BY typname">>].
  
  
negative.code: 
  %% @doc find type by OID
  -spec find_by_oid(oid(), db()) -> type_info() | undefined.
  find_by_oid(Oid, #oid_db{by_oid = Dict}) ->
      kv_get(Oid, Dict, undefined).
  
  