BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table

Lists: pgsql-bugs
From: miroslav(dot)sulc(at)fordfrog(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
Date: 2012-06-30 10:58:11
Message-ID: E1SkvNT-00066C-C4@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 6712
Logged by: Miroslav Šulc
Email address: miroslav(dot)sulc(at)fordfrog(dot)com
PostgreSQL version: Unsupported/Unknown
Operating system: Gentoo Linux
Description:

here is the test case:

test=# create table test_constraints (id int, val1 varchar, val2 int, unique
(val1, val2));
NOTICE: CREATE TABLE / UNIQUE will create implicit index
"test_constraints_val1_val2_key" for table "test_constraints"
CREATE TABLE
test=# create table test_constraints_inh () inherits (test_constraints);
CREATE TABLE
test=# alter table only test_constraints drop constraint
test_constraints_val1_val2_key;
ERROR: constraint "test_constraints_val1_val2_key" of relation
"test_constraints_inh" does not exist

postgresql tries to drop the constraint even from descendant table though
"only" is specified.


From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: <miroslav(dot)sulc(at)fordfrog(dot)com>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
Date: 2012-07-02 10:46:31
Message-ID: 008101cd583f$f184ab40$d48e01c0$@kapila@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

> From: pgsql-bugs-owner(at)postgresql(dot)org [mailto:pgsql-bugs-owner(at)postgresql(dot)org] On Behalf Of miroslav(dot)sulc(at)fordfrog(dot)com
> Sent: Saturday, June 30, 2012 4:28 PM
> The following bug has been logged on the website:

> Bug reference: 6712
> Logged by: Miroslav Šulc
> Email address: miroslav(dot)sulc(at)fordfrog(dot)com
> PostgreSQL version: Unsupported/Unknown
> Operating system: Gentoo Linux
> Description:

> here is the test case:

> test=# create table test_constraints (id int, val1 varchar, val2 int, unique
> (val1, val2));
> NOTICE: CREATE TABLE / UNIQUE will create implicit index
> "test_constraints_val1_val2_key" for table "test_constraints"
> CREATE TABLE
> test=# create table test_constraints_inh () inherits (test_constraints);
> CREATE TABLE
> test=# alter table only test_constraints drop constraint
> test_constraints_val1_val2_key;
> ERROR: constraint "test_constraints_val1_val2_key" of relation
> "test_constraints_inh" does not exist

> postgresql tries to drop the constraint even from descendant table though
> "only" is specified.

In function ATExecDropConstraint(), for the constarint "test_constraints_val1_val2_key" con->connoinherit is false,
due to which it tries to drop the constrint from child table as well.
I have checked that from function index_constraint_create() when it calls function CreateConstraintEntry(), the flag for noinherit passed is false.
I think this is the reason of failure for the same.

With Regards,
Amit Kapila.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
Cc: miroslav(dot)sulc(at)fordfrog(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
Date: 2012-08-30 22:07:47
Message-ID: 20120830220747.GE32350@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Jul 2, 2012 at 04:16:31PM +0530, Amit Kapila wrote:
> > From: pgsql-bugs-owner(at)postgresql(dot)org [mailto:pgsql-bugs-owner(at)postgresql(dot)org] On Behalf Of miroslav(dot)sulc(at)fordfrog(dot)com
> > Sent: Saturday, June 30, 2012 4:28 PM
> > The following bug has been logged on the website:
>
> > Bug reference: 6712
> > Logged by: Miroslav Šulc
> > Email address: miroslav(dot)sulc(at)fordfrog(dot)com
> > PostgreSQL version: Unsupported/Unknown
> > Operating system: Gentoo Linux
> > Description:
>
> > here is the test case:
>
> > test=# create table test_constraints (id int, val1 varchar, val2 int, unique
> > (val1, val2));
> > NOTICE: CREATE TABLE / UNIQUE will create implicit index
> > "test_constraints_val1_val2_key" for table "test_constraints"
> > CREATE TABLE
> > test=# create table test_constraints_inh () inherits (test_constraints);
> > CREATE TABLE
> > test=# alter table only test_constraints drop constraint
> > test_constraints_val1_val2_key;
> > ERROR: constraint "test_constraints_val1_val2_key" of relation
> > "test_constraints_inh" does not exist
>
>
> > postgresql tries to drop the constraint even from descendant table though
> > "only" is specified.
>
>
> In function ATExecDropConstraint(), for the constarint "test_constraints_val1_val2_key" con->connoinherit is false,
> due to which it tries to drop the constrint from child table as well.
> I have checked that from function index_constraint_create() when it calls function CreateConstraintEntry(), the flag for noinherit passed is false.
> I think this is the reason of failure for the same.

I believe this if fixed in all current versions of Postgres. I tested
9.1, 9.2rc1, and 9.3.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +