pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
14+ messages / 7 participants
[nested] [flat]

* BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-06-30 10:58  miroslav.sulc@fordfrog.com
  0 siblings, 1 reply; 14+ messages in thread

From: miroslav.sulc@fordfrog.com @ 2012-06-30 10:58 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6712
Logged by:          Miroslav Šulc
Email address:      miroslav.sulc@fordfrog.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.




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not	work on inherited master table
@ 2012-07-02 10:46  Amit Kapila <amit.kapila@huawei.com>
  parent: miroslav.sulc@fordfrog.com
  0 siblings, 1 reply; 14+ messages in thread

From: Amit Kapila @ 2012-07-02 10:46 UTC (permalink / raw)
  To: miroslav.sulc@fordfrog.com; pgsql-bugs

> From: pgsql-bugs-owner@postgresql.org [mailto:pgsql-bugs-owner@postgresql.org] On Behalf Of miroslav.sulc@fordfrog.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.sulc@fordfrog.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.




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-15 21:23  Noah Misch <noah@leadboat.com>
  0 siblings, 3 replies; 14+ messages in thread

From: Noah Misch @ 2012-07-15 21:23 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila@huawei.com>; +Cc: miroslav.sulc@fordfrog.com; pgsql-bugs

On Mon, Jul 02, 2012 at 04:16:31PM +0530, Amit Kapila wrote:
> > From: pgsql-bugs-owner@postgresql.org [mailto:pgsql-bugs-owner@postgresql.org] On Behalf Of miroslav.sulc@fordfrog.com
> > Sent: Saturday, June 30, 2012 4:28 PM

> > 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.

ONLY shouldn't be necessary, either.

> 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.

Agreed.  The other non-CHECK callers also get this wrong:

[local] regression=# select contype,connoinherit,count(*) from pg_constraint group by 1,2;
 contype | connoinherit | count 
---------+--------------+-------
 p       | f            |     7
 x       | f            |     2
 c       | f            |    17
 f       | f            |     5

One can construct similar bugs around dropping foreign key and exclusion
constraints.  Though it may be irrelevant for command semantics, additionally
using connoinherit = 't' for contype = 't' (CONSTRAINT_TRIGGER) would
more-accurately represent the nature of those constraints.

Care to prepare a patch with a test case addition?

Thanks,
nm



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint	does not work on inherited master table
@ 2012-07-16 08:14  Amit Kapila <amit.kapila@huawei.com>
  parent: Noah Misch <noah@leadboat.com>
  2 siblings, 0 replies; 14+ messages in thread

From: Amit Kapila @ 2012-07-16 08:14 UTC (permalink / raw)
  To: 'Noah Misch' <noah@leadboat.com>; +Cc: miroslav.sulc@fordfrog.com; pgsql-bugs

From: Noah Misch [mailto:noah@leadboat.com] 
Sent: Monday, July 16, 2012 2:54 AM
> > From: pgsql-bugs-owner@postgresql.org
[mailto:pgsql-bugs-owner@postgresql.org] On Behalf Of
miroslav.sulc@fordfrog.com
> > Sent: Saturday, June 30, 2012 4:28 PM


> Care to prepare a patch with a test case addition?
  Yes. I have started working.

With Regards,
Amit Kapila.




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint	does not work on inherited master table
@ 2012-07-16 11:19  Amit Kapila <amit.kapila@huawei.com>
  parent: Noah Misch <noah@leadboat.com>
  2 siblings, 0 replies; 14+ messages in thread

From: Amit Kapila @ 2012-07-16 11:19 UTC (permalink / raw)
  To: 'Noah Misch' <noah@leadboat.com>; +Cc: miroslav.sulc@fordfrog.com; pgsql-bugs

From: Noah Misch [mailto:noah@leadboat.com] 
Sent: Monday, July 16, 2012 2:54 AM

> One can construct similar bugs around dropping foreign key and exclusion
> constraints.  Though it may be irrelevant for command semantics,
additionally
> using connoinherit = 't' for contype = 't' (CONSTRAINT_TRIGGER) would
> more-accurately represent the nature of those constraints.

Code Changes
----------------
I will make changes in following functions to ensure that connoinherit
should be appropriately set(pass the value as true).  
a. index_constraint_create() 
b. ATAddForeignKeyConstraint() 
c. CreateTrigger().

Other places I have checked seems to be fine.

Test
--------
I will create testcases similar to mentioned in bug report for
a. unique key case, same as in bug-report
b. foreign key case
c. exclusion constraint case 


> Care to prepare a patch with a test case addition?
 Let me know if above is sufficient or shall I include anything more in
patch.


With Regards,
Amit Kapila.




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-16 15:12  Noah Misch <noah@leadboat.com>
  parent: Noah Misch <noah@leadboat.com>
  2 siblings, 3 replies; 14+ messages in thread

From: Noah Misch @ 2012-07-16 15:12 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila@huawei.com>; +Cc: miroslav.sulc@fordfrog.com; pgsql-bugs

On Mon, Jul 16, 2012 at 04:49:46PM +0530, Amit Kapila wrote:
> Code Changes
> ----------------
> I will make changes in following functions to ensure that connoinherit
> should be appropriately set(pass the value as true).  
> a. index_constraint_create() 
> b. ATAddForeignKeyConstraint() 
> c. CreateTrigger().
> 
> Other places I have checked seems to be fine.

Looks right.

> Test
> --------
> I will create testcases similar to mentioned in bug report for
> a. unique key case, same as in bug-report

Good.

> b. foreign key case
> c. exclusion constraint case 

Test coverage for those is optional.

> > Care to prepare a patch with a test case addition?
>  Let me know if above is sufficient or shall I include anything more in
> patch.

I can't think of anything else.


As a side question for the list, should we fix this differently in 9.2 to
avoid forcing an initdb for the next beta?  Perhaps have
ATExecDropConstraint() only respect connoinherit for CONSTRAINT_CHECK?



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-16 16:47  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Noah Misch <noah@leadboat.com>
  2 siblings, 1 reply; 14+ messages in thread

From: Tom Lane @ 2012-07-16 16:47 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: Amit Kapila <amit.kapila@huawei.com>; miroslav.sulc@fordfrog.com; pgsql-bugs

Noah Misch <noah@leadboat.com> writes:
> As a side question for the list, should we fix this differently in 9.2 to
> avoid forcing an initdb for the next beta?

I'm confused, why would an initdb be involved?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-16 16:53  Noah Misch <noah@leadboat.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 14+ messages in thread

From: Noah Misch @ 2012-07-16 16:53 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Amit Kapila <amit.kapila@huawei.com>; miroslav.sulc@fordfrog.com; pgsql-bugs

On Mon, Jul 16, 2012 at 12:47:37PM -0400, Tom Lane wrote:
> Noah Misch <noah@leadboat.com> writes:
> > As a side question for the list, should we fix this differently in 9.2 to
> > avoid forcing an initdb for the next beta?
> 
> I'm confused, why would an initdb be involved?

pg_constraint.connoinherit is presently only correct for CHECK constraints.
It will take an initdb to update those values comprehensively.



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-17 08:59  Amit kapila <amit.kapila@huawei.com>
  parent: Noah Misch <noah@leadboat.com>
  2 siblings, 1 reply; 14+ messages in thread

From: Amit kapila @ 2012-07-17 08:59 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: miroslav.sulc@fordfrog.com <miroslav.sulc@fordfrog.com>; pgsql-bugs

> From: Noah Misch [noah@leadboat.com]
> Sent: Monday, July 16, 2012 8:42 PM
> On Mon, Jul 16, 2012 at 04:49:46PM +0530, Amit Kapila wrote:

>> > Care to prepare a patch with a test case addition?
>>  Let me know if above is sufficient or shall I include anything more in
>> patch.

> I can't think of anything else.

Patch is attached with this mail.

> As a side question for the list, should we fix this differently in 9.2 to
> avoid forcing an initdb for the next beta?  Perhaps have
> ATExecDropConstraint() only respect connoinherit for CONSTRAINT_CHECK?

Let me know if anything needs to be done for this?

