Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNsTZ-0000nE-1r for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Aug 2022 09:03:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oNsTX-0003oO-BD for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Aug 2022 09:03:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNsTW-0003oF-BN for pgsql-hackers@lists.postgresql.org; Tue, 16 Aug 2022 09:03:03 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNsTS-0007oH-FI for pgsql-hackers@postgresql.org; Tue, 16 Aug 2022 09:03:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660640578; x=1692176578; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=JnhaQR5OkaiTFSJfdWqKzhMB5dP7MOAA+U6z9AVfwk0=; b=bqR1QuKlvKiQj3XbtZOu/j0X7tQlfz3RwoyFs/lorHTwrh4lKF1wFQAB ZaHeFbBAds5KdFxlXgbU1ovXhoH+uYltdfnouLOI24dQpQWYPXSl6RLci Qu3jqsXgNtKzwOktAthTi1356lgLfMpL2ugDgEwdYEHkU355NEZXqfIJL A=; X-IronPort-AV: E=Sophos;i="5.93,240,1654560000"; d="scan'208";a="218274081" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-22c2b493.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 09:02:40 +0000 Received: from EX13D03EUC003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-22c2b493.us-west-2.amazon.com (Postfix) with ESMTPS id AF69A44909; Tue, 16 Aug 2022 09:02:38 +0000 (UTC) Received: from [192.168.1.150] (10.43.161.123) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 16 Aug 2022 09:02:34 +0000 Message-ID: <520bd3ce-334b-b9c2-2130-858fb04ce56f@amazon.com> Date: Tue, 16 Aug 2022 11:02:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers Content-Language: en-US To: Michael Paquier CC: Jacob Champion , Joe Conway , Robert Haas , Tom Lane , "sfrost@snowman.net" , "rjuju123@gmail.com" , "pgsql-hackers@postgresql.org" , "andres@anarazel.de" References: <34308245-ea21-82ee-b1fd-00b4766f3527@amazon.com> <2a1e2717-8c68-3f9e-1e02-32da71deb327@amazon.com> <127bd019-04f0-313c-551c-d949cdc4ad50@amazon.com> From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.43.161.123] X-ClientProxiedBy: EX13d09UWC004.ant.amazon.com (10.43.162.114) To EX13D03EUC003.ant.amazon.com (10.43.164.192) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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