Hi Pavan,

Here's a little patch against CVS HEAD + NewHOT-v7.0.patch to fix the conflict between MVCC-safe cluster and HOT.


index_getnext is modified to return all tuples in a HOT chain when called with SnapshotAny. Cluster will insert them all as normal cold updates.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com
Index: src/backend/access/index/indexam.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository2/pgsql/src/backend/access/index/indexam.c,v
retrieving revision 1.97
diff -c -r1.97 indexam.c
*** src/backend/access/index/indexam.c	5 Jan 2007 22:19:23 -0000	1.97
--- src/backend/access/index/indexam.c	19 Apr 2007 12:07:35 -0000
***************
*** 404,409 ****
--- 404,428 ----
  
  	SCAN_CHECKS;
  	GET_SCAN_PROCEDURE(amgettuple);
+ 	
+ 	/*
+ 	 * With SnapshotAny, there can be multiple visible tuples in a HOT chain,
+ 	 * all represented by a single index entry. We need to return all of them
+ 	 * to the caller. The first one is returned in the loop below as usual,
+ 	 * but before we move to the next index tuple, return any remaining tuples
+ 	 * from the previous chain.
+ 	 */
+ 	if (BufferIsValid(scan->xs_cbuf) && scan->xs_snapshot == SnapshotAny)
+ 	{
+ 		bool found;
+ 
+ 		LockBuffer(scan->xs_cbuf, BUFFER_LOCK_SHARE);
+ 		found = heap_hot_fetch(scan->heapRelation, scan->xs_snapshot,
+ 							   heapTuple, scan->xs_cbuf);
+ 		LockBuffer(scan->xs_cbuf, BUFFER_LOCK_UNLOCK);
+ 		if (found)
+ 			return heapTuple;
+ 	}
  
  	/* just make sure this is false... */
  	scan->kill_prior_tuple = false;
Index: src/backend/commands/cluster.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository2/pgsql/src/backend/commands/cluster.c,v
retrieving revision 1.159
diff -c -r1.159 cluster.c
*** src/backend/commands/cluster.c	8 Apr 2007 01:26:28 -0000	1.159
--- src/backend/commands/cluster.c	19 Apr 2007 12:02:00 -0000
***************
*** 717,722 ****
--- 717,723 ----
  										 scan->xs_cbuf))
  		{
  			case HEAPTUPLE_DEAD:
+ 			case HEAPTUPLE_DEAD_CHAIN:
  				/* Definitely dead */
  				isdead = true;
  				break;
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to