relcache-rebuild-order.patch

text/x-patch

Filename: relcache-rebuild-order.patch
Type: text/x-patch
Part: 0
Message: Re: error: could not find pg_class tuple for index 2662
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 81cea8b..0e4b17c 100644
*** a/src/backend/utils/cache/relcache.c
--- b/src/backend/utils/cache/relcache.c
*************** RelationCacheInvalidate(void)
*** 2185,2204 ****
  		{
  			/*
  			 * Add this entry to list of stuff to rebuild in second pass.
! 			 * pg_class_oid_index goes on the front of rebuildFirstList, other
! 			 * nailed indexes on the back, and everything else into
! 			 * rebuildList (in no particular order).
  			 */
! 			if (relation->rd_isnailed &&
! 				relation->rd_rel->relkind == RELKIND_INDEX)
  			{
  				if (RelationGetRelid(relation) == ClassOidIndexId)
- 					rebuildFirstList = lcons(relation, rebuildFirstList);
- 				else
  					rebuildFirstList = lappend(rebuildFirstList, relation);
  			}
  			else
! 				rebuildList = lcons(relation, rebuildList);
  		}
  	}
  
--- 2185,2207 ----
  		{
  			/*
  			 * Add this entry to list of stuff to rebuild in second pass.
! 			 * pg_class goes on the front of rebuildFirstList,
! 			 * pg_class_oid_index goes to the back of rebuildFirstList, other
! 			 * nailed indexes go on the front of rebuildList, and everything
! 			 * else goes to the back of rebuildList.
  			 */
! 			if (RelationGetRelid(relation) == RelationRelationId)
! 				rebuildFirstList = lcons(relation, rebuildFirstList);
! 			else if (relation->rd_isnailed &&
! 					 relation->rd_rel->relkind == RELKIND_INDEX)
  			{
  				if (RelationGetRelid(relation) == ClassOidIndexId)
  					rebuildFirstList = lappend(rebuildFirstList, relation);
+ 				else
+ 					rebuildList = lcons(relation, rebuildList);
  			}
  			else
! 				rebuildList = lappend(rebuildList, relation);
  		}
  	}