aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/rewriteheap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/heap/rewriteheap.c')
-rw-r--r--src/backend/access/heap/rewriteheap.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index 628e3b1277e..84472f80cd9 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -111,6 +111,7 @@
#include "storage/smgr.h"
#include "utils/memutils.h"
#include "utils/rel.h"
+#include "utils/tqual.h"
/*
@@ -128,6 +129,8 @@ typedef struct RewriteStateData
* determine tuple visibility */
TransactionId rs_freeze_xid;/* Xid that will be used as freeze cutoff
* point */
+ MultiXactId rs_freeze_multi;/* MultiXactId that will be used as freeze
+ * cutoff point for multixacts */
MemoryContext rs_cxt; /* for hash tables and entries and tuples in
* them */
HTAB *rs_unresolved_tups; /* unmatched A tuples */
@@ -177,6 +180,7 @@ static void raw_heap_insert(RewriteState state, HeapTuple tup);
* new_heap new, locked heap relation to insert tuples to
* oldest_xmin xid used by the caller to determine which tuples are dead
* freeze_xid xid before which tuples will be frozen
+ * freeze_multi multixact before which multis will be frozen
* use_wal should the inserts to the new heap be WAL-logged?
*
* Returns an opaque RewriteState, allocated in current memory context,
@@ -184,7 +188,8 @@ static void raw_heap_insert(RewriteState state, HeapTuple tup);
*/
RewriteState
begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin,
- TransactionId freeze_xid, bool use_wal)
+ TransactionId freeze_xid, MultiXactId freeze_multi,
+ bool use_wal)
{
RewriteState state;
MemoryContext rw_cxt;
@@ -213,6 +218,7 @@ begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin,
state->rs_use_wal = use_wal;
state->rs_oldest_xmin = oldest_xmin;
state->rs_freeze_xid = freeze_xid;
+ state->rs_freeze_multi = freeze_multi;
state->rs_cxt = rw_cxt;
/* Initialize hash tables used to track update chains */
@@ -337,7 +343,8 @@ rewrite_heap_tuple(RewriteState state,
* While we have our hands on the tuple, we may as well freeze any
* very-old xmin or xmax, so that future VACUUM effort can be saved.
*/
- heap_freeze_tuple(new_tuple->t_data, state->rs_freeze_xid);
+ heap_freeze_tuple(new_tuple->t_data, state->rs_freeze_xid,
+ state->rs_freeze_multi);
/*
* Invalid ctid means that ctid should point to the tuple itself. We'll
@@ -348,15 +355,15 @@ rewrite_heap_tuple(RewriteState state,
/*
* If the tuple has been updated, check the old-to-new mapping hash table.
*/
- if (!(old_tuple->t_data->t_infomask & (HEAP_XMAX_INVALID |
- HEAP_IS_LOCKED)) &&
+ if (!((old_tuple->t_data->t_infomask & HEAP_XMAX_INVALID) ||
+ HeapTupleHeaderIsOnlyLocked(old_tuple->t_data)) &&
!(ItemPointerEquals(&(old_tuple->t_self),
&(old_tuple->t_data->t_ctid))))
{
OldToNewMapping mapping;
memset(&hashkey, 0, sizeof(hashkey));
- hashkey.xmin = HeapTupleHeaderGetXmax(old_tuple->t_data);
+ hashkey.xmin = HeapTupleHeaderGetUpdateXid(old_tuple->t_data);
hashkey.tid = old_tuple->t_data->t_ctid;
mapping = (OldToNewMapping)