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 1oVwJw-0005lD-MG for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Sep 2022 14:46:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oVwJv-00071Q-HF for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Sep 2022 14:46:27 +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 1oVwJu-00071H-Qg for pgsql-hackers@lists.postgresql.org; Wed, 07 Sep 2022 14:46:27 +0000 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oVwJq-0004Bo-Sf for pgsql-hackers@lists.postgresql.org; Wed, 07 Sep 2022 14:46:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662561982; x=1694097982; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to; bh=6WNqtTbRAqAOGfiEAX1DQr0kXXn/IiLwcSfHJT5rSsQ=; b=N4ngP19DCpyiJRIAA0h8FSArxh6umwFiqdeZZ3uiaKaDhJ80sFJoDYrU UBQfjaxNf/uNOva3xU5vrZKIQ9UTs4q6RWnASOFFSuQlQaIjQ7TphVofq wcsPxnRkkNEvvrneCDMoOP9knaOb1J0jtDyNhIiER+Ut2MjojlQGRcUqC k=; X-IronPort-AV: E=Sophos;i="5.93,297,1654560000"; d="scan'208,217";a="238568222" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-4213ea4c.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 14:46:10 +0000 Received: from EX13D03EUC003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2c-4213ea4c.us-west-2.amazon.com (Postfix) with ESMTPS id 0873E81155; Wed, 7 Sep 2022 14:46:09 +0000 (UTC) Received: from [192.168.25.177] (10.43.164.23) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 7 Sep 2022 14:46:07 +0000 Content-Type: multipart/alternative; boundary="------------0bKvExX2q0br5JuBzu5HPtfO" Message-ID: <9dae37cb-abe0-a773-da74-3e2b62279d4c@amazon.com> Date: Wed, 7 Sep 2022 16:46:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: SYSTEM_USER reserved word implementation Content-Language: en-US To: Michael Paquier CC: Jacob Champion , Alvaro Herrera , Tom Lane , Joe Conway , PostgreSQL Hackers References: <20220627173250.46lvecpvuunc7pf5@alvherre.pgsql> <24d638c7-16f6-afb9-c25c-6a29c169210e@amazon.com> <8fe1752a-2e3d-4ee8-656c-0caf5d860b0e@amazon.com> <1da0e60c-bd85-9f2d-2039-103055338b00@amazon.com> <40b4e4d0-d034-ea19-3ec3-1557f498770f@amazon.com> From: "Drouvot, Bertrand" In-Reply-To: X-Originating-IP: [10.43.164.23] X-ClientProxiedBy: EX13D51EUC001.ant.amazon.com (10.43.164.111) 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 --------------0bKvExX2q0br5JuBzu5HPtfO Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Hi, On 9/7/22 10:48 AM, Michael Paquier wrote: > On Fri, Aug 26, 2022 at 10:02:26AM +0900, Michael Paquier wrote: >> FWIW, I was also wondering about the need for all this initialization >> stanza and the extra SystemUser in TopMemoryContext. Now that we have >> MyClientConnectionInfo, I was thinking to just build the string in the >> SQL function as that's the only code path that needs to know about >> it. True that this approach saves some extra palloc() calls each time >> the function is called. > At the end, fine by me to keep this approach as that's more > consistent. I have reviewed the patch, Thanks for looking at it! > and a few things caught my > attention: > - I think that we'd better switch InitializeSystemUser() to have two > const char * as arguments for authn_id and an auth_method, so as there > is no need to use tweaks with UserAuth or ClientConnectionInfo in > miscadmin.h to bypass an inclusion of libpq-be.h or hba.h. Good point, thanks! And there is no need to pass the whole ClientConnectionInfo (should we add more fields to it in the future). > - The OID of the new function should be in the range 8000-9999, as > taught by unused_oids. Thanks for pointing out! My reasoning was to use one available OID close to the ones used for session_user and current_user. > - Environments where the code is built without krb5 support would skip > the test where SYSTEM_USER should be not NULL when authenticated, so I > have added a test for that with MD5 in src/test/authentication/. Good point, thanks for the new test (as that would also not be tested (once added) in the new peer TAP test [1] for platforms where peer authentication is not supported). > - Docs have been reworded, and I have applied an indentation. Thanks, looks good to me. > - No need to use 200k rows in the table used to force the parallel > scan, as long as the costs are set. Right. > > It is a bit late here, so I may have missed something. For now, how > does the attached look to you? +# Test SYSTEM_USER <> NULL with parallel workers. Nit: What about "Test SYSTEM_USER get the correct value with parallel workers" as that's what we are actually testing. Except the Nit above, that looks all good to me. [1]: https://commitfest.postgresql.org/39/3845/ Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services:https://aws.amazon.com --------------0bKvExX2q0br5JuBzu5HPtfO Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit

Hi,

On 9/7/22 10:48 AM, Michael Paquier wrote:
On Fri, Aug 26, 2022 at 10:02:26AM +0900, Michael Paquier wrote:
FWIW, I was also wondering about the need for all this initialization
stanza and the extra SystemUser in TopMemoryContext.  Now that we have
MyClientConnectionInfo, I was thinking to just build the string in the
SQL function as that's the only code path that needs to know about
it.  True that this approach saves some extra palloc() calls each time
the function is called.
At the end, fine by me to keep this approach as that's more
consistent.  I have reviewed the patch, 

Thanks for looking at it!

and a few things caught my
attention:
- I think that we'd better switch InitializeSystemUser() to have two
const char * as arguments for authn_id and an auth_method, so as there
is no need to use tweaks with UserAuth or ClientConnectionInfo in
miscadmin.h to bypass an inclusion of libpq-be.h or hba.h.

Good point, thanks! And there is no need to pass the whole ClientConnectionInfo (should we add more fields to it in the future).

- The OID of the new function  should be in the range 8000-9999, as
taught by unused_oids.

Thanks for pointing out!

My reasoning was to use one available OID close to the ones used for session_user and current_user.

- Environments where the code is built without krb5 support would skip
the test where SYSTEM_USER should be not NULL when authenticated, so I
have added a test for that with MD5 in src/test/authentication/.

Good point, thanks for the new test (as that would also not be tested (once added) in the new peer TAP test [1] for platforms where peer authentication is not supported).

- Docs have been reworded, and I have applied an indentation.
Thanks, looks good to me.
- No need to use 200k rows in the table used to force the parallel
scan, as long as the costs are set.
Right.

It is a bit late here, so I may have missed something.  For now, how
does the attached look to you?

+# Test SYSTEM_USER <> NULL with parallel workers.

Nit: What about "Test SYSTEM_USER get the correct value with parallel workers" as that's what we are actually testing.

Except the Nit above, that looks all good to me.


[1]: https://commitfest.postgresql.org/39/3845/

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
--------------0bKvExX2q0br5JuBzu5HPtfO--