David E. Wheeler wrote:
On Sep 8, 2009, at 8:45 AM, Andrew Dunstan wrote:
No doubt it's possible to have DBD::Pg learn about user-defined
composites and arrays of them, although the code for doing so might
get a bit elaborate, but how would it handle a type defined in C, the
representation of which it has no way of knowing about at all? I
think we have to accept that the existence of type extensibility in
Postgres means that there will be at least some types that DBD::Pg
has to treat as opaque bits of text.
Is there not a simple way to tell via the protocol what the data type
of each column is, and whether or not it is an array of that type?
DBD::Pg already does the former, to decide if something should be
decoded to utf8, but the list of types is supports is hard-coded in
the driver.
The protocol doesn't know anything about arrays or composites, AFAIK. If
it passes the type oid, it will be the oid of the array or composite
type, but the receiver has no way in the protocol of knowing that the
type is such an animal. Of course, it is possible to look that up in the
catalog (see pg_type columns typtype, typelem and typarray). But, as I
pointed out above, none of that helps you determine the info for a type
that is user-defined in C.
See RowDescription section in
<http://www.postgresql.org/docs/current/static/protocol-message-formats.html>
cheers
andrew