Bring some order and sanity to error handling in the xml patch. Use a TRY block instead of (inadequate) ad-hoc coding to ensure that libxml is cleaned up after a failure.  Report the intended SQLCODE instead of defaulting to XX000.  Avoid risking use of a dangling pointer by keeping the persistent error buffer in TopMemoryContext. Be less trusting that error messages don't contain %.
Bring some order and sanity to error handling in the xml patch.
Use a TRY block instead of (inadequate) ad-hoc coding to ensure that
libxml is cleaned up after a failure.  Report the intended SQLCODE
instead of defaulting to XX000.  Avoid risking use of a dangling
pointer by keeping the persistent error buffer in TopMemoryContext.
Be less trusting that error messages don't contain %.

This patch doesn't do anything about changing the way the messages
are put together --- this is just about mechanism.

kmjungersen/PostgresXL,postmind-net/postgres-xl,postmind-net/postgres-xl,lisakowen/gpdb,yazun/postgres-xl,foyzur/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,janebeckman/gpdb,pavanvd/postgres-xl,arcivanov/postgres-xl,tpostgres-projects/tPostgres,Quikling/gpdb,Postgres-XL/Postgres-XL,50wu/gpdb,foyzur/gpdb,royc1/gpdb,edespino/gpdb,ahachete/gpdb,xinzweb/gpdb,foyzur/gpdb,Chibin/gpdb,Postgres-XL/Postgres-XL,rvs/gpdb,lintzc/gpdb,0x0FFF/gpdb,ashwinstar/gpdb,lisakowen/gpdb,zaksoup/gpdb,tangp3/gpdb,snaga/postgres-xl,arcivanov/postgres-xl,yuanzhao/gpdb,atris/gpdb,rubikloud/gpdb,xuegang/gpdb,greenplum-db/gpdb,pavanvd/postgres-xl,Quikling/gpdb,ashwinstar/gpdb,xuegang/gpdb,Quikling/gpdb,adam8157/gpdb,chrishajas/gpdb,jmcatamney/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,techdragon/Postgres-XL,ovr/postgres-xl,randomtask1155/gpdb,randomtask1155/gpdb,rvs/gpdb,lpetrov-pivotal/gpdb,rvs/gpdb,greenplum-db/gpdb,rubikloud/gpdb,cjcjameson/gpdb,zeroae/postgres-xl,Quikling/gpdb,oberstet/postgres-xl,foyzur/gpdb,xuegang/gpdb,lpetrov-pivotal/gpdb,tpostgres-projects/tPostgres,jmcatamney/gpdb,xuegang/gpdb,rvs/gpdb,50wu/gpdb,cjcjameson/gpdb,xuegang/gpdb,ovr/postgres-xl,greenplum-db/gpdb,kaknikhil/gpdb,atris/gpdb,xuegang/gpdb,cjcjameson/gpdb,randomtask1155/gpdb,ahachete/gpdb,kmjungersen/PostgresXL,janebeckman/gpdb,ashwinstar/gpdb,50wu/gpdb,rubikloud/gpdb,Quikling/gpdb,edespino/gpdb,lisakowen/gpdb,royc1/gpdb,postmind-net/postgres-xl,snaga/postgres-xl,tangp3/gpdb,Chibin/gpdb,rvs/gpdb,adam8157/gpdb,greenplum-db/gpdb,adam8157/gpdb,ashwinstar/gpdb,yazun/postgres-xl,xinzweb/gpdb,Quikling/gpdb,oberstet/postgres-xl,Postgres-XL/Postgres-XL,CraigHarris/gpdb,Chibin/gpdb,CraigHarris/gpdb,pavanvd/postgres-xl,0x0FFF/gpdb,lintzc/gpdb,royc1/gpdb,xuegang/gpdb,foyzur/gpdb,tangp3/gpdb,edespino/gpdb,randomtask1155/gpdb,zaksoup/gpdb,rubikloud/gpdb,atris/gpdb,chrishajas/gpdb,ahachete/gpdb,postmind-net/postgres-xl,tangp3/gpdb,tangp3/gpdb,kaknikhil/gpdb,0x0FFF/gpdb,Chibin/gpdb,zeroae/postgres-xl,greenplum-db/gpdb,Quikling/gpdb,ovr/postgres-xl,arcivanov/postgres-xl,xuegang/gpdb,royc1/gpdb,jmcatamney/gpdb,Chibin/gpdb,cjcjameson/gpdb,atris/gpdb,CraigHarris/gpdb,tpostgres-projects/tPostgres,janebeckman/gpdb,ashwinstar/gpdb,yazun/postgres-xl,CraigHarris/gpdb,lpetrov-pivotal/gpdb,xuegang/gpdb,randomtask1155/gpdb,kaknikhil/gpdb,ashwinstar/gpdb,chrishajas/gpdb,chrishajas/gpdb,edespino/gpdb,cjcjameson/gpdb,50wu/gpdb,cjcjameson/gpdb,lintzc/gpdb,jmcatamney/gpdb,ahachete/gpdb,kaknikhil/gpdb,rubikloud/gpdb,tangp3/gpdb,lintzc/gpdb,ashwinstar/gpdb,snaga/postgres-xl,adam8157/gpdb,janebeckman/gpdb,tangp3/gpdb,kmjungersen/PostgresXL,xinzweb/gpdb,0x0FFF/gpdb,xinzweb/gpdb,kmjungersen/PostgresXL,zeroae/postgres-xl,rubikloud/gpdb,lintzc/gpdb,rvs/gpdb,randomtask1155/gpdb,CraigHarris/gpdb,ahachete/gpdb,edespino/gpdb,royc1/gpdb,kaknikhil/gpdb,Postgres-XL/Postgres-XL,Chibin/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,50wu/gpdb,chrishajas/gpdb,zeroae/postgres-xl,janebeckman/gpdb,atris/gpdb,tangp3/gpdb,lpetrov-pivotal/gpdb,cjcjameson/gpdb,foyzur/gpdb,jmcatamney/gpdb,royc1/gpdb,yuanzhao/gpdb,ovr/postgres-xl,edespino/gpdb,ahachete/gpdb,foyzur/gpdb,ovr/postgres-xl,kaknikhil/gpdb,lintzc/gpdb,0x0FFF/gpdb,kaknikhil/gpdb,zaksoup/gpdb,Quikling/gpdb,Chibin/gpdb,snaga/postgres-xl,yuanzhao/gpdb,rvs/gpdb,chrishajas/gpdb,edespino/gpdb,Quikling/gpdb,randomtask1155/gpdb,randomtask1155/gpdb,lintzc/gpdb,rvs/gpdb,techdragon/Postgres-XL,zaksoup/gpdb,zaksoup/gpdb,techdragon/Postgres-XL,chrishajas/gpdb,CraigHarris/gpdb,oberstet/postgres-xl,xinzweb/gpdb,0x0FFF/gpdb,xinzweb/gpdb,0x0FFF/gpdb,rvs/gpdb,yuanzhao/gpdb,edespino/gpdb,tpostgres-projects/tPostgres,lisakowen/gpdb,50wu/gpdb,Chibin/gpdb,rubikloud/gpdb,kaknikhil/gpdb,yuanzhao/gpdb,greenplum-db/gpdb,yazun/postgres-xl,atris/gpdb,edespino/gpdb,yuanzhao/gpdb,techdragon/Postgres-XL,pavanvd/postgres-xl,ahachete/gpdb,xinzweb/gpdb,Quikling/gpdb,janebeckman/gpdb,zeroae/postgres-xl,CraigHarris/gpdb,foyzur/gpdb,edespino/gpdb,atris/gpdb,royc1/gpdb,rvs/gpdb,kaknikhil/gpdb,zaksoup/gpdb,Postgres-XL/Postgres-XL,adam8157/gpdb,50wu/gpdb,adam8157/gpdb,arcivanov/postgres-xl,ashwinstar/gpdb,0x0FFF/gpdb,janebeckman/gpdb,janebeckman/gpdb,postmind-net/postgres-xl,yuanzhao/gpdb,adam8157/gpdb,50wu/gpdb,rubikloud/gpdb,zaksoup/gpdb,adam8157/gpdb,yazun/postgres-xl,jmcatamney/gpdb,yuanzhao/gpdb,lintzc/gpdb,arcivanov/postgres-xl,pavanvd/postgres-xl,CraigHarris/gpdb,lpetrov-pivotal/gpdb,Chibin/gpdb,janebeckman/gpdb,lisakowen/gpdb,Chibin/gpdb,arcivanov/postgres-xl,cjcjameson/gpdb,oberstet/postgres-xl,jmcatamney/gpdb,greenplum-db/gpdb,lpetrov-pivotal/gpdb,cjcjameson/gpdb,ahachete/gpdb,lisakowen/gpdb,tpostgres-projects/tPostgres,zaksoup/gpdb,lisakowen/gpdb,lpetrov-pivotal/gpdb,royc1/gpdb,chrishajas/gpdb,cjcjameson/gpdb,snaga/postgres-xl,yuanzhao/gpdb,xinzweb/gpdb,janebeckman/gpdb,atris/gpdb,kmjungersen/PostgresXL,lpetrov-pivotal/gpdb,lisakowen/gpdb,lintzc/gpdb,techdragon/Postgres-XL