Add copy/equal support for XID lists
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 12 Jul 2022 14:11:04 +0000 (16:11 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 12 Jul 2022 14:11:04 +0000 (16:11 +0200)
Commit f10a025cfe97 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

src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/test/modules/test_oat_hooks/test_oat_hooks.c

index b8e40a4195ac6884903716fb41a9a682cd9d3802..e76fda8eba3cfcaa6519856d4db7eee59786eea9 100644 (file)
@@ -187,11 +187,12 @@ copyObjectImpl(const void *from)
            break;
 
            /*
-            * Lists of integers and OIDs don't need to be deep-copied, so we
-            * perform a shallow copy via list_copy()
+            * Lists of integers, OIDs and XIDs don't need to be deep-copied,
+            * so we perform a shallow copy via list_copy()
             */
        case T_IntList:
        case T_OidList:
+       case T_XidList:
            retval = list_copy(from);
            break;
 
index 8d54e1a4866800b27372fa439eb5142bed42eab7..0373aa30fe9fd1bcc91023188bb279507911d087 100644 (file)
@@ -188,6 +188,13 @@ _equalList(const List *a, const List *b)
                    return false;
            }
            break;
+       case T_XidList:
+           forboth(item_a, a, item_b, b)
+           {
+               if (lfirst_xid(item_a) != lfirst_xid(item_b))
+                   return false;
+           }
+           break;
        default:
            elog(ERROR, "unrecognized list node type: %d",
                 (int) a->type);
@@ -238,6 +245,7 @@ equal(const void *a, const void *b)
        case T_List:
        case T_IntList:
        case T_OidList:
+       case T_XidList:
            retval = _equalList(a, b);
            break;
 
index 0ad77e743de00f914a5739f4280a1298f8152840..1f40d632e07970d1f0d3d375196bef3f97fbecac 100644 (file)
@@ -1122,6 +1122,9 @@ nodetag_to_string(NodeTag tag)
        case T_OidList:
            return "OidList";
            break;
+       case T_XidList:
+           return "XidList";
+           break;
        case T_ExtensibleNode:
            return "ExtensibleNode";
            break;