Re: Bug?? -- Alter table drop constraint doesn't seem to work on a primary key constraint in 7.2beta2 - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: Bug?? -- Alter table drop constraint doesn't seem to work on a primary key constraint in 7.2beta2
Date
Msg-id GNELIHDDFBOCMGBFGEFOIEFMCAAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: Bug?? -- Alter table drop constraint doesn't seem to work on a primary key constraint in 7.2beta2  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Bug?? -- Alter table drop constraint doesn't seem to work on a primary key constraint in 7.2beta2
List pgsql-hackers
> Barry Lind <barry@xythos.com> writes:
> > I was looking at the 7.2 docs online at developer.postgresql.org.  The
> > only example of 'drop constraint' in the text for the 'alter table'
> > command shows its usage without the RESTRICT/CASCADE option.

I could have sworn that the documentation patch for this specified that the
restrict clause was needed.

Here you go (from the Notes section):

In DROP CONSTRAINT, the RESTRICT keyword is required, although dependencies
are not yet checked. The CASCADE option is unsupported. Currently DROP
CONSTRAINT drops only CHECK constraints. To remove a PRIMARY or UNIQUE
constraint, drop the relevant index using the DROP INDEX command. To remove
FOREIGN KEY constraints you need to recreate and reload the table, using
other parameters to the CREATE TABLE command.

> Erroneous example fixed.
>
> > But I still can't get it to work for me.  Consider the
> following test case:
>
> > create table test (col_a integer not null, col_b text);
> > alter table test add constraint test_pk primary key (col_a);
> > alter table test drop constraint test_pk restrict;
>
> > psql:test.sql:8: ERROR:  ALTER TABLE / DROP CONSTRAINT: test_pk
> does not
> > exist
>
> Looking at the code, the problem is that DROP CONSTRAINT only works with
> CHECK constraints at the moment.  This does seem to be adequately
> documented.  Improving the functionality will have to wait for some
> future development cycle.

DROP CONSTRAINT can only drop CHECK constraints at the moment - and I could
also have sworn that that was documented in my SGML patch!

Perhaps the fall-through message about the constraint not existing is
somewhat misleading...

Anyway Barry - you can just go "DROP INDEX test_pk".  In fact -

Chris



pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: regression test database borked
Next
From: Tom Lane
Date:
Subject: Re: fts.postgresql.org problem ! still no routing