Eliminate memory leaks in plperl's spi_prepare() function.
Eliminate memory leaks in plperl's spi_prepare() function.

Careless use of TopMemoryContext for I/O function data meant that repeated
use of spi_prepare and spi_freeplan would leak memory at the session level,
as per report from Christian Schröder.  In addition, spi_prepare
leaked a lot of transient data within the current plperl function's SPI
Proc context, which would be a problem for repeated use of spi_prepare
within a single plperl function call; and it wasn't terribly careful
about releasing permanent allocations in event of an error, either.

In passing, clean up some copy-and-pasteos in query-lookup error messages.

Alex Hunsaker and Tom Lane

xinzweb/gpdb,yazun/postgres-xl,xinzweb/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,xinzweb/gpdb,greenplum-db/gpdb,yazun/postgres-xl,ashwinstar/gpdb,zeroae/postgres-xl,yazun/postgres-xl,Postgres-XL/Postgres-XL,jmcatamney/gpdb,Postgres-XL/Postgres-XL,ashwinstar/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,Postgres-XL/Postgres-XL,greenplum-db/gpdb,ovr/postgres-xl,pavanvd/postgres-xl,lisakowen/gpdb,oberstet/postgres-xl,adam8157/gpdb,ovr/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,greenplum-db/gpdb,techdragon/Postgres-XL,50wu/gpdb,ashwinstar/gpdb,50wu/gpdb,zeroae/postgres-xl,adam8157/gpdb,lisakowen/gpdb,ashwinstar/gpdb,ovr/postgres-xl,oberstet/postgres-xl,adam8157/gpdb,ashwinstar/gpdb,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,50wu/gpdb,jmcatamney/gpdb,lisakowen/gpdb,jmcatamney/gpdb,Postgres-XL/Postgres-XL,xinzweb/gpdb,adam8157/gpdb,pavanvd/postgres-xl,lisakowen/gpdb,lisakowen/gpdb,oberstet/postgres-xl,50wu/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,adam8157/gpdb,ashwinstar/gpdb,techdragon/Postgres-XL,greenplum-db/gpdb,yazun/postgres-xl,50wu/gpdb,ovr/postgres-xl,techdragon/Postgres-XL,zeroae/postgres-xl,adam8157/gpdb,pavanvd/postgres-xl,lisakowen/gpdb,50wu/gpdb,yazun/postgres-xl,xinzweb/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,jmcatamney/gpdb,xinzweb/gpdb,xinzweb/gpdb,ovr/postgres-xl,techdragon/Postgres-XL,50wu/gpdb,pavanvd/postgres-xl,pavanvd/postgres-xl,xinzweb/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,Postgres-XL/Postgres-XL,techdragon/Postgres-XL,zeroae/postgres-xl,zeroae/postgres-xl,adam8157/gpdb