Code review for tqueue.c: fix memory leaks, speed it up, other fixes.
Code review for tqueue.c: fix memory leaks, speed it up, other fixes.

When doing record typmod remapping, tqueue.c did fresh catalog lookups
for each tuple it processed, which was pretty horrible performance-wise
(it seemed to about halve the already none-too-quick speed of bulk reads
in parallel mode).  Worse, it insisted on putting bits of that data into
TopMemoryContext, from where it never freed them, causing a
session-lifespan memory leak.  (I suppose this was coded with the idea
that the sender process would quit after finishing the query ---
but the receiver uses the same code.)

Restructure to avoid repetitive catalog lookups and to keep that data
in a query-lifespan context, in or below the context where the
TQueueDestReceiver or TupleQueueReader itself lives.

Fix some other bugs such as continuing to use a tupledesc after
releasing our refcount on it.  Clean up cavalier datatype choices
(typmods are int32, please, not int, and certainly not Oid).  Improve
comments and error message wording.

ashwinstar/gpdb,50wu/gpdb,greenplum-db/gpdb,50wu/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,lisakowen/gpdb,greenplum-db/gpdb,50wu/gpdb,greenplum-db/gpdb,50wu/gpdb,lisakowen/gpdb,lisakowen/gpdb,greenplum-db/gpdb,xinzweb/gpdb,adam8157/gpdb,jmcatamney/gpdb,adam8157/gpdb,xinzweb/gpdb,lisakowen/gpdb,xinzweb/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,xinzweb/gpdb,50wu/gpdb,50wu/gpdb,lisakowen/gpdb,adam8157/gpdb,50wu/gpdb,xinzweb/gpdb,ashwinstar/gpdb,50wu/gpdb,adam8157/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,adam8157/gpdb,adam8157/gpdb,xinzweb/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,xinzweb/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,lisakowen/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,lisakowen/gpdb