Re: [PATCH] Expose port->authn_id to extensions and triggers

From: "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Jacob Champion <jchampion(at)timescale(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "sfrost(at)snowman(dot)net" <sfrost(at)snowman(dot)net>, "rjuju123(at)gmail(dot)com" <rjuju123(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "andres(at)anarazel(dot)de" <andres(at)anarazel(dot)de>
Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers
Date: 2022-08-16 09:02:30
Message-ID: 520bd3ce-334b-b9c2-2130-858fb04ce56f@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 8/14/22 11:57 AM, Michael Paquier wrote:
> On Fri, Aug 12, 2022 at 03:34:04PM +0200, Drouvot, Bertrand wrote:
>> 3)
>>
>> +SerializeClientConnectionInfo(Size maxsize, char *start_address)
>> +{
>> +       /*
>> +        * First byte is an indication of whether or not authn_id has been
>> set to
>> +        * non-NULL, to differentiate that case from the empty string.
>> +        */
>>
>> is authn_id being an empty string possible?
> I don't recall that this can be the case yet, but we cannot discard
> it.
Fair point.
> One thing was itching me about the serialization and
> deserialization logic though: could it be more readable if we used an
> intermediate structure to store the length of the serialized strings?
> We use this approach in other areas, like for the snapshot data in
> snapmgr.c. This would handle the case of an empty and NULL string, by
> storing -1 as length for NULL and >= 0 for the string length if there
> is something set, while making the addition of more fields a
> no-brainer.

I think that's a good idea and I think that would be more readable (as
compare to storing a "hint" in the first byte).

Regards,

--
Bertrand Drouvot
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2022-08-16 09:06:01 Re: Logical WAL sender unresponsive during decoding commit
Previous Message Daniel Gustafsson 2022-08-16 08:45:30 Re: [PG15 Doc] remove "tty" connect string from manual