From 13d2a332b84c38a1ccdd3705977e3a0859028bf5 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Fri, 8 Feb 2019 10:44:54 +0900 Subject: [PATCH v25 1/5] Keep track of writing on non-temporary relation --- src/backend/executor/nodeModifyTable.c | 12 ++++++++++++ src/include/access/xact.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 01fe11a..778ff27 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -588,6 +588,10 @@ ExecInsert(ModifyTableState *mtstate, estate->es_output_cid, 0, NULL); + /* Make note that we've wrote on non-temprary relation */ + if (RelationNeedsWAL(resultRelationDesc)) + MyXactFlags |= XACT_FLAGS_WROTENONTEMPREL; + /* insert index entries for tuple */ if (resultRelInfo->ri_NumIndices > 0) recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL, @@ -940,6 +944,10 @@ ldelete:; if (tupleDeleted) *tupleDeleted = true; + /* Make note that we've wrote on non-temprary relation */ + if (RelationNeedsWAL(resultRelationDesc)) + MyXactFlags |= XACT_FLAGS_WROTENONTEMPREL; + /* * If this delete is the result of a partition key update that moved the * tuple to a new partition, put this row into the transition OLD TABLE, @@ -1451,6 +1459,10 @@ lreplace:; recheckIndexes = ExecInsertIndexTuples(slot, estate, false, NULL, NIL); } + /* Make note that we've wrote on non-temprary relation */ + if (RelationNeedsWAL(resultRelationDesc)) + MyXactFlags |= XACT_FLAGS_WROTENONTEMPREL; + if (canSetTag) (estate->es_processed)++; diff --git a/src/include/access/xact.h b/src/include/access/xact.h index d714551..6f4013e 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -103,6 +103,12 @@ 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 */ typedef enum -- 2.10.5