improve_commit_with_OCDR_v3.patch
application/octet-stream
Filename: improve_commit_with_OCDR_v3.patch
Type: application/octet-stream
Part: 1
Patch
Format: unified
Series: patch v3
| File | + | − |
|---|---|---|
| src/backend/access/heap/heapam.c | 4 | 0 |
| src/backend/commands/tablecmds.c | 7 | 1 |
| src/include/commands/tablecmds.h | 2 | 0 |
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index b19d1cf..bfc1bad 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -54,6 +54,7 @@
#include "access/xlogutils.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
+#include "commands/tablecmds.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
@@ -2056,6 +2057,9 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
heap_freetuple(heaptup);
}
+ if (RelationUsesLocalBuffers(relation))
+ MyXactInsertedIntoTempRel = true;
+
return HeapTupleGetOid(tup);
}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index cad8311..e1eac61 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -106,6 +106,8 @@ typedef struct OnCommitItem
SubTransactionId deleting_subid;
} OnCommitItem;
+bool MyXactInsertedIntoTempRel = false;
+
static List *on_commits = NIL;
@@ -10118,7 +10120,8 @@ PreCommit_on_commit_actions(void)
/* Do nothing (there shouldn't be such entries, actually) */
break;
case ONCOMMIT_DELETE_ROWS:
- oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid);
+ if (MyXactInsertedIntoTempRel)
+ oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid);
break;
case ONCOMMIT_DROP:
{
@@ -10146,6 +10149,7 @@ PreCommit_on_commit_actions(void)
}
}
}
+
if (oids_to_truncate != NIL)
{
heap_truncate(oids_to_truncate);
@@ -10194,6 +10198,8 @@ AtEOXact_on_commit_actions(bool isCommit)
cur_item = lnext(prev_item);
}
}
+
+ MyXactInsertedIntoTempRel = false;
}
/*
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index 27dc5e8..54d39da 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -78,4 +78,6 @@ extern void AtEOSubXact_on_commit_actions(bool isCommit,
extern void RangeVarCallbackOwnsTable(const RangeVar *relation,
Oid relId, Oid oldRelId, void *arg);
+extern bool MyXactInsertedIntoTempRel;
+
#endif /* TABLECMDS_H */