Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] DROP COLUMN round 4

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
Cc: "Patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] DROP COLUMN round 4
Date: 2002-07-31 05:44:06
Message-ID: 25216.1028094246@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
"Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> writes:
> 1. It cascade deletes objects, but it _always_ cascades, no matter what
> behaviour I specify.  Also, it doesn't give me indications that
> it's cascade deleted an object.
>> 
>> Would you give a specific example?

> [ dropping a column silently drops an index on the column ]

This happens because indexes are marked DEPENDENCY_AUTO on their
columns.  The drop will cascade to the index even under RESTRICT;
if you have message level set to DEBUG1 or higher you'll be told
about it, but otherwise the behavior is to zap the index quietly.

An example of a case where RESTRICT should make a difference is
where you have a foreign key reference from another table, or
a view that uses the column you're trying to delete.

We can debate whether indexes ought to be AUTO dependencies or not.
It seems reasonable to me though.  Indexes aren't really independent
objects to my mind, only auxiliary thingummies...

>> AlterTableDropColumn neglects to heap_close the relation, but I'm
>> surprised that error isn't reported sooner.

> Fixed.  New diff attached - fixes regression tests as well, plus re-merged
> against HEAD.

Thanks, will work from this.

> Note that the check against the parent attribute when adding a foreign key
> probably should be improved.  ie. It relies on the fact that the parent
> column(s) should not have a unique index on them (thanks to dependencies),
> rather than actually checking the attisdropped attribute.

Uh ... maybe it's too late at night here, but I didn't follow.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Thomas LockhartDate: 2002-07-31 05:48:39
Subject: Re: WAL file location
Previous:From: Curt SampsonDate: 2002-07-31 05:37:20
Subject: Re: Rules and Views

pgsql-patches by date

Next:From: Christopher Kings-LynneDate: 2002-07-31 06:27:03
Subject: Re: [HACKERS] DROP COLUMN round 4
Previous:From: Christopher Kings-LynneDate: 2002-07-31 05:29:24
Subject: Re: [HACKERS] DROP COLUMN round 4

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group