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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com>
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-14 09:57:40
Message-ID: YvjHFPs2yEDiMLVU@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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. 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.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-08-14 10:11:11 Re: Tab completion for "ALTER TYPE typename SET" and rearranged "Alter TYPE typename RENAME"
Previous Message Gurjeet Singh 2022-08-14 05:52:33 Re: Patch proposal: New hooks in the connection path