With Regards,
Amit Kapila.=

Attachments:

defect_fix_6712.patch (text/plain, 8.7K) download diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 0c51923..1546d48 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -1154,7 +1154,7 @@ index_constraint_create(Relation heapRelation, NULL, true, /* islocal */ 0, /* inhcount */ - false); /* noinherit */ + true); /* noinherit */ /* * Register the index as internally dependent on the constraint. diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index d69809a..0461b15 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -6052,7 +6052,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, NULL, true, /* islocal */ 0, /* inhcount */ - false); /* isnoinherit */ + true); /* isnoinherit */ /* * Create the triggers that will enforce the constraint. diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index faa7f0c..b74f577 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -459,7 +459,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, NULL, true, /* islocal */ 0, /* inhcount */ - false); /* isnoinherit */ + true); /* isnoinherit */ } /* diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index 3128154..5ab9386 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -969,6 +969,123 @@ DETAIL: drop cascades to table inht2 drop cascades to table inhts drop cascades to table inht3 drop cascades to table inht4 +-- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints +CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2)); +CREATE TABLE test_constraints_inh () INHERITS (test_constraints); +\d+ test_constraints + Table "public.test_constraints" + Column | Type | Modifiers | Storage | Stats target | Description +--------+-------------------+-----------+----------+--------------+------------- + id | integer | | plain | | + val1 | character varying | | extended | | + val2 | integer | | plain | | +Indexes: + "test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2) +Child tables: test_constraints_inh +Has OIDs: no + +ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key; +\d+ test_constraints + Table "public.test_constraints" + Column | Type | Modifiers | Storage | Stats target | Description +--------+-------------------+-----------+----------+--------------+------------- + id | integer | | plain | | + val1 | character varying | | extended | | + val2 | integer | | plain | | +Child tables: test_constraints_inh +Has OIDs: no + +\d+ test_constraints_inh + Table "public.test_constraints_inh" + Column | Type | Modifiers | Storage | Stats target | Description +--------+-------------------+-----------+----------+--------------+------------- + id | integer | | plain | | + val1 | character varying | | extended | | + val2 | integer | | plain | | +Inherits: test_constraints +Has OIDs: no + +DROP TABLE test_constraints_inh; +DROP TABLE test_constraints; +CREATE TABLE circles ( + c circle, + EXCLUDE USING gist (c WITH &&) +); +CREATE TABLE circles_inh () INHERITS (circles); +\d+ circles + Table "public.circles" + Column | Type | Modifiers | Storage | Stats target | Description +--------+--------+-----------+---------+--------------+------------- + c | circle | | plain | | +Indexes: + "circles_c_excl" EXCLUDE USING gist (c WITH &&) +Child tables: circles_inh +Has OIDs: no + +ALTER TABLE circles DROP CONSTRAINT circles_c_excl; +\d+ circles + Table "public.circles" + Column | Type | Modifiers | Storage | Stats target | Description +--------+--------+-----------+---------+--------------+------------- + c | circle | | plain | | +Child tables: circles_inh +Has OIDs: no + +\d+ circles_inh + Table "public.circles_inh" + Column | Type | Modifiers | Storage | Stats target | Description +--------+--------+-----------+---------+--------------+------------- + c | circle | | plain | | +Inherits: circles +Has OIDs: no + +DROP TABLE circles_inh; +DROP TABLE circles; +-- Test non-inheritable foreign key contraints +CREATE TABLE test_primary_constraints(id int PRIMARY KEY); +CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id)); +CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints); +\d+ test_primary_constraints + Table "public.test_primary_constraints" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + id | integer | not null | plain | | +Indexes: + "test_primary_constraints_pkey" PRIMARY KEY, btree (id) +Referenced by: + TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id) +Has OIDs: no + +\d+ test_foreign_constraints + Table "public.test_foreign_constraints" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + id1 | integer | | plain | | +Foreign-key constraints: + "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id) +Child tables: test_foreign_constraints_inh +Has OIDs: no + +ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey; +\d+ test_foreign_constraints + Table "public.test_foreign_constraints" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + id1 | integer | | plain | | +Child tables: test_foreign_constraints_inh +Has OIDs: no + +\d+ test_foreign_constraints_inh + Table "public.test_foreign_constraints_inh" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + id1 | integer | | plain | | +Inherits: test_foreign_constraints +Has OIDs: no + +DROP TABLE test_foreign_constraints_inh; +DROP TABLE test_foreign_constraints; +DROP TABLE test_primary_constraints; -- -- Test parameterized append plans for inheritance trees -- diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql index 6e6921a..b4d9e40 100644 --- a/src/test/regress/sql/inherit.sql +++ b/src/test/regress/sql/inherit.sql @@ -291,6 +291,42 @@ SELECT a.attrelid::regclass, a.attname, a.attinhcount, e.expected DROP TABLE inht1, inhs1 CASCADE; + +-- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints +CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2)); +CREATE TABLE test_constraints_inh () INHERITS (test_constraints); +\d+ test_constraints +ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key; +\d+ test_constraints +\d+ test_constraints_inh +DROP TABLE test_constraints_inh; +DROP TABLE test_constraints; + +CREATE TABLE circles ( + c circle, + EXCLUDE USING gist (c WITH &&) +); +CREATE TABLE circles_inh () INHERITS (circles); +\d+ circles +ALTER TABLE circles DROP CONSTRAINT circles_c_excl; +\d+ circles +\d+ circles_inh +DROP TABLE circles_inh; +DROP TABLE circles; + +-- Test non-inheritable foreign key contraints +CREATE TABLE test_primary_constraints(id int PRIMARY KEY); +CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id)); +CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints); +\d+ test_primary_constraints +\d+ test_foreign_constraints +ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey; +\d+ test_foreign_constraints +\d+ test_foreign_constraints_inh +DROP TABLE test_foreign_constraints_inh; +DROP TABLE test_foreign_constraints; +DROP TABLE test_primary_constraints; + -- -- Test parameterized append plans for inheritance trees --
^ permalink raw reply [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-19 11:53  Noah Misch <noah@leadboat.com>
  parent: Amit kapila <amit.kapila@huawei.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Noah Misch @ 2012-07-19 11:53 UTC (permalink / raw)
  To: Amit kapila <amit.kapila@huawei.com>; +Cc: miroslav.sulc@fordfrog.com <miroslav.sulc@fordfrog.com>; pgsql-bugs

On Tue, Jul 17, 2012 at 08:59:50AM +0000, Amit kapila wrote:
> Patch is attached with this mail.

Thanks.  This patch is ready for committer.

> +-- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints
> +CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2));
> +CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
> +\d+ test_constraints
> +ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
> +\d+ test_constraints
> +\d+ test_constraints_inh

To keep output terse, I would have omitted "\d" commands or retained only the
post-DROP "\d+ test_constraints".  Granted, that's subjective.



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint	does not work on inherited master table
@ 2012-07-20 02:57  Amit Kapila <amit.kapila@huawei.com>
  parent: Noah Misch <noah@leadboat.com>
  0 siblings, 1 reply; 14+ messages in thread

From: Amit Kapila @ 2012-07-20 02:57 UTC (permalink / raw)
  To: 'Noah Misch' <noah@leadboat.com>; +Cc: miroslav.sulc@fordfrog.com; pgsql-bugs

From: Noah Misch [mailto:noah@leadboat.com] 
Sent: Thursday, July 19, 2012 5:23 PM
On Tue, Jul 17, 2012 at 08:59:50AM +0000, Amit kapila wrote:
>> Patch is attached with this mail.

> Thanks.  This patch is ready for committer.

>> +-- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints
>> +CREATE TABLE test_constraints (id int, val1 varchar, val2 int,
UNIQUE(val1, val2));
>> +CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
>> +\d+ test_constraints
>> +ALTER TABLE ONLY test_constraints DROP CONSTRAINT
test_constraints_val1_val2_key;
>> +\d+ test_constraints
>> +\d+ test_constraints_inh

> To keep output terse, I would have omitted "\d" commands or retained only
the
> post-DROP "\d+ test_constraints".  Granted, that's subjective.

Thanks for the review of patch.

With Regards,
Amit Kapila.




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-20 12:57  Alvaro Herrera <alvherre@commandprompt.com>
  parent: Amit Kapila <amit.kapila@huawei.com>
  0 siblings, 0 replies; 14+ messages in thread

From: Alvaro Herrera @ 2012-07-20 12:57 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila@huawei.com>; +Cc: Noah Misch <noah@leadboat.com>; miroslav.sulc <miroslav.sulc@fordfrog.com>; pgsql-bugs


Excerpts from Amit Kapila's message of jue jul 19 22:57:04 -0400 2012:
> From: Noah Misch [mailto:noah@leadboat.com] 
> Sent: Thursday, July 19, 2012 5:23 PM
> On Tue, Jul 17, 2012 at 08:59:50AM +0000, Amit kapila wrote:
> >> Patch is attached with this mail.
> 
> > Thanks.  This patch is ready for committer.

Thanks, will see about it.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
@ 2012-07-20 18:13  Alvaro Herrera <alvherre@commandprompt.com>
  parent: Noah Misch <noah@leadboat.com>
  2 siblings, 0 replies; 14+ messages in thread

From: Alvaro Herrera @ 2012-07-20 18:13 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: Amit Kapila <amit.kapila@huawei.com>; miroslav.sulc <miroslav.sulc@fordfrog.com>; pgsql-bugs


Excerpts from Noah Misch's message of lun jul 16 11:12:01 -0400 2012:

> As a side question for the list, should we fix this differently in 9.2 to
> avoid forcing an initdb for the next beta?  Perhaps have
> ATExecDropConstraint() only respect connoinherit for CONSTRAINT_CHECK?

My answer here was "yes", so the patch I just pushed to the 9.2 branch
contains such an override.  I also included a catversion bump in HEAD
even though the catalog inconsistency is likly to be very minor.

Thanks.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not	work on inherited master table
@ 2012-08-30 22:07  Bruce Momjian <bruce@momjian.us>
  parent: Amit Kapila <amit.kapila@huawei.com>
  0 siblings, 0 replies; 14+ messages in thread

From: Bruce Momjian @ 2012-08-30 22:07 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila@huawei.com>; +Cc: miroslav.sulc@fordfrog.com; pgsql-bugs

On Mon, Jul  2, 2012 at 04:16:31PM +0530, Amit Kapila wrote:
> > From: pgsql-bugs-owner@postgresql.org [mailto:pgsql-bugs-owner@postgresql.org] On Behalf Of miroslav.sulc@fordfrog.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.sulc@fordfrog.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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




^ permalink  raw  reply  [nested|flat] 14+ messages in thread


end of thread, other threads:[~2012-08-30 22:07 UTC | newest]

Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-06-30 10:58 BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table miroslav.sulc@fordfrog.com
2012-07-02 10:46 ` Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not	work on inherited master table Amit Kapila <amit.kapila@huawei.com>
2012-08-30 22:07   ` Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not	work on inherited master table Bruce Momjian <bruce@momjian.us>
2012-07-15 21:23 Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table Noah Misch <noah@leadboat.com>
2012-07-16 08:14 ` Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint	does not work on inherited master table Amit Kapila <amit.kapila@huawei.com>
2012-07-16 11:19 ` Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint	does not work on inherited master table Amit Kapila <amit.kapila@huawei.com>
2012-07-16 15:12 ` Noah Misch <noah@leadboat.com>
2012-07-16 16:47   ` Tom Lane <tgl@sss.pgh.pa.us>
2012-07-16 16:53     ` Noah Misch <noah@leadboat.com>
2012-07-17 08:59   ` Amit kapila <amit.kapila@huawei.com>
2012-07-19 11:53     ` Noah Misch <noah@leadboat.com>
2012-07-20 02:57       ` Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint	does not work on inherited master table Amit Kapila <amit.kapila@huawei.com>
2012-07-20 12:57         ` Alvaro Herrera <alvherre@commandprompt.com>
2012-07-20 18:13   ` Alvaro Herrera <alvherre@commandprompt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox