aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/nodes/list.c')
-rw-r--r--src/backend/nodes/list.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c
index f843f861ef8..9d8f4fd5c7c 100644
--- a/src/backend/nodes/list.c
+++ b/src/backend/nodes/list.c
@@ -54,6 +54,7 @@
#define IsPointerList(l) ((l) == NIL || IsA((l), List))
#define IsIntegerList(l) ((l) == NIL || IsA((l), IntList))
#define IsOidList(l) ((l) == NIL || IsA((l), OidList))
+#define IsXidList(l) ((l) == NIL || IsA((l), XidList))
#ifdef USE_ASSERT_CHECKING
/*
@@ -71,7 +72,8 @@ check_list_invariants(const List *list)
Assert(list->type == T_List ||
list->type == T_IntList ||
- list->type == T_OidList);
+ list->type == T_OidList ||
+ list->type == T_XidList);
}
#else
#define check_list_invariants(l) ((void) 0)
@@ -384,6 +386,24 @@ lappend_oid(List *list, Oid datum)
}
/*
+ * Append a TransactionId to the specified list. See lappend()
+ */
+List *
+lappend_xid(List *list, TransactionId datum)
+{
+ Assert(IsXidList(list));
+
+ if (list == NIL)
+ list = new_list(T_XidList, 1);
+ else
+ new_tail_cell(list);
+
+ llast_xid(list) = datum;
+ check_list_invariants(list);
+ return list;
+}
+
+/*
* Make room for a new cell at position 'pos' (measured from 0).
* The data in the cell is left undefined, and must be filled in by the
* caller. 'list' is assumed to be non-NIL, and 'pos' must be a valid
@@ -715,6 +735,26 @@ list_member_oid(const List *list, Oid datum)
}
/*
+ * Return true iff the TransactionId 'datum' is a member of the list.
+ */
+bool
+list_member_xid(const List *list, TransactionId datum)
+{
+ const ListCell *cell;
+
+ Assert(IsXidList(list));
+ check_list_invariants(list);
+
+ foreach(cell, list)
+ {
+ if (lfirst_oid(cell) == datum)
+ return true;
+ }
+
+ return false;
+}
+
+/*
* Delete the n'th cell (counting from 0) in list.
*
* The List is pfree'd if this was the last member.