diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/heapam.h | 2 | ||||
-rw-r--r-- | src/include/access/heapam_xlog.h | 1 | ||||
-rw-r--r-- | src/include/access/htup_details.h | 12 | ||||
-rw-r--r-- | src/include/executor/nodeModifyTable.h | 3 | ||||
-rw-r--r-- | src/include/storage/itemptr.h | 16 |
5 files changed, 30 insertions, 4 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 608f50b0616..7d756f20b08 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -167,7 +167,7 @@ extern void heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples, CommandId cid, int options, BulkInsertState bistate); extern HTSU_Result heap_delete(Relation relation, ItemPointer tid, CommandId cid, Snapshot crosscheck, bool wait, - HeapUpdateFailureData *hufd); + HeapUpdateFailureData *hufd, bool changingPart); extern void heap_finish_speculative(Relation relation, HeapTuple tuple); extern void heap_abort_speculative(Relation relation, HeapTuple tuple); extern HTSU_Result heap_update(Relation relation, ItemPointer otid, diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h index 0052e4c569a..cf88ff7cb44 100644 --- a/src/include/access/heapam_xlog.h +++ b/src/include/access/heapam_xlog.h @@ -93,6 +93,7 @@ #define XLH_DELETE_CONTAINS_OLD_TUPLE (1<<1) #define XLH_DELETE_CONTAINS_OLD_KEY (1<<2) #define XLH_DELETE_IS_SUPER (1<<3) +#define XLH_DELETE_IS_PARTITION_MOVE (1<<4) /* convenience macro for checking whether any form of old tuple was logged */ #define XLH_DELETE_CONTAINS_OLD \ diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h index cebaea097d1..cf56d4ace43 100644 --- a/src/include/access/htup_details.h +++ b/src/include/access/htup_details.h @@ -83,8 +83,10 @@ * * A word about t_ctid: whenever a new tuple is stored on disk, its t_ctid * is initialized with its own TID (location). If the tuple is ever updated, - * its t_ctid is changed to point to the replacement version of the tuple. - * Thus, a tuple is the latest version of its row iff XMAX is invalid or + * its t_ctid is changed to point to the replacement version of the tuple or + * the block number (ip_blkid) is invalidated if the tuple is moved from one + * partition to another partition relation due to an update of the partition + * key. Thus, a tuple is the latest version of its row iff XMAX is invalid or * t_ctid points to itself (in which case, if XMAX is valid, the tuple is * either locked or deleted). One can follow the chain of t_ctid links * to find the newest version of the row. Beware however that VACUUM might @@ -445,6 +447,12 @@ do { \ ItemPointerSet(&(tup)->t_ctid, token, SpecTokenOffsetNumber) \ ) +#define HeapTupleHeaderSetMovedPartitions(tup) \ + ItemPointerSetMovedPartitions(&(tup)->t_ctid) + +#define HeapTupleHeaderIndicatesMovedPartitions(tup) \ + ItemPointerIndicatesMovedPartitions(&tup->t_ctid) + #define HeapTupleHeaderGetDatumLength(tup) \ VARSIZE(tup) diff --git a/src/include/executor/nodeModifyTable.h b/src/include/executor/nodeModifyTable.h index 94fd60c38cf..7e9ab3cb6b4 100644 --- a/src/include/executor/nodeModifyTable.h +++ b/src/include/executor/nodeModifyTable.h @@ -27,7 +27,8 @@ extern TupleTableSlot *ExecDelete(ModifyTableState *mtstate, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *planSlot, EPQState *epqstate, EState *estate, bool *tupleDeleted, bool processReturning, HeapUpdateFailureData *hufdp, - MergeActionState *actionState, bool canSetTag); + MergeActionState *actionState, bool canSetTag, + bool changingPart); extern TupleTableSlot *ExecUpdate(ModifyTableState *mtstate, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot, TupleTableSlot *planSlot, EPQState *epqstate, EState *estate, diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h index 6c9ed3696b7..626c98f9691 100644 --- a/src/include/storage/itemptr.h +++ b/src/include/storage/itemptr.h @@ -154,6 +154,22 @@ typedef ItemPointerData *ItemPointer; (pointer)->ip_posid = InvalidOffsetNumber \ ) +/* + * ItemPointerIndicatesMovedPartitions + * True iff the block number indicates the tuple has moved to another + * partition. + */ +#define ItemPointerIndicatesMovedPartitions(pointer) \ + !BlockNumberIsValid(ItemPointerGetBlockNumberNoCheck(pointer)) + +/* + * ItemPointerSetMovedPartitions + * Indicate that the item referenced by the itempointer has moved into a + * different partition. + */ +#define ItemPointerSetMovedPartitions(pointer) \ + ItemPointerSetBlockNumber((pointer), InvalidBlockNumber) + /* ---------------- * externs * ---------------- |