Do a conditional SPI_push/SPI_pop when replanning a query in RevalidateCachedPlan.  This is to avoid a "SPI_ERROR_CONNECT" failure when the planner calls a SPI-using function and we are already inside one. The alternative fix is to expect callers of RevalidateCachedPlan to do this, which seems likely to result in additional hard-to-detect bugs of omission. Per reports from Frank van Vugt and Marek Lewczuk.
Do a conditional SPI_push/SPI_pop when replanning a query in
RevalidateCachedPlan.  This is to avoid a "SPI_ERROR_CONNECT" failure when
the planner calls a SPI-using function and we are already inside one.
The alternative fix is to expect callers of RevalidateCachedPlan to do this,
which seems likely to result in additional hard-to-detect bugs of omission.
Per reports from Frank van Vugt and Marek Lewczuk.

Back-patch to 8.3. It's much harder to trigger the bug in 8.3, due to a
smaller set of cases in which plans can be invalidated, but it could happen.
(I think perhaps only a SI reset event could make 8.3 fail here, but that's
certainly within the realm of possibility.)

xuegang/gpdb,ahachete/gpdb,jmcatamney/gpdb,chrishajas/gpdb,Chibin/gpdb,0x0FFF/gpdb,chrishajas/gpdb,yuanzhao/gpdb,janebeckman/gpdb,chrishajas/gpdb,lintzc/gpdb,greenplum-db/gpdb,xinzweb/gpdb,royc1/gpdb,Quikling/gpdb,CraigHarris/gpdb,cjcjameson/gpdb,lisakowen/gpdb,cjcjameson/gpdb,lisakowen/gpdb,rvs/gpdb,zaksoup/gpdb,Chibin/gpdb,Quikling/gpdb,lisakowen/gpdb,rvs/gpdb,50wu/gpdb,xuegang/gpdb,rvs/gpdb,lintzc/gpdb,cjcjameson/gpdb,janebeckman/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,xuegang/gpdb,adam8157/gpdb,chrishajas/gpdb,kaknikhil/gpdb,50wu/gpdb,Quikling/gpdb,yuanzhao/gpdb,jmcatamney/gpdb,50wu/gpdb,Chibin/gpdb,adam8157/gpdb,chrishajas/gpdb,edespino/gpdb,Quikling/gpdb,jmcatamney/gpdb,lintzc/gpdb,yuanzhao/gpdb,greenplum-db/gpdb,zaksoup/gpdb,yuanzhao/gpdb,zaksoup/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,CraigHarris/gpdb,Chibin/gpdb,janebeckman/gpdb,jmcatamney/gpdb,adam8157/gpdb,zaksoup/gpdb,lintzc/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,royc1/gpdb,lisakowen/gpdb,yuanzhao/gpdb,xinzweb/gpdb,ahachete/gpdb,xuegang/gpdb,ashwinstar/gpdb,Quikling/gpdb,Chibin/gpdb,0x0FFF/gpdb,yuanzhao/gpdb,ahachete/gpdb,0x0FFF/gpdb,zaksoup/gpdb,xuegang/gpdb,edespino/gpdb,janebeckman/gpdb,kaknikhil/gpdb,rvs/gpdb,0x0FFF/gpdb,rvs/gpdb,ashwinstar/gpdb,edespino/gpdb,rvs/gpdb,edespino/gpdb,xinzweb/gpdb,greenplum-db/gpdb,kaknikhil/gpdb,Chibin/gpdb,zaksoup/gpdb,kaknikhil/gpdb,ahachete/gpdb,Chibin/gpdb,0x0FFF/gpdb,xuegang/gpdb,cjcjameson/gpdb,adam8157/gpdb,yuanzhao/gpdb,jmcatamney/gpdb,ahachete/gpdb,janebeckman/gpdb,0x0FFF/gpdb,yuanzhao/gpdb,50wu/gpdb,cjcjameson/gpdb,xuegang/gpdb,50wu/gpdb,CraigHarris/gpdb,janebeckman/gpdb,ahachete/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,ahachete/gpdb,Quikling/gpdb,rvs/gpdb,xuegang/gpdb,xinzweb/gpdb,CraigHarris/gpdb,greenplum-db/gpdb,lisakowen/gpdb,janebeckman/gpdb,ashwinstar/gpdb,xinzweb/gpdb,janebeckman/gpdb,janebeckman/gpdb,lintzc/gpdb,50wu/gpdb,xinzweb/gpdb,50wu/gpdb,ashwinstar/gpdb,lintzc/gpdb,xinzweb/gpdb,edespino/gpdb,0x0FFF/gpdb,kaknikhil/gpdb,edespino/gpdb,Quikling/gpdb,royc1/gpdb,lisakowen/gpdb,adam8157/gpdb,50wu/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,zaksoup/gpdb,edespino/gpdb,rvs/gpdb,yuanzhao/gpdb,chrishajas/gpdb,edespino/gpdb,ahachete/gpdb,janebeckman/gpdb,rvs/gpdb,jmcatamney/gpdb,cjcjameson/gpdb,CraigHarris/gpdb,chrishajas/gpdb,Quikling/gpdb,edespino/gpdb,lintzc/gpdb,adam8157/gpdb,CraigHarris/gpdb,ashwinstar/gpdb,royc1/gpdb,adam8157/gpdb,CraigHarris/gpdb,lintzc/gpdb,royc1/gpdb,lisakowen/gpdb,edespino/gpdb,royc1/gpdb,greenplum-db/gpdb,Quikling/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,Chibin/gpdb,cjcjameson/gpdb,adam8157/gpdb,CraigHarris/gpdb,royc1/gpdb,lintzc/gpdb,xinzweb/gpdb,xuegang/gpdb,royc1/gpdb,chrishajas/gpdb,Chibin/gpdb,Quikling/gpdb,cjcjameson/gpdb,rvs/gpdb,0x0FFF/gpdb,greenplum-db/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,Chibin/gpdb,lisakowen/gpdb,zaksoup/gpdb,ashwinstar/gpdb