Hi,
I am sending new version of this patch
1. now generic TableExpr is better separated from a real content generation
2. I removed cached typmod - using row type cache everywhere - it is consistent with other few places in Pg where dynamic types are used - the result tupdesc is generated few times more - but it is not on critical path.
3. More comments, few more lines in doc.
4. Reformated by pgindent
Regards
Pavel