pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Drouvot, Bertrand <bdrouvot@amazon.com>
To: Jacob Champion <jchampion@timescale.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Joe Conway <mail@joeconway.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: sfrost@snowman.net <sfrost@snowman.net>
Cc: rjuju123@gmail.com <rjuju123@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: andres@anarazel.de <andres@anarazel.de>
Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers
Date: Wed, 17 Aug 2022 09:53:45 +0200
Message-ID: <2541c086-e370-d114-69a7-b48b05b25471@amazon.com> (raw)
In-Reply-To: <CAAWbhmgJ-5YHyOO4ioa-q1bDRexiwMBFru6jJVmV+ShUx_0yeQ@mail.gmail.com>
References: <Yu4JhEvh1V0sGWXv@paquier.xyz>
	<af85ae52-de60-6a98-d69e-7d410aee752d@joeconway.com>
	<Yu9slCBp0WWD4Qx1@paquier.xyz>
	<d25a412e-9686-d37f-3bd1-63b821f67a51@amazon.com>
	<YvImQ0sl1dV4TBNg@paquier.xyz>
	<34308245-ea21-82ee-b1fd-00b4766f3527@amazon.com>
	<CAAWbhmi4OHmk0EVBuQrYcwbotF8uFayDVgkL-H-gqrK0XmeSeg@mail.gmail.com>
	<2a1e2717-8c68-3f9e-1e02-32da71deb327@amazon.com>
	<CAAWbhmiRZMBLCKjJV43skOxiBM71P82O2KMJf-n97t4zUtdqDw@mail.gmail.com>
	<127bd019-04f0-313c-551c-d949cdc4ad50@amazon.com>
	<YvjHFPs2yEDiMLVU@paquier.xyz>
	<520bd3ce-334b-b9c2-2130-858fb04ce56f@amazon.com>
	<CAAWbhmgJ-5YHyOO4ioa-q1bDRexiwMBFru6jJVmV+ShUx_0yeQ@mail.gmail.com>

Hi,

On 8/16/22 6:58 PM, Jacob Champion wrote:
> Sounds good. v3, attached, should make the requested changes:
> - declare `struct ClientConnectionInfo`
> - use an intermediate serialization struct
> - switch to length-"prefixing" for the string
>
> I do like the way this reads compared to before.

Thanks for the new version!

+       /* Copy authn_id into the space after the struct. */
+       if (serialized.authn_id_len >= 0)

Maybe remove the "." at the end of the comment? (to be consistent with 
the other comment just above)

+/*
+ * Restore MyClientConnectionInfo from its serialized representation.
+ */
+void
+RestoreClientConnectionInfo(char *conninfo)
+{
+       SerializedClientConnectionInfo serialized;
+       char       *authn_id;

Move "char       *authn_id;" in the "if (serialized.authn_id_len >= 0)" 
below?

+
+       memcpy(&serialized, conninfo, sizeof(serialized));
+       authn_id = conninfo + sizeof(serialized);

Move "authn_id = conninfo + sizeof(serialized)" in the "if 
(serialized.authn_id_len >= 0)" below?

+
+       /* Copy the fields back into place. */

Remove the "." at the end of the comment?

+       MyClientConnectionInfo.authn_id = NULL;
+       MyClientConnectionInfo.auth_method = serialized.auth_method;
+
+       if (serialized.authn_id_len >= 0)
+               MyClientConnectionInfo.authn_id = 
MemoryContextStrdup(TopMemoryContext,
+ authn_id);

This instead?

     if (serialized.authn_id_len >= 0)
     {
         char       *authn_id;
         authn_id = conninfo + sizeof(serialized);
         MyClientConnectionInfo.authn_id = 
MemoryContextStrdup(TopMemoryContext,
authn_id);
     }

+ src/backend/utils/init/miscinit.c:RestoreClientConnectionInfo(char 
*conninfo)
+ src/include/miscadmin.h:extern void RestoreClientConnectionInfo(char 
*procinfo);

conninfo in both to be consistent?

Apart from the comments above, that looks good to me.

Regards,

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






view thread (89+ messages)  latest in thread

Message-ID: <2541c086-e370-d114-69a7-b48b05b25471@amazon.com>
Permalink:  ../2541c086-e370-d114-69a7-b48b05b25471@amazon.com/
Also on:    postgresql.org/message-id/2541c086-e370-d114-69a7-b48b05b25471@amazon.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: bdrouvot@amazon.com, jchampion@timescale.com, michael@paquier.xyz, mail@joeconway.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, sfrost@snowman.net, rjuju123@gmail.com, andres@anarazel.de
  Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers
  In-Reply-To: <2541c086-e370-d114-69a7-b48b05b25471@amazon.com>
  References: <Yu4JhEvh1V0sGWXv@paquier.xyz> <af85ae52-de60-6a98-d69e-7d410aee752d@joeconway.com> <Yu9slCBp0WWD4Qx1@paquier.xyz> <d25a412e-9686-d37f-3bd1-63b821f67a51@amazon.com> <YvImQ0sl1dV4TBNg@paquier.xyz> <34308245-ea21-82ee-b1fd-00b4766f3527@amazon.com> <CAAWbhmi4OHmk0EVBuQrYcwbotF8uFayDVgkL-H-gqrK0XmeSeg@mail.gmail.com> <2a1e2717-8c68-3f9e-1e02-32da71deb327@amazon.com> <CAAWbhmiRZMBLCKjJV43skOxiBM71P82O2KMJf-n97t4zUtdqDw@mail.gmail.com> <127bd019-04f0-313c-551c-d949cdc4ad50@amazon.com> <YvjHFPs2yEDiMLVU@paquier.xyz> <520bd3ce-334b-b9c2-2130-858fb04ce56f@amazon.com> <CAAWbhmgJ-5YHyOO4ioa-q1bDRexiwMBFru6jJVmV+ShUx_0yeQ@mail.gmail.com> <2541c086-e370-d114-69a7-b48b05b25471@amazon.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox