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 1jNiv9-0004rB-Sw for pgsql-general@arkaria.postgresql.org; Sun, 12 Apr 2020 20:09:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jNiv8-00028L-PH for pgsql-general@arkaria.postgresql.org; Sun, 12 Apr 2020 20:09:34 +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 1jNiv8-00028E-Ek for pgsql-general@lists.postgresql.org; Sun, 12 Apr 2020 20:09:34 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jNiv6-0005I3-Os for pgsql-general@postgresql.org; Sun, 12 Apr 2020 20:09:34 +0000 Received: by mail-wr1-x42f.google.com with SMTP id x18so4017711wrq.2 for ; Sun, 12 Apr 2020 13:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=QCFgll3URhVOaOqBY/E0d3PyI1ZeIBKZbUPQzkT/Et8=; b=gQKVewA0dIq1Yi+0zJy6UMpcMQhRsMyGrSAG2Exh0tpqYiiNk5yxu47aJMnS1PjEly xMjGtx+8DXDhVvQXfPrCMxWgpHgci9MjtZSksyIOTKAtJxuXNqfINTB81nCV6673VCx2 kn6Rkksi1Zv41jqusawTf4Xr03jjYk6YEULMqwBe0qCJ89FgMhA2xu/T+3WlXRR1XUAB zPRa754plC/q60pWlfGFnyXaMFLljkeiZSSg5BHLZAq+lnehlbyJG4EQgoBk1xqn4nUV RAAUrGxBjT5IA8xnoQyDtz7qS+Y6MAIujGqvicypXvn4FJa+GdkBrlhOBImCtPdzPEiQ hSoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=QCFgll3URhVOaOqBY/E0d3PyI1ZeIBKZbUPQzkT/Et8=; b=jACSUhWpCKnwO8yG36UcqNzds18uBJTG+m1E4ZYEZYG+6KSZ9YQAtYEAEBKzJ0neMU DXG97wM1AR5kd5mqIh3wXqjxwGXpu+XNA0U68EL8WZ0wAkjDDtrYmPj2ImU6mcNk6pF+ 8JGssJqhe9cf3g7HP2BNDAt2ZC2kNx7mxJx8E1VIORgOXgqeBeu9a8Gm3s+1fh/6qqjC xuZZNKlhv6docd/bqYOcENca7QRitdjJTAJketNabotM6HaQ17nIuVrRjfvIgTtBdhGE gEi2ahkdQ1gytk8RznD5m1i8TOHSF0sEuf/+jWLHZavM7kVwKdlIvMnjy/9Y4sAHeP5V uS9A== X-Gm-Message-State: AGi0Pub0TiULSZeBMPM5pWnkjlv7GV6bKbKvH8xk79Z7zqm7bvldPLBm FHeE2Mf/iYQrtYVs1NgJ0z6wtg== X-Google-Smtp-Source: APiQypI7kClH1deGmSlcnVgUrM0NsFa7A2InjtnZqgbYJYnRmRLLxxgO3pWSQvuq1tUPFSKpiVXdAw== X-Received: by 2002:a5d:438c:: with SMTP id i12mr3384089wrq.14.1586722171030; Sun, 12 Apr 2020 13:09:31 -0700 (PDT) Received: from dynamic-eou3qian5fyugyv5g-pd01.res.v6.highway.a1.net (dynamic-eou3qian5fyugyv5g-pd01.res.v6.highway.a1.net. [2001:871:60:b50e:8a36:c403:13d8:fa34]) by smtp.gmail.com with ESMTPSA id y20sm12513365wra.79.2020.04.12.13.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 13:09:30 -0700 (PDT) Message-ID: Subject: Re: Which commands are guaranteed to drop role From: Laurenz Albe To: Andrus , pgsql-general Date: Sun, 12 Apr 2020 22:09:29 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, 2020-04-12 at 00:25 +0300, Andrus wrote: > User "currentuser" tries to delete role "roletodelete" from this database using > > But got error > > ERROR: role "roletodelete" cannot be dropped because some objects depend on it > DETAIL: privileges for schema public; > > How to create script which is guaranteed to delete role ? You cannot write such a script, but you will have to REVOKE and change ownership and ALTER DEFAULT PRIVILEGES until no more dependencies on the role exist. That is why you are well advised not to grant permissions to a role that you plan to drop. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com