From 683b47de51f23bb899c92bac8bc3947d2d262c5a Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Thu, 8 Feb 2018 11:26:46 +0900 Subject: [PATCH v21 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 fb63471..c2db19b 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2629,6 +2629,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); } @@ -3453,6 +3457,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; } @@ -4403,6 +4411,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 689c57c..2c1b2d8 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