diff options
| author | Alvaro Herrera | 2022-07-04 12:52:12 +0000 |
|---|---|---|
| committer | Alvaro Herrera | 2022-07-04 12:52:12 +0000 |
| commit | f10a025cfe97c1a341f636368e67af5ca644c5d8 (patch) | |
| tree | 54e24a8088feaec1b65fba755a7329f18a5f0687 /src/include | |
| parent | 55f4802785f66a584c05dca40e5d9b25491674b2 (diff) | |
Implement List support for TransactionId
Use it for RelationSyncEntry->streamed_txns, which is currently using an
integer list.
The API support is not complete, not because it is hard to write but
because it's unclear that it's worth the code space, there being so
little use of XID lists.
Discussion: https://postgr.es/m/202205130830.g5ntonhztspb@alvherre.pgsql
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/nodes.h | 1 | ||||
| -rw-r--r-- | src/include/nodes/pg_list.h | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index b3b407579b0..7ce1fc4deb6 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -317,6 +317,7 @@ typedef enum NodeTag T_List, T_IntList, T_OidList, + T_XidList, /* * TAGS FOR EXTENSIBLE NODES (extensible.h) diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index 2cb9d1371d9..66e70263b2f 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -45,6 +45,7 @@ typedef union ListCell void *ptr_value; int int_value; Oid oid_value; + TransactionId xid_value; } ListCell; typedef struct List @@ -169,6 +170,7 @@ list_length(const List *l) #define lfirst(lc) ((lc)->ptr_value) #define lfirst_int(lc) ((lc)->int_value) #define lfirst_oid(lc) ((lc)->oid_value) +#define lfirst_xid(lc) ((lc)->xid_value) #define lfirst_node(type,lc) castNode(type, lfirst(lc)) #define linitial(l) lfirst(list_nth_cell(l, 0)) @@ -194,6 +196,7 @@ list_length(const List *l) #define llast(l) lfirst(list_last_cell(l)) #define llast_int(l) lfirst_int(list_last_cell(l)) #define llast_oid(l) lfirst_oid(list_last_cell(l)) +#define llast_xid(l) lfirst_xid(list_last_cell(l)) #define llast_node(type,l) castNode(type, llast(l)) /* @@ -202,6 +205,7 @@ list_length(const List *l) #define list_make_ptr_cell(v) ((ListCell) {.ptr_value = (v)}) #define list_make_int_cell(v) ((ListCell) {.int_value = (v)}) #define list_make_oid_cell(v) ((ListCell) {.oid_value = (v)}) +#define list_make_xid_cell(v) ((ListCell) {.xid_value = (v)}) #define list_make1(x1) \ list_make1_impl(T_List, list_make_ptr_cell(x1)) @@ -248,6 +252,21 @@ list_length(const List *l) list_make_oid_cell(x3), list_make_oid_cell(x4), \ list_make_oid_cell(x5)) +#define list_make1_xid(x1) \ + list_make1_impl(T_XidList, list_make_xid_cell(x1)) +#define list_make2_xid(x1,x2) \ + list_make2_impl(T_XidList, list_make_xid_cell(x1), list_make_xid_cell(x2)) +#define list_make3_xid(x1,x2,x3) \ + list_make3_impl(T_XidList, list_make_xid_cell(x1), list_make_xid_cell(x2), \ + list_make_xid_cell(x3)) +#define list_make4_xid(x1,x2,x3,x4) \ + list_make4_impl(T_XidList, list_make_xid_cell(x1), list_make_xid_cell(x2), \ + list_make_xid_cell(x3), list_make_xid_cell(x4)) +#define list_make5_xid(x1,x2,x3,x4,x5) \ + list_make5_impl(T_XidList, list_make_xid_cell(x1), list_make_xid_cell(x2), \ + list_make_xid_cell(x3), list_make_xid_cell(x4), \ + list_make_xid_cell(x5)) + /* * Locate the n'th cell (counting from 0) of the list. * It is an assertion failure if there is no such cell. @@ -539,6 +558,7 @@ extern List *list_make5_impl(NodeTag t, ListCell datum1, ListCell datum2, extern pg_nodiscard List *lappend(List *list, void *datum); extern pg_nodiscard List *lappend_int(List *list, int datum); extern pg_nodiscard List *lappend_oid(List *list, Oid datum); +extern pg_nodiscard List *lappend_xid(List *list, TransactionId datum); extern pg_nodiscard List *list_insert_nth(List *list, int pos, void *datum); extern pg_nodiscard List *list_insert_nth_int(List *list, int pos, int datum); @@ -557,6 +577,7 @@ extern bool list_member(const List *list, const void *datum); extern bool list_member_ptr(const List *list, const void *datum); extern bool list_member_int(const List *list, int datum); extern bool list_member_oid(const List *list, Oid datum); +extern bool list_member_xid(const List *list, TransactionId datum); extern pg_nodiscard List *list_delete(List *list, void *datum); extern pg_nodiscard List *list_delete_ptr(List *list, void *datum); |
