Re: How to determine what is preventing deleting a rule

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to determine what is preventing deleting a rule
Date: 2019-08-17 23:49:06
Message-ID: 25628.1566085746@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

stan <stanb(at)panix(dot)com> writes:
> I have deleted, what i thought were all the objects referenced by these roles,
> but I still get an error saying there is one object they reference.
> How can I find out what this object is?

The error should tell you, if you're connected to the database where
that object is.

regression=# create database d1;
CREATE DATABASE
regression=# create database d2;
CREATE DATABASE
regression=# create user joe;
CREATE ROLE
regression=# \c d2 joe
You are now connected to database "d2" as user "joe".
d2=> create table tt(d1 int);
CREATE TABLE
d2=> \c d1 postgres
You are now connected to database "d1" as user "postgres".
d1=# drop user joe;
ERROR: role "joe" cannot be dropped because some objects depend on it
DETAIL: 1 object in database d2
d1=# \c d2
You are now connected to database "d2" as user "postgres".
d2=# drop user joe;
ERROR: role "joe" cannot be dropped because some objects depend on it
DETAIL: owner of table tt

Unfortunately, we can't see into the catalogs of a different database
to explain about dependencies there ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message stan 2019-08-17 23:56:24 Roles versus users
Previous Message stan 2019-08-17 23:37:25 How to determine what is preventing deleting a rule