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 1oqXWs-0004PX-V4 for pgsql-docs@arkaria.postgresql.org; Thu, 03 Nov 2022 10:32:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oqXWr-00073l-PE for pgsql-docs@arkaria.postgresql.org; Thu, 03 Nov 2022 10:32:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqXWr-00073c-FK for pgsql-docs@lists.postgresql.org; Thu, 03 Nov 2022 10:32:57 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oqXWl-0003Nw-0D for pgsql-docs@lists.postgresql.org; Thu, 03 Nov 2022 10:32:56 +0000 Received: by mail-ej1-x631.google.com with SMTP id d26so3938020eje.10 for ; Thu, 03 Nov 2022 03:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=2ZEF8iMXWyfm07kiL/b/RiHYWcaeBNc/1Qqv+FVfDyo=; b=6x+Hp9fcgvX0cmppj2X19NNdw+spu2SqRpC74oI1gDnipYBv1xRRfg7VULYzzXg4QZ CG7L0igBaGnaXAjDahXO3FW13iaiIVTpWtKNiOPlf5TdIC2N4HpfHvra365gSR92zZgW 425Td3LnE4RKg68aduzKMVyQdK+2JCbGgC/JKyDKXbKoAtV7uenT+2fxBb91/WoQIJcJ 0oHrciyBaiZqAOMyjqCbSOHxtax9Y4mfnfx7yV7J0KOH89ZDCgY+B/JzXoRXoTeVkxzl xHDXLkH/LO2xpiFpJAR6qjyprsryzddCPLxrDjRKOJqmLRE0O1y6R3LkbAYEO4E2qCJD 3YCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2ZEF8iMXWyfm07kiL/b/RiHYWcaeBNc/1Qqv+FVfDyo=; b=1vyOVEjvckDesD63QfBFQpycdQ8R9k22w7c55E7WPch2ZWqXxd+2pMqATIjs0S9Jo2 yHV+WyDfBfU5cM+6dWXZhXz9nEZDA61j19MCM++a+12r+1M/e2dm9QESiUfGWhcxSYee D5AD5O/5/EuC4KAO2pNLZG/ZAGfQd57KB2RBE89/SHLYXekoIhbMRXoHHi7FoqsS1mFL dMDrVRIXK1joOhcuLwOtKTe2o1k3lME4+qD+wv5DPbvI6K0qVx5O5XaIrayTwVZg4LlJ FffLiokIheDWmHU7W7hlB0FtgtISZQfFo0FYd93gYWefoxvGXvl4edMh5KNdGcnjcBpK /hcw== X-Gm-Message-State: ACrzQf2TzfSPMjxjgLc3PZeHQc+p1Wb45lV0oQCcJmd5pl9Icr2VDBIv EEIKfei7hjWSZgVS9D+tek7RBR68OiAQwQ== X-Google-Smtp-Source: AMsMyM4r5Y6qP9bWyG8mSQLl1lwTSGreZAhygjcWgOnWZTS+t6KRLqobvqntXAKj8xz05bl+m0itew== X-Received: by 2002:a17:907:25c1:b0:77b:9966:ccf1 with SMTP id ae1-20020a17090725c100b0077b9966ccf1mr28780296ejc.763.1667471569880; Thu, 03 Nov 2022 03:32:49 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:1d8c:788c:407d:490b:9a90]) by smtp.gmail.com with ESMTPSA id cw26-20020a056402229a00b0045723aa48ccsm316715edb.93.2022.11.03.03.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 03:32:49 -0700 (PDT) Message-ID: <4a6f157edc4ae38a2050a5893e6729cbb98113bc.camel@cybertec.at> Subject: Re: Version 14/15 documentation Section "Alter Default Privileges" From: Laurenz Albe To: David Burns , "pgsql-docs@lists.postgresql.org" Date: Thu, 03 Nov 2022 11:32:48 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2022-11-02 at 19:29 +0000, David Burns wrote: > To Whom It May Concern; It concerns me, because I often see questions from people who misunderstand this. > Some additional clarity in the versions 14/15 documentation would be helpful specifically > surrounding the "target_role" clause for the ALTER DEFAULT PRIVILEGES command. > To the uninitiated, the current description seems vague.  Maybe something like the following would help: >   > target_role >        The name of an existing role of which the current role is a member. > Default privileges are only applied to objects created by the targeted role/user (FOR ROLE target_role). >  If the FOR ROLE clause is omitted, the targeted user defaults to the current user executing the > ALTER DEFAULT PRIVILEGES command. +1 I like the wording, except that I would replace "targeted role/user (FOR ROLE target_role)" with "target role" for added clarity. >   The result can be seen using the following query: >   > select   table_catalog as database >          ,table_schema >          ,table_name >          ,privilege_type >          ,grantee >          ,'revoke '||privilege_type||' on '||table_schema||'.'||table_name||' from '||grantee||';' as revoke_stmt > from     information_schema.table_privileges > where    table_schema = 'my_schema' > and      table_name = 'my_table' > order by 1,2,3,5,4; I am not so happy with that query; I thinks that is going too far. Perhaps we can say that the "psql" command "\ddp" can be used to view default privileges. > Also, additional explanation about the differences between global defaults versus > schema-level defaults, and how to identify them, would be helpful. The examples already cover that in some detail. > Additional explanation about exactly what is happening would help to put this command into perspective. > On successful execution with the correct parameter values, and using both the FOR ROLE and > IN SCHEMA clauses, I also received privilege grants directed to the user executing the > ALTER DEFAULT PRIVILEGES command.  This was in addition to the expected privileges specified in the command. > I'm not sure why this occurred or how to eliminate it, in the interest of establishing "least privilege" permissions. ALTER DEFAULT PRIVILEGES does nothing like that... Yours, Laurenz Albe