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 1pIYgl-0002Wc-DB for pgsql-committers@arkaria.postgresql.org; Thu, 19 Jan 2023 17:26: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 1pIYgk-0000vA-0q for pgsql-committers@arkaria.postgresql.org; Thu, 19 Jan 2023 17:26:58 +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 1pIYgj-0000v1-18 for pgsql-committers@lists.postgresql.org; Thu, 19 Jan 2023 17:26:57 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIYge-0007Nk-Rx for pgsql-committers@lists.postgresql.org; Thu, 19 Jan 2023 17:26:56 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 5709E320025E; Thu, 19 Jan 2023 12:26:49 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 19 Jan 2023 12:26:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1674149208; x=1674235608; bh=k eHDogBPqPLVSCovjeVe1XMgMYThGA+8/wM0bxrj+0M=; b=ZPpIVeAKnT4PstXZp zZaDWrQg+BRhPbxZE+YHqiRrmcMLTvQGrN5d3AERREBqnYp6qBDS7r2ILDIgxJ0w V8/2jbJZolGNpZa3Vjg900VZeeeMsMXN4HfV42xfznDprrMO/GI6tHnzPxVoCaai DaiSLjP0NJYZuty3lXEbjobf/vgYK2JJOt4ZVqhQy2oj380pas6FiG1c7SjqQgtp uecTyX9W/R1k2l8PbD5Su/aBEVRJdYbL4ceoYqANxNB0rm4xJUXO+OXKKDlMY+pw SRHqRZmslrwP3VOVnXyamsjB3fDjjlfO7ccounMGDGeCZkqrgvtbfTB/FxJEPp3s XeTQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddutddguddtvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeej keffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghl vhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Jan 2023 12:26:48 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id AE44298; Thu, 19 Jan 2023 18:18:53 +0100 (CET) Date: Thu, 19 Jan 2023 18:18:53 +0100 From: Alvaro Herrera To: Tom Lane Cc: pgsql-committers@lists.postgresql.org, Amit Langote Subject: Re: pgsql: Remove some dead code in selfuncs.c Message-ID: <20230119171853.tdhnnzc6p4qum2hu@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4069769.1674146627@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Jan-19, Tom Lane wrote: > I wrote: > > Alvaro Herrera writes: > >> Remove some dead code in selfuncs.c > >> RelOptInfo.userid is the same for all relations in a given inheritance > >> tree, so the code in examine_variable() and example_simple_variable() > >> that repeats the ACL checks on the root parent rel instead of a given > >> leaf child relations need not recompute userid too. > > > This change seems rather ill-advised. > > Ah, sorry, -ENOCAFFEINE. It's talking about the access-as-user field, > not the relation's owner. I agree that as querytrees are currently > built, this is probably a safe optimization. But do we really want > to hard-wire such a subtle assumption to gain a microscopic speed > benefit? It's not as though GetUserId() is expensive. Well, I didn't see it as an optimization but rather a removal of confusing code. Given the current RTEPermissionInfo representation, it's just not possible for an "otherrel" to have a different access-as-user value than what "the relation mentioned in the query" has -- by construction, they share the same RTEPermissionInfo. If we wanted to decouple selfuncs.c from that knowledge, then what we should be doing is obtain the RTEPermissionInfo for the relation, and use the userid from there. But the code I deleted wasn't doing that, it was just using the same 'onerel' all the time. It's not difficult (or expensive) to do otherwise, but it seems somewhat pointless. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "El destino baraja y nosotros jugamos" (A. Schopenhauer)