Ticket #147 (new defect)

Opened 7 months ago

Last modified 7 months ago

pqxx::result::column_type should return type name

Reported by: anonymous Assigned to: jtv
Priority: normal Milestone:
Component: portability Version: 2.6
Severity: normal Keywords:
Cc:

Description

Hi,

it should be possible to return the type name for a given column. There are no guarantees that the OID for user defined types will be the same from one creation to another (we experienced this in-house for some types)

Ideally there should be another method for the result class that will return the type name. One can use the following SQL statement to retrieve the column types, names, OID, and type names from the system database:

SELECT a.attnum, a.attname, a.atttypid, t.typname 
   FROM pg_class c, pg_attribute a, pg_type t 
   WHERE c.relname = '$tablename'
   AND a.attnum > 0 AND a.attrelid = c.oid
   AND a.atttypid = t.oid ORDER BY a.attnum;

regards, teodor

Attachments

Change History

06/12/08 13:26:32 changed by jtv

Thanks! Retrieving all of them may be a bit much, but perhaps it would be worth getting them for all columns in the result set when a single type name is requested. A id-to-name mapping could cache type ids and type names for the connection.


Add/Change #147 (pqxx::result::column_type should return type name)




Change Properties
Action