Incorporate a couple of recent tuplesort.c improvements into tuplestore.c. In particular, ensure that enlargement of the memtuples[] array doesn't fall foul of MaxAllocSize when work_mem is very large, and don't bother enlarging it if that would force an immediate switch into 'tape' mode anyway.
Incorporate a couple of recent tuplesort.c improvements into tuplestore.c.
In particular, ensure that enlargement of the memtuples[] array doesn't
fall foul of MaxAllocSize when work_mem is very large, and don't bother
enlarging it if that would force an immediate switch into 'tape' mode anyway.

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