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 1qJxu3-00015b-3D for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Jul 2023 15:06:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qJxu1-0004oS-VB for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Jul 2023 15:06:45 +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 1qJxu1-0004nw-Gz; Thu, 13 Jul 2023 15:06:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qJxty-000Ctp-18; Thu, 13 Jul 2023 15:06:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 36DF1bq52879333; Thu, 13 Jul 2023 11:01:37 -0400 From: Tom Lane To: Pavel Luzanov cc: "David G. Johnston" , "Jonathan S. Katz" , Robert Haas , David Zhang , "pgsql-hackers@lists.postgresql.org" , rmt@lists.postgresql.org, horikyota.ntt@gmail.com Subject: Re: psql: Add role's membership options to the \du+ command In-reply-to: <50ea2597-5e3f-372c-1ea8-5ba4f3edd690@postgrespro.ru> References: <2977612.1683131109@sss.pgh.pa.us> <39e7431c-1224-ab05-c67c-68f4cf625442@postgrespro.ru> <6b64c59a-fe41-bb07-d0cd-856896412b00@postgresql.org> <7aa3d663-1ea9-de0d-c13a-cbce83902214@postgrespro.ru> <4128935.1687478926@sss.pgh.pa.us> <105356.1687565531@sss.pgh.pa.us> <41517a12-6599-b54b-d30b-3bae906a280b@postgrespro.ru> <1721887.1688836041@sss.p! gh.pa.us> <50ea2597-5e3f-372c-1ea8-5ba4f3edd690@postgrespro.ru> Comments: In-reply-to Pavel Luzanov message dated "Thu, 13 Jul 2023 11:26:07 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2879331.1689260497.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 13 Jul 2023 11:01:37 -0400 Message-ID: <2879332.1689260497@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Pavel Luzanov writes: > On 08.07.2023 20:07, Tom Lane wrote >> 3. Not sure about use of LEFT JOIN in the query. That will mean we >> get a row out even for roles that have no grants, which seems like >> clutter. The LEFT JOINs to r and g are fine, but I suggest changing >> the first join to a plain join. > Can you explain why LEFT JOIN to r and g are fine after removing LEFT > JOIN to pam? The idea with that, IMO, is to do something at least minimally sane if there's a bogus role OID in pg_auth_members. With plain joins, the output row would disappear and you'd have no clue that anything is wrong. With left joins, you get a row with a null column and there's reason to investigate why. Since such a case should not happen in normal use, I don't think it counts for discussions about compactness of output. However, this is also an argument for using a plain not left join between pg_roles and pg_auth_members: if we do it as per the earlier patch, then nulls in the output are common and wouldn't draw your attention. (Indeed, I think broken and not-broken pg_auth_members contents would be indistinguishable.) > I plan to replace it to: >   pg_catalog.concat_ws(', ', >     CASE WHEN pam.admin_option THEN 'ADMIN' END, >     CASE WHEN m.rolinherit THEN 'INHERIT' END, >     'SET' >   ) AS "Options", That does not seem right. Is it impossible for pam.set_option to be false? Even if it is, should this code assume that? regards, tom lane