Use T_IntList for uint32

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Subject: Use T_IntList for uint32
Date: 2020-08-31 11:29:06
Message-ID: CAA4eK1K=LFXnJO4+ySo85xc+Aqca75_KXMUXwYMLowuzai5TdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Borisov 2020-08-31 11:57:56 Re: [PATCH] Covering SPGiST index
Previous Message torikoshia 2020-08-31 11:22:18 Get memory contexts of an arbitrary backend process