Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT

From: "Tim Knowles" <tim(at)ametco(dot)co(dot)uk>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT
Date: 2002-09-30 15:39:11
Message-ID: NGBBIAKALHHLLCHKLBONOECPCBAA.tim@ametco.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Is their any way to know if an index is a unique constraint from within the
dependency checker? In testing with pg_dump I've noted that it seems to
know (I assume from contype in pg_constraint) if the index is just a unique
index or a constraint.

How about this:

Cannot drop unique constraint (index t1_pkey) because part of constraint c1
from table t1 requires it

If this is possible it would at least get you in to a 'constraint mindset'
and hopefully make you realise thats its a constraint first and an index as
a bonus/side effect, so to speak.

Is this easily possible?

Best Regards,

Tim Knowles

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: 30 September 2002 15:51
To: Tim Knowles
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: [BUGS] Bug #785: 7.3b2 : Possible Inconsistency with DROP
INDEX ... CASCADE and DROP CONSTRAINT

"Tim Knowles" <tim(at)ametco(dot)co(dot)uk> writes:
> ... I do though think the error message could do with a slight change
> of wording from:

> ERROR: Cannot drop index t1_pkey because constraint c1 on table t1
requires
> it
> You may drop constraint c1 on table t1 instead
> to:

> ERROR: Cannot drop index t1_pkey because constraint c1 on table t1
requires
> it
> To drop index t1_pkey you will need to drop the constraint c1 from
> table t1 first

Well, no, because the second message is not accurate at all for this
situation. The hint to drop the constraint *instead* is perfectly
correct; when you do that the index will go away too.

I was thinking more of rewording the first line, perhaps like this:

> ERROR: Cannot drop index t1_pkey because it is part of constraint c1 on
table t1

but wasn't completely satisfied with that either.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2002-09-30 18:20:15 Bug #791: Error when inserting timestamp 2002-10-13 00:00:00
Previous Message Tom Lane 2002-09-30 14:50:55 Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT