Attached is v3, which is mostly putting Andres's suggestion above (use heap_deform_tuple) into a code generation context. Everything interesting is in 0002, and again only touches pg_cast as an experiment. Some design points which could be debatable:
- I thought individual C files would be a pain for the build process, so I just dumped the new functions into a single file, with the extern declarations in the pg_*.h files.
- I used `#include "catalog/pg_cast.h"` just for Form_pg_cast, but maybe a forward declaration would work.
- To get the struct member assignments, I resorted to a Perl hash to map the attribute types to the DatumGet* macros. That may not be great, but I don't have a better idea at the moment.
- I directly called this function for the table scan rather than hide it behind a new variant of GETSTRUCT as I did before. That seems clearer to me about the intent.
The syscache use of GETSTRUCT still uses a simple cast of the tuple (for pg_cast those calls live in parse_coerce.c, which is unchanged from master in v3). Next step I think is to see about the syscache piece -- teaching a syscache miss to deform the entire tuple into a struct and store it in the syscache.
--
John Naylor
EDB:
http://www.enterprisedb.com