Fix RelationCacheInitializePhase2 (Phase3, in HEAD) to cope with the possibility of shared-inval messages causing a relcache flush while it tries to fill in missing data in preloaded relcache entries.  There are actually two distinct failure modes here:
Fix RelationCacheInitializePhase2 (Phase3, in HEAD) to cope with the
possibility of shared-inval messages causing a relcache flush while it tries
to fill in missing data in preloaded relcache entries.  There are actually
two distinct failure modes here:

1. The flush could delete the next-to-be-processed cache entry, causing
the subsequent hash_seq_search calls to go off into the weeds.  This is
the problem reported by Michael Brown, and I believe it also accounts
for bug #5074.  The simplest fix is to restart the hashtable scan after
we've read any new data from the catalogs.  It appears that pre-8.4
branches have not suffered from this failure, because by chance there were
no other catalogs sharing the same hash chains with the catalogs that
RelationCacheInitializePhase2 had work to do for.  However that's obviously
pretty fragile, and it seems possible that derivative versions with
additional system catalogs might be vulnerable, so I'm back-patching this
part of the fix anyway.

2. The flush could delete the *current* cache entry, in which case the
pointer to the newly-loaded data would end up being stored into an
already-deleted Relation struct.  As long as it was still deleted, the only
consequence would be some leaked space in CacheMemoryContext.  But it seems
possible that the Relation struct could already have been recycled, in
which case this represents a hard-to-reproduce clobber of cached data
structures, with unforeseeable consequences.  The fix here is to pin the
entry while we work on it.

In passing, also change RelationCacheInitializePhase2 to Assert that
formrdesc() set up the relation's cached TupleDesc (rd_att) with the
correct type OID and hasoids values.  This is more appropriate than
silently updating the values, because the original tupdesc might already
have been copied into the catcache.  However this part of the patch is
not in HEAD because it fails due to some questionable recent changes in
formrdesc :-(.  That will be cleaned up in a subsequent patch.

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