From c655515f56192080e0aef9b138952ae33713c091 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Thu, 8 Feb 2018 11:26:46 +0900 Subject: [PATCH v18 1/4] Keep track of writing on non-temporary relation. --- src/backend/access/heap/heapam.c | 12 ++++++++++++ src/include/access/xact.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 5f1a69c..31a44ca 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2623,6 +2623,10 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, heap_freetuple(heaptup); } + /* Make note that we've wrote on non-temprary relation */ + if (RelationNeedsWAL(relation)) + MyXactFlags |= XACT_FLAGS_WROTENONTEMPREL; + return HeapTupleGetOid(tup); } @@ -3444,6 +3448,10 @@ l1: if (old_key_tuple != NULL && old_key_copied) heap_freetuple(old_key_tuple); + /* Make note that we've wrote on non-temprary relation */ + if (RelationNeedsWAL(relation)) + MyXactFlags |= XACT_FLAGS_WROTENONTEMPREL; + return HeapTupleMayBeUpdated; } @@ -4394,6 +4402,10 @@ l2: if (old_key_tuple != NULL && old_key_copied) heap_freetuple(old_key_tuple); + /* Make note that we've wrote on non-temprary relation */ + if (RelationNeedsWAL(relation)) + MyXactFlags |= XACT_FLAGS_WROTENONTEMPREL; + bms_free(hot_attrs); bms_free(proj_idx_attrs); bms_free(key_attrs); diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 083e879..c7b4144 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -98,6 +98,11 @@ extern int MyXactFlags; */ #define XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK (1U << 1) +/* + * XACT_FLAGS_WROTENONTEMPREL - set when we wrote data on non-temporary + * relation. + */ +#define XACT_FLAGS_WROTENONTEMPREL (1U << 2) /* * start- and end-of-transaction callbacks for dynamically loaded modules -- 2.10.5