Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT - Mailing list pgsql-bugs

From Tim Knowles
Subject Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT
Date
Msg-id NGBBIAKALHHLLCHKLBONOECPCBAA.tim@ametco.co.uk
Whole thread Raw
In response to Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@sss.pgh.pa.us]
Sent: 30 September 2002 15:51
To: Tim Knowles
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] Bug #785: 7.3b2 : Possible Inconsistency with DROP
INDEX ... CASCADE and DROP CONSTRAINT


"Tim Knowles" <tim@ametco.co.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug #785: 7.3b2 : Possible Inconsistency with DROP INDEX ... CASCADE and DROP CONSTRAINT
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #791: Error when inserting timestamp 2002-10-13 00:00:00