Prevent incorrect updates of pg_index while reindexing pg_index itself.
Prevent incorrect updates of pg_index while reindexing pg_index itself.

The places that attempt to change pg_index.indcheckxmin during a reindexing
operation cannot be executed safely if pg_index itself is the subject of
the operation.  This is the explanation for a couple of recent reports of
VACUUM FULL failing with
	ERROR:  duplicate key value violates unique constraint "pg_index_indexrelid_index"
	DETAIL:  Key (indexrelid)=(2678) already exists.

However, there isn't any real need to update indcheckxmin in such a
situation, if we assume that pg_index can never contain a truly broken HOT
chain.  This assumption holds if new indexes are never created on it during
concurrent operations, which is something we don't consider safe for any
system catalog, not just pg_index.  Accordingly, modify the code to not
manipulate indcheckxmin when reindexing any system catalog.

Back-patch to 8.3, where HOT was introduced.  The known failure scenarios
involve 9.0-style VACUUM FULL, so there might not be any real risk before
9.0, but let's not assume that.

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