Skip to content

Commit 5ca0fe5

Browse files
committed
Add copy/equal support for XID lists
Commit f10a025 added support for List to store Xids, but didn't handle the new type in all cases. Add some obviously necessary pieces. As far as I am aware, this is all dead code as far as core code is concerned, but it seems unacceptable not to have it in case third-party code wants to rely on this type of list. (Some parts of the List API remain unimplemented, but that can be fixed as and when needed -- see lack of list_intersection_oid, list_deduplicate_int as precedents.) Discussion: https://postgr.es/m/20220708164534.nbejhgt4ajz35p65@alvherre.pgsql
1 parent d3117fc commit 5ca0fe5

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ copyObjectImpl(const void *from)
187187
break;
188188

189189
/*
190-
* Lists of integers and OIDs don't need to be deep-copied, so we
191-
* perform a shallow copy via list_copy()
190+
* Lists of integers, OIDs and XIDs don't need to be deep-copied,
191+
* so we perform a shallow copy via list_copy()
192192
*/
193193
case T_IntList:
194194
case T_OidList:
195+
case T_XidList:
195196
retval = list_copy(from);
196197
break;
197198

src/backend/nodes/equalfuncs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ _equalList(const List *a, const List *b)
188188
return false;
189189
}
190190
break;
191+
case T_XidList:
192+
forboth(item_a, a, item_b, b)
193+
{
194+
if (lfirst_xid(item_a) != lfirst_xid(item_b))
195+
return false;
196+
}
197+
break;
191198
default:
192199
elog(ERROR, "unrecognized list node type: %d",
193200
(int) a->type);
@@ -238,6 +245,7 @@ equal(const void *a, const void *b)
238245
case T_List:
239246
case T_IntList:
240247
case T_OidList:
248+
case T_XidList:
241249
retval = _equalList(a, b);
242250
break;
243251

src/test/modules/test_oat_hooks/test_oat_hooks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,9 @@ nodetag_to_string(NodeTag tag)
11221122
case T_OidList:
11231123
return "OidList";
11241124
break;
1125+
case T_XidList:
1126+
return "XidList";
1127+
break;
11251128
case T_ExtensibleNode:
11261129
return "ExtensibleNode";
11271130
break;

0 commit comments

Comments
 (0)