Index: src/backend/commands/tablecmds.c
===================================================================
RCS file: /var/lib/cvs/pgsql/src/backend/commands/tablecmds.c,v
retrieving revision 1.162
diff -c -r1.162 tablecmds.c
*** src/backend/commands/tablecmds.c	28 Jun 2005 05:08:54 -0000	1.162
--- src/backend/commands/tablecmds.c	29 Jun 2005 07:15:07 -0000
***************
*** 4801,4806 ****
--- 4801,4809 ----
  	ScanKeyData key[3];
  	SysScanDesc scan;
  	HeapTuple	depTup;
+ 	List *tmp_list = NIL;
+ 	List *tmp_list2 = NIL;
+ 	ListCell *lc;
  
  	attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
  
***************
*** 4893,4901 ****
  
  	while (HeapTupleIsValid(depTup = systable_getnext(scan)))
  	{
! 		Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup);
  		ObjectAddress foundObject;
  
  		/* We don't expect any PIN dependencies on columns */
  		if (foundDep->deptype == DEPENDENCY_PIN)
  			elog(ERROR, "cannot alter type of a pinned column");
--- 4896,4941 ----
  
  	while (HeapTupleIsValid(depTup = systable_getnext(scan)))
  	{
! 		tmp_list = lappend(tmp_list, heap_copytuple(depTup));
! 	}
! 
! 	foreach (lc, tmp_list)
! 	{
! 		if (lnext(lc) != NULL)
! 		{
! 			Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT((HeapTuple) lfirst(lc));
! 			Form_pg_depend foundDepNext = (Form_pg_depend) GETSTRUCT((HeapTuple) lfirst(lnext(lc)));
! 
! 			if (foundDep->refclassid == foundDepNext->refclassid &&
! 				foundDep->refobjid == foundDepNext->refobjid &&
! 				foundDep->refobjsubid == foundDepNext->refobjsubid)
! 			{
! 				if (random() > (MAX_RANDOM_VALUE / 2))
! 				{
! 					tmp_list2 = lappend(tmp_list2, lfirst(lnext(lc)));
! 					tmp_list2 = lappend(tmp_list2, lfirst(lc));
! 					lc = lnext(lc);
! 					elog(NOTICE, "choosing to shuffle");
! 					continue;
! 				}
! 				else
! 					elog(NOTICE, "choosing not to shuffle");
! 			}
! 		}
! 
! 		tmp_list2 = lappend(tmp_list2, lfirst(lc));
! 	}
! 
! 	Assert(list_length(tmp_list) == list_length(tmp_list2));
! 
! 	foreach (lc, tmp_list2)
! 	{
! 		Form_pg_depend foundDep;
  		ObjectAddress foundObject;
  
+ 		depTup = lfirst(lc);
+ 		foundDep = (Form_pg_depend) GETSTRUCT(depTup);
+ 
  		/* We don't expect any PIN dependencies on columns */
  		if (foundDep->deptype == DEPENDENCY_PIN)
  			elog(ERROR, "cannot alter type of a pinned column");
