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 1nIfeZ-0000Xz-I8 for pgsql-general@arkaria.postgresql.org; Fri, 11 Feb 2022 23:48:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIfeX-0003qq-SP for pgsql-general@arkaria.postgresql.org; Fri, 11 Feb 2022 23:48:37 +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 1nIfeW-0003qh-05 for pgsql-general@lists.postgresql.org; Fri, 11 Feb 2022 23:48:37 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIfeS-0002AE-Qd for pgsql-general@lists.postgresql.org; Fri, 11 Feb 2022 23:48:34 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 402E15C00F9; Fri, 11 Feb 2022 18:48:31 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 11 Feb 2022 18:48:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; bh=DElWUCz9zl2/Mt czqq8ahrP1W5VooZNZCxU+Kuqvzg4=; b=MJdsCMq98Zy2+ri8tnvGk+Izm40vNK Kw5fR0B5pAKt7ORvZ0O5F/sV1bc1jQEGJc09InHwUH5m2f8uzzhpjkMiJL34q57B N9ZC6cRAejEB5Zv1M/OcQN1q49CzrNu5VjMvUbr4W/rToZXldfaAHj1Lvk7iqnk0 h3wzR6KLSMaGZL8DvzgA08O3YdK8B2UM1hTT8dHwWQQ8r9fD5Y0jmtp+FFb1GFUB eScqoh+dU0TnDY/xnWW7IQ6k0w8cN3BAQp0fe+NHBUmKhEfvpUkNojqC8WC+MAtz LOm8gFovzapByDA+ImkgaRzHm8Uf9Bo8oyjNtcPddZT0Qru2Z8Vj2Igw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=DElWUCz9zl2/Mtczqq8ahrP1W5VooZNZCxU+Kuqvz g4=; b=JZ3LFI5BEdxuxZzXI8V3GYPLsmPoDsphuCiWbmMMEITSdu+jdhtGhPUZg IV3Eaj326SQW3BGw1bNF/cIpvNFovCfdbi8XpxFeZQ78HUjm5CeMHwERqojOqBKp 3VanhpkTX4vyDKrPK//1DLQq+Guxdvpl89xgI1dG85zcM6AWg31TvRIJ46//kzuW hr2zHKXnna3ht36OslXveMi5H0AX2B1VyM9JxoYkHGtjBGLW9Bykk+XeSxwVUyXy qYI13ldlMEBd6Re7eZtz1eJw5pzs/R/VZ4gIERh965cNzUI6M3iOaPClda6o3rcj lsh8KzmHrNre5ven6hl++U8epY+Lg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrieeggddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepleekgeejhfekteehfeduveetheeivdduheekudelteef vdffueehtddvgedtfeefnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgr nhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 11 Feb 2022 18:48:30 -0500 (EST) Message-ID: <613f1225-26ae-6772-c5da-1cb725674e4f@aklaver.com> Date: Fri, 11 Feb 2022 15:48:29 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: "grant usage on schema" confers the ability to execute all user-defined functions in that schema, with needing to grant "execute" Content-Language: en-US To: Bryn Llewellyn , "David G. Johnston" , Tom Lane PostgreSQL Cc: jeremy@musicsmith.net, pgsql-general list References: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com> <46C22E9C-280C-446E-911F-6915702E554E@yugabyte.com> <2188505.1644617120@sss.pgh.pa.us> <2162E383-66F7-432A-BFEF-16B922C57C79@yugabyte.com> From: Adrian Klaver In-Reply-To: <2162E383-66F7-432A-BFEF-16B922C57C79@yugabyte.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/11/22 15:14, Bryn Llewellyn wrote: >> /david.g.johnston@gmail.com wrote:/ >> > I looked at Chapter 52, "System Catalogs" at > https://www.postgresql.org/docs/current/catalogs.html > . It lists 97 > relations. I'll have to defer reading about every one of these to > another day. I searched the page for likely names looking for ones with > "priv" and "rol". There's just a small number of hits. I drilled down on > these. But none seemed to help finding out which objects, of which > kinds, have which privileges (or roles) granted to which grantees. > > Which catalog relations are sufficient to support a query that lists > out, for example, every user-defined function and procedure with its (at > least first-level) grantees? Tip if you do: psql -d test -U postgres -h localhost -E the -E will get you the queries for the \ meta-commands. So: \df+ tag_changeset_fnc Yields: SELECT n.nspname as "Schema", p.proname as "Name", pg_catalog.pg_get_function_result(p.oid) as "Result data type", pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types", CASE p.prokind WHEN 'a' THEN 'agg' WHEN 'w' THEN 'window' WHEN 'p' THEN 'proc' ELSE 'func' END as "Type", CASE WHEN p.provolatile = 'i' THEN 'immutable' WHEN p.provolatile = 's' THEN 'stable' WHEN p.provolatile = 'v' THEN 'volatile' END as "Volatility", CASE WHEN p.proparallel = 'r' THEN 'restricted' WHEN p.proparallel = 's' THEN 'safe' WHEN p.proparallel = 'u' THEN 'unsafe' END as "Parallel", pg_catalog.pg_get_userbyid(p.proowner) as "Owner", CASE WHEN prosecdef THEN 'definer' ELSE 'invoker' END AS "Security", pg_catalog.array_to_string(p.proacl, E'\n') AS "Access privileges", l.lanname as "Language", p.prosrc as "Source code", pg_catalog.obj_description(p.oid, 'pg_proc') as "Description" FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang WHERE p.proname OPERATOR(pg_catalog.~) '^(tag_changeset_fnc)$' COLLATE pg_catalog.default AND pg_catalog.pg_function_is_visible(p.oid) ORDER BY 1, 2, 4; The parts you would be interested in are "Owner", "Security" and "Access privileges". You could modify the query to slim the results down some. -- Adrian Klaver adrian.klaver@aklaver.com