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 1qda6h-003zmB-NC for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Sep 2023 17:44:56 +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 1qda6g-003lHN-Kv for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Sep 2023 17:44:54 +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 1qda6f-003lGz-K0 for pgsql-hackers@lists.postgresql.org; Tue, 05 Sep 2023 17:44:54 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qda6b-002uYX-Da for pgsql-hackers@lists.postgresql.org; Tue, 05 Sep 2023 17:44:52 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 0FC8E3200980 for ; Tue, 5 Sep 2023 13:44:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 05 Sep 2023 13:44:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :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=fm1; t=1693935887; x=1694022287; bh=284nlytSw0Gak 0j2Zt6juuNEEcqnI/WBE9EqPBl42lQ=; b=OZztwguhFxevL//84iNyCI2L5rt+b NJMq/uS0M2vjNyRZTk7YJkbSpb2hO9OWH/xjoOPzyof/dUEdfdZnn9ZlD6G/5qkn Rtecx8tdAZLwiwup5gWiLPNAS2M+Vg2ab4BMLWjlQDtTl+H1zJYsJXHgX4Kapvsa nZRg18MFdjaXISAf29eqneYWSZR2dm89QeGiw2b9opA+GuWj5QaiMAlHj5YWS8ds 2A+3Ehv7Ndg+QtY22kPcXfG7h/CG4W4TDASgs9rkdviJRxOKqtME2jI7JHmDizLL ReTliHPHZP0VB7X2mBICO4B0HfF+/DzHScpDWqg93gActa5N0OikpEjYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehuddgleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfesthekredttddtjeenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhephfejhedvgefhudefiefgtddtudetuddvgeevhfdvueefvdet gffhheffudfhgfejnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 5 Sep 2023 13:44:46 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 178E0426; Tue, 5 Sep 2023 19:44:44 +0200 (CEST) Date: Tue, 5 Sep 2023 19:44:44 +0200 From: Alvaro Herrera To: Pg Hackers Subject: missing privilege check after not-null constraint rework Message-ID: <202309051744.y4mndw5gwzhh@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Here's a fix to move the privilege check on constraint dropping from ATExecDropConstraint to dropconstraint_internal. The former doesn't recurse anymore, so there's no point in doing that or in fact even having the 'recursing' argument anymore. This fixes the following test case CREATE ROLE alice; CREATE ROLE bob; GRANT ALL ON SCHEMA PUBLIC to alice, bob; GRANT alice TO bob; SET ROLE alice; CREATE TABLE parent (a int NOT NULL); SET ROLE bob; CREATE TABLE child () INHERITS (parent); At this point, bob owns the child table, to which alice has no access. But alice can do this: ALTER TABLE parent ALTER a DROP NOT NULL; which is undesirable, because it removes the NOT NULL constraint from table child, which is owned by bob. Alternatively, we could say that Alice is allowed to drop the constraint on her table, and that we should react by marking the constraint on Bob's child table as 'islocal' instead of removing it. Now, I'm pretty sure we don't really care one bit about this case, and the reason is this: we seem to have no tests for mixed-ownership table hierarchies. If we did care, we would have some, and this bug would not have occurred in the first place. Besides, nobody likes legacy inheritance anyway. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "La persona que no quería pecar / estaba obligada a sentarse en duras y empinadas sillas / desprovistas, por cierto de blandos atenuantes" (Patricio Vogel)