Improve memory management for PL/Perl functions.
Improve memory management for PL/Perl functions.

Unlike PL/Tcl, PL/Perl at least made an attempt to clean up after itself
when a function gets redefined.  But it was still using TopMemoryContext
for the fn_mcxt of argument/result I/O functions, resulting in the
potential for memory leaks depending on what those functions did, and the
retail alloc/free logic was pretty bulky as well.  Fix things to use a
per-function memory context like the other PLs now do.  Tweak a couple of
places where things were being done in a not-very-safe order (on the
principle that a memory leak is better than leaving global state
inconsistent after an error).  Also make some minor cosmetic adjustments,
mostly in field names, to make the code look similar to the way PL/Tcl does
now wherever it's essentially the same logic.

Michael Paquier and Tom Lane

Discussion: <3a0012762824dd3b8bf8ed1837977a61616fd9aa@mail.gmail.com>

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