Pg_record_inspect is a project mainly written in C, it's free.
Support for dynamic inspection of record types in plpgsql
record_inspect defines functions which allow introspection of record and composite types from PL/pgSQL and PL/SQL. record_inspect defines the following database objects, all in the schema record_inspect.
fieldinfo [composite type] Used to by fieldinfos() to describe a record's fields. Contains the fields fieldname (name), fieldtype (regclass), fieldtypemod (varchar)
fieldinfo[] fieldinfos(record)
Returns an array of
anyelement fieldvalue(record, field name, defval anyelement, coerce boolean)
Returns the value of the field
anyelement fieldvalues(record, defval anyelement, coerce boolean)
Returns an array containing values of the record'' fields. NULL values are
replaced by
Do
make install
or
make PG_CONFIG=/path/to/your/pg_config install
This will install record_inspect.so into
Before you're able to use record_inspect from a specific database, you need to register the types and functions of record_inspect with that database. This is what record_inspect.sql is for. Simply do psql your_database < record_inspect.sql