Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1stEpq-00Ee4P-Qh for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Sep 2024 23:20:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1stEpp-00H9UZ-Pv for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Sep 2024 23:20:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1stEpp-00H9UR-D3 for pgsql-bugs@lists.postgresql.org; Tue, 24 Sep 2024 23:20:45 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1stEpl-000tB6-Nd for pgsql-bugs@lists.postgresql.org; Tue, 24 Sep 2024 23:20:44 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id EC72E138027E; Tue, 24 Sep 2024 19:20:40 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Tue, 24 Sep 2024 19:20:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1727220040; x=1727306440; bh=JIzGCwoHQo W1jBDB2PtqgMNjkq5vrSsdws+zECajFFs=; b=qta4V9OFPG9gYXRrsHq1N9mYFf XRy0gPY57JJQt7l/QUbtPq5Yp5aOul2bzcK24pyE9W1raX/ZGOvbKVMSFUAP8jHs Ezi/o0+HGBtWQEt0brJBfkEZVgFr7Fa2CLgAWyLLzBWEQPE1XWqprQ4H39vMWBnA UtkWsRRhSyMVLzHmuSEgXuiOyUE+SelcLfJvhdWcqHS4tMLONgd2SHgfZdxSOLhJ cN7mis0fo+ImUDlPCGufiiiDJutkjbkz63KMUDuEpMcTcmwKKRmnTy9/vUR0J4Xg /M92kWpRjjUuyDzMY7z3GkJsYGo1r/j/bbPOSnolX2CQnOFAO87RHjvRADQg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1727220040; x=1727306440; bh=JIzGCwoHQoW1jBDB2PtqgMNjkq5v rSsdws+zECajFFs=; b=cinAF2HiwsjKdC7GB1CrJQb39aOZ78XHaNye6bnWTnXH IGEUamUvcWkWKEOfwH2YsSC5hQbzEy9FwJvjYXpmHJldH1PF4YQLy+6M32s+m3jG xzi6zTJ4XpKtPORYhpKVtsbVOvyED31+8MCEOCyUgWsP7D5uenN7vSkaScQoT3xe y06YSoQM3NrUfFRgH+w3hdYybJFnx8h1dL767vbILZmN/DSsW+r3C4HhpjNkLWKx wIEdVjEMend3cjLEYCl86kL73Rp8DXJUkFBUsYY5/+1Fnw+sPfmzTUOaouUGyK9x ARsm6BI78rabo4PeV5/ieHfX4hpNJE0MEpYVX2MVoA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtgedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhf gggtuggjsehgtdorredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruc eomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepffdu leehgefhkeefgfeftdfhkedutddvhfdukeeggeehieekffelhfelkeehteefnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhes phgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepmhgrshgrohdrfhhujhhiihesohhsshdrnhhtthgurghtrgdrtgho mhdprhgtphhtthhopeigohhfsehthhgvsghuihhlugdrtghomhdprhgtphhtthhopehnrg hthhgrnhgusghoshhsrghrthesghhmrghilhdrtghomhdprhgtphhtthhopehpohhsthhg rhgvshhvrghisghhrghvvgesghhmrghilhdrtghomhdprhgtphhtthhopehtghhlsehssh hsrdhpghhhrdhprgdruhhspdhrtghpthhtohepnhhorghhsehlvggruggsohgrthdrtgho mhdprhgtphhtthhopehpghhsqhhlqdgsuhhgsheslhhishhtshdrphhoshhtghhrvghsqh hlrdhorhhgpdhrtghpthhtohepvhhsvghkrghrsehmihgtrhhoshhofhhtrdgtohhm X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Sep 2024 19:20:38 -0400 (EDT) Date: Wed, 25 Sep 2024 08:20:22 +0900 From: Michael Paquier To: Fujii Masao Cc: Christophe Pettus , Nathan Bossart , vaibhave postgres , Tom Lane , Noah Misch , pgsql-bugs@lists.postgresql.org, vsekar@microsoft.com Subject: Re: vacuumdb: permission denied for schema "pg_temp_7" Message-ID: References: <20240920215030.8d.nmisch@google.com> <2603142.1726873660@sss.pgh.pa.us> <5f37ee56-14fb-44fe-9150-9eb97e10538b@oss.nttdata.com> <2649165.1726898595@sss.pgh.pa.us> <00d98a9f-bec1-4cd0-b59e-1043ae04c8bc@oss.nttdata.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xmt1f+3PxrVpsfSV" Content-Disposition: inline In-Reply-To: <00d98a9f-bec1-4cd0-b59e-1043ae04c8bc@oss.nttdata.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xmt1f+3PxrVpsfSV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 24, 2024 at 11:20:43PM +0900, Fujii Masao wrote: > On 2024/09/24 10:08, Michael Paquier wrote: >> About the permission restrictions depending on the objects listed, the >> filtering query uses currently a list of VALUES in a CTE. Perhaps it >> would be more elegant to switch that to a SELECT with some >> has_schema_privilege() for the cases where OBJFILTER_SCHEMA is >> used? >>=20 >> There permission checks with USAGE and MAINTAIN are broader, so I'd >> choose to add a skip on the temp persistence first and backpatch it >> down to 12 as there is also a performance argument. Then tackle the >> rest by reworking the VALUES part in the CTE. >=20 > Are you suggesting that any objects a user lacks sufficient privileges for > should be silently excluded from vacuuming? This could make vacuumdb appe= ar > successful because no errors occur, but some tables the user intended to > vacuum might be skipped without notice. That seems more problematic to me. >=20 > Sorry if I misunderstood your point. I don't really have a strong opinion in favor of skipping the objects or fail hard, because both have arguments. My point was just that, if we were to skip the objects, then the query needs a bit of rework and a SELECT with some extra filters in the CTE felt kind of right. If the consensus is that errors are better, my point about rewriting the query is most probably moot. > Is ownership really necessary in these cases? A similar issue can easily > happen with reindexdb as follows, so I think that should be fixed as well. >=20 > =3D# CREATE ROLE admin WITH LOGIN; > =3D# GRANT pg_maintain TO admin; > =3D# CREATE TEMP TABLE tt (i int primary key); > =3D# \! bin/reindexdb -U admin -j 2 postgres > reindexdb: error: query failed: ERROR: permission denied for schema pg_t= emp_0 > LINE 4: AND c.oid OPERATOR(pg_catalog.=3D) 'pg_temp_0.tt'::pg_catalo... > ^ > reindexdb: detail: Query was: SELECT c.relname, ns.nspname > FROM pg_catalog.pg_class c, pg_catalog.pg_namespace ns > WHERE c.relnamespace OPERATOR(pg_catalog.=3D) ns.oid > AND c.oid OPERATOR(pg_catalog.=3D) 'pg_temp_0.tt'::pg_catalog.regclass; >=20 > We should probably add a condition like "relpersistence !=3D CppAsString2= (RELPERSISTENCE_TEMP)" > to the queries in get_parallel_object_list(). Missed your point. An extra filter based on relpersistence can indeed make sense for this path. -- Michael --xmt1f+3PxrVpsfSV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmbzSTYACgkQnvQgOdby QH2O8Q//dfyoaYHrIr0x4meS7jD/ipiYpCKtkiBV/eKJESF3+ossOZZJOMSwHmCK SJHAw0nv175Z6iZmm7cBDQGdPObvMuHLQRl7rfegZEBhNOD9eFtGktmlJbbAG/Co gdnoCkdlbRu2GVhZyMbYyFZ8+3LuMQNxZrzObFkdB2XSs9SnZcA0q0dQoc5S2VmM xhLDoo4pP0GWhOWhuyshHkxQ8cWqpuakZYzyAXS9oQjSJs+C3vhYODKFw0GhAqru +JKyQhgNgTySnlxKXvVISPOmsAaaCIZV5OEX4PpqXFUzRBAQvRS++AiWmKH43kx8 UV7VaMtCkCKa0rhdWjGH4VFyMARSo3+31vVJ1qx0D+M1ADD8SroWW6ume7PbLAbc TuDpptYja6VM4Xnbn62Kho3iIuvvis0kgg6ClCb6CVDH1RLCFsZLkrGi/BiEsx1m ieRh01RXqAnTPsN38FU9Ekmgg295cqJBSmp6k+utgiPTJCFikGrrdoP7hZHQecEK vmta18QvzFTZuyP0TGWc6AcCKuc7aTGWITwQPUyUygORKZw6Yspkf5q9l+XGmY9O VenRXzF5m9GeuMmPgtBWSuGT0gu14B/Kj5O9mIgyuFa/eESLcCdREwEfBcc/rLdU 7RrM9ErylPDm5jYUE3mqKjATxQQuooJUcz07RxFeMfDw3JjLn44= =6230 -----END PGP SIGNATURE----- --xmt1f+3PxrVpsfSV--