Use T_IntList for uint32 - Mailing list pgsql-hackers

From Amit Kapila
Subject Use T_IntList for uint32
Date
Msg-id CAA4eK1K=LFXnJO4+ySo85xc+Aqca75_KXMUXwYMLowuzai5TdQ@mail.gmail.com
Whole thread Raw
Responses Re: Use T_IntList for uint32
Re: Use T_IntList for uint32
List pgsql-hackers
Currently pg_list.h doesn't have a variant for uint32 list (like
T_UIntList), is there a reason other than that that we don't need it
till now? I see that one can use T_OidList instead (as Oid is uint32)
but I am not sure if that is a good idea to say use it for maintaining
a list of TransactionIds. We need to use such a variant of T_UIntlist
at one place in the patch for the "streaming of in-progress
transactions" [1].

The current use case is as below:

typedef struct RelationSyncEntry
{
..
List    *streamed_txns; /* streamed toplevel transactions with this
* schema */

/*
 * We expect relatively small number of streamed transactions.
 */
static bool
get_schema_sent_in_streamed_txn(RelationSyncEntry *entry, TransactionId xid)
{
..
foreach (lc, entry->streamed_txns)
{
if (xid == lfirst_int(lc))
return true;
}
..
}

/*
 * Add the xid in the rel sync entry for which we have already sent the schema
 * of the relation.
 */
static void
set_schema_sent_in_streamed_txn(RelationSyncEntry *entry, TransactionId xid)
{
..
entry->streamed_txns = lappend_int(entry->streamed_txns, xid);
..
}

Now, as far as I can see there is no problem in using T_IntList in
such usage because we are not going to fetch stored unsigned value as
a signed value, so the comparison in get_schema_sent_in_streamed_txn
should work well. However, still, I thought it would be better if
there is a built-in T_UIntList.

Thoughts?

[1] - https://www.postgresql.org/message-id/CAFiTN-u_4uvGjAPO536m-YsR%2Bk9J-%3Dwqx2K9CtrFOHcJPa7Szg%40mail.gmail.com

-- 
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: torikoshia
Date:
Subject: Get memory contexts of an arbitrary backend process
Next
From: Pavel Borisov
Date:
Subject: Re: [PATCH] Covering SPGiST index