Re: [PATCHES] Inherited Constraints

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] Inherited Constraints
Date: 2006-03-06 17:12:40
Message-ID: 200603061712.k26HCeX26727@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Added to TODO:

o Prevent parent tables from altering or dropping constraints
like CHECK that are inherited by child tables

Dropping constraints should only be possible with CASCADE.

and we already have this in TODO:

o %Prevent child tables from altering or dropping constraints
like CHECK that were inherited from the parent table

so I think we now have all the failure cases documented.

---------------------------------------------------------------------------

Bruce Momjian wrote:
>
> Where are we on this patch? My testing shows it is still shows we have
> a problem:
>
> test=> CREATE TABLE x(y INT CHECK(y > 0));
> CREATE TABLE
> test=> CREATE TABLE z(a INT) inherits (x);
> CREATE TABLE
> test=> ALTER TABLE z DROP CONSTRAINT "x_y_check";
> ALTER TABLE
> test=> ALTER TABLE x DROP CONSTRAINT "x_y_check";
> ALTER TABLE
>
> Deleting the parent constraint first does not require CASCADE, as it
> should, I think:
>
> test=> CREATE TABLE x(y INT CHECK(y > 0));
> CREATE TABLE
> test=> CREATE TABLE z(a INT) inherits (x);
> CREATE TABLE
> test=> ALTER TABLE x DROP CONSTRAINT "x_y_check";
> ALTER TABLE
> test=> ALTER TABLE z DROP CONSTRAINT "x_y_check";
> ERROR: CONSTRAINT "x_y_check" does NOT exist
>
> ---------------------------------------------------------------------------
>
> Simon Riggs wrote:
> > On Thu, 2005-12-08 at 11:10 +0000, Simon Riggs wrote:
> > > On Wed, 2005-12-07 at 21:24 +0000, Simon Riggs wrote:
> > > > Following patch implements record of whether a constraint is inherited
> > > > or not, and prevents dropping of inherited constraints.
> > >
> > > Patch posted to -patches list.
> > >
> > > > What it doesn't do:
> > > > It doesn't yet prevent dropping the parent constraint, which is wrong,
> > > > clearly, but what to do about it?
> > > > 1. make dropping a constraint drop all constraints dependent upon it
> > > > (without any explicit cascade)
> > > > 2. add a new clause to ALTER TABLE .... DROP CONSTRAINT .... CASCADE
> > > >
> > > > I prefer (1), since it is SQL Standard compliant, easier to remember and
> > > > automatic de-inheritance is the natural opposite of the automatic
> > > > inheritance process.
> > >
> > > Comments, please -hackers?
> >
> > Late night hacking again....
> >
> > ALTER TABLE .... DROP CONSTRAINT .... CASCADE
> >
> > does of course already exist, so the following should cause dependency
> > violation ERRORs:
> > - omitting the CASCADE when attempting to delete parent constraint
> > - attempting to drop the child constraint
> >
> > Best Regards, Simon Riggs
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >
>
> --
> Bruce Momjian http://candle.pha.pa.us
> SRA OSS, Inc. http://www.sraoss.com
>
> + If your life is a hard drive, Christ can be your backup. +
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2006-03-06 17:59:20 Re: Coverity Open Source Defect Scan of PostgreSQL
Previous Message Marc G. Fournier 2006-03-06 16:50:15 Re: Coverity Open Source Defect Scan of PostgreSQL

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-03-06 17:41:15 Re: LDAP auth
Previous Message Dmitry Karasik 2006-03-06 09:12:27 Re: implement prepared queries in plperl