mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Repair possible failure to update hint bits back to disk, per
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php. I plan a more permanent fix in HEAD, but for the back branches it seems best to just touch the places that actually have a problem.
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.9 2002/09/04 20:31:08 momjian Exp $
 | 
					 * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.9.2.1 2004/10/13 22:22:20 tgl Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Copyright (c) 2001,2002	Tatsuo Ishii
 | 
					 * Copyright (c) 2001,2002	Tatsuo Ishii
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -103,6 +103,9 @@ pgstattuple(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	/* scan the relation */
 | 
						/* scan the relation */
 | 
				
			||||||
	while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
 | 
						while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
							uint16		sv_infomask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							sv_infomask = tuple->t_data->t_infomask;
 | 
				
			||||||
		if (HeapTupleSatisfiesNow(tuple->t_data))
 | 
							if (HeapTupleSatisfiesNow(tuple->t_data))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			tuple_len += tuple->t_len;
 | 
								tuple_len += tuple->t_len;
 | 
				
			||||||
@@ -113,6 +116,8 @@ pgstattuple(PG_FUNCTION_ARGS)
 | 
				
			|||||||
			dead_tuple_len += tuple->t_len;
 | 
								dead_tuple_len += tuple->t_len;
 | 
				
			||||||
			dead_tuple_count++;
 | 
								dead_tuple_count++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (sv_infomask != tuple->t_data->t_infomask)
 | 
				
			||||||
 | 
								SetBufferCommitInfoNeedsSave(scan->rs_cbuf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * To avoid physically reading the table twice, try to do the
 | 
							 * To avoid physically reading the table twice, try to do the
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.149 2002/09/26 22:46:29 tgl Exp $
 | 
					 *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.149.2.1 2004/10/13 22:22:21 tgl Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * INTERFACE ROUTINES
 | 
					 * INTERFACE ROUTINES
 | 
				
			||||||
@@ -1271,6 +1271,7 @@ heap_delete(Relation relation, ItemPointer tid,
 | 
				
			|||||||
	PageHeader	dp;
 | 
						PageHeader	dp;
 | 
				
			||||||
	Buffer		buffer;
 | 
						Buffer		buffer;
 | 
				
			||||||
	int			result;
 | 
						int			result;
 | 
				
			||||||
 | 
						uint16		sv_infomask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* increment access statistics */
 | 
						/* increment access statistics */
 | 
				
			||||||
	IncrHeapAccessStat(local_delete);
 | 
						IncrHeapAccessStat(local_delete);
 | 
				
			||||||
@@ -1294,7 +1295,10 @@ heap_delete(Relation relation, ItemPointer tid,
 | 
				
			|||||||
	tp.t_tableOid = relation->rd_id;
 | 
						tp.t_tableOid = relation->rd_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
l1:
 | 
					l1:
 | 
				
			||||||
 | 
						sv_infomask = tp.t_data->t_infomask;
 | 
				
			||||||
	result = HeapTupleSatisfiesUpdate(&tp, cid);
 | 
						result = HeapTupleSatisfiesUpdate(&tp, cid);
 | 
				
			||||||
 | 
						if (sv_infomask != tp.t_data->t_infomask)
 | 
				
			||||||
 | 
							SetBufferCommitInfoNeedsSave(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (result == HeapTupleInvisible)
 | 
						if (result == HeapTupleInvisible)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -1311,7 +1315,7 @@ l1:
 | 
				
			|||||||
		XactLockTableWait(xwait);
 | 
							XactLockTableWait(xwait);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
 | 
							LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
 | 
				
			||||||
		if (TransactionIdDidAbort(xwait))
 | 
							if (!TransactionIdDidCommit(xwait))
 | 
				
			||||||
			goto l1;
 | 
								goto l1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
@@ -1470,6 +1474,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
 | 
				
			|||||||
	Size		newtupsize,
 | 
						Size		newtupsize,
 | 
				
			||||||
				pagefree;
 | 
									pagefree;
 | 
				
			||||||
	int			result;
 | 
						int			result;
 | 
				
			||||||
 | 
						uint16		sv_infomask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* increment access statistics */
 | 
						/* increment access statistics */
 | 
				
			||||||
	IncrHeapAccessStat(local_replace);
 | 
						IncrHeapAccessStat(local_replace);
 | 
				
			||||||
@@ -1498,7 +1503,10 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
l2:
 | 
					l2:
 | 
				
			||||||
 | 
						sv_infomask = oldtup.t_data->t_infomask;
 | 
				
			||||||
	result = HeapTupleSatisfiesUpdate(&oldtup, cid);
 | 
						result = HeapTupleSatisfiesUpdate(&oldtup, cid);
 | 
				
			||||||
 | 
						if (sv_infomask != oldtup.t_data->t_infomask)
 | 
				
			||||||
 | 
							SetBufferCommitInfoNeedsSave(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (result == HeapTupleInvisible)
 | 
						if (result == HeapTupleInvisible)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -1515,7 +1523,7 @@ l2:
 | 
				
			|||||||
		XactLockTableWait(xwait);
 | 
							XactLockTableWait(xwait);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
 | 
							LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
 | 
				
			||||||
		if (TransactionIdDidAbort(xwait))
 | 
							if (!TransactionIdDidCommit(xwait))
 | 
				
			||||||
			goto l2;
 | 
								goto l2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
@@ -1795,6 +1803,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
 | 
				
			|||||||
	ItemId		lp;
 | 
						ItemId		lp;
 | 
				
			||||||
	PageHeader	dp;
 | 
						PageHeader	dp;
 | 
				
			||||||
	int			result;
 | 
						int			result;
 | 
				
			||||||
 | 
						uint16		sv_infomask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* increment access statistics */
 | 
						/* increment access statistics */
 | 
				
			||||||
	IncrHeapAccessStat(local_mark4update);
 | 
						IncrHeapAccessStat(local_mark4update);
 | 
				
			||||||
@@ -1814,7 +1823,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
 | 
				
			|||||||
	tuple->t_len = ItemIdGetLength(lp);
 | 
						tuple->t_len = ItemIdGetLength(lp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
l3:
 | 
					l3:
 | 
				
			||||||
 | 
						sv_infomask = tuple->t_data->t_infomask;
 | 
				
			||||||
	result = HeapTupleSatisfiesUpdate(tuple, cid);
 | 
						result = HeapTupleSatisfiesUpdate(tuple, cid);
 | 
				
			||||||
 | 
						if (sv_infomask != tuple->t_data->t_infomask)
 | 
				
			||||||
 | 
							SetBufferCommitInfoNeedsSave(*buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (result == HeapTupleInvisible)
 | 
						if (result == HeapTupleInvisible)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -1831,7 +1843,7 @@ l3:
 | 
				
			|||||||
		XactLockTableWait(xwait);
 | 
							XactLockTableWait(xwait);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
 | 
							LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
 | 
				
			||||||
		if (TransactionIdDidAbort(xwait))
 | 
							if (!TransactionIdDidCommit(xwait))
 | 
				
			||||||
			goto l3;
 | 
								goto l3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 | 
					 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.43.2.4 2003/10/31 03:57:41 wieck Exp $
 | 
					 * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.43.2.5 2004/10/13 22:22:22 tgl Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * ----------
 | 
					 * ----------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -241,6 +241,9 @@ RI_FKey_check(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	 * We should not even consider checking the row if it is no longer
 | 
						 * We should not even consider checking the row if it is no longer
 | 
				
			||||||
	 * valid since it was either deleted (doesn't matter) or updated (in
 | 
						 * valid since it was either deleted (doesn't matter) or updated (in
 | 
				
			||||||
	 * which case it'll be checked with its final values).
 | 
						 * which case it'll be checked with its final values).
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * Note: we need not SetBufferCommitInfoNeedsSave() here since the
 | 
				
			||||||
 | 
						 * new tuple's commit state can't possibly change.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (new_row)
 | 
						if (new_row)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user