1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Clean up the representation of special snapshots by including a "method

pointer" in every Snapshot struct.  This allows removal of the case-by-case
tests in HeapTupleSatisfiesVisibility, which should make it a bit faster
(I didn't try any performance tests though).  More importantly, we are no
longer violating portable C practices by assuming that small integers are
distinct from all pointer values, and HeapTupleSatisfiesDirty no longer
has a non-reentrant API involving side-effects on a global variable.

There were a couple of places calling HeapTupleSatisfiesXXX routines
directly rather than through the HeapTupleSatisfiesVisibility macro.
Since these places had to be changed anyway, I chose to make them go
through the macro for uniformity.

Along the way I renamed HeapTupleSatisfiesSnapshot to HeapTupleSatisfiesMVCC
to emphasize that it's only used with MVCC-type snapshots.  I was sorely
tempted to rename HeapTupleSatisfiesVisibility to HeapTupleSatisfiesSnapshot,
but forebore for the moment to avoid confusion and reduce the likelihood that
this patch breaks some of the pending patches.  Might want to reconsider
doing that later.
This commit is contained in:
Tom Lane
2007-03-25 19:45:14 +00:00
parent 75c6519ff6
commit e85a01df67
10 changed files with 148 additions and 121 deletions

View File

@ -15,7 +15,7 @@
*
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.92 2007/03/15 23:12:06 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.93 2007/03/25 19:45:14 tgl Exp $
*
* ----------
*/
@ -277,11 +277,11 @@ RI_FKey_check(PG_FUNCTION_ARGS)
* We should not even consider checking the row if it is no longer valid,
* since it was either deleted (so the deferred check should be skipped)
* or updated (in which case only the latest version of the row should be
* checked). Test its liveness with HeapTupleSatisfiesItself.
* checked). Test its liveness according to SnapshotSelf.
*
* NOTE: The normal coding rule is that one must acquire the buffer
* content lock to call HeapTupleSatisfiesFOO. We can skip that here
* because we know that AfterTriggerExecute just fetched the tuple
* content lock to call HeapTupleSatisfiesVisibility. We can skip that
* here because we know that AfterTriggerExecute just fetched the tuple
* successfully, so there cannot be a VACUUM compaction in progress on the
* page (either heap_fetch would have waited for the VACUUM, or the
* VACUUM's LockBufferForCleanup would be waiting for us to drop pin).
@ -289,7 +289,7 @@ RI_FKey_check(PG_FUNCTION_ARGS)
* can be entitled to change its xmin/xmax.
*/
Assert(new_row_buf != InvalidBuffer);
if (!HeapTupleSatisfiesItself(new_row->t_data, new_row_buf))
if (!HeapTupleSatisfiesVisibility(new_row, SnapshotSelf, new_row_buf))
return PointerGetDatum(NULL);
/*