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 1luNku-0000pX-Fg for pgsql-committers@arkaria.postgresql.org; Fri, 18 Jun 2021 23:18:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1luNks-0004xq-52 for pgsql-committers@arkaria.postgresql.org; Fri, 18 Jun 2021 23:18:30 +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 1luNkq-0004xi-Oj for pgsql-committers@lists.postgresql.org; Fri, 18 Jun 2021 23:18:29 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luNkn-0002Ak-ME for pgsql-committers@lists.postgresql.org; Fri, 18 Jun 2021 23:18:27 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5441D5C00D4; Fri, 18 Jun 2021 19:18:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 18 Jun 2021 19:18:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=MFCee6a6qf/oheyktfxBvZTOM1E 3ai9uh/UwjKgcjIk=; b=fJzm1gyGZS7nbqQ8gJS15SbGqtRmyGl0NemvkvWJBeb wFbB7PISV6dXcKoc+hjVvij41VW6RKXBDcC+4TvKEi/T/nYb6P8levGQ/gC8IHUS mVWYGqyKwCjhp4UZctzu945+9XFclAxuvhUwWWRy/WLWp/Clfb7EguO5JxZ3IMqj s+/5vlUZJ3xHVH559jXOFUANpcnOUS0yyceyQPsDQz1yyW2Ll4Ps88sqdyyfybmi croK+wbgSKIahdiorm/h9jN4WPC2d55iN3jh+tBLCGBW9peIJzPHJQ91wFv7/JoS M+NfLuVi0eGmEzxFX2KPcKExXrhRNZA7Ccisq/EJxGw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=MFCee6 a6qf/oheyktfxBvZTOM1E3ai9uh/UwjKgcjIk=; b=ml+EDdt+GHAvUxKb47L6iT cNQUqV/5sFft7Xwy7athbc+ZtL7ncurOrSuJeYlVBW7qRZFVUFEjXDRx+g/2qJrz sYopozc9wVFMzKrrnxMW4Li5b8ZPD8/5emahuFJPxE+g/fAcUWMRogGod6kFsKQ6 5XiSX0/XgH9Fw0QHwfxqJGaX8EYGZ8tJqFs1xleLj35eDUNpsbrezMUhr4Su2f9Z LCinINxz7hZgG9hJt9yMnRZpAQwRmQFY6EOals8ti2QG+FiM2jDxA8kwQutlUSH+ vK59j4rGDVt3h2VYvgWos3ru+BGG6fOUMXsnZX8N4+CW2Orxarr10PnnGC0aXOQQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrh hnpedvgeduuefhtdeuleettdevjeehheeiveeuieegleetgeeljeelieeuieehgeevhfen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthh grvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 18 Jun 2021 19:18:21 -0400 (EDT) Date: Sat, 19 Jun 2021 08:18:18 +0900 From: Michael Paquier To: Tom Lane Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="H8UlFvnSq97aWz9B" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --H8UlFvnSq97aWz9B Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 18, 2021 at 10:00:33PM +0000, Tom Lane wrote: > Fix misbehavior of DROP OWNED BY with duplicate polroles entries. >=20 > Ordinarily, a pg_policy.polroles array wouldn't list the same role > more than once; but CREATE POLICY does not prevent that. If we > perform DROP OWNED BY on a role that is listed more than once, > RemoveRoleFromObjectPolicy either suffered an assertion failure > or encountered a tuple-updated-by-self error. Rewrite it to cope > correctly with duplicate entries, and add a CommandCounterIncrement > call to prevent the other problem. >=20 > Per discussion, there's other cleanup that ought to happen here, > but this seems like the minimum essential fix. A nit here. + /* If any roles remain, update the policy entry. */ + if (num_roles > 0) + { /* This is the array for the new tuple */ This indentation is incorrect. -- Michael --H8UlFvnSq97aWz9B Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmDNKboACgkQnvQgOdby QH3auhAAidxRtugydolPIJGiOMfUIIE4NltqIIqzIbRbHmgM1N2SXd+fb+s0AJs3 vPkU5vAtDxM979NXF7l46SND7DH0mgbnzuxDLaKm/hUit860evS97giZIu+NVxZz 9JErID04sVBpIqgsw47xzIuPizaenDfvYuOyBxj+aXqk4MNQkpsB2uBEtIsywoQX NoWn53TNiWu335YLEaH+ho5XD9yEZ/+NHR1bOb4RWFrI9iMPqo6hb+wfgdJKd8C5 ybAhwMmDjoU3PjOBCjjoFK+SlCcwVNWbO1v5mZnnDkiqEBOYpj4Uq3aEtPiTwVEE xIHHVr/ZLN/W9TD05tG43NsM9j2tVnNa50Q3wZJH0Qa2JA0g7MLRCrlthLm8Ez2G zvvUVeZin1u4/Jx7pdrY6jONcReMAT1jByHbzH2jmgHv4rZW96JFqBY7Fn7FyEh3 AKoXMokmTFn/V7I6m5qlepr4xuWE1lA0QdL5oQ1p5tCNwMxokXjRFWJ6ERbJ9aeU xwqapsJQ06fKGumZbllom5wVSL738l26thlSnBh+Hc8X49ALSy01b5PxwfPK868M d+eobnVAqgaNRP756EWe+6Lr446bPsLzlF6uLREOECdBJDzAfb15EuPVbX5fsoTi 61E48YQ1YYTew1jtditHi/KokD4/kWQB8kCG63otqecabaJTPH4= =3Cka -----END PGP SIGNATURE----- --H8UlFvnSq97aWz9B--