Index: src/backend/access/heap/heapam.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/heap/heapam.c,v
retrieving revision 1.225
diff -c -r1.225 heapam.c
*** src/backend/access/heap/heapam.c	25 Jan 2007 02:17:25 -0000	1.225
--- src/backend/access/heap/heapam.c	31 Jan 2007 11:23:03 -0000
***************
*** 1420,1426 ****
--- 1420,1431 ----
  	 */
  	if (HeapTupleHasExternal(tup) ||
  		(MAXALIGN(tup->t_len) > TOAST_TUPLE_THRESHOLD))
+ 	{
+ 		ereport(LOG, (errmsg("MAXALIGN(t_len):%d, TOAST_TUPLE_THRESHOLD:%d",
+  						MAXALIGN(tup->t_len),
+  						TOAST_TUPLE_THRESHOLD)));
  		heaptup = toast_insert_or_update(relation, tup, NULL, use_wal);
+ 	}
  	else
  		heaptup = tup;
  
Index: src/backend/access/heap/tuptoaster.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v
retrieving revision 1.69
diff -c -r1.69 tuptoaster.c
*** src/backend/access/heap/tuptoaster.c	25 Jan 2007 02:17:26 -0000	1.69
--- src/backend/access/heap/tuptoaster.c	31 Jan 2007 11:23:03 -0000
***************
*** 366,371 ****
--- 366,383 ----
  	bool		toast_free[MaxHeapAttributeNumber];
  	bool		toast_delold[MaxHeapAttributeNumber];
  
+ 	static bool	in_use = false;
+ 	
+ 	if (in_use)
+ 		elog(PANIC, "toast_insert_or_update() in recursion");
+ 	in_use = true;
+ 
+ 	static int	in_use = 0;
+ 	
+ 	ereport(LOG, (errmsg("toast_insert_or_update: recurse_depth(%d)",
+ 					in_use)));
+ 	in_use++;
+ 
  	/*
  	 * Get the tuple descriptor and break down the tuple(s) into fields.
  	 */
***************
*** 800,805 ****
--- 812,824 ----
  			if (toast_delold[i])
  				toast_delete_datum(rel, toast_oldvalues[i]);
  
+ 	in_use = false;
+ 
+ 	if (in_use > 1)
+ 		elog(PANIC, "toast_insert_or_update got into recursion");
+ 
+ 	in_use--;
+ 
  	return result_tuple;
  }
