Insert into getCopyDataMessage() the same logic that already existed in the main code path for enlarging libpq's input buffer in one swoop when needing to read a long data message.  Without this, the code will double the buffer size, read more data, notice it still hasn't got the whole message, and repeat till it finally has a large enough buffer.  Which wastes a lot of data-moving effort and also memory (since malloc probably can't do anything very useful with the freed-up smaller buffers).  Not sure why this wasn't there already; certainly the COPY data path is a place where we're quite likely to see long data messages.  I'm not backpatching though, since this is just a marginal performance issue rather than a real bug.
Insert into getCopyDataMessage() the same logic that already existed in the
main code path for enlarging libpq's input buffer in one swoop when needing to
read a long data message.  Without this, the code will double the buffer size,
read more data, notice it still hasn't got the whole message, and repeat till
it finally has a large enough buffer.  Which wastes a lot of data-moving
effort and also memory (since malloc probably can't do anything very useful
with the freed-up smaller buffers).  Not sure why this wasn't there already;
certainly the COPY data path is a place where we're quite likely to see long
data messages.  I'm not backpatching though, since this is just a marginal
performance issue rather than a real bug.

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