Re: domain access privilege

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: domain access privilege
Date: 2002-07-20 18:49:49
Message-ID: 10919.1027190989@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
>> You can drop the table whether they want you to or not; the foreign key
>> constraint goes away by CASCADE.

> I tried this as the user owning the referenced table (using 7.2.1) and
> I was unable to do the drop.

Sorry, I was speaking of the 7.3 implementation. In current CVS:

regression=# \c - tgl
You are now connected as new user tgl.
cregression=> create table mytable(f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'mytable_pkey' for table 'mytable'
CREATE TABLE
regression=> \c - postgres
You are now connected as new user postgres.
regression=# create table bar (f1 int references mytable);
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
CREATE TABLE
regression=# \c - tgl
You are now connected as new user tgl.
regression=> drop table mytable;
NOTICE: constraint $1 on table bar depends on table mytable
ERROR: Cannot drop table mytable because other objects depend on it
Use DROP ... CASCADE to drop the dependent objects too
regression=> drop table mytable cascade;
NOTICE: Drop cascades to constraint $1 on table bar
DROP TABLE

With debugging message level cranked up a little, it is possible to see
that the triggers implementing the constraint go away too:

regression=> drop table mytable cascade;
DEBUG: StartTransactionCommand
DEBUG: Drop auto-cascades to type mytable
NOTICE: Drop cascades to constraint $1 on table bar
DEBUG: Drop auto-cascades to trigger RI_ConstraintTrigger_290343 on table mytable
DEBUG: Drop auto-cascades to trigger RI_ConstraintTrigger_290341 on table mytable
DEBUG: Drop auto-cascades to trigger RI_ConstraintTrigger_290339 on table bar
DEBUG: Drop auto-cascades to constraint mytable_pkey on table mytable
DEBUG: Drop auto-cascades to index mytable_pkey
DEBUG: CommitTransactionCommand
DROP TABLE

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-07-20 19:11:24 Re: timestamped archive data index searches
Previous Message Stephen Birch 2002-07-20 18:46:21 Re: timestamped archive data index searches