summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAlexander Korotkov2024-03-21 21:00:43 +0000
committerAlexander Korotkov2024-03-21 21:00:43 +0000
commit0997e0af273d80add75bcf5616eee000d0a78397 (patch)
tree199c96b60baaead3d37a9918ee63f256f2f21410 /src/include
parentc35a3fb5e067fc95f13206418e3785d2cb059da1 (diff)
Add TupleTableSlotOps.is_current_xact_tuple() method
This allows us to abstract how/whether table AM uses transaction identifiers. A custom table AM can use a custom slot, which may not store xmin directly, but determine the tuple belonging to the current transaction in the other way. Discussion: https://postgr.es/m/CAPpHfdurb9ycV8udYqM%3Do0sPS66PJ4RCBM1g-bBpvzUfogY0EA%40mail.gmail.com Reviewed-by: Matthias van de Meent, Mark Dilger, Pavel Borisov Reviewed-by: Nikita Malakhov, Japin Li
Diffstat (limited to 'src/include')
-rw-r--r--src/include/executor/tuptable.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
index 6133dbcd0a3..b82655e7e55 100644
--- a/src/include/executor/tuptable.h
+++ b/src/include/executor/tuptable.h
@@ -167,6 +167,12 @@ struct TupleTableSlotOps
Datum (*getsysattr) (TupleTableSlot *slot, int attnum, bool *isnull);
/*
+ * Check if the tuple is created by the current transaction. Throws an
+ * error if the slot doesn't contain the storage tuple.
+ */
+ bool (*is_current_xact_tuple) (TupleTableSlot *slot);
+
+ /*
* Make the contents of the slot solely depend on the slot, and not on
* underlying resources (like another memory context, buffers, etc).
*/
@@ -427,6 +433,21 @@ slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
}
/*
+ * slot_is_current_xact_tuple - check if the slot's current tuple is created
+ * by the current transaction.
+ *
+ * If the slot does not contain a storage tuple, this will throw an error.
+ * Hence before calling this function, callers should make sure that the
+ * slot type supports storage tuples and that there is currently one inside
+ * the slot.
+ */
+static inline bool
+slot_is_current_xact_tuple(TupleTableSlot *slot)
+{
+ return slot->tts_ops->is_current_xact_tuple(slot);
+}
+
+/*
* ExecClearTuple - clear the slot's contents
*/
static inline TupleTableSlot *