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.96) (envelope-from ) id 1vOCvQ-00EZWU-0P for pgsql-general@arkaria.postgresql.org; Wed, 26 Nov 2025 10:39:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vOCvO-00FaxP-2L for pgsql-general@arkaria.postgresql.org; Wed, 26 Nov 2025 10:39:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vOCvO-00FaxG-1D for pgsql-general@lists.postgresql.org; Wed, 26 Nov 2025 10:39:02 +0000 Received: from mail-yx1-xb132.google.com ([2607:f8b0:4864:20::b132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vOCvM-001aZd-3B for pgsql-general@lists.postgresql.org; Wed, 26 Nov 2025 10:39:02 +0000 Received: by mail-yx1-xb132.google.com with SMTP id 956f58d0204a3-641e4744e59so6836845d50.2 for ; Wed, 26 Nov 2025 02:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764153539; x=1764758339; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=omy7LHaJ8A/fH1pd6TVgROHc27o4T5lpHdSQggsIp74=; b=UATzSBZ5+1IYxCzHmSW2u0U/Qx1fFdNnCqzVU6namVsPyRVtPCoKnsQwevWVh2cF/7 tG5lJKazH+Fjmi7haAt4fwdxHPTDDMzCBOdhBmBL3IOV94MFNrsrBGe1SsICZYiHBdZ9 z6rxRu482JyG0B+S52A0nVeqLXux7hbE2v2aUu7mTZM6OLq0JqvNjFgqo43++C6ctGao qLrRK/fBdNIA+JSx4Juk/TZiSzZEwWzQkdzxt2aCWVTvt50PW7jEcQDdUeuw7uVOzlnA kINxiMxBCiiK5bGZbNjHR4JIEP1o8QVpltrpiAa0CKT06MG9Q4vFmS+kP+J/Ra5u6Kn4 GgWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764153539; x=1764758339; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=omy7LHaJ8A/fH1pd6TVgROHc27o4T5lpHdSQggsIp74=; b=u2aSXhURU4vlzFbPDzu2Yu3VSMhrVbZVJDlCbGkRVhvXPc3nfLEJBWwD8mGEJ94hov ban1Zh6dWXEdYThSVdzwcGdGzyyw0gwyXTFbicF0VtqQ2pUaCFr5cbPDBYlG+5lsSKO1 WiSWFxjN8k72miu4+T6mTkZCtvtYdqQ0F8DDJErSD1leeA0MbpUiYX4LlGU6fq6qwxsv cJEHax9Ptpy1WrQo+LQCAEvAQCi2i6X0AyGZJeR2mrX6BK988IfRrz/ZTj1hbPAV4aEE IweUzFmI62HGrVZxb0LOV33qRPV5WU+DaZ7gRKz9QbNWNd6u2WXf/xOngIYvZ21jCHyj 2xpg== X-Forwarded-Encrypted: i=1; AJvYcCWhXgGp1gyQEcONnEnY1uqijNijc6MXzzPcM+hcP4x/MuspIv+Y4jJzMcFMUTn0xCb0zo1ckkkVGsH1CrnL@lists.postgresql.org X-Gm-Message-State: AOJu0YwkZ1d1ZjOGdo+QbQbGzRCcVnrqO9nxD34jsJa8VhzqMihoyrJN ele4HAQUVqX07Y5DnDnr9pUxyUfoF+q0zmLTvCoDIi3JYeUj1NFMix4MGrmwGhKQVqKr1D/2Qge wLvQNyy6iQ64IJDZ6q0ESYUMSVApisYXstw== X-Gm-Gg: ASbGnctsC2OpbSJkI/fEMSEDGz/qJaYcIQmYUCbRTdnGCSYe0EDyJyctI4b0wi5KSIp oftuq+de6lTzKPT5Z494QauuR6oc/8HWpDVETiom3mhPOAsaYvM5Q9/DXYf/azN4gHaumFNofY3 KudTMdgLDsV2oDi5mrIgiQaxpoUCV9Wog8+VM9JzVECVc0X9G+IV1El6ffU5VHfMPT2NTjf19ye GT0bwwt0Zc+OMczpwU/adoMbu2uvMG1ktpv9nAS87HZgkxsF/cD3AVNQVKrx/U5WHOV3++B2T3k V18Sslg= X-Google-Smtp-Source: AGHT+IGgPXmFvikXprxBtEBA8WqGhstM2eQBpO15qVLiGD4mtUZt86agwlyw4Xa7+SDtjS3gw1GwuRfNm3QupqImMX4= X-Received: by 2002:a05:690e:159c:10b0:63f:9d1e:eb83 with SMTP id 956f58d0204a3-64302a4c9dbmr10867870d50.30.1764153538906; Wed, 26 Nov 2025 02:38:58 -0800 (PST) MIME-Version: 1.0 References: <1484313.1764115685@sss.pgh.pa.us> <1507599.1764128700@sss.pgh.pa.us> In-Reply-To: <1507599.1764128700@sss.pgh.pa.us> From: immerrr again Date: Wed, 26 Nov 2025 11:38:48 +0100 X-Gm-Features: AWmQ_bkE12d3esXxKMDpelMxzYEchGKX8wTi3Rlx30DpsqRSdQ5EfSj9Y2zMU-I Message-ID: Subject: Re: DROP ROLE blocked by pg_init_privs To: Tom Lane Cc: Pavel Luzanov , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000040e2806447d0158" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000040e2806447d0158 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Nov 26, 2025 at 4:45=E2=80=AFAM Tom Lane wrote: > immerrr again writes: > > On Wed, Nov 26, 2025 at 1:08=E2=80=AFAM Tom Lane wr= ote: > >> The missing step here is > >> DROP OWNED BY test_role; > > > It just makes me uneasy to run a command with such potential for data > loss > > in order to remove a role. > > ... > (b) the usual procedure is to do REASSIGN OWNED first. Anything > that remains to be dropped by DROP OWNED must be an access permission > not an object. > (c) you do know that DDL in Postgres is transactional, right? > You can roll it back if you don't like the results. > Being able to roll back a dropped role doesn't seem like a huge help. I mean, if I can detect that a table/function/type is missing after the fact, it's probably even easier to check which ones are preventing the role from being dropped in the first place, right? REASSIGN before DROP does help, thanks. There's still a potential for someone to create or reassign a new object to that role just before it's dropped, but it's not a big deal. > > So much so that I have written a couple of > > queries to manually clean up the system tables pg_init_privs/pg_shdepen= ds > > instead (see [1]). > > Yup, that's far safer. No possibility of irretrievably hosing your > database through ill-considered manual catalog changes, for sure. > I wouldn't be discussing it here if I were happy about it. Carpet-reassigning and -dropping didn't feel right, so I had explored an alternative path. That one didn't feel right either. It made me wonder: if there was no PG command for it, was there a yet another approach that was better? I guess not, and everyone is just happy with REASSIGN+DROP, that's fine. Thanks --000000000000040e2806447d0158 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Nov 26, 2025 at 4:45=E2=80=AFAM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
immerrr again <immerrr@gmail.com> writes:
> On Wed, Nov 26, 2025 at 1:08=E2=80=AFAM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The missing step here is
>> DROP OWNED BY test_role;

> It just makes me uneasy to run a command with such potential for data = loss
> in order to remove a role.

...
(b) the usual procedure is to do REASSIGN OWNED first.=C2=A0 Anything
that remains to be dropped by DROP OWNED must be an access permission
not an object.=C2=A0

(c) you do know that DDL in Postgres is transactional, right?
You can roll it back if you don't like the results.

Being able to roll back a dropped role doesn't seem li= ke a huge help. I mean, if I can detect that a table/function/type is missi= ng after the fact, it's probably even easier to check which ones are pr= eventing the role from being=C2=A0dropped in the first place, right?
<= div>
REASSIGN before DROP does help, thanks. There's stil= l a potential for someone to create or reassign a new object to that role j= ust before it's dropped, but it's not a big deal.
=C2=A0<= /div>
> So much so that I have written a couple of
> queries to manually clean up the system tables pg_init_privs/pg_shdepe= nds
> instead (see [1]).

Yup, that's far safer.=C2=A0 No possibility of irretrievably hosing you= r
database through ill-considered manual catalog changes, for sure.

I wouldn't be discussing it here if I were h= appy about it. Carpet-reassigning and -dropping didn't feel right, so I= had explored an alternative path. That one didn't feel right either. I= t made me wonder: if there was no PG command for it, was there a yet anothe= r approach that was better? I guess not, and everyone is just happy with RE= ASSIGN+DROP, that's fine.

Thanks
--000000000000040e2806447d0158